diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java index 2458a2450..62ab5fbee 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java @@ -47,22 +47,8 @@ import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManag import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator; -import com.github.intellectualsites.plotsquared.plot.util.ChatManager; -import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; -import com.github.intellectualsites.plotsquared.plot.util.ConsoleColors; -import com.github.intellectualsites.plotsquared.plot.util.EconHandler; -import com.github.intellectualsites.plotsquared.plot.util.EventUtil; -import com.github.intellectualsites.plotsquared.plot.util.InventoryUtil; -import com.github.intellectualsites.plotsquared.plot.util.MainUtil; -import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils; -import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; -import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; -import com.github.intellectualsites.plotsquared.plot.util.StringMan; -import com.github.intellectualsites.plotsquared.plot.util.TaskManager; -import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; -import com.github.intellectualsites.plotsquared.plot.util.UUIDHandlerImplementation; +import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.bukkit.util.UpdateUtility; -import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; import com.sk89q.worldedit.WorldEdit; @@ -100,6 +86,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.getUserID; import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass; public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @@ -164,6 +151,15 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain new UpdateUtility(this).updateChecker(); + new PremiumVerification(); + PremiumVerification.isPremium(); + if (PremiumVerification.isPremium()) { + PlotSquared.log(Captions.PREFIX + "&6PlotSquared version licensed to Spigot user " + getUserID()); + PlotSquared.log(Captions.PREFIX + "&6Thanks for supporting us :)"); + } else { + PlotSquared.log(Captions.PREFIX + "&6Couldn't verify purchase :("); + } + if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { new Placeholders(this).register(); PlotSquared.log(Captions.PREFIX + "&6PlaceholderAPI found! Hook activated."); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugPaste.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugPaste.java index 426b46eaa..56232ef0b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugPaste.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugPaste.java @@ -25,6 +25,9 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.getDownloadID; +import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.getUserID; + @CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste", description = "Upload settings.yml, worlds.yml, PlotSquared.use_THIS.yml your latest.log and Multiverse's worlds.yml (if being used) to https://athion.net/ISPaster/paste", permission = "plots.debugpaste", category = CommandCategory.DEBUG, confirmation = true, requiredType = RequiredType.NONE) @@ -50,6 +53,8 @@ public class DebugPaste extends SubCommand { b.append( "# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your " + "problem\n\n"); + b.append("# PlotSquared Information\n"); + b.append("This PlotSquared version is licensed to the spigot user ").append(getUserID()).append(" under ").append(getDownloadID()).append("\n"); b.append("# Server Information\n"); b.append("Server Version: ").append(PlotSquared.get().IMP.getServerImplementation()) .append("\n"); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/PluginCmd.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/PluginCmd.java index 89bd81bec..5cbb7926d 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/PluginCmd.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/PluginCmd.java @@ -6,21 +6,18 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.TaskManager; +import static com.github.intellectualsites.plotsquared.plot.util.PremiumVerification.isPremium; + @CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", usage = "/plot plugin", aliases = "version", category = CommandCategory.INFO) public class PluginCmd extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { - TaskManager.IMP.taskAsync(new Runnable() { - @Override public void run() { - MainUtil.sendMessage(player, String.format( - "$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)", - PlotSquared.get().getVersion())); - MainUtil.sendMessage(player, - "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21 $2& $1NotMyFault"); - MainUtil.sendMessage(player, - "$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki"); - } + TaskManager.IMP.taskAsync(() -> { + MainUtil.sendMessage(player, String.format("$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)", PlotSquared.get().getVersion())); + MainUtil.sendMessage(player, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21 $2& $1NotMyFault"); + MainUtil.sendMessage(player, "$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki"); + MainUtil.sendMessage(player, "$2>> $1&lPremium$2: $1" + isPremium()); }); return true; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/PremiumVerification.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/PremiumVerification.java new file mode 100644 index 000000000..d9136d20b --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/PremiumVerification.java @@ -0,0 +1,35 @@ +package com.github.intellectualsites.plotsquared.plot.util; + +public class PremiumVerification { + private static Boolean usingPremium; + + /** + * @return Account ID if downloaded through SpigotMC + */ + public static String getUserID() { + return "%%__USER__%%"; + } + + /** + * @return Download ID if downloaded through SpigotMC + */ + public static String getDownloadID() { + return "%%__NONCE__%%"; + } + + /** + * @param userID Spigot user ID + * @return true if userID does not contain __USER__ + */ + private static Boolean isPremium(String userID) { + return !userID.contains("__USER__"); + } + + /** + * Returns true if this plugin is premium + */ + public static Boolean isPremium() { + return usingPremium == null ? isPremium(getUserID()) : usingPremium; + } + +}