SteamWar/BauSystem
Archiviert
13
0

Add CommandTNT by Region.buildAreaEnabled()

Dieser Commit ist enthalten in:
jojo 2021-01-24 17:02:34 +01:00
Ursprung f04bf70087
Commit 7871a88824
3 geänderte Dateien mit 26 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -103,7 +103,7 @@ public class CommandTNT implements CommandExecutor, Listener {
sendToActionBar(getDisableMessage()); sendToActionBar(getDisableMessage());
return false; return false;
} }
if (args.length != 0 && (args[0].equalsIgnoreCase("testblock") || args[0].equalsIgnoreCase("tb"))) { if (args.length != 0 && Region.buildAreaEnabled() && (args[0].equalsIgnoreCase("testblock") || args[0].equalsIgnoreCase("tb"))) {
tntMode = TNTMode.ONLY_TB; tntMode = TNTMode.ONLY_TB;
sendToActionBar(getTestblockEnableMessage()); sendToActionBar(getTestblockEnableMessage());
return false; return false;
@ -116,8 +116,13 @@ public class CommandTNT implements CommandExecutor, Listener {
sendToActionBar(getDisableMessage()); sendToActionBar(getDisableMessage());
break; break;
case OFF: case OFF:
tntMode = TNTMode.ONLY_TB; if (Region.buildAreaEnabled()) {
sendToActionBar(getTestblockEnableMessage()); tntMode = TNTMode.ONLY_TB;
sendToActionBar(getTestblockEnableMessage());
} else {
tntMode = TNTMode.ON;
sendToActionBar(getEnableMessage());
}
break; break;
} }
return false; return false;

Datei anzeigen

@ -21,6 +21,7 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.world.Region;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
@ -34,17 +35,19 @@ public class CommandTNTTabComplete implements TabCompleter {
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) return new ArrayList<>(); if(!(sender instanceof Player)) return new ArrayList<>();
return tntTabComplete((Player) sender, args); return tntTabComplete(args);
} }
private List<String> tntTabComplete(Player player, String[] args) { private List<String> tntTabComplete(String[] args) {
List<String> tabComplete = new ArrayList<>(); List<String> tabComplete = new ArrayList<>();
tabComplete.add("an"); tabComplete.add("an");
tabComplete.add("on"); tabComplete.add("on");
tabComplete.add("aus"); tabComplete.add("aus");
tabComplete.add("off"); tabComplete.add("off");
tabComplete.add("testblock"); if (Region.buildAreaEnabled()) {
tabComplete.add("tb"); tabComplete.add("testblock");
tabComplete.add("tb");
}
if (args.length >= 2) { if (args.length >= 2) {
return new ArrayList<>(); return new ArrayList<>();

Datei anzeigen

@ -37,6 +37,11 @@ import java.util.logging.Level;
public class Region { public class Region {
private static final List<Region> regions = new ArrayList<>(); private static final List<Region> regions = new ArrayList<>();
private static boolean buildArea = false;
public static boolean buildAreaEnabled() {
return buildArea;
}
static{ static{
YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
@ -143,6 +148,9 @@ public class Region {
ConfigurationSection buildAreaSection = config.getConfigurationSection("buildArea"); ConfigurationSection buildAreaSection = config.getConfigurationSection("buildArea");
buildArea = buildAreaSection != null ? new Prototype(buildAreaSection) : null; buildArea = buildAreaSection != null ? new Prototype(buildAreaSection) : null;
if (buildArea != null) {
Region.buildArea = true;
}
protectSchematic = config.getString("protection", null); protectSchematic = config.getString("protection", null);
@ -151,9 +159,9 @@ public class Region {
} }
public boolean inRegion(Region region, Location l){ public boolean inRegion(Region region, Location l){
return inRange(l.getX(), region.minX + offsetX, sizeX + offsetX) && return inRange(l.getX(), region.minX + offsetX, sizeX) &&
inRange(l.getY(), region.minY + offsetY, sizeY + offsetY) && inRange(l.getY(), region.minY + offsetY, sizeY) &&
inRange(l.getZ(), region.minZ + offsetZ, sizeZ + offsetZ); inRange(l.getZ(), region.minZ + offsetZ, sizeZ);
} }
public void fastreset(Region region){ public void fastreset(Region region){