Remove version checks and donation key handling

This commit is contained in:
Roman Zhuravlev 2025-11-02 05:12:01 +05:00
parent b04735a0c5
commit 422fbd1483
6 changed files with 5 additions and 91 deletions

View file

@ -120,12 +120,7 @@ public class CommandHandler implements CommandExecutor {
NetworkDebugCommand.runCommand(user, permission, argumentArray); NetworkDebugCommand.runCommand(user, permission, argumentArray);
} }
else if (corecommand.equals("migrate-db")) { else if (corecommand.equals("migrate-db")) {
if (!VersionUtils.validDonationKey()) { Extensions.runDatabaseMigration(corecommand, user, argumentArray);
Chat.sendMessage(user, Color.DARK_AQUA + "Griefus " + Color.WHITE + "- " + Phrase.build(Phrase.DONATION_KEY_REQUIRED));
}
else {
Extensions.runDatabaseMigration(corecommand, user, argumentArray);
}
} }
else { else {
Chat.sendMessage(user, Color.DARK_AQUA + "Griefus " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + corecommand)); 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 <parameters>")); Chat.sendMessage(user, Color.DARK_AQUA + "Griefus " + Color.WHITE + "- " + Phrase.build(Phrase.MISSING_PARAMETERS, Color.WHITE, "/co <parameters>"));
} }
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; return true;
} }

View file

@ -14,11 +14,9 @@ import net.coreprotect.consumer.process.Process;
import net.coreprotect.language.Phrase; import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector; import net.coreprotect.language.Selector;
import net.coreprotect.patch.Patch; import net.coreprotect.patch.Patch;
import net.coreprotect.thread.NetworkHandler;
import net.coreprotect.utility.Chat; import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color; import net.coreprotect.utility.Color;
import net.coreprotect.utility.SystemUtils; import net.coreprotect.utility.SystemUtils;
import net.coreprotect.utility.VersionUtils;
public class StatusCommand { public class StatusCommand {
private static ConcurrentHashMap<String, Boolean> alert = new ConcurrentHashMap<>(); private static ConcurrentHashMap<String, Boolean> alert = new ConcurrentHashMap<>();
@ -36,28 +34,8 @@ public class StatusCommand {
CoreProtect instance = CoreProtect.getInstance(); CoreProtect instance = CoreProtect.getInstance();
PluginDescriptionFile pdfFile = instance.getDescription(); PluginDescriptionFile pdfFile = instance.getDescription();
String versionCheck = ""; Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA + "Griefus" + Color.WHITE + " -----");
if (Config.getGlobal().CHECK_UPDATES) { Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.STATUS_VERSION, Color.WHITE, ConfigHandler.EDITION_NAME + " v" + pdfFile.getVersion()));
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) + ")");
}
/* /*
Items processed (since server start) Items processed (since server start)

View file

@ -49,7 +49,6 @@ public class ConfigHandler extends Queue {
public static final int EDITION_VERSION = 2; public static final int EDITION_VERSION = 2;
public static final String EDITION_BRANCH = VersionUtils.getBranch(); public static final String EDITION_BRANCH = VersionUtils.getBranch();
public static final String EDITION_NAME = VersionUtils.getPluginName(); 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 JAVA_VERSION = "11.0";
public static final String MINECRAFT_VERSION = "1.16"; public static final String MINECRAFT_VERSION = "1.16";
public static final String PATCH_VERSION = "23.0"; public static final String PATCH_VERSION = "23.0";

View file

@ -32,7 +32,7 @@ public class VersionCheckService {
return false; 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] : ""))); Chat.console(Phrase.build(Phrase.VERSION_INCOMPATIBLE, "Minecraft", bukkitVersion[0] + "." + bukkitVersion[1] + (bukkitVersion.length > 2 ? "." + bukkitVersion[2] : "")));
return false; return false;
} }

View file

@ -39,22 +39,12 @@ public class NetworkHandler extends Language implements Runnable {
private boolean startup = true; private boolean startup = true;
private boolean background = false; private boolean background = false;
private boolean translate = true; private boolean translate = true;
private static String latestVersion = null;
private static String latestEdgeVersion = null;
public NetworkHandler(boolean startup, boolean background) { public NetworkHandler(boolean startup, boolean background) {
this.startup = startup; this.startup = startup;
this.background = background; this.background = background;
} }
public static String latestVersion() {
return latestVersion;
}
public static String latestEdgeVersion() {
return latestEdgeVersion;
}
@Override @Override
public void run() { public void run() {
try { try {

View file

@ -9,7 +9,6 @@ import org.bukkit.plugin.Plugin;
import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler; import net.coreprotect.config.ConfigHandler;
import net.coreprotect.language.Phrase; import net.coreprotect.language.Phrase;
import net.coreprotect.thread.NetworkHandler;
import net.coreprotect.worldedit.CoreProtectEditSessionEvent; import net.coreprotect.worldedit.CoreProtectEditSessionEvent;
public class VersionUtils { public class VersionUtils {
@ -57,17 +56,7 @@ public class VersionUtils {
return "Griefus"; return "Griefus";
} }
String name = instance.getDescription().getName(); return 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;
} }
public static boolean isSpigot() { public static boolean isSpigot() {
@ -103,18 +92,10 @@ public class VersionUtils {
return true; return true;
} }
public static boolean isCommunityEdition() {
return !isBranch("edge") && !isBranch("coreprotect") && !validDonationKey();
}
public static boolean isBranch(String branch) { public static boolean isBranch(String branch) {
return ConfigHandler.EDITION_BRANCH.contains("-" + branch); return ConfigHandler.EDITION_BRANCH.contains("-" + branch);
} }
public static boolean validDonationKey() {
return NetworkHandler.donationKey() != null;
}
public static String getBranch() { public static String getBranch() {
String branch = ""; String branch = "";
try { try {