+ 修复配置文件错误

+ 隐藏 /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 me.skymc.taboolib.TabooLib;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.util.Arrays;
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() {
return globalFilter;
}

View File

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

View File

@ -189,7 +189,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
sender.sendMessage(getEmptyLine());
sender.sendMessage(getCommandTitle());
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());
}
@ -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) {
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) {
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();
}
// 注销异常拦截
e.getPlugin().getLogger().setFilter(null);
TLoggerFilter.eject(e.getPlugin());
}
}

View File

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