Add Region section Support for /tnt /fire /freeze #168
@ -26,10 +26,6 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
||||
|
||||
public class CommandFire extends RegionToggleCommand {
|
||||
|
||||
public CommandFire() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
String getNoPermMessage() {
|
||||
return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren";
|
||||
|
@ -32,10 +32,6 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
|
||||
public class CommandFreeze extends RegionToggleCommand {
|
||||
|
||||
public CommandFreeze(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
String getNoPermMessage() {
|
||||
|
||||
return "§cDu darfst diese Welt nicht einfrieren";
|
||||
|
@ -36,7 +36,7 @@ public class CommandTNT implements CommandExecutor, Listener {
|
||||
|
||||
public enum TNTMode {
|
||||
ON("§aan"),
|
||||
ONLY_TB("§7nur §eTestblock"),
|
||||
ONLY_TB("§7Kein §eBaurahmen"),
|
||||
OFF("§caus");
|
||||
|
||||
private String name;
|
||||
@ -112,28 +112,28 @@ public class CommandTNT implements CommandExecutor, Listener {
|
||||
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region == null) {
|
||||
tntGlobalToggle(player, requestedMode, requestedMessage);
|
||||
tntGlobalToggle(requestedMode, requestedMessage);
|
||||
return false;
|
||||
}
|
||||
tntToggle(region, requestedMode, requestedMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void tntGlobalToggle(Player player, TNTMode requestedMode, String requestedMessage) {
|
||||
private void tntGlobalToggle(TNTMode requestedMode, String requestedMessage) {
|
||||
if (requestedMode != null && requestedMode != TNTMode.ONLY_TB) {
|
||||
Region.NoRegion.tnt = requestedMode;
|
||||
RegionToggleCommand.actionBar(player, requestedMessage);
|
||||
RegionToggleCommand.actionBar(requestedMessage);
|
||||
return;
|
||||
}
|
||||
switch (Region.NoRegion.tnt) {
|
||||
case ON:
|
||||
case ONLY_TB:
|
||||
Region.NoRegion.tnt = TNTMode.OFF;
|
||||
RegionToggleCommand.actionBar(player, getDisableMessage());
|
||||
RegionToggleCommand.actionBar(getDisableMessage());
|
||||
break;
|
||||
case OFF:
|
||||
Region.NoRegion.tnt = TNTMode.ON;
|
||||
RegionToggleCommand.actionBar(player, getEnableMessage());
|
||||
RegionToggleCommand.actionBar(getEnableMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import org.bukkit.event.Listener;
|
||||
|
||||
public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
||||
|
||||
RegionToggleCommand() {
|
||||
public RegionToggleCommand() {
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
|
||||
@ -54,9 +54,9 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region == null) {
|
||||
if (toggleGlobal()) {
|
||||
actionBar(player, getEnableMessage());
|
||||
actionBar(getEnableMessage());
|
||||
} else {
|
||||
actionBar(player, getDisableMessage());
|
||||
actionBar(getDisableMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -72,8 +72,8 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation())).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||
}
|
||||
|
||||
public static void actionBar(Player player, String s) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s));
|
||||
public static void actionBar(String s) {
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||
Lixfel
hat
Sollte evtl. an alle außerhalb einer Region gehen? Sollte evtl. an alle außerhalb einer Region gehen?
|
||||
}
|
||||
|
||||
abstract String getNoPermMessage();
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Evtl. super-Konstruktor public machen, dann kannst du dir den Konstruktor komplett sparen.