Skip to content

Commit

Permalink
Add NMS check information on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzimmermann committed May 28, 2024
1 parent 5b7e466 commit 6b5cfa5
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.codingair.codingapi.API;
import de.codingair.codingapi.files.ConfigFile;
import de.codingair.codingapi.files.FileManager;
import de.codingair.codingapi.nms.NmsCheck;
import de.codingair.codingapi.player.chat.ChatButtonManager;
import de.codingair.codingapi.server.specification.Version;
import de.codingair.codingapi.utils.Value;
Expand Down Expand Up @@ -40,6 +41,7 @@
import org.jetbrains.annotations.NotNull;

import java.io.FileNotFoundException;
import java.util.logging.Level;

public class TradeSystem extends JavaPlugin implements Proxy {
private static TradeSystem instance;
Expand All @@ -62,6 +64,7 @@ public class TradeSystem extends JavaPlugin implements Proxy {
private TradeCMD tradeCMD;

private boolean firstSetup;
private boolean workingNms = false;
private YamlConfiguration oldConfig;

public static void log(String message) {
Expand Down Expand Up @@ -95,6 +98,8 @@ public static InvitationManager invitations() {
@Override
public void onEnable() {
instance = this;
checkNms();

API.getInstance().onEnable(this);

printConsoleInfo(() -> {
Expand Down Expand Up @@ -130,6 +135,12 @@ public void onEnable() {

@Override
public void onDisable() {
if (!workingNms) {
getLogger().log(Level.SEVERE, "This Minecraft version does not seem to be supported yet. Please contact the author with the given error above.");
getLogger().log(Level.SEVERE, "Here's an invitation to the discord for support: https://discord.gg/DxKMcGjQbp");
return;
} else workingNms = false;

API.getInstance().onDisable(this);
Bukkit.getScheduler().cancelTasks(this);

Expand Down Expand Up @@ -179,6 +190,11 @@ private void printConsoleInfo(Runnable runnable) {
log(" ");
}

private void checkNms() {
NmsCheck.test(new Class[0]);
workingNms = true;
}

private void loadManagers() {
this.tradeHandler.load();
this.layoutManager.load();
Expand Down

0 comments on commit 6b5cfa5

Please sign in to comment.