From 16f7754f6c5d311cea1eb5c73061f2cfe0c32832 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 30 Nov 2021 19:07:12 +0100 Subject: [PATCH 1/6] Changing to Schem Nodes --- BauSystem_Main/src/BauSystem.properties | 1 + .../features/region/RegionCommand.java | 12 ++--- .../features/region/ResetCommand.java | 9 ++-- .../features/region/TestblockCommand.java | 49 +++++++++++++------ .../region/items/ResetBauGuiItem.java | 23 +++------ .../region/items/TestblockBauGuiItem.java | 27 ++-------- .../features/world/ClipboardListener.java | 12 ++--- .../de/steamwar/bausystem/region/Region.java | 12 ++--- 8 files changed, 69 insertions(+), 76 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 9c4ad833..d3d7ed9a 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -21,6 +21,7 @@ PREFIX = §eBau§8System§8» TIME = HH:mm:ss DATE=........ COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===--- +ONLY_SCHEMS=§cDu kannst hier keinen Ordner angeben # Permission PERMISSION_WORLD = Einstellungen vornehmen diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java index 4d07ca8a..693799a4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -32,7 +32,7 @@ import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.*; -import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicNode; import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -125,17 +125,17 @@ public class RegionCommand extends SWCommand { } @Register(value = "restore", description = "REGION_REGION_HELP_RESTORE_SCHEMATIC") - public void schematicRestoreCommand(@Guard("WORLD_EDIT") Player p, String s) { + public void schematicRestoreCommand(@Guard("WORLD_EDIT") Player p, SchematicNode node) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) return; - Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); - if (schem == null) { - BauSystem.MESSAGE.send("REGION_REGION_NO_SCHEM", p); + if(node.isDir()) { + BauSystem.MESSAGE.send("ONLY_SCHEMS", p); return; } + try { - region.reset(schem, RegionType.NORMAL, RegionExtensionType.NORMAL, true); + region.reset(node, RegionType.NORMAL, RegionExtensionType.NORMAL, true); RegionUtils.message(region, "REGION_REGION_RESTORED"); } catch (IOException e) { BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java index 1d0c0454..16a879b4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java @@ -31,7 +31,7 @@ import de.steamwar.command.GuardCheckType; import de.steamwar.command.GuardChecker; import de.steamwar.command.GuardResult; import de.steamwar.command.SWCommand; -import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicNode; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -59,16 +59,15 @@ public class ResetCommand extends SWCommand { } @Register(description = "REGION_RESET_HELP_SCHEMATIC") - public void schematicResetCommand(@Guard Player p, String s) { + public void schematicResetCommand(@Guard Player p, SchematicNode node) { Region region = regionCheck(p); if (region == null) return; - Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); - if (schem == null) { + if (node == null) { BauSystem.MESSAGE.send("REGION_RESET_NO_SCHEM", p); return; } try { - region.reset(schem, RegionType.NORMAL); + region.reset(node, RegionType.NORMAL); RegionUtils.message(region, "REGION_RESET_RESETED"); } catch (IOException e) { BauSystem.MESSAGE.send("REGION_RESET_ERROR", p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java index 138ab34b..3773e2ec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java @@ -28,8 +28,10 @@ import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.*; -import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicNode; +import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.io.IOException; @@ -65,29 +67,27 @@ public class TestblockCommand extends SWCommand { } @Register(description = "REGION_TB_HELP_SCHEMATIC") - public void schematicTestblockCommand(Player p, String s) { - schematicTestblockCommand(p, s, RegionExtensionType.NORMAL); + public void schematicTestblockCommand(Player p, @Mapper("withPublic") SchematicNode node) { + schematicTestblockCommand(p, node, RegionExtensionType.NORMAL); } @Register - public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, String s) { - schematicTestblockCommand(p, s, regionExtensionType); + public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, @Mapper("withPublic") SchematicNode node) { + schematicTestblockCommand(p, node, regionExtensionType); } @Register(description = "REGION_TB_HELP_SCHEMATIC_EXTENSION") - public void schematicTestblockCommand(@Guard Player p, String s, RegionExtensionType regionExtensionType) { + public void schematicTestblockCommand(@Guard Player p, @Mapper("withPublic") SchematicNode node, RegionExtensionType regionExtensionType) { Region region = regionCheck(p); if (region == null) return; - Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); - if (schem == null) { - schem = Schematic.getSchemFromDB(s, 0); - if (schem == null) { - BauSystem.MESSAGE.send("REGION_TB_NO_SCHEM", p); - return; - } + + if(node.isDir()) { + BauSystem.MESSAGE.send("ONLY_SCHEMS", p); + return; } + try { - region.reset(schem, RegionType.TESTBLOCK, regionExtensionType); + region.reset(node, RegionType.TESTBLOCK, regionExtensionType); RegionUtils.message(region, "REGION_TB_DONE"); } catch (IOException e) { BauSystem.MESSAGE.send("REGION_TB_ERROR", p); @@ -129,4 +129,25 @@ public class TestblockCommand extends SWCommand { } return region; } + + @Mapper("withPublic") + public TypeMapper nodeWithPublic() { + return new TypeMapper() { + @Override + public List tabCompletes(CommandSender commandSender, String[] strings, String s) { + List stringList = new ArrayList<>(SchematicNode.getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), s)); + stringList.addAll(SchematicNode.getNodeTabcomplete(SteamwarUser.get(0), s)); + return stringList; + } + + @Override + public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) { + SchematicNode node = SchematicNode.getNodeFromPath(SteamwarUser.get(((Player) commandSender).getUniqueId()), s); + if(node == null) { + node = SchematicNode.getNodeFromPath(SteamwarUser.get(0), s); + } + return node; + } + }; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java index d6cb05d9..e49b0584 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java @@ -26,7 +26,9 @@ import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; -import de.steamwar.sql.Schematic; +import de.steamwar.inventory.SchematicSelector; +import de.steamwar.sql.SchematicNode; +import de.steamwar.sql.SteamwarUser; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -54,24 +56,11 @@ public class ResetBauGuiItem extends BauGuiItem { p.closeInventory(); p.performCommand("reset"); } else { - List> schemList = new ArrayList<>(); - for (Schematic schem : Schematic.getSchemsAccessibleByUser(p.getUniqueId())) { - Material m; - if (schem.getItem().isEmpty()) - m = SWItem.getMaterial("CAULDRON_ITEM"); - else - m = SWItem.getMaterial(schem.getItem()); - - SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), clickType -> { - }); - schemList.add(new SWListInv.SWListEntry<>(item, schem)); - } - SWListInv inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_RESET_TITLE", p), schemList, (clickType, schematic) -> { + SchematicSelector selector = new SchematicSelector(p, SchematicSelector.selectSchematic(), node -> { p.closeInventory(); - p.performCommand("reset " + schematic.getSchemName()); + p.performCommand("reset " + node.generateBreadcrumbs(SteamwarUser.get(p.getUniqueId()))); }); - p.closeInventory(); - inv.open(); + selector.open(); } return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java index 5c00d970..ead46636 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java @@ -25,17 +25,13 @@ import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; -import de.steamwar.inventory.SWListInv; -import de.steamwar.sql.Schematic; +import de.steamwar.inventory.SchematicSelector; +import de.steamwar.sql.SteamwarUser; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - @Linked(LinkageType.BAU_GUI_ITEM) public class TestblockBauGuiItem extends BauGuiItem { @@ -54,24 +50,11 @@ public class TestblockBauGuiItem extends BauGuiItem { p.closeInventory(); p.performCommand("testblock"); } else { - p.closeInventory(); - List> schemList = new ArrayList<>(); - for (Schematic schem : Schematic.getSchemsAccessibleByUser(p.getUniqueId())) { - Material m; - if (schem.getItem().isEmpty()) - m = SWItem.getMaterial("CAULDRON_ITEM"); - else - m = SWItem.getMaterial(schem.getItem()); - - SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), clickType -> { - }); - schemList.add(new SWListInv.SWListEntry<>(item, schem)); - } - SWListInv inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_TESTBLOCK_TITLE", p), schemList, (clickType, schematic) -> { + SchematicSelector selector = new SchematicSelector(p, SchematicSelector.selectSchematic(), node -> { p.closeInventory(); - p.performCommand("testblock " + schematic.getSchemName()); + p.performCommand("testblock " + node.generateBreadcrumbs(SteamwarUser.get(p.getUniqueId()))); }); - inv.open(); + selector.open(); } return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java index 64b10d8d..633896db 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java @@ -21,8 +21,9 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicType; +import de.steamwar.sql.SteamwarUser; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; @@ -38,7 +39,7 @@ public class ClipboardListener implements Listener { @EventHandler public void onLogin(PlayerJoinEvent e) { try { - Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, e.getPlayer().getUniqueId()); + SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0); if (schematic != null) { schematic.loadToPlayer(e.getPlayer()); } @@ -50,11 +51,10 @@ public class ClipboardListener implements Listener { @EventHandler public void onLogout(PlayerQuitEvent e) { UUID playerUUID = e.getPlayer().getUniqueId(); - Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID); + SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0); boolean newSchem = false; if (schematic == null) { - Schematic.createSchem(CLIPBOARD_SCHEMNAME, playerUUID, "", SchematicType.Normal); - schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID); + schematic = SchematicNode.createSchematic(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0); newSchem = true; } @@ -62,7 +62,7 @@ public class ClipboardListener implements Listener { schematic.saveFromPlayer(e.getPlayer()); } catch (Exception ex) { if (newSchem) { - schematic.remove(); + schematic.delete(); } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index c8cc81ba..19c81868 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -29,7 +29,7 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.shared.SizedStack; import de.steamwar.core.VersionedCallable; -import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicNode; import lombok.AccessLevel; import lombok.Getter; import lombok.NonNull; @@ -378,7 +378,7 @@ public class Region { reset(null, regionType); } - public void reset(Schematic schematic, RegionType regionType) throws IOException { + public void reset(SchematicNode schematic, RegionType regionType) throws IOException { reset(schematic, regionType, RegionExtensionType.NORMAL, false); } @@ -386,7 +386,7 @@ public class Region { reset(null, regionType, regionExtensionType, false); } - public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType) throws IOException { + public void reset(SchematicNode schematic, RegionType regionType, RegionExtensionType regionExtensionType) throws IOException { reset(schematic, regionType, regionExtensionType, false); } @@ -396,11 +396,11 @@ public class Region { undoSessions.push(editSession); } - public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir) throws IOException { + public void reset(SchematicNode schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir) throws IOException { reset(schematic, regionType, regionExtensionType, ignoreAir, false); } - public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors) throws IOException { + public void reset(SchematicNode schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors) throws IOException { if (!hasReset(regionType)) { return; } @@ -408,7 +408,7 @@ public class Region { regionExtensionType = RegionExtensionType.NORMAL; } - PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemType().fightType() || schematic.getSchemType().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), onlyColors, regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel); + PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemtype().fightType() || schematic.getSchemtype().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), onlyColors, regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel); Point pastePoint; File tempFile = null; -- 2.39.2 From 7925bd7af281f3d6d925eb45636d22ec4d7c7417 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 30 Nov 2021 19:39:54 +0100 Subject: [PATCH 2/6] Remove useless Stuff --- .../steamwar/bausystem/features/world/ClipboardListener.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java index 633896db..3082b29e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java @@ -22,15 +22,12 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SchematicType; import de.steamwar.sql.SteamwarUser; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.UUID; - @Linked(LinkageType.LISTENER) public class ClipboardListener implements Listener { @@ -50,7 +47,6 @@ public class ClipboardListener implements Listener { @EventHandler public void onLogout(PlayerQuitEvent e) { - UUID playerUUID = e.getPlayer().getUniqueId(); SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0); boolean newSchem = false; if (schematic == null) { -- 2.39.2 From ce0efeeef374901a3ed31da64dd070d3d0617984 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 3 Dec 2021 15:30:13 +0100 Subject: [PATCH 3/6] Rebuild --- BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java | 1 - 1 file changed, 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 3cbd13e5..709d0e17 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem; -import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.config.ColorConfig; import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.linkage.LinkageUtils; -- 2.39.2 From 7f2b3fc3ea192c76cd6f587a2a6cc0c2ec56239d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 4 Dec 2021 01:49:07 +0100 Subject: [PATCH 4/6] Fix --- .../de/steamwar/bausystem/features/region/ResetCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java index 16a879b4..d17fadef 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java @@ -62,8 +62,8 @@ public class ResetCommand extends SWCommand { public void schematicResetCommand(@Guard Player p, SchematicNode node) { Region region = regionCheck(p); if (region == null) return; - if (node == null) { - BauSystem.MESSAGE.send("REGION_RESET_NO_SCHEM", p); + if (node.isDir()) { + BauSystem.MESSAGE.send("ONLY_SCHEMS", p); return; } try { -- 2.39.2 From 534f352c370143207b4438985e10f71398b9dacc Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 4 Dec 2021 22:09:24 +0100 Subject: [PATCH 5/6] Fix Lixfels Problems --- BauSystem_Main/src/BauSystem.properties | 1 + .../features/region/items/ResetBauGuiItem.java | 16 +++++++--------- .../region/items/TestblockBauGuiItem.java | 10 +++++++--- .../features/team/LockSchemCommand.java | 14 +++++++++----- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 8356d29b..7fc13eb9 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -883,6 +883,7 @@ REGION_TNT_BUILD=§cEine Explosion hätte Blöcke im Baubereich zerstört # Team LOCK_SCHEM_NO_USER=§7Dieser Spieler existiert nicht! LOCK_SCHEM_NO_SCHEM=§7Dieser Spieler besitzt keine Schematic mit diesem Namen! +LOCK_SCHEM_DIR=§7Die angegebene Schematic ist ein Ordner LOCK_SCHEM_LOCKED=§e{0} §7von §e{1} §7wurde von §e{2} §7auf §eNORMAL §7zurück gesetz. §f§lGrund: §f{3} LOCK_SCHEM_HELP=§8/§eschemlock §8[§7Owner§8] [§7Schematic§8] [§7Grund§8] - §7Sperre eine Schematic AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert. diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java index e49b0584..336843fb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java @@ -21,26 +21,24 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.features.region.ResetCommand; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; -import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SchematicSelector; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SteamwarUser; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - @Linked(LinkageType.BAU_GUI_ITEM) public class ResetBauGuiItem extends BauGuiItem { + @LinkedInstance + private ResetCommand resetCommand; + public ResetBauGuiItem() { super(6); } @@ -54,11 +52,11 @@ public class ResetBauGuiItem extends BauGuiItem { public boolean click(ClickType click, Player p) { if (click == ClickType.LEFT) { p.closeInventory(); - p.performCommand("reset"); + resetCommand.genericResetCommand(p); } else { SchematicSelector selector = new SchematicSelector(p, SchematicSelector.selectSchematic(), node -> { p.closeInventory(); - p.performCommand("reset " + node.generateBreadcrumbs(SteamwarUser.get(p.getUniqueId()))); + resetCommand.schematicResetCommand(p, node); }); selector.open(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java index ead46636..f789ea78 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java @@ -21,12 +21,13 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.features.region.TestblockCommand; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SchematicSelector; -import de.steamwar.sql.SteamwarUser; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -35,6 +36,9 @@ import org.bukkit.inventory.ItemStack; @Linked(LinkageType.BAU_GUI_ITEM) public class TestblockBauGuiItem extends BauGuiItem { + @LinkedInstance + private TestblockCommand testblockCommand; + public TestblockBauGuiItem() { super(5); } @@ -48,11 +52,11 @@ public class TestblockBauGuiItem extends BauGuiItem { public boolean click(ClickType click, Player p) { if (click == ClickType.LEFT) { p.closeInventory(); - p.performCommand("testblock"); + testblockCommand.genericTestblockCommand(p); } else { SchematicSelector selector = new SchematicSelector(p, SchematicSelector.selectSchematic(), node -> { p.closeInventory(); - p.performCommand("testblock " + node.generateBreadcrumbs(SteamwarUser.get(p.getUniqueId()))); + testblockCommand.schematicTestblockCommand(p, node); }); selector.open(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java index 62a7d3a9..a06aef53 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java @@ -68,9 +68,13 @@ public class LockSchemCommand extends SWCommand { BauSystem.MESSAGE.send("LOCK_SCHEM_NO_USER", p); return; } - Schematic schematic = Schematic.getSchemFromDB(schematicName, schemOwner.getUUID()); + SchematicNode schematic = SchematicNode.getNodeFromPath(schemOwner, schematicName); if (schematic == null) { - BauSystem.MESSAGE.send("LOCK_SCHEM_NO_SCHEM", p); + BauSystem.MESSAGE.send("LOCK_SCHEM_DIR", p); + return; + } + + if(schematic.isDir()) { return; } @@ -79,9 +83,9 @@ public class LockSchemCommand extends SWCommand { builder.append(s).append(" "); } - BauSystem.MESSAGE.send("LOCK_SCHEM_LOCKED", p, schematic.getSchemName(), schemOwner.getUserName(), schematic.getSchemType().name(), builder.toString()); - schematic.setSchemType(SchematicType.Normal); - new CheckedSchematic(schematic.getSchemName(), schematic.getSchemOwner(), steamwarUser.getId(), Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), builder.toString()); + BauSystem.MESSAGE.send("LOCK_SCHEM_LOCKED", p, schematic.getName(), schemOwner.getUserName(), schematic.getSchemtype().name(), builder.toString()); + schematic.setSchemtype(SchematicType.Normal); + new CheckedSchematic(schematic.getName(), schematic.getOwner(), steamwarUser.getId(), Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), builder.toString()); } private void sendHelp(Player player) { -- 2.39.2 From c6b79bc64afde3b7274b6014f8d6dd97feb1cadc Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 4 Dec 2021 22:11:46 +0100 Subject: [PATCH 6/6] Fix Message --- .../de/steamwar/bausystem/features/team/LockSchemCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java index a06aef53..d7cbe22d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java @@ -70,11 +70,12 @@ public class LockSchemCommand extends SWCommand { } SchematicNode schematic = SchematicNode.getNodeFromPath(schemOwner, schematicName); if (schematic == null) { - BauSystem.MESSAGE.send("LOCK_SCHEM_DIR", p); + BauSystem.MESSAGE.send("LOCK_SCHEM_NO_SCHEM", p); return; } if(schematic.isDir()) { + BauSystem.MESSAGE.send("LOCK_SCHEM_DIR", p); return; } -- 2.39.2