From 6e195a6c93df55cb4e38249ab30ac1fa38fe1493 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 22 Aug 2022 18:38:36 +0200 Subject: [PATCH] Commandframework fixed --- .../schematicsystem/commands/GUI.java | 2 -- .../commands/SchematicCommand.java | 25 ++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java index a2de41e..9d8229c 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java @@ -19,12 +19,10 @@ package de.steamwar.schematicsystem.commands; -import de.steamwar.core.Core; import de.steamwar.inventory.*; import de.steamwar.schematicsystem.SafeSchematicNode; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.sql.*; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 512d568..8634d16 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -26,6 +26,8 @@ import de.steamwar.providers.BauServerInfo; import de.steamwar.schematicsystem.SafeSchematicNode; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.sql.*; +import lombok.extern.log4j.Log4j; +import lombok.extern.log4j.Log4j2; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.HoverEvent; @@ -45,11 +47,13 @@ import java.util.stream.Collectors; import static de.steamwar.schematicsystem.commands.SchematicCommandHelp.*; import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*; +@Log4j2 @SuppressWarnings("unused") public class SchematicCommand extends SWCommand { private static final Map> searchMapper = new HashMap<>(); + static { searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new))); searchMapper.put("-owner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s))); @@ -83,33 +87,36 @@ public class SchematicCommand extends SWCommand { @Register("list") @Register({"list", "/"}) - public void schemList(Player player, @OptionalValue("1") int page) { + public void schemList(Player player, @OptionalValue(value = "1", onlyUINIG = true) int page) { + log.info("list / page \"{}\"", page); renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), Math.max(page - 1, 0), null, SchematicListBehavior.DEFAULT); } @Register({"list", "public"}) public void schemListPublic(Player player, @Validator("isDirValidator") @Mapper("publicDirMapper") SchematicNode node, @OptionalValue("1") int page) { + log.info("list public \"{}\" page \"{}\"", node.generateBreadcrumbs(getUser(player)), page); schemList(player, node, page); } @Register({"list", "public"}) @Register({"list", "public", "/"}) - public void schemListPublic(Player player, @OptionalValue("1") int page) { + public void schemListPublic(Player player, @OptionalValue(value = "1", onlyUINIG = true) int page) { + log.info("list public \"/\" page \"{}\"", page); renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), Math.max(page - 1, 0), null, SchematicListBehavior.builder().setPublics(true).setPageCommandGen(integer -> "/schem list public " + integer).build()); } - - @Register({"info", "public"}) - public void schemInfoPublic(Player player, @Validator("isDirValidator") @Mapper("publicMapper") SchematicNode node) { - schemInfo(player, node); - } - @Register("list") public void schemList(Player player, @Validator("isDirValidator") @Mapper("dirMapper") SchematicNode node, @OptionalValue("1") int page) { + log.info("list \"{}\" page \"{}\"", node.generateBreadcrumbs(getUser(player)), page); SteamwarUser user = getUser(player); renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), Math.max(page - 1, 0), node, SchematicListBehavior.builder().setPublics(node.getOwner() == 0).setPageCommandGen(value -> "/schem list " + (node.getOwner()==0?"public ":"") + node.generateBreadcrumbs(user) + " " + value).build()); } + @Register({"info", "public"}) + public void schemInfoPublic(Player player, @Validator("isDirValidator") @Mapper("publicMapper") SchematicNode node) { + schemInfo(player, node); + } + @Register({"l", "public"}) @Register({"load", "public"}) public void loadSchemPublic(Player player, @Validator("isSchemValidator") @Mapper("publicMapper") SchematicNode node) { @@ -713,7 +720,7 @@ public class SchematicCommand extends SWCommand { private boolean nodeNullCheck(AbstractValidator.MessageSender messageSender, SchematicNode node) { if (node == null) { - messageSender.send("COMMAND_LIST_INVALID_NODE"); + messageSender.send("COMMAND_INVALID_NODE"); return false; } return true;