From c493a0dece5780aa975ac5bf19899e3c369ebc9b Mon Sep 17 00:00:00 2001 From: Intelli Date: Mon, 19 Aug 2024 20:55:35 -0600 Subject: [PATCH] Added support for Community Edition builds --- .../net/coreprotect/command/CommandHandler.java | 2 +- .../net/coreprotect/command/StatusCommand.java | 3 ++- .../net/coreprotect/config/ConfigHandler.java | 1 + src/main/java/net/coreprotect/utility/Util.java | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/coreprotect/command/CommandHandler.java b/src/main/java/net/coreprotect/command/CommandHandler.java index 081e5bd..aaf5050 100755 --- a/src/main/java/net/coreprotect/command/CommandHandler.java +++ b/src/main/java/net/coreprotect/command/CommandHandler.java @@ -1290,7 +1290,7 @@ public class CommandHandler implements CommandExecutor { public void run() { try { Thread.sleep(5000); - Chat.sendMessage(user, Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_HEADER, "CoreProtect") + Color.WHITE + " -----"); + Chat.sendMessage(user, Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_HEADER, "CoreProtect" + (Util.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "")) + Color.WHITE + " -----"); Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_NOTICE, Color.WHITE, "CoreProtect v" + latestVersion)); Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DOWNLOAD, Color.WHITE, "www.coreprotect.net/download/")); } diff --git a/src/main/java/net/coreprotect/command/StatusCommand.java b/src/main/java/net/coreprotect/command/StatusCommand.java index 4c20e84..c46a42d 100755 --- a/src/main/java/net/coreprotect/command/StatusCommand.java +++ b/src/main/java/net/coreprotect/command/StatusCommand.java @@ -17,6 +17,7 @@ import net.coreprotect.patch.Patch; import net.coreprotect.thread.NetworkHandler; import net.coreprotect.utility.Chat; import net.coreprotect.utility.Color; +import net.coreprotect.utility.Util; public class StatusCommand { private static ConcurrentHashMap alert = new ConcurrentHashMap<>(); @@ -42,7 +43,7 @@ public class StatusCommand { } } - Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "-----"); + Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect" + (Util.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "") + Color.WHITE + " -----"); Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.STATUS_VERSION, Color.WHITE, ConfigHandler.EDITION_NAME + " v" + pdfFile.getVersion() + ".") + versionCheck); String donationKey = NetworkHandler.donationKey(); diff --git a/src/main/java/net/coreprotect/config/ConfigHandler.java b/src/main/java/net/coreprotect/config/ConfigHandler.java index 09dcf71..ab13b92 100644 --- a/src/main/java/net/coreprotect/config/ConfigHandler.java +++ b/src/main/java/net/coreprotect/config/ConfigHandler.java @@ -43,6 +43,7 @@ public class ConfigHandler extends Queue { public static final int EDITION_VERSION = 2; public static final String EDITION_BRANCH = Util.getBranch(); public static final String EDITION_NAME = Util.getPluginName(); + public static final String COMMUNITY_EDITION = "Community Edition"; public static final String JAVA_VERSION = "11.0"; public static final String SPIGOT_VERSION = "1.15"; public static String path = "plugins/CoreProtect/"; diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index 8e859b3..19b3e57 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -63,6 +63,7 @@ import net.coreprotect.database.rollback.Rollback; import net.coreprotect.language.Phrase; import net.coreprotect.model.BlockGroup; import net.coreprotect.thread.CacheHandler; +import net.coreprotect.thread.NetworkHandler; import net.coreprotect.thread.Scheduler; import net.coreprotect.utility.serialize.ItemMetaHandler; import net.coreprotect.worldedit.CoreProtectEditSessionEvent; @@ -112,6 +113,9 @@ public class Util extends Queue { if (branch.startsWith("-edge")) { name = name + " " + branch.substring(1, 2).toUpperCase() + branch.substring(2, 5); } + else if (isCommunityEdition()) { + name = name + " " + ConfigHandler.COMMUNITY_EDITION; + } return name; } @@ -1385,6 +1389,18 @@ public class Util extends Queue { return true; } + public static boolean isCommunityEdition() { + return !isBranch("edge") && !isBranch("coreprotect") && !validDonationKey(); + } + + public static boolean isBranch(String branch) { + return ConfigHandler.EDITION_BRANCH.contains("-" + branch); + } + + public static boolean validDonationKey() { + return NetworkHandler.donationKey() != null; + } + public static String getBranch() { String branch = ""; try {