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());
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;
sendToActionBar(getTestblockEnableMessage());
return false;
@ -116,8 +116,13 @@ public class CommandTNT implements CommandExecutor, Listener {
sendToActionBar(getDisableMessage());
break;
case OFF:
tntMode = TNTMode.ONLY_TB;
sendToActionBar(getTestblockEnableMessage());
if (Region.buildAreaEnabled()) {
tntMode = TNTMode.ONLY_TB;
sendToActionBar(getTestblockEnableMessage());
} else {
tntMode = TNTMode.ON;
sendToActionBar(getEnableMessage());
}
break;
}
return false;

Datei anzeigen

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

Datei anzeigen

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