Parcourir la source

Adding check if PAPI is installed on the server

RedstoneFuture il y a 1 semaine
Parent
commit
773ef6bd4c

+ 7 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/MissileWars.java

@@ -61,6 +61,8 @@ public class MissileWars extends JavaPlugin {
     
     @Getter private Paster schematicPaster;
     
+    private boolean isPapiInstalled;
+    
     public MissileWars() {
         instance = this;
     }
@@ -131,7 +133,11 @@ public class MissileWars extends JavaPlugin {
     private void initialPapiSupport() {
         if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
             new MissileWarsPlaceholder(this).register();
-            Logger.NORMAL.log("The PlaceholderAPI is installed. New placeholders are provided by MissileWars.");
+            isPapiInstalled = true;
+            Logger.NORMAL.log("PlaceholderAPI is installed. New placeholders are provided by MissileWars.");
+        } else {
+            isPapiInstalled = false;
+            Logger.NORMAL.log("PlaceholderAPI is not installed. Placeholders arent working for now.");
         }
     }
     

+ 3 - 0
missilewars-plugin/src/main/java/de/butzlabben/missilewars/configuration/PluginMessages.java

@@ -263,6 +263,9 @@ public class PluginMessages {
     }
     
     public static String getPapiMessage(String message, Player player) {
+        // Is PAPI (soft-depend) installed on the server?
+        if (!MissileWars.getInstance().isPapiInstalled()) return message;
+        
         return ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player, message));
     }
 }