diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java index c890995f..d1cc2e93 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java @@ -31,6 +31,7 @@ import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.ArrayList; @@ -81,15 +82,37 @@ public class TNTCommand extends SWCommand { @ClassMapper(value = TNTMode.class, local = true) public TypeMapper tntModeTypeMapper() { - Map tntModeMap = new HashMap<>(); - tntModeMap.put("an", TNTMode.ALLOW); - tntModeMap.put("on", TNTMode.ALLOW); - tntModeMap.put("aus", TNTMode.DENY); - tntModeMap.put("off", TNTMode.DENY); + Map tntModeMapReduced = new HashMap<>(); + tntModeMapReduced.put("an", TNTMode.ALLOW); + tntModeMapReduced.put("on", TNTMode.ALLOW); + tntModeMapReduced.put("aus", TNTMode.DENY); + tntModeMapReduced.put("off", TNTMode.DENY); + + Map tntModeMap = new HashMap<>(tntModeMapReduced); tntModeMap.put("testblock", TNTMode.ONLY_TB); tntModeMap.put("tb", TNTMode.ONLY_TB); - List tabCompletes = new ArrayList<>(tntModeMap.keySet()); - return SWCommandUtils.createMapper(s -> tntModeMap.getOrDefault(s, null), s -> tabCompletes); + + return new TypeMapper() { + @Override + public List tabCompletes(CommandSender sender, String[] strings, String s) { + Region region = Region.getRegion(((Player) sender).getLocation()); + if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { + return new ArrayList<>(tntModeMap.keySet()); + } else { + return new ArrayList<>(tntModeMapReduced.keySet()); + } + } + + @Override + public TNTMode map(CommandSender sender, String[] previousArguments, String s) { + Region region = Region.getRegion(((Player) sender).getLocation()); + if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { + return tntModeMap.getOrDefault(s, null); + } else { + return tntModeMapReduced.getOrDefault(s, null); + } + } + }; } private String getEnableMessage() { @@ -105,7 +128,7 @@ public class TNTCommand extends SWCommand { } private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) { - if (requestedMode != null && region.hasType(RegionType.TESTBLOCK)) { + if (requestedMode != null && region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { region.set(Flag.TNT, requestedMode); RegionUtils.actionBar(region, requestedMessage); return; @@ -117,7 +140,7 @@ public class TNTCommand extends SWCommand { RegionUtils.actionBar(region, getDisableMessage()); break; case DENY: - if (region.hasType(RegionType.TESTBLOCK)) { + if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { region.set(Flag.TNT, TNTMode.ONLY_TB); RegionUtils.actionBar(region, getTestblockEnableMessage()); } else { diff --git a/yapion/prototypes3.yapion b/yapion/prototypes3.yapion index 6532828c..38c4ecb2 100644 --- a/yapion/prototypes3.yapion +++ b/yapion/prototypes3.yapion @@ -17,7 +17,6 @@ } mwg{ displayName(MiniWarGear) - protection(sections3/MWGProtection.schem) schematic(sections3/MWGArena.schem) sizeX(63) sizeY(256) @@ -34,7 +33,6 @@ } wg{ displayName(WarGear) - protection(sections3/WGProtection.schem) schematic(sections3/WGArena.schem) sizeX(133) sizeY(255)