1
mirror of https://github.com/CarmJos/UserPrefix.git synced 2026-06-04 15:28:21 +08:00

当出现错误时,将发送错误的前缀是哪一个。

This commit is contained in:
carm
2021-09-15 16:36:25 +08:00
parent ee2cc259ef
commit 85f5e7d95a
3 changed files with 55 additions and 33 deletions
@@ -43,12 +43,15 @@ public class Main extends JavaPlugin {
log("注册变量...");
new UserPrefixExpansion(getInstance()).register();
} else {
log("未安装 PlaceholderAPI 放弃注册变量...");
log("未安装 PlaceholderAPI 不进行变量注册...");
log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI");
}
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
showAD();
if (Bukkit.getOnlinePlayers().size() > 0) {
Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载
}
@@ -64,6 +67,9 @@ public class Main extends JavaPlugin {
Bukkit.getServicesManager().unregisterAll(this);
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
showAD();
}
/**
@@ -89,4 +95,9 @@ public class Main extends JavaPlugin {
return instance;
}
private void showAD() {
log("&7感谢您使用 &3&lUserPrefix " + getDescription().getVersion() + "&7!");
log("&7本插件由 &b&lYourCraft &7提供长期支持与维护。");
}
}
@@ -41,7 +41,7 @@ public class PrefixManager {
for (String prefixIdentifier : prefixesSection.getKeys(false)) {
ConfigurationSection configuredPrefixSection = prefixesSection.getConfigurationSection(prefixIdentifier);
if (configuredPrefixSection == null) continue;
try {
String name = configuredPrefixSection.getString("name", "前缀名配置错误");
String content = configuredPrefixSection.getString("content", "&r");
String permission = configuredPrefixSection.getString("permission");
@@ -57,6 +57,10 @@ public class PrefixManager {
Main.log("完成前缀加载 " + prefixIdentifier + " : " + name);
dataPrefixes.put(prefixIdentifier, new ConfiguredPrefix(prefixIdentifier, name, content, weight, permission, itemHasPermission, itemNoPermission, itemUsing));
} catch (Exception exception) {
Main.log("在加载前缀 " + prefixIdentifier + " 时出错,请检查配置!");
exception.printStackTrace();
}
}
PrefixManager.prefixes.clear();
@@ -67,6 +71,7 @@ public class PrefixManager {
PrefixManager.defaultPrefix = null;
ConfigurationSection defaultPrefixSection = ConfigManager.getConfig().getConfigurationSection("defaultPrefix");
if (defaultPrefixSection != null) {
try {
String name = defaultPrefixSection.getString("name", "默认前缀");
String content = defaultPrefixSection.getString("content", "&r");
ItemStack itemNotUsing = defaultPrefixSection.getItemStack(
@@ -87,6 +92,10 @@ public class PrefixManager {
.toItemStack()
);
PrefixManager.defaultPrefix = new ConfiguredPrefix("default", name, content, 0, null, itemNotUsing, null, itemUsing);
} catch (Exception ex) {
Main.log("在加载默认前缀时出错,请检查配置!");
ex.printStackTrace();
}
} else {
PrefixManager.defaultPrefix = new ConfiguredPrefix("default", "默认前缀", "&r", 0, null,
new ItemStackFactory(Material.NAME_TAG)
+2
View File
@@ -3,6 +3,8 @@ name: UserPrefix
version: ${project.version}
authors:
- Carm
- YourCraft
- SakuraGame
depend:
- LuckPerms
softdepend: