Skip to content

Commit

Permalink
Added support for Community Edition builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Aug 20, 2024
1 parent cff6be6 commit c493a0d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/coreprotect/command/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ class updateAlert implements Runnable {
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/"));
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/coreprotect/command/StatusCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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<String, Boolean> alert = new ConcurrentHashMap<>();
Expand All @@ -42,7 +43,7 @@ public void run() {
}
}

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();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/coreprotect/config/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/net/coreprotect/utility/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
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;
Expand Down Expand Up @@ -112,6 +113,9 @@ public static String getPluginName() {
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;
}
Expand Down Expand Up @@ -1385,6 +1389,18 @@ public static boolean isFolia() {
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 {
Expand Down

0 comments on commit c493a0d

Please sign in to comment.