SteamWar/BauSystem2.0
Archiviert
12
0

Fix CustomCommandListener

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-08-24 18:11:38 +02:00
Ursprung e7968bed60
Commit b68bbdca14

Datei anzeigen

@ -181,17 +181,22 @@ public class CustomCommandListener implements Listener {
playerMap.remove(e.getPlayer());
}
private boolean save(Player p) {
if (!playerMap.containsKey(p)) {
UserConfig.removePlayerConfig(p.getUniqueId(), "bausystem-commands");
return true;
}
private YAPIONObject output(Player p) {
YAPIONObject yapionObject = new YAPIONObject();
YAPIONMap yapionMap = new YAPIONMap();
yapionObject.add("", yapionMap);
playerMap.get(p).stream().filter(MenuCommand.class::isInstance).map(MenuCommand.class::cast).forEach(menuCommand -> {
menuCommand.toYAPION(yapionMap);
});
return yapionObject;
}
private boolean save(Player p) {
if (!playerMap.containsKey(p)) {
UserConfig.removePlayerConfig(p.getUniqueId(), "bausystem-commands");
return true;
}
YAPIONObject yapionObject = output(p);
if (yapionObject.toYAPION(new LengthOutput()).getLength() > 64 * 1024) {
return false;
}
@ -238,7 +243,17 @@ public class CustomCommandListener implements Listener {
menuCommands.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, command, Arrays.asList("§7Klicke zum rausnehmen", "§7Middle Klicke zum kopieren"), false, clickType -> {
}), menuCommand));
});
SWListInv<MenuCommand> menuCommandSWListInv = new SWListInv<>(p, "§eScript Commands", false, menuCommands, (clickType, menuCommand) -> {
int length = (int) output(p).toYAPION(new LengthOutput()).getLength();
StringBuilder menuName = new StringBuilder();
menuName.append("§eScript Commands");
if (length > 58982) {
if (length == 655336) {
menuName.append(" §8(§cVoll§8)");
} else {
menuName.append(" §8(§6Fast Voll§8)");
}
}
SWListInv<MenuCommand> menuCommandSWListInv = new SWListInv<>(p, menuName.toString(), false, menuCommands, (clickType, menuCommand) -> {
if (!clickType.isCreativeAction()) {
playerMap.get(p).removeIf(customCommand -> customCommand == menuCommand);
}