+ 修复配置文件错误

+ 隐藏 /taboolib 命令下的部分子命令
This commit is contained in:
坏黑 2018-12-24 23:05:06 +08:00
parent 87dc1252f1
commit 738bb7820a
6 changed files with 95 additions and 15 deletions

View File

@ -7,6 +7,7 @@ import com.ilummc.tlib.filter.impl.FilterExceptionMirror;
import com.ilummc.tlib.filter.impl.FilterInvalidPluginLoader; import com.ilummc.tlib.filter.impl.FilterInvalidPluginLoader;
import me.skymc.taboolib.TabooLib; import me.skymc.taboolib.TabooLib;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -63,6 +64,18 @@ public class TLoggerFilter implements Filter {
} }
} }
public static void eject(Plugin plugin) {
try {
if (plugin.getLogger().getFilter() instanceof TLoggerFilter) {
((TLoggerFilter) plugin.getLogger().getFilter()).filter = null;
((TLoggerFilter) plugin.getLogger().getFilter()).logger = null;
plugin.getLogger().setFilter(null);
}
} catch (Throwable t) {
t.printStackTrace();
}
}
public static TLoggerFilter getGlobalFilter() { public static TLoggerFilter getGlobalFilter() {
return globalFilter; return globalFilter;
} }

View File

@ -182,12 +182,14 @@ public class TabooLibMainCommand extends BaseMainCommand {
} }
}; };
@CommandRegister(priority = 5)
BaseSubCommand emptyLine1 = null;
@CommandRegister(priority = 6) @CommandRegister(priority = 6)
BaseSubCommand attributes = new BaseSubCommand() { BaseSubCommand attributes = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "attributes"; return "attributes";
@ -212,6 +214,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 7) @CommandRegister(priority = 7)
BaseSubCommand enchants = new BaseSubCommand() { BaseSubCommand enchants = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "enchants"; return "enchants";
@ -236,6 +243,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 8) @CommandRegister(priority = 8)
BaseSubCommand potions = new BaseSubCommand() { BaseSubCommand potions = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "potions"; return "potions";
@ -260,6 +272,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 9) @CommandRegister(priority = 9)
BaseSubCommand flags = new BaseSubCommand() { BaseSubCommand flags = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "flags"; return "flags";
@ -284,6 +301,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 10) @CommandRegister(priority = 10)
BaseSubCommand slots = new BaseSubCommand() { BaseSubCommand slots = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "slots"; return "slots";
@ -308,6 +330,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 11) @CommandRegister(priority = 11)
BaseSubCommand sounds = new BaseSubCommand() { BaseSubCommand sounds = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "sounds"; return "sounds";
@ -334,12 +361,14 @@ public class TabooLibMainCommand extends BaseMainCommand {
} }
}; };
@CommandRegister(priority = 12)
BaseSubCommand emptyLine2 = null;
@CommandRegister(priority = 13) @CommandRegister(priority = 13)
BaseSubCommand getVariable = new BaseSubCommand() { BaseSubCommand getVariable = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "getVariable"; return "getVariable";
@ -372,6 +401,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 13.1) @CommandRegister(priority = 13.1)
BaseSubCommand setVariable = new BaseSubCommand() { BaseSubCommand setVariable = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "setVariable"; return "setVariable";
@ -402,12 +436,14 @@ public class TabooLibMainCommand extends BaseMainCommand {
} }
}; };
@CommandRegister(priority = 13.2)
BaseSubCommand getEmptyLine3 = null;
@CommandRegister(priority = 13.3) @CommandRegister(priority = 13.3)
BaseSubCommand cycleList = new BaseSubCommand() { BaseSubCommand cycleList = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "cycleList"; return "cycleList";
@ -434,6 +470,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 14) @CommandRegister(priority = 14)
BaseSubCommand cycleInfo = new BaseSubCommand() { BaseSubCommand cycleInfo = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "cycleInfo"; return "cycleInfo";
@ -477,6 +518,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 15) @CommandRegister(priority = 15)
BaseSubCommand cycleReset = new BaseSubCommand() { BaseSubCommand cycleReset = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "cycleReset"; return "cycleReset";
@ -520,6 +566,11 @@ public class TabooLibMainCommand extends BaseMainCommand {
@CommandRegister(priority = 16) @CommandRegister(priority = 16)
BaseSubCommand cycleUpdate = new BaseSubCommand() { BaseSubCommand cycleUpdate = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "cycleUpdate"; return "cycleUpdate";
@ -689,11 +740,14 @@ public class TabooLibMainCommand extends BaseMainCommand {
} }
}; };
@CommandRegister(priority = 24)
BaseSubCommand getEmptyLine6 = null;
@CommandRegister(priority = 24.1) @CommandRegister(priority = 24.1)
BaseSubCommand lagServer = new BaseSubCommand() { BaseSubCommand lagServer = new BaseSubCommand() {
@Override
public boolean hideInHelp() {
return true;
}
@Override @Override
public String getLabel() { public String getLabel() {
return "lagServer"; return "lagServer";

View File

@ -189,7 +189,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
sender.sendMessage(getEmptyLine()); sender.sendMessage(getEmptyLine());
sender.sendMessage(getCommandTitle()); sender.sendMessage(getCommandTitle());
sender.sendMessage(getEmptyLine()); sender.sendMessage(getEmptyLine());
subCommands.stream().filter(subCommands -> hasPermission(sender, subCommands)).map(subCommand -> subCommand == null ? getEmptyLine() : subCommand.getCommandString(label)).forEach(sender::sendMessage); subCommands.stream().filter(subCommands -> !hideInHelp(subCommands) && hasPermission(sender, subCommands)).map(subCommand -> subCommand == null ? getEmptyLine() : subCommand.getCommandString(label)).forEach(sender::sendMessage);
sender.sendMessage(getEmptyLine()); sender.sendMessage(getEmptyLine());
} }
@ -206,6 +206,10 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
} }
} }
private boolean hideInHelp(BaseSubCommand baseSubCommand) {
return baseSubCommand != null && baseSubCommand.hideInHelp();
}
private boolean hasPermission(CommandSender sender, BaseSubCommand baseSubCommand) { private boolean hasPermission(CommandSender sender, BaseSubCommand baseSubCommand) {
return baseSubCommand == null || baseSubCommand.getPermission() == null || sender.hasPermission(baseSubCommand.getPermission()); return baseSubCommand == null || baseSubCommand.getPermission() == null || sender.hasPermission(baseSubCommand.getPermission());
} }

View File

@ -102,4 +102,13 @@ public abstract class BaseSubCommand {
public String getCommandString(String label) { public String getCommandString(String label) {
return TLocale.asString("COMMANDS.INTERNAL.COMMAND-HELP", label, getLabel(), Arrays.stream(getArguments()).map(parameter -> parameter.toString() + " ").collect(Collectors.joining()), getDescription()); return TLocale.asString("COMMANDS.INTERNAL.COMMAND-HELP", label, getLabel(), Arrays.stream(getArguments()).map(parameter -> parameter.toString() + " ").collect(Collectors.joining()), getDescription());
} }
/**
* 是否在命令帮助中隐藏
*
* @return boolean
*/
public boolean hideInHelp() {
return false;
}
} }

View File

@ -101,6 +101,6 @@ public class ListenerPlugin implements Listener {
runnable.run(); runnable.run();
} }
// 注销异常拦截 // 注销异常拦截
e.getPlugin().getLogger().setFilter(null); TLoggerFilter.eject(e.getPlugin());
} }
} }

View File

@ -57,7 +57,7 @@ UPDATE-CHECK: true
UPDATE-DOWNLOAD: false UPDATE-DOWNLOAD: false
# 是否启用附属插件异常拦截 # 是否启用附属插件异常拦截
EXCEPTION-z: true EXCEPTION-MIRROR: true
# 是否在关闭服务器时清理玩家数据 # 是否在关闭服务器时清理玩家数据
# 该配置将在启用数据库储存时失效 # 该配置将在启用数据库储存时失效