Skip to content

Commit

Permalink
Only start CoreProtect on supported Minecraft versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Aug 20, 2024
1 parent c493a0d commit ea1b86c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/main/java/net/coreprotect/CoreProtect.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ public void onDisable() {
private static boolean performVersionChecks() {
try {
String[] bukkitVersion = Bukkit.getServer().getBukkitVersion().split("[-.]");
if (Util.newVersion(bukkitVersion[0] + "." + bukkitVersion[1], ConfigHandler.SPIGOT_VERSION)) {
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Spigot", ConfigHandler.SPIGOT_VERSION));
if (Util.newVersion(bukkitVersion[0] + "." + bukkitVersion[1], ConfigHandler.MINECRAFT_VERSION)) {
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Minecraft", ConfigHandler.MINECRAFT_VERSION));
return false;
}
if (Util.newVersion(ConfigHandler.LATEST_VERSION, bukkitVersion[0] + "." + bukkitVersion[1]) && Util.isBranch("master")) {
Chat.console(Phrase.build(Phrase.VERSION_INCOMPATIBLE, "Minecraft", bukkitVersion[0] + "." + bukkitVersion[1]));
return false;
}
String[] javaVersion = (System.getProperty("java.version").replaceAll("[^0-9.]", "") + ".0").split("\\.");
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/coreprotect/command/PurgeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ else if (endTime < 86400) {
int restrictCount = 0;

if (argBlocks.size() > 0) {
if (!Util.validDonationKey()) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DONATION_KEY_REQUIRED));
return;
}

StringBuilder includeListMaterial = new StringBuilder();
StringBuilder includeListEntity = new StringBuilder();

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/coreprotect/config/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class ConfigHandler extends Queue {
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 final String MINECRAFT_VERSION = "1.15";
public static final String LATEST_VERSION = "1.21";
public static String path = "plugins/CoreProtect/";
public static String sqlite = "database.db";
public static String host = "127.0.0.1";
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/language/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static void loadPhrases() {
phrases.put(Phrase.DEVELOPMENT_BRANCH, "Development branch detected, skipping patch scripts.");
phrases.put(Phrase.DIRT_BLOCK, "Placed a temporary safety block under you.");
phrases.put(Phrase.DISABLE_SUCCESS, "Success! Disabled {0}");
phrases.put(Phrase.DONATION_KEY_REQUIRED, "A valid donation key is required for that command.");
phrases.put(Phrase.ENABLE_FAILED, "{0} was unable to start.");
phrases.put(Phrase.ENABLE_SUCCESS, "{0} has been successfully enabled!");
phrases.put(Phrase.ENJOY_COREPROTECT, "Enjoy {0}? Join our Discord!");
Expand Down Expand Up @@ -232,6 +233,7 @@ public static void loadPhrases() {
phrases.put(Phrase.USING_SQLITE, "Using SQLite for data storage.");
phrases.put(Phrase.VALID_DONATION_KEY, "Valid donation key.");
phrases.put(Phrase.VERSION_NOTICE, "Version {0} is now available.");
phrases.put(Phrase.VERSION_INCOMPATIBLE, "{0} {1} is not supported.");
phrases.put(Phrase.VERSION_REQUIRED, "{0} {1} or higher is required.");
phrases.put(Phrase.WORLD_NOT_FOUND, "World \"{0}\" not found.");

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/language/Phrase.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public enum Phrase {
DEVELOPMENT_BRANCH,
DIRT_BLOCK,
DISABLE_SUCCESS,
DONATION_KEY_REQUIRED,
ENABLE_FAILED,
ENABLE_SUCCESS,
ENJOY_COREPROTECT,
Expand Down Expand Up @@ -215,6 +216,7 @@ public enum Phrase {
USING_SQLITE,
VALID_DONATION_KEY,
VERSION_NOTICE,
VERSION_INCOMPATIBLE,
VERSION_REQUIRED,
WORLD_NOT_FOUND;

Expand Down

0 comments on commit ea1b86c

Please sign in to comment.