SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
jojo 2021-02-03 15:38:12 +01:00
Ursprung 16ad0ad5e6
Commit 168819e5c8
4 geänderte Dateien mit 11 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -26,10 +26,6 @@ import org.bukkit.event.block.BlockSpreadEvent;
public class CommandFire extends RegionToggleCommand { public class CommandFire extends RegionToggleCommand {
public CommandFire() {
super();
}
@Override @Override
String getNoPermMessage() { String getNoPermMessage() {
return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren"; return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren";

Datei anzeigen

@ -32,10 +32,6 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
public class CommandFreeze extends RegionToggleCommand { public class CommandFreeze extends RegionToggleCommand {
public CommandFreeze(){
super();
}
@Override @Override
String getNoPermMessage() { String getNoPermMessage() {
return "§cDu darfst diese Welt nicht einfrieren"; return "§cDu darfst diese Welt nicht einfrieren";

Datei anzeigen

@ -36,7 +36,7 @@ public class CommandTNT implements CommandExecutor, Listener {
public enum TNTMode { public enum TNTMode {
ON("§aan"), ON("§aan"),
ONLY_TB("§7nur §eTestblock"), ONLY_TB("§7Kein §eBaurahmen"),
OFF("§caus"); OFF("§caus");
private String name; private String name;
@ -112,28 +112,28 @@ public class CommandTNT implements CommandExecutor, Listener {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (region == null) { if (region == null) {
tntGlobalToggle(player, requestedMode, requestedMessage); tntGlobalToggle(requestedMode, requestedMessage);
return false; return false;
} }
tntToggle(region, requestedMode, requestedMessage); tntToggle(region, requestedMode, requestedMessage);
return false; 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) { if (requestedMode != null && requestedMode != TNTMode.ONLY_TB) {
Region.NoRegion.tnt = requestedMode; Region.NoRegion.tnt = requestedMode;
RegionToggleCommand.actionBar(player, requestedMessage); RegionToggleCommand.actionBar(requestedMessage);
return; return;
} }
switch (Region.NoRegion.tnt) { switch (Region.NoRegion.tnt) {
case ON: case ON:
case ONLY_TB: case ONLY_TB:
Region.NoRegion.tnt = TNTMode.OFF; Region.NoRegion.tnt = TNTMode.OFF;
RegionToggleCommand.actionBar(player, getDisableMessage()); RegionToggleCommand.actionBar(getDisableMessage());
break; break;
case OFF: case OFF:
Region.NoRegion.tnt = TNTMode.ON; Region.NoRegion.tnt = TNTMode.ON;
RegionToggleCommand.actionBar(player, getEnableMessage()); RegionToggleCommand.actionBar(getEnableMessage());
break; break;
} }
} }

Datei anzeigen

@ -36,7 +36,7 @@ import org.bukkit.event.Listener;
public abstract class RegionToggleCommand implements CommandExecutor, Listener { public abstract class RegionToggleCommand implements CommandExecutor, Listener {
RegionToggleCommand() { public RegionToggleCommand() {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
} }
@ -54,9 +54,9 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (region == null) { if (region == null) {
if (toggleGlobal()) { if (toggleGlobal()) {
actionBar(player, getEnableMessage()); actionBar(getEnableMessage());
} else { } else {
actionBar(player, getDisableMessage()); actionBar(getDisableMessage());
} }
return false; 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))); 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) { public static void actionBar(String s) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)); Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
} }
abstract String getNoPermMessage(); abstract String getNoPermMessage();