From 422fbd14830c52b5c0ff4f78ea73ec8111f677dd Mon Sep 17 00:00:00 2001 From: Roman Zhuravlev Date: Sun, 2 Nov 2025 05:12:01 +0500 Subject: [PATCH] Remove version checks and donation key handling --- .../coreprotect/command/CommandHandler.java | 36 +------------------ .../coreprotect/command/StatusCommand.java | 26 ++------------ .../net/coreprotect/config/ConfigHandler.java | 1 - .../services/VersionCheckService.java | 2 +- .../coreprotect/thread/NetworkHandler.java | 10 ------ .../net/coreprotect/utility/VersionUtils.java | 21 +---------- 6 files changed, 5 insertions(+), 91 deletions(-) diff --git a/src/main/java/net/coreprotect/command/CommandHandler.java b/src/main/java/net/coreprotect/command/CommandHandler.java index 7e416ba..36b769b 100755 --- a/src/main/java/net/coreprotect/command/CommandHandler.java +++ b/src/main/java/net/coreprotect/command/CommandHandler.java @@ -120,12 +120,7 @@ public class CommandHandler implements CommandExecutor { NetworkDebugCommand.runCommand(user, permission, argumentArray); } else if (corecommand.equals("migrate-db")) { - if (!VersionUtils.validDonationKey()) { - Chat.sendMessage(user, Color.DARK_AQUA + "Griefus " + Color.WHITE + "- " + Phrase.build(Phrase.DONATION_KEY_REQUIRED)); - } - else { - Extensions.runDatabaseMigration(corecommand, user, argumentArray); - } + Extensions.runDatabaseMigration(corecommand, user, argumentArray); } else { Chat.sendMessage(user, Color.DARK_AQUA + "Griefus " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + corecommand)); @@ -135,35 +130,6 @@ public class CommandHandler implements CommandExecutor { Chat.sendMessage(user, Color.DARK_AQUA + "Griefus " + Color.WHITE + "- " + Phrase.build(Phrase.MISSING_PARAMETERS, Color.WHITE, "/co ")); } - if (user.isOp() && versionAlert.get(user.getName()) == null) { - String latestVersion = NetworkHandler.latestVersion(); - String latestEdgeVersion = NetworkHandler.latestEdgeVersion(); - if (latestVersion != null || latestEdgeVersion != null) { - versionAlert.put(user.getName(), true); - class updateAlert implements Runnable { - @Override - public void run() { - try { - Thread.sleep(5000); - Chat.sendMessage(user, Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_HEADER, "Griefus" + (VersionUtils.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "")) + Color.WHITE + " -----"); - if (latestVersion != null) { - Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_NOTICE, Color.WHITE, "Griefus CE v" + latestVersion)); - Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DOWNLOAD, Color.WHITE, "www.griefus.zhdev.org/download/")); - } - else if (!VersionUtils.isCommunityEdition()) { - Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_NOTICE, Color.WHITE, "Griefus v" + latestEdgeVersion)); - Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DOWNLOAD, Color.WHITE, "www.griefus.zhdev.org/latest/")); - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - } - (new Thread(new updateAlert())).start(); - } - } - return true; } diff --git a/src/main/java/net/coreprotect/command/StatusCommand.java b/src/main/java/net/coreprotect/command/StatusCommand.java index 5bfcc47..06a30f7 100755 --- a/src/main/java/net/coreprotect/command/StatusCommand.java +++ b/src/main/java/net/coreprotect/command/StatusCommand.java @@ -14,11 +14,9 @@ import net.coreprotect.consumer.process.Process; import net.coreprotect.language.Phrase; import net.coreprotect.language.Selector; import net.coreprotect.patch.Patch; -import net.coreprotect.thread.NetworkHandler; import net.coreprotect.utility.Chat; import net.coreprotect.utility.Color; import net.coreprotect.utility.SystemUtils; -import net.coreprotect.utility.VersionUtils; public class StatusCommand { private static ConcurrentHashMap alert = new ConcurrentHashMap<>(); @@ -36,28 +34,8 @@ public class StatusCommand { CoreProtect instance = CoreProtect.getInstance(); PluginDescriptionFile pdfFile = instance.getDescription(); - String versionCheck = ""; - if (Config.getGlobal().CHECK_UPDATES) { - String latestVersion = NetworkHandler.latestVersion(); - String latestEdgeVersion = NetworkHandler.latestEdgeVersion(); - if (latestVersion != null) { - versionCheck = " (" + Phrase.build(Phrase.LATEST_VERSION, "v" + latestVersion) + ")"; - } - else if (latestEdgeVersion != null && !VersionUtils.isCommunityEdition()) { - versionCheck = " (" + Phrase.build(Phrase.LATEST_VERSION, "v" + latestEdgeVersion) + ")"; - } - } - - Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA + "Griefus" + (VersionUtils.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(); - if (donationKey != null) { - Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.STATUS_LICENSE, Color.WHITE, Phrase.build(Phrase.VALID_DONATION_KEY)) + " (" + donationKey + ")"); - } - else { - Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.STATUS_LICENSE, Color.WHITE, Phrase.build(Phrase.INVALID_DONATION_KEY)) + Color.GREY + Color.ITALIC + " (" + Phrase.build(Phrase.CHECK_CONFIG) + ")"); - } + Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA + "Griefus" + Color.WHITE + " -----"); + Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.STATUS_VERSION, Color.WHITE, ConfigHandler.EDITION_NAME + " v" + pdfFile.getVersion())); /* Items processed (since server start) diff --git a/src/main/java/net/coreprotect/config/ConfigHandler.java b/src/main/java/net/coreprotect/config/ConfigHandler.java index 88187a1..3deac5d 100644 --- a/src/main/java/net/coreprotect/config/ConfigHandler.java +++ b/src/main/java/net/coreprotect/config/ConfigHandler.java @@ -49,7 +49,6 @@ public class ConfigHandler extends Queue { public static final int EDITION_VERSION = 2; public static final String EDITION_BRANCH = VersionUtils.getBranch(); public static final String EDITION_NAME = VersionUtils.getPluginName(); - public static final String COMMUNITY_EDITION = "Community Edition"; public static final String JAVA_VERSION = "11.0"; public static final String MINECRAFT_VERSION = "1.16"; public static final String PATCH_VERSION = "23.0"; diff --git a/src/main/java/net/coreprotect/services/VersionCheckService.java b/src/main/java/net/coreprotect/services/VersionCheckService.java index 34b04ac..803545a 100644 --- a/src/main/java/net/coreprotect/services/VersionCheckService.java +++ b/src/main/java/net/coreprotect/services/VersionCheckService.java @@ -32,7 +32,7 @@ public class VersionCheckService { return false; } - if (VersionUtils.newVersion(ConfigHandler.LATEST_VERSION, bukkitVersion[0] + "." + bukkitVersion[1] + (bukkitVersion.length > 2 && bukkitVersion[2].matches("\\d+") ? "." + bukkitVersion[2] : "")) && VersionUtils.isCommunityEdition()) { + if (VersionUtils.newVersion(ConfigHandler.LATEST_VERSION, bukkitVersion[0] + "." + bukkitVersion[1] + (bukkitVersion.length > 2 && bukkitVersion[2].matches("\\d+") ? "." + bukkitVersion[2] : ""))) { Chat.console(Phrase.build(Phrase.VERSION_INCOMPATIBLE, "Minecraft", bukkitVersion[0] + "." + bukkitVersion[1] + (bukkitVersion.length > 2 ? "." + bukkitVersion[2] : ""))); return false; } diff --git a/src/main/java/net/coreprotect/thread/NetworkHandler.java b/src/main/java/net/coreprotect/thread/NetworkHandler.java index bb0050f..b17f5b8 100755 --- a/src/main/java/net/coreprotect/thread/NetworkHandler.java +++ b/src/main/java/net/coreprotect/thread/NetworkHandler.java @@ -39,22 +39,12 @@ public class NetworkHandler extends Language implements Runnable { private boolean startup = true; private boolean background = false; private boolean translate = true; - private static String latestVersion = null; - private static String latestEdgeVersion = null; public NetworkHandler(boolean startup, boolean background) { this.startup = startup; this.background = background; } - public static String latestVersion() { - return latestVersion; - } - - public static String latestEdgeVersion() { - return latestEdgeVersion; - } - @Override public void run() { try { diff --git a/src/main/java/net/coreprotect/utility/VersionUtils.java b/src/main/java/net/coreprotect/utility/VersionUtils.java index d232505..9a11dea 100644 --- a/src/main/java/net/coreprotect/utility/VersionUtils.java +++ b/src/main/java/net/coreprotect/utility/VersionUtils.java @@ -9,7 +9,6 @@ import org.bukkit.plugin.Plugin; import net.coreprotect.CoreProtect; import net.coreprotect.config.ConfigHandler; import net.coreprotect.language.Phrase; -import net.coreprotect.thread.NetworkHandler; import net.coreprotect.worldedit.CoreProtectEditSessionEvent; public class VersionUtils { @@ -57,17 +56,7 @@ public class VersionUtils { return "Griefus"; } - String name = instance.getDescription().getName(); - String branch = ConfigHandler.EDITION_BRANCH; - - 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; + return instance.getDescription().getName(); } public static boolean isSpigot() { @@ -103,18 +92,10 @@ public class VersionUtils { 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 {