Skip to content

Commit

Permalink
重写插件是否存在的判断
Browse files Browse the repository at this point in the history
  • Loading branch information
stevei5mc committed Aug 26, 2024
1 parent 43c84c7 commit 2d77c2f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import healthapi.PlayerHealth;
import cn.stevei5mc.NewTipsVariables.variables.LoadSupportPlugins;
import cn.nukkit.utils.Config;
import cn.stevei5mc.NewTipsVariables.utils.PluginsState;

public class GetConfigInfo {
/**
Expand Down Expand Up @@ -93,7 +94,7 @@ public static String getPlayerHealth(Player player) {
double healthValue;
String healthValue2;
String healthMaxValue;
if (LoadSupportPlugins.pl5) {
if (PluginsState.getInstance().healthAPI) {
PlayerHealth health = PlayerHealth.getPlayerHealth(player);
healthValue = health.getHealth();
healthValue2 = String.valueOf(healthValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,43 @@ public static PluginsState getInstance() {

// 插件的状态
public boolean playerPoints = false;
public boolean EconomyAPI = false;
public boolean OreArea = false;
public boolean RSTask = false;
public boolean HealthAPI = false;
public boolean LevelAwakenSystem = false;
public boolean RSWeapon = false;
public boolean LuckPerms = false;
public boolean economyAPI = false;
public boolean oreArea = false;
public boolean rSTask = false;
public boolean healthAPI = false;
public boolean levelAwakenSystem = false;
public boolean rSWeapon = false;
public boolean luckPerms = false;

public void setPluginState(String pluginName) {

switch (pluginName) {
case "playerPoints":
playerPoints = true;
break;
case "EconomyAPI":
economyAPI = true;
break;
case "OreArea":
oreArea = true;
break;
case "RSTask":
rSTask = true;
break;
case "HealthAPI":
healthAPI = true;
break;
case "LevelAwakenSystem":
levelAwakenSystem = true;
break;
case "RSWeapon":
rSWeapon = true;
break;
case "LuckPerms":
luckPerms = true;
break;
default:
// 对于其他插件,不做任何操作,因为没有必要
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,37 @@
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.LuckPermsVar;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
import cn.stevei5mc.NewTipsVariables.utils.PluginsState;
import java.util.*;

public class LoadSupportPlugins{
private static LuckPerms luckperms;
public static LuckPerms getLP() {
return luckperms;
}

//加载相关插件的变量时的提示
public static String successMsg = Main.debugPrefix+"§a找到插件§e【§b{0}§e】§a相关变量已加载";
public static String failureMsg = Main.debugPrefix+"§c无法找到插件§e【§b{0}§e】§c相关变量加载失败,请安装相关插件再试";

//需要加载的变量的插件
public static void loadSupportVariables(Player player) {
/* boolean debug = Main.debug;
String plugin;
plugin = "playerPoints";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
pl1 = true;
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
PluginsState ps = PluginsState.getInstance();
String successMsg = Main.debugPrefix+"§a找到插件§e【§b{0}§e】§a相关变量已加载";
String failureMsg = Main.debugPrefix+"§c无法找到插件§e【§b{0}§e】§c相关变量加载失败,请安装相关插件再试";
boolean debug = Main.debug;
List<String> pluginList = Arrays.asList("playerPoints","EconomyAPI","OreArea","RSTask","HealthAPI","LevelAwakenSystem","RSWeapon","LuckPerms");
for(String plugin: pluginList){
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
ps.setPluginState(plugin);
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
}
}
plugin = "EconomyAPI";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
Api.registerVariables("SmallasWaterPlugins", SmallasWaterPlugins.class);
if (ps.economyAPI) {
Api.registerVariables("economyApiVariable", economyApiVariable.class);
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
}
plugin = "OreArea";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
pl3 = true;
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
}
plugin = "RSTask";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
pl4 = true;
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
}
plugin = "HealthAPI";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
pl5 = true;
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
}
plugin = "LevelAwakenSystem";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
pl6 = true;
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
}
plugin = "RSWeapon";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
pl7 = true;
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
}
Api.registerVariables("SmallasWaterPlugins", SmallasWaterPlugins.class);
plugin = "LuckPerms";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
if (ps.luckPerms) {
luckperms = LuckPermsProvider.get();
Api.registerVariables("LuckPermsVar", LuckPermsVar.class);
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
}
} */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public void strReplace() {
if (ps.playerPoints) {
playerPoint();
}
if (ps.RsTask) {
if (ps.rSTask) {
RsTask();
}
if (ps.OreArea) {
if (ps.oreArea) {
OreArea();
}
if (ps.HealthAPI) {
if (ps.healthAPI) {
HealthAPI();
}
if (ps.RSWeapon) {
if (ps.rSWeapon) {
RSWeapon();
}
if (ps.LevelAwakenSystem) {
if (ps.levelAwakenSystem) {
LevelAwakenSystem();
}
}
Expand Down

0 comments on commit 2d77c2f

Please sign in to comment.