1
mirror of https://github.com/CarmJos/UserPrefix.git synced 2026-06-05 00:35:02 +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("注册变量..."); log("注册变量...");
new UserPrefixExpansion(getInstance()).register(); new UserPrefixExpansion(getInstance()).register();
} else { } else {
log("未安装 PlaceholderAPI 放弃注册变量..."); log("未安装 PlaceholderAPI 不进行变量注册...");
log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI");
} }
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。"); log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
showAD();
if (Bukkit.getOnlinePlayers().size() > 0) { if (Bukkit.getOnlinePlayers().size() > 0) {
Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载 Bukkit.getOnlinePlayers().forEach(UserManager::initPlayer); // 适配热重载
} }
@@ -64,6 +67,9 @@ public class Main extends JavaPlugin {
Bukkit.getServicesManager().unregisterAll(this); Bukkit.getServicesManager().unregisterAll(this);
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。"); log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
showAD();
} }
/** /**
@@ -89,4 +95,9 @@ public class Main extends JavaPlugin {
return instance; 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)) { for (String prefixIdentifier : prefixesSection.getKeys(false)) {
ConfigurationSection configuredPrefixSection = prefixesSection.getConfigurationSection(prefixIdentifier); ConfigurationSection configuredPrefixSection = prefixesSection.getConfigurationSection(prefixIdentifier);
if (configuredPrefixSection == null) continue; if (configuredPrefixSection == null) continue;
try {
String name = configuredPrefixSection.getString("name", "前缀名配置错误"); String name = configuredPrefixSection.getString("name", "前缀名配置错误");
String content = configuredPrefixSection.getString("content", "&r"); String content = configuredPrefixSection.getString("content", "&r");
String permission = configuredPrefixSection.getString("permission"); String permission = configuredPrefixSection.getString("permission");
@@ -57,6 +57,10 @@ public class PrefixManager {
Main.log("完成前缀加载 " + prefixIdentifier + " : " + name); Main.log("完成前缀加载 " + prefixIdentifier + " : " + name);
dataPrefixes.put(prefixIdentifier, new ConfiguredPrefix(prefixIdentifier, name, content, weight, permission, itemHasPermission, itemNoPermission, itemUsing)); dataPrefixes.put(prefixIdentifier, new ConfiguredPrefix(prefixIdentifier, name, content, weight, permission, itemHasPermission, itemNoPermission, itemUsing));
} catch (Exception exception) {
Main.log("在加载前缀 " + prefixIdentifier + " 时出错,请检查配置!");
exception.printStackTrace();
}
} }
PrefixManager.prefixes.clear(); PrefixManager.prefixes.clear();
@@ -67,6 +71,7 @@ public class PrefixManager {
PrefixManager.defaultPrefix = null; PrefixManager.defaultPrefix = null;
ConfigurationSection defaultPrefixSection = ConfigManager.getConfig().getConfigurationSection("defaultPrefix"); ConfigurationSection defaultPrefixSection = ConfigManager.getConfig().getConfigurationSection("defaultPrefix");
if (defaultPrefixSection != null) { if (defaultPrefixSection != null) {
try {
String name = defaultPrefixSection.getString("name", "默认前缀"); String name = defaultPrefixSection.getString("name", "默认前缀");
String content = defaultPrefixSection.getString("content", "&r"); String content = defaultPrefixSection.getString("content", "&r");
ItemStack itemNotUsing = defaultPrefixSection.getItemStack( ItemStack itemNotUsing = defaultPrefixSection.getItemStack(
@@ -87,6 +92,10 @@ public class PrefixManager {
.toItemStack() .toItemStack()
); );
PrefixManager.defaultPrefix = new ConfiguredPrefix("default", name, content, 0, null, itemNotUsing, null, itemUsing); PrefixManager.defaultPrefix = new ConfiguredPrefix("default", name, content, 0, null, itemNotUsing, null, itemUsing);
} catch (Exception ex) {
Main.log("在加载默认前缀时出错,请检查配置!");
ex.printStackTrace();
}
} else { } else {
PrefixManager.defaultPrefix = new ConfiguredPrefix("default", "默认前缀", "&r", 0, null, PrefixManager.defaultPrefix = new ConfiguredPrefix("default", "默认前缀", "&r", 0, null,
new ItemStackFactory(Material.NAME_TAG) new ItemStackFactory(Material.NAME_TAG)
+2
View File
@@ -3,6 +3,8 @@ name: UserPrefix
version: ${project.version} version: ${project.version}
authors: authors:
- Carm - Carm
- YourCraft
- SakuraGame
depend: depend:
- LuckPerms - LuckPerms
softdepend: softdepend: