From db86661637ac11ac96d85edb9ec312f07f244b9a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 11 Apr 2021 12:07:00 +0200 Subject: [PATCH] Hotfix CommandTestblock --- .../bausystem/commands/CommandTestblock.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index bd96756..9a37080 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -21,15 +21,23 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.tracer.show.ShowModeParameterType; import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.regions.RegionExtensionType; import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.logging.Level; public class CommandTestblock extends SWCommand { @@ -64,12 +72,17 @@ public class CommandTestblock extends SWCommand { } - @Register({"schem"}) + @Register public void schematicTestblockCommand(Player p, String s) { schematicTestblockCommand(p, s, RegionExtensionType.NORMAL); } - @Register({"schem"}) + @Register + public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, String s) { + schematicTestblockCommand(p, s, regionExtensionType); + } + + @Register public void schematicTestblockCommand(Player p, String s, RegionExtensionType regionExtensionType) { if (!permissionCheck(p)) return; Region region = regionCheck(p); @@ -88,6 +101,18 @@ public class CommandTestblock extends SWCommand { } } + @ClassMapper(value = RegionExtensionType.class, local = true) + private TypeMapper regionExtensionTypeTypeMapper() { + Map showModeParameterTypesMap = new HashMap<>(); + showModeParameterTypesMap.put("-normal", RegionExtensionType.NORMAL); + showModeParameterTypesMap.put("-n", RegionExtensionType.NORMAL); + showModeParameterTypesMap.put("-extension", RegionExtensionType.EXTENSION); + showModeParameterTypesMap.put("-e", RegionExtensionType.EXTENSION); + + List tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet()); + return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes); + } + private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.WORLDEDIT)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen");