Add Premium verification

This commit is contained in:
NotMyFault
2020-02-19 23:55:43 +01:00
parent a3759f93a2
commit 95394ec54f
4 changed files with 58 additions and 25 deletions

View File

@ -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");

View File

@ -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;
}

View File

@ -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;
}
}