From aa77cb9c290203dd41dd4e3d9c9d8de7cf7bda06 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 12 Mar 2021 09:31:37 +0100 Subject: [PATCH] Formatted every File! Renamed IAutoLoader to AbstractAutoLoader --- .../bausystem/commands/TPSLimit_12.java | 2 +- .../bausystem/tracer/TraceEntity_12.java | 8 +- .../bausystem/world/AutoLoader_12.java | 47 ++++---- .../bausystem/world/RegionListener_12.java | 3 +- .../steamwar/bausystem/world/Region_12.java | 15 +-- .../bausystem/world/ScriptListener_12.java | 5 +- .../commands/CommandDebugStick_15.java | 5 +- .../bausystem/commands/TPSLimit_15.java | 2 +- .../bausystem/tracer/TNTTracer_15.java | 4 +- .../bausystem/tracer/TraceEntity_15.java | 8 +- .../bausystem/world/AutoLoader_15.java | 14 +-- .../bausystem/world/RegionListener_15.java | 3 +- .../steamwar/bausystem/world/Region_15.java | 39 ++++--- .../bausystem/world/ScriptListener_15.java | 5 +- ...utoLoader.java => AbstractAutoLoader.java} | 10 +- .../steamwar/bausystem/world/Detoloader.java | 8 +- .../bausystem/commands/CommandBau.java | 18 +-- .../bausystem/commands/CommandClear.java | 14 ++- .../bausystem/commands/CommandDebugStick.java | 4 +- .../bausystem/commands/CommandDetonator.java | 6 +- .../CommandDetonatorTabCompleter.java | 2 +- .../bausystem/commands/CommandFire.java | 8 +- .../bausystem/commands/CommandFreeze.java | 4 +- .../bausystem/commands/CommandGamemode.java | 108 +++++++++--------- .../bausystem/commands/CommandGills.java | 4 +- .../bausystem/commands/CommandInjector.java | 3 +- .../bausystem/commands/CommandLoader.java | 46 ++++---- .../bausystem/commands/CommandLockschem.java | 10 +- .../bausystem/commands/CommandNV.java | 4 +- .../bausystem/commands/CommandProtect.java | 12 +- .../bausystem/commands/CommandReset.java | 12 +- .../CommandSimulatorTabCompleter.java | 2 +- .../bausystem/commands/CommandSkull.java | 6 +- .../bausystem/commands/CommandSpeed.java | 8 +- .../commands/CommandTNTTabComplete.java | 2 +- .../bausystem/commands/CommandTPSLimiter.java | 4 +- .../CommandTPSLimiterTabComplete.java | 3 +- .../bausystem/commands/CommandTeleport.java | 70 ++++++------ .../bausystem/commands/CommandTestblock.java | 10 +- .../bausystem/commands/CommandTime.java | 56 ++++----- .../bausystem/commands/CommandTrace.java | 6 +- .../commands/CommandTraceTabCompleter.java | 2 +- .../commands/RegionToggleCommand.java | 6 +- .../steamwar/bausystem/gui/GuiTraceShow.java | 9 +- .../bausystem/tracer/RoundedTNTPosition.java | 6 +- .../bausystem/tracer/TNTPosition.java | 2 +- .../tracer/record/RecordStateMachine.java | 2 +- .../bausystem/tracer/record/RecordStatus.java | 2 +- .../tracer/record/TraceAutoHandler.java | 10 +- .../bausystem/tracer/show/Record.java | 4 +- .../bausystem/tracer/show/ShowMode.java | 1 + .../tracer/show/TraceShowManager.java | 4 +- .../steamwar/bausystem/world/AFKStopper.java | 8 +- .../steamwar/bausystem/world/AutoLoader.java | 10 +- .../bausystem/world/BauScoreboard.java | 2 +- .../bausystem/world/ClipboardListener.java | 12 +- .../steamwar/bausystem/world/Detonator.java | 14 +-- .../bausystem/world/DetonatorListener.java | 10 +- .../bausystem/world/PredefinedBook.java | 20 ++-- .../de/steamwar/bausystem/world/Region.java | 44 +++---- .../bausystem/world/RegionListener.java | 30 ++--- .../bausystem/world/ScriptListener.java | 14 +-- .../bausystem/world/TNTSimulator.java | 2 +- .../de/steamwar/bausystem/world/TPSUtils.java | 3 +- .../src/de/steamwar/bausystem/world/Welt.java | 21 ++-- 65 files changed, 430 insertions(+), 408 deletions(-) rename BauSystem_API/src/de/steamwar/bausystem/world/{IAutoLoader.java => AbstractAutoLoader.java} (90%) diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java index 4cd4c22..b7e5272 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -49,7 +49,7 @@ class TPSLimit_12 { static void sendTickPackets() { Bukkit.getOnlinePlayers().forEach(player -> { - PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; + PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection; for (Packet p : packets) { connection.sendPacket(p); } diff --git a/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceEntity_12.java b/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceEntity_12.java index c96f4bc..c42cf23 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceEntity_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceEntity_12.java @@ -44,9 +44,9 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity { this.setCustomNameVisible(true); this.setCustomName("Bumm"); this.exploded = true; - if(references++ > 0) + if (references++ > 0) sendDestroy(player); - }else if(references++ > 0) + } else if (references++ > 0) return; PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this, 0, 0); @@ -60,7 +60,7 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity { @Override public boolean hide(Player player, boolean force) { - if(!force && --references > 0) + if (!force && --references > 0) return false; sendDestroy(player); @@ -68,7 +68,7 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity { return true; } - private void sendDestroy(Player player){ + private void sendDestroy(Player player) { PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); } diff --git a/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java index 72bfcd1..dcc629a 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java @@ -33,11 +33,12 @@ import java.util.stream.Collectors; class AutoLoader_12 { - private AutoLoader_12(){} + private AutoLoader_12() { + } - static boolean tntPlaceActionPerform(Location location){ + static boolean tntPlaceActionPerform(Location location) { Material m = location.getBlock().getType(); - if(m != Material.AIR && m != Material.STATIONARY_WATER && m != Material.WATER) + if (m != Material.AIR && m != Material.STATIONARY_WATER && m != Material.WATER) return false; location.getBlock().setType(Material.TNT); @@ -45,34 +46,34 @@ class AutoLoader_12 { } @SuppressWarnings("deprecation") - static boolean setRedstone(Location location, boolean active){ + static boolean setRedstone(Location location, boolean active) { Block block = location.getBlock(); Material material = block.getType(); - if(material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON){ - if(active) - block.setData((byte)(block.getData() | 8)); + if (material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON) { + if (active) + block.setData((byte) (block.getData() | 8)); else - block.setData((byte)(block.getData() & -9)); - }else if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE) { + block.setData((byte) (block.getData() & -9)); + } else if (material == Material.STONE_PLATE || material == Material.WOOD_PLATE) { if (active) block.setData((byte) 1); else block.setData((byte) 0); - }else if(material == Material.TRIPWIRE) { - if(active) { + } else if (material == Material.TRIPWIRE) { + if (active) { ArmorStand armorStand = (ArmorStand) Bukkit.getWorlds().get(0).spawnEntity(location, EntityType.ARMOR_STAND); armorStand.setVisible(false); armorStand.setBasePlate(false); armorStand.addScoreboardTag("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ()); - }else { + } else { List entityList = Bukkit.getWorlds().get(0).getEntitiesByClasses(ArmorStand.class).stream().filter(entity -> entity.getScoreboardTags().contains("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ())) .limit(1) .collect(Collectors.toList()); - if(entityList.isEmpty()) return false; + if (entityList.isEmpty()) return false; entityList.get(0).remove(); } - }else{ + } else { return false; } block.getState().update(true); @@ -80,24 +81,24 @@ class AutoLoader_12 { } @SuppressWarnings("deprecation") - static Detoloader onPlayerInteractLoader(PlayerInteractEvent event){ + static Detoloader onPlayerInteractLoader(PlayerInteractEvent event) { Block block = event.getClickedBlock(); Material material = block.getType(); - if(material == Material.LEVER){ - if((block.getData() & 8) == 8) { + if (material == Material.LEVER) { + if ((block.getData() & 8) == 8) { return new Detoloader("Hebel", 0).setActive(false); - }else{ + } else { return new Detoloader("Hebel", 0).setActive(true); } - }else if(material == Material.STONE_BUTTON){ + } else if (material == Material.STONE_BUTTON) { return new Detoloader("Knopf", Detoloader.STONE_BUTTON); - }else if(material == Material.WOOD_BUTTON){ + } else if (material == Material.WOOD_BUTTON) { return new Detoloader("Knopf", Detoloader.WOODEN_BUTTON); - }else if (material == Material.NOTE_BLOCK) { + } else if (material == Material.NOTE_BLOCK) { return new Detoloader("Noteblock", Detoloader.NOTE_BLOCK); - }else if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){ + } else if (material == Material.STONE_PLATE || material == Material.WOOD_PLATE) { return new Detoloader("Druckplatte", Detoloader.PRESSURE_PLATE); - }else if (material == Material.TRIPWIRE) { + } else if (material == Material.TRIPWIRE) { return new Detoloader("Tripwire", Detoloader.TRIPWIRE); } return new Detoloader("§eUnbekannter Block betätigt (nicht aufgenommen)", -1).setAddBack(false); diff --git a/BauSystem_12/src/de/steamwar/bausystem/world/RegionListener_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/RegionListener_12.java index 12c6cc8..7a23b75 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/world/RegionListener_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/world/RegionListener_12.java @@ -28,7 +28,8 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; class RegionListener_12 { - private RegionListener_12(){} + private RegionListener_12() { + } static boolean isWorldEditCommand(String command) { if (command.startsWith("/")) { diff --git a/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java index bfd38c6..302e8dc 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java @@ -37,9 +37,10 @@ import java.io.IOException; import java.util.Objects; class Region_12 { - private Region_12(){} + private Region_12() { + } - static void paste(File file, int x, int y, int z, boolean rotate){ + static void paste(File file, int x, int y, int z, boolean rotate) { World w = new BukkitWorld(Bukkit.getWorlds().get(0)); Clipboard clipboard; try { @@ -51,18 +52,18 @@ class Region_12 { paste(clipboard, x, y, z, rotate); } - static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){ + static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate) { World w = new BukkitWorld(Bukkit.getWorlds().get(0)); Vector dimensions = clipboard.getDimensions(); Vector v = new Vector(x, y, z); Vector offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); AffineTransform aT = new AffineTransform(); - if(rotate){ + if (rotate) { aT = aT.rotateY(180); - v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); - }else{ - v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset); + v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); + } else { + v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset); } EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1); diff --git a/BauSystem_12/src/de/steamwar/bausystem/world/ScriptListener_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/ScriptListener_12.java index 061befa..ad802f1 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/world/ScriptListener_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/world/ScriptListener_12.java @@ -23,9 +23,10 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; class ScriptListener_12 { - private ScriptListener_12(){} + private ScriptListener_12() { + } - static boolean isNoBook(ItemStack item){ + static boolean isNoBook(ItemStack item) { return item.getType() != Material.BOOK_AND_QUILL && item.getType() != Material.WRITTEN_BOOK; } } diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java index 8bbf9dd..1e5f751 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/CommandDebugStick_15.java @@ -25,9 +25,10 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; class CommandDebugStick_15 { - private CommandDebugStick_15(){} + private CommandDebugStick_15() { + } - static void giveStick(Player player){ + static void giveStick(Player player) { PlayerUtils.giveItemToPlayer(player, new ItemStack(Material.DEBUG_STICK)); } } diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java index 2860e2a..04cd25c 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -50,7 +50,7 @@ class TPSLimit_15 { static void sendTickPackets() { Bukkit.getOnlinePlayers().forEach(player -> { - PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; + PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection; for (Packet p : packets) { connection.sendPacket(p); } diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java index 20ef07f..7f38e0d 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java @@ -34,11 +34,11 @@ public class TNTTracer_15 { public static boolean inWater(World world, Vector tntPosition) { Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ()); - if(block.getType() == Material.WATER) + if (block.getType() == Material.WATER) return true; BlockData data = block.getBlockData(); - if(!(data instanceof Waterlogged)) + if (!(data instanceof Waterlogged)) return false; return ((Waterlogged) data).isWaterlogged(); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceEntity_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceEntity_15.java index 56ecf23..e8e2c63 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceEntity_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceEntity_15.java @@ -50,9 +50,9 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity { this.setCustomNameVisible(true); this.setCustomName(new ChatComponentText("Bumm")); this.exploded = true; - if(references++ > 0) + if (references++ > 0) sendDestroy(player); - }else if(references++ > 0) + } else if (references++ > 0) return; PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, tnt ? Block.getCombinedId(Blocks.TNT.getBlockData()) : Block.getCombinedId(Blocks.WHITE_STAINED_GLASS.getBlockData()), ZERO); @@ -65,7 +65,7 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity { @Override public boolean hide(Player player, boolean force) { - if(!force && --references > 0) + if (!force && --references > 0) return false; sendDestroy(player); @@ -73,7 +73,7 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity { return true; } - private void sendDestroy(Player player){ + private void sendDestroy(Player player) { PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); } diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index a69a11f..1fb8062 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -54,7 +54,7 @@ class AutoLoader_15 { powerable.setPowered(active); block.setBlockData(powerable); - if(data instanceof Openable) { + if (data instanceof Openable) { Openable openable = (Openable) data; openable.setOpen(active); block.setBlockData(openable); @@ -63,7 +63,7 @@ class AutoLoader_15 { if (data instanceof Switch) { Switch swtch = (Switch) data; Block relative; - switch(swtch.getFace()){ + switch (swtch.getFace()) { case FLOOR: relative = block.getRelative(BlockFace.DOWN); break; @@ -75,7 +75,7 @@ class AutoLoader_15 { break; } updateBlock(relative); - } else if(block.getType() == Material.TRIPWIRE) { + } else if (block.getType() == Material.TRIPWIRE) { updateBlock(block); } return true; @@ -101,13 +101,13 @@ class AutoLoader_15 { return new Detoloader("Hebel", 0).setActive(!powerable.isPowered()); } else if (material == Material.STONE_BUTTON) { return new Detoloader("Knopf", Detoloader.STONE_BUTTON); - } else if (material.name().contains("PRESSURE_PLATE")){ + } else if (material.name().contains("PRESSURE_PLATE")) { return new Detoloader("Druckplatte", Detoloader.PRESSURE_PLATE); } else if (material.name().contains("BUTTON")) { return new Detoloader("Knopf", Detoloader.WOODEN_BUTTON); - }else if (material == Material.NOTE_BLOCK) { + } else if (material == Material.NOTE_BLOCK) { return new Detoloader("Noteblock", Detoloader.NOTE_BLOCK); - }else if (material.name().equals("TRIPWIRE")) { + } else if (material.name().equals("TRIPWIRE")) { return new Detoloader("Tripwire", Detoloader.TRIPWIRE); } else { return new Detoloader("§eUnbekannter Block betätigt (aufgenommen)", 0).setAddBack(false); @@ -115,7 +115,7 @@ class AutoLoader_15 { } static boolean getLever(Block block) { - if(!(block.getBlockData() instanceof Powerable)) + if (!(block.getBlockData() instanceof Powerable)) return false; return ((Powerable) block.getBlockData()).isPowered(); } diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/RegionListener_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/RegionListener_15.java index fd22589..3d53bb9 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/RegionListener_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/RegionListener_15.java @@ -32,7 +32,8 @@ import java.lang.reflect.InvocationTargetException; import java.util.logging.Level; class RegionListener_15 { - private RegionListener_15(){} + private RegionListener_15() { + } static boolean isWorldEditCommand(String command) { if (command.startsWith("/")) { diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java index cbec486..3aea08c 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java @@ -44,9 +44,10 @@ import java.io.IOException; import java.util.Objects; class Region_15 { - private Region_15(){} + private Region_15() { + } - static void paste(File file, int x, int y, int z, boolean rotate){ + static void paste(File file, int x, int y, int z, boolean rotate) { Clipboard clipboard; try { clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read(); @@ -57,16 +58,16 @@ class Region_15 { paste(clipboard, x, y, z, rotate); } - static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){ + static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate) { BlockVector3 dimensions = clipboard.getDimensions(); BlockVector3 v = BlockVector3.at(x, y, z); BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); AffineTransform aT = new AffineTransform(); - if(rotate){ + if (rotate) { aT = aT.rotateY(180); - v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); - }else{ - v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset); + v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); + } else { + v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset); } EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1); @@ -76,7 +77,7 @@ class Region_15 { e.flushSession(); } - static void fastpaste(File file, int x, int y, int z, boolean rotate){ + static void fastpaste(File file, int x, int y, int z, boolean rotate) { Clipboard clipboard; try { clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read(); @@ -87,26 +88,26 @@ class Region_15 { BlockVector3 dimensions = clipboard.getDimensions(); BlockVector3 v = BlockVector3.at(x, y, z); BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); - if(rotate){ - v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); - }else{ - v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset); + if (rotate) { + v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); + } else { + v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset); } - WorldServer world = ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle(); + WorldServer world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(); v = v.add(offset); - for(int X = v.getBlockX(); X < v.getBlockX() + dimensions.getBlockX(); X++){ - for(int Y = v.getBlockY(); Y < v.getBlockY() + dimensions.getBlockY(); Y++){ - for(int Z = v.getBlockZ(); Z < v.getBlockZ() + dimensions.getBlockZ(); Z++){ + for (int X = v.getBlockX(); X < v.getBlockX() + dimensions.getBlockX(); X++) { + for (int Y = v.getBlockY(); Y < v.getBlockY() + dimensions.getBlockY(); Y++) { + for (int Z = v.getBlockZ(); Z < v.getBlockZ() + dimensions.getBlockZ(); Z++) { BlockPosition blockPos = new BlockPosition(X, Y, Z); BaseBlock fullBlock = clipboard.getFullBlock(BlockVector3.at(X, Y, Z).subtract(v).add(clipboard.getRegion().getMinimumPoint())); BlockData replaceTo = BukkitAdapter.adapt(fullBlock); world.removeTileEntity(blockPos); - if(replaceTo == null) - world.setTypeAndData(blockPos, ((CraftBlockData)Material.AIR.createBlockData()).getState(), 1042); + if (replaceTo == null) + world.setTypeAndData(blockPos, ((CraftBlockData) Material.AIR.createBlockData()).getState(), 1042); else - world.setTypeAndData(new BlockPosition(X, Y, Z), ((CraftBlockData)replaceTo).getState(), 1042); + world.setTypeAndData(new BlockPosition(X, Y, Z), ((CraftBlockData) replaceTo).getState(), 1042); world.getChunkProvider().flagDirty(blockPos); } diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/ScriptListener_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/ScriptListener_15.java index 3964be0..4045105 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/ScriptListener_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/ScriptListener_15.java @@ -23,9 +23,10 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; class ScriptListener_15 { - private ScriptListener_15(){} + private ScriptListener_15() { + } - static boolean isNoBook(ItemStack item){ + static boolean isNoBook(ItemStack item) { return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK; } } diff --git a/BauSystem_API/src/de/steamwar/bausystem/world/IAutoLoader.java b/BauSystem_API/src/de/steamwar/bausystem/world/AbstractAutoLoader.java similarity index 90% rename from BauSystem_API/src/de/steamwar/bausystem/world/IAutoLoader.java rename to BauSystem_API/src/de/steamwar/bausystem/world/AbstractAutoLoader.java index 336a20a..d30fe2d 100644 --- a/BauSystem_API/src/de/steamwar/bausystem/world/IAutoLoader.java +++ b/BauSystem_API/src/de/steamwar/bausystem/world/AbstractAutoLoader.java @@ -26,7 +26,7 @@ import org.bukkit.entity.Player; import java.util.LinkedList; -abstract class IAutoLoader { +abstract class AbstractAutoLoader { abstract Player getPlayer(); abstract boolean setRedstone(Location location, boolean active); @@ -44,9 +44,9 @@ abstract class IAutoLoader { abstract static class LoaderAction { final Location location; - final IAutoLoader loader; + final AbstractAutoLoader loader; - LoaderAction(IAutoLoader loader, Location location){ + LoaderAction(AbstractAutoLoader loader, Location location){ this.location = location; this.loader = loader; loader.getActions().add(this); @@ -63,7 +63,7 @@ abstract class IAutoLoader { final int length; int status; - RedstoneActivation(IAutoLoader loader, Location location, int ticks, boolean active){ + RedstoneActivation(AbstractAutoLoader loader, Location location, int ticks, boolean active){ super(loader, location); this.length = ticks; this.active = active; @@ -93,7 +93,7 @@ abstract class IAutoLoader { final int length; int status; - TemporaryActivation(IAutoLoader loader, Location location, int ticks){ + TemporaryActivation(AbstractAutoLoader loader, Location location, int ticks){ super(loader, location); this.length = ticks; status = 0; diff --git a/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java b/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java index d81ca0d..531fff5 100644 --- a/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java +++ b/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java @@ -79,9 +79,9 @@ public class Detoloader { } //Timings - public static final int STONE_BUTTON = 20; - public static final int WOODEN_BUTTON = 30; + public static final int STONE_BUTTON = 20; + public static final int WOODEN_BUTTON = 30; public static final int PRESSURE_PLATE = 20; - public static final int NOTE_BLOCK = 1; - public static final int TRIPWIRE = 20; + public static final int NOTE_BLOCK = 1; + public static final int TRIPWIRE = 20; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index d1b509c..083ee4a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -32,7 +32,7 @@ public class CommandBau implements CommandExecutor { private void onToggleBD(Player p, String arg) { SteamwarUser id = SteamwarUser.get(arg); - if(negativeToggleCheck(p, id)){ + if (negativeToggleCheck(p, id)) { return; } @@ -42,7 +42,7 @@ public class CommandBau implements CommandExecutor { private void onToggleWE(Player p, String arg) { SteamwarUser id = SteamwarUser.get(arg); - if(negativeToggleCheck(p, id)){ + if (negativeToggleCheck(p, id)) { return; } @@ -52,7 +52,7 @@ public class CommandBau implements CommandExecutor { private void onToggleWorld(Player p, String arg) { SteamwarUser id = SteamwarUser.get(arg); - if(negativeToggleCheck(p, id)){ + if (negativeToggleCheck(p, id)) { return; } @@ -60,7 +60,7 @@ public class CommandBau implements CommandExecutor { Welt.toggleWorld(p, target); } - private boolean negativeToggleCheck(Player p, SteamwarUser id){ + private boolean negativeToggleCheck(Player p, SteamwarUser id) { if (id == null) { p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler"); return true; @@ -76,19 +76,19 @@ public class CommandBau implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if(!BauSystem.getOwner().equals(player.getUniqueId())){ + if (!BauSystem.getOwner().equals(player.getUniqueId())) { player.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!"); return false; } - if(args[0].equalsIgnoreCase("togglebuild")){ + if (args[0].equalsIgnoreCase("togglebuild")) { onToggleBD(player, args[1]); - }else if(args[0].equalsIgnoreCase("togglewe")){ + } else if (args[0].equalsIgnoreCase("togglewe")) { onToggleWE(player, args[1]); - }else if(args[0].equalsIgnoreCase("toggleworld")){ + } else if (args[0].equalsIgnoreCase("toggleworld")) { onToggleWorld(player, args[1]); } return false; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java index 1379005..e976c13 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java @@ -36,32 +36,34 @@ public class CommandClear extends BukkitCommand { description = "Leere dein Inventar oder das eines anderen Spielers."; usageMessage = "/clear [Spieler]"; } + public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if (args.length == 0){ + if (args.length == 0) { clear(player); player.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert."); return true; } // check if admin - if(Welt.noPermission(player, Permission.world)){ + if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren."); return false; } Player target = Bukkit.getPlayerExact(args[0]); - if(!(target instanceof Player)){ + if (!(target instanceof Player)) { player.sendMessage(BauSystem.PREFIX + "§cDas ist kein Spieler."); return false; } clear(target); - target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() +" §7geleert."); - player.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() +" §7wurde geleert."); + target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() + " §7geleert."); + player.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert."); return true; } - private void clear(Player player){ + + private void clear(Player player) { player.getInventory().clear(); player.getInventory().setHelmet(new ItemStack(Material.AIR)); player.getInventory().setChestplate(new ItemStack(Material.AIR)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index 74e9f66..b3ac2bf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -33,11 +33,11 @@ public class CommandDebugStick implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if (Welt.noPermission(player, Permission.build)){ + if (Welt.noPermission(player, Permission.build)) { player.sendMessage(BauSystem.PREFIX + "§cKein Debugstick für dich hier."); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java index e45e53b..6f237ab 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java @@ -39,7 +39,7 @@ public class CommandDetonator implements CommandExecutor { } private boolean permissionCheck(Player player) { - if(Welt.noPermission(player, Permission.world)){ + if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen"); return false; } @@ -48,11 +48,11 @@ public class CommandDetonator implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if(args.length == 0){ + if (args.length == 0) { help(player); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java index 4a20f89..f60157b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java @@ -31,7 +31,7 @@ public class CommandDetonatorTabCompleter implements TabCompleter { @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) return new ArrayList<>(); + if (!(sender instanceof Player)) return new ArrayList<>(); return detonaterTabComplete((Player) sender, args); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java index 1b6f158..a1ea0e3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java @@ -30,12 +30,14 @@ public class CommandFire extends RegionToggleCommand { String getNoPermMessage() { return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren"; } + @Override - String getEnableMessage(){ + String getEnableMessage() { return "§cFeuerschaden deaktiviert"; } + @Override - String getDisableMessage(){ + String getDisableMessage() { return "§aFeuerschaden aktiviert"; } @@ -51,7 +53,7 @@ public class CommandFire extends RegionToggleCommand { } @EventHandler - public void onFireSpread(BlockSpreadEvent e){ + public void onFireSpread(BlockSpreadEvent e) { if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java index f770e21..47953a3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java @@ -100,12 +100,12 @@ public class CommandFreeze extends RegionToggleCommand { } @EventHandler - public void onRedstoneEvent(BlockRedstoneEvent e){ + public void onRedstoneEvent(BlockRedstoneEvent e) { if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setNewCurrent(e.getOldCurrent()); } @EventHandler - public void onBlockDispense(BlockDispenseEvent e){ + public void onBlockDispense(BlockDispenseEvent e) { if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java index 2f5f5c7..757f08d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java @@ -34,75 +34,75 @@ import java.util.List; public class CommandGamemode extends BukkitCommand { private static final List GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival", - "spectator"); + "spectator"); public CommandGamemode() { - super("gamemode"); - List aliases = new ArrayList<>(); - aliases.add("gm"); - this.setAliases(aliases); - this.description = "Ändert den Spielmodus eines Spielers"; - this.usageMessage = "/gm [Spielmodus]"; + super("gamemode"); + List aliases = new ArrayList<>(); + aliases.add("gm"); + this.setAliases(aliases); + this.description = "Ändert den Spielmodus eines Spielers"; + this.usageMessage = "/gm [Spielmodus]"; } public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!(sender instanceof Player)) { - return false; - }else if (args.length == 0) { - sender.sendMessage(BauSystem.PREFIX + this.usageMessage); - return false; - } + if (!(sender instanceof Player)) { + return false; + } else if (args.length == 0) { + sender.sendMessage(BauSystem.PREFIX + this.usageMessage); + return false; + } - Player p = (Player) sender; + Player p = (Player) sender; - if(!p.getUniqueId().equals(BauSystem.getOwner())){ - BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); - if(member == null || !member.isBuild()){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern"); - return false; - } - } + if (!p.getUniqueId().equals(BauSystem.getOwner())) { + BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); + if (member == null || !member.isBuild()) { + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern"); + return false; + } + } - GameMode mode = createMode(args[0]); + GameMode mode = createMode(args[0]); - if(mode == null){ - p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus"); - return false; - } + if (mode == null) { + p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus"); + return false; + } - p.setGameMode(mode); - return true; + p.setGameMode(mode); + return true; } @SuppressWarnings("deprecation") - private GameMode createMode(String modeArg){ - try { - return GameMode.getByValue(Integer.parseInt(modeArg)); - } catch (NumberFormatException ignored) { - if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c"))) - return GameMode.CREATIVE; - else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a"))) - return GameMode.ADVENTURE; - else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp"))) - return GameMode.SPECTATOR; - else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s"))) - return GameMode.SURVIVAL; - } - return null; - } + private GameMode createMode(String modeArg) { + try { + return GameMode.getByValue(Integer.parseInt(modeArg)); + } catch (NumberFormatException ignored) { + if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c"))) + return GameMode.CREATIVE; + else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a"))) + return GameMode.ADVENTURE; + else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp"))) + return GameMode.SPECTATOR; + else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s"))) + return GameMode.SURVIVAL; + } + return null; + } - @Override + @Override public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); + Validate.notNull(sender, "Sender cannot be null"); + Validate.notNull(args, "Arguments cannot be null"); + Validate.notNull(alias, "Alias cannot be null"); - if (args.length == 1) - return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, - new ArrayList<>(GAMEMODE_NAMES.size())); - if (args.length == 2) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); + if (args.length == 1) + return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, + new ArrayList<>(GAMEMODE_NAMES.size())); + if (args.length == 2) { + return super.tabComplete(sender, alias, args); + } + return ImmutableList.of(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java index 927ef5a..8095e91 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java @@ -31,7 +31,7 @@ public class CommandGills implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; toggleGills(player); @@ -39,7 +39,7 @@ public class CommandGills implements CommandExecutor { } public static void toggleGills(Player player) { - if(player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { + if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { player.sendMessage(BauSystem.PREFIX + "Wassersicht deaktiviert"); player.removePotionEffect(PotionEffectType.WATER_BREATHING); return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInjector.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInjector.java index 5fdc72c..b1b322e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInjector.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInjector.java @@ -27,7 +27,8 @@ import java.lang.reflect.Field; public class CommandInjector { - private CommandInjector(){} + private CommandInjector() { + } private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName(); private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java index 385099c..0cd79d0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java @@ -30,7 +30,7 @@ import org.bukkit.entity.Player; public class CommandLoader implements CommandExecutor { - private void help(Player player){ + private void help(Player player) { player.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen"); player.sendMessage("§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion"); player.sendMessage("§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab"); @@ -42,21 +42,21 @@ public class CommandLoader implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if(Welt.noPermission(player, Permission.build)){ + if (Welt.noPermission(player, Permission.build)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden"); return false; } - if(args.length == 0){ + if (args.length == 0) { help(player); return false; } - switch(args[0].toLowerCase()){ + switch (args[0].toLowerCase()) { case "setup": setup(player); break; @@ -81,16 +81,16 @@ public class CommandLoader implements CommandExecutor { return false; } - private void setup(Player player){ + private void setup(Player player) { AutoLoader.getLoader(player).setup(); } - private void undo(Player player){ + private void undo(Player player) { AutoLoader loader = loader(player); - if(loader == null) + if (loader == null) return; - if(!loader.isSetup()){ + if (!loader.isSetup()) { player.sendMessage("§cDer AutoLader wird in den Setup-Zustand versetzt"); setup(player); } @@ -98,58 +98,58 @@ public class CommandLoader implements CommandExecutor { loader.undo(); } - private void start(Player player){ + private void start(Player player) { AutoLoader loader = loader(player); - if(loader == null) + if (loader == null) return; loader.start(); } - private void stop(Player player){ - if(!AutoLoader.hasLoader(player)){ + private void stop(Player player) { + if (!AutoLoader.hasLoader(player)) { player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader"); return; } AutoLoader.getLoader(player).stop(); } - private void wait(Player player, String[] args){ - if(args.length != 2){ + private void wait(Player player, String[] args) { + if (args.length != 2) { help(player); return; } AutoLoader loader = loader(player); - if(loader == null) + if (loader == null) loader = AutoLoader.getLoader(player); try { loader.wait(Integer.parseInt(args[1])); - }catch (NumberFormatException e){ + } catch (NumberFormatException e) { player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Ganzzahl an"); } } - private void speed(Player player, String[] args){ - if(args.length != 2){ + private void speed(Player player, String[] args) { + if (args.length != 2) { help(player); return; } AutoLoader loader = loader(player); - if(loader == null) + if (loader == null) loader = AutoLoader.getLoader(player); try { loader.blockWait(Integer.parseInt(args[1])); - }catch (NumberFormatException e){ + } catch (NumberFormatException e) { player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Ganzzahl an"); } } - private AutoLoader loader(Player player){ - if(AutoLoader.hasLoader(player)) + private AutoLoader loader(Player player) { + if (AutoLoader.hasLoader(player)) return AutoLoader.getLoader(player); player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader"); player.sendMessage(BauSystem.PREFIX + "§7Es wird ein neuer AutoLader gestartet"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java index 93077e4..6ac4742 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java @@ -32,31 +32,31 @@ import org.bukkit.entity.Player; public class CommandLockschem implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); - if(userGroup != UserGroup.Admin && + if (userGroup != UserGroup.Admin && userGroup != UserGroup.Developer && userGroup != UserGroup.Moderator && userGroup != UserGroup.Supporter) return false; - if(args.length != 2) { + if (args.length != 2) { sendHelp(player); return false; } SteamwarUser schemOwner = SteamwarUser.get(args[0]); - if(schemOwner == null) { + if (schemOwner == null) { player.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); return false; } Schematic schematic = Schematic.getSchemFromDB(args[1], schemOwner.getUUID()); - if(schematic == null) { + if (schematic == null) { player.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java index 5155659..196887d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java @@ -31,7 +31,7 @@ public class CommandNV implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; toggleNightvision(player); @@ -39,7 +39,7 @@ public class CommandNV implements CommandExecutor { } public static void toggleNightvision(Player player) { - if(player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { + if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { player.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert"); player.removePotionEffect(PotionEffectType.NIGHT_VISION); return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java index b6a34d0..92e83bc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java @@ -32,15 +32,15 @@ import org.bukkit.entity.Player; import java.util.logging.Level; -public class CommandProtect implements CommandExecutor { +public class CommandProtect implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if(Welt.noPermission(player, Permission.worldedit)){ + if (Welt.noPermission(player, Permission.worldedit)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen"); return false; } @@ -52,16 +52,16 @@ public class CommandProtect implements CommandExecutor { } try { Schematic schem = null; - if(args.length > 0){ + if (args.length > 0) { schem = Schematic.getSchemFromDB(args[0], player.getUniqueId()); - if(schem == null){ + if (schem == null) { player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); return false; } } region.protect(schem); player.sendMessage(BauSystem.PREFIX + "§7Boden geschützt"); - }catch(Exception e){ + } catch (Exception e) { player.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region"); Bukkit.getLogger().log(Level.WARNING, "Failed protect", e); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index e53927d..0b8fcbb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -36,11 +36,11 @@ public class CommandReset implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if(Welt.noPermission(player, Permission.world)){ + if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen"); return false; } @@ -51,18 +51,18 @@ public class CommandReset implements CommandExecutor { return false; } try { - if(args.length > 0){ + if (args.length > 0) { Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId()); - if(schem == null){ + if (schem == null) { player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); return false; } region.reset(schem); - }else{ + } else { region.fastreset(); } player.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); - }catch(Exception e){ + } catch (Exception e) { player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); Bukkit.getLogger().log(Level.WARNING, "Failed reset", e); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java index 0103d30..17a5049 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java @@ -32,7 +32,7 @@ public class CommandSimulatorTabCompleter implements TabCompleter { @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) return new ArrayList<>(); + if (!(sender instanceof Player)) return new ArrayList<>(); return simulatorTabComplete((Player) sender, args); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java index bd8d121..c2277bd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java @@ -33,17 +33,17 @@ public class CommandSkull implements CommandExecutor { @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { - if(!(commandSender instanceof Player)) + if (!(commandSender instanceof Player)) return false; Player p = (Player) commandSender; - if(args.length != 1){ + if (args.length != 1) { p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8]"); return false; } ItemStack is = SWItem.getPlayerSkull(args[0]).getItemStack(); - SkullMeta sm = (SkullMeta)is.getItemMeta(); + SkullMeta sm = (SkullMeta) is.getItemMeta(); assert sm != null; sm.setDisplayName("§e" + args[0] + "§8s Kopf"); is.setItemMeta(sm); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java index 17088a4..223af4d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java @@ -29,19 +29,19 @@ public class CommandSpeed implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if (args.length == 0){ + if (args.length == 0) { player.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]"); return false; } float speed; - try{ + try { speed = Float.parseFloat(args[0]); - }catch(NumberFormatException e){ + } catch (NumberFormatException e) { player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java index dbc18b1..c924432 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java @@ -34,7 +34,7 @@ public class CommandTNTTabComplete implements TabCompleter { @Override public List 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(args); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index f997911..58f79ea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -102,7 +102,7 @@ public class CommandTPSLimiter implements CommandExecutor { private void tpsLimiter() { delay = 20 / currentTPSLimit; - loops = (int)Math.ceil(delay); + loops = (int) Math.ceil(delay); sleepDelay = (long) (50 * delay) / loops; TPSUtils.setTPS(currentTPSLimit); @@ -141,7 +141,7 @@ public class CommandTPSLimiter implements CommandExecutor { } public static double getCurrentTPSLimit() { - return (double)Math.round(currentTPSLimit * 10.0D) / 10.0D; + return (double) Math.round(currentTPSLimit * 10.0D) / 10.0D; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java index 00dc116..c3f316f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java @@ -33,7 +33,8 @@ public class CommandTPSLimiterTabComplete implements TabCompleter { private List arguments = new ArrayList<>(Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); public CommandTPSLimiterTabComplete() { - if (TPSUtils.isWarpAllowed()) arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); + if (TPSUtils.isWarpAllowed()) + arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java index ba9f241..27f37e9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java @@ -31,51 +31,51 @@ import org.bukkit.event.player.PlayerTeleportEvent; import java.util.List; public class CommandTeleport extends BukkitCommand { - public CommandTeleport() { - super("tp"); - description = "Teleportiert dich zu einem genannten Spieler."; - usageMessage = "/tp [Spieler]"; - } + public CommandTeleport() { + super("tp"); + description = "Teleportiert dich zu einem genannten Spieler."; + usageMessage = "/tp [Spieler]"; + } - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!(sender instanceof Player)) - return false; - else if (args.length != 1) { - sender.sendMessage(BauSystem.PREFIX + usageMessage); - return false; - } + public boolean execute(CommandSender sender, String currentAlias, String[] args) { + if (!(sender instanceof Player)) + return false; + else if (args.length != 1) { + sender.sendMessage(BauSystem.PREFIX + usageMessage); + return false; + } - Player p = (Player) sender; + Player p = (Player) sender; - Player target = Bukkit.getPlayerExact(args[0]); + Player target = Bukkit.getPlayerExact(args[0]); - if (target == null) { - p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline."); - return true; - } + if (target == null) { + p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline."); + return true; + } - if(p.getUniqueId().equals(target.getUniqueId())){ - p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!"); - return false; - } + if (p.getUniqueId().equals(target.getUniqueId())) { + p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!"); + return false; + } - if(!BauSystem.getOwner().equals(p.getUniqueId())){ - BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); - if(member == null || !member.isBuild()){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!"); - return false; - } - } + if (!BauSystem.getOwner().equals(p.getUniqueId())) { + BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); + if (member == null || !member.isBuild()) { + p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!"); + return false; + } + } - p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); - return true; + p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); + return true; } public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); + Validate.notNull(sender, "Sender cannot be null"); + Validate.notNull(args, "Arguments cannot be null"); + Validate.notNull(alias, "Alias cannot be null"); - return super.tabComplete(sender, alias, args); + return super.tabComplete(sender, alias, args); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index c8982b2..ce431a7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -36,11 +36,11 @@ public class CommandTestblock implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if(Welt.noPermission(player, Permission.worldedit)){ + if (Welt.noPermission(player, Permission.worldedit)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen"); return false; } @@ -52,16 +52,16 @@ public class CommandTestblock implements CommandExecutor { } try { Schematic schem = null; - if(args.length > 0){ + if (args.length > 0) { schem = Schematic.getSchemFromDB(args[0], player.getUniqueId()); - if(schem == null){ + if (schem == null) { player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); return false; } } region.resetTestblock(schem); player.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); - }catch(Exception e){ + } catch (Exception e) { player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks"); Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java index 3e1ab57..425658f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java @@ -30,38 +30,38 @@ import org.bukkit.entity.Player; public class CommandTime extends BukkitCommand { public CommandTime() { - super("time"); - this.description = "Ändert die Zeit auf der Spielwelt"; - this.usageMessage = "/time "; + super("time"); + this.description = "Ändert die Zeit auf der Spielwelt"; + this.usageMessage = "/time "; } public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!(sender instanceof Player)) { - return false; - } else if (args.length == 0) { - sender.sendMessage(BauSystem.PREFIX + this.usageMessage); - return false; - } - Player player = (Player) sender; + if (!(sender instanceof Player)) { + return false; + } else if (args.length == 0) { + sender.sendMessage(BauSystem.PREFIX + this.usageMessage); + return false; + } + Player player = (Player) sender; - if (Welt.noPermission(player, Permission.world)){ - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); - return false; - } + if (Welt.noPermission(player, Permission.world)) { + player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); + return false; + } - int time; - try{ - time = Integer.valueOf(args[0]); - }catch(NumberFormatException e){ - player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); - return false; - } - if (time < 0 || time > 24000) { - player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); - return false; - } + int time; + try { + time = Integer.valueOf(args[0]); + } catch (NumberFormatException e) { + player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); + return false; + } + if (time < 0 || time > 24000) { + player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); + return false; + } - Bukkit.getWorlds().get(0).setTime(time); - return false; - } + Bukkit.getWorlds().get(0).setTime(time); + return false; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java index 3d30f71..529a118 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java @@ -49,7 +49,7 @@ public class CommandTrace implements CommandExecutor { } private boolean permissionCheck(Player player) { - if(Welt.noPermission(player, Permission.world)){ + if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); return false; } @@ -58,10 +58,10 @@ public class CommandTrace implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) return false; + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if(args.length == 0){ + if (args.length == 0) { help(player); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java index 47e9912..ff7329b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java @@ -45,7 +45,7 @@ public class CommandTraceTabCompleter implements TabCompleter { @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) return new ArrayList<>(); + if (!(sender instanceof Player)) return new ArrayList<>(); return tracerTabComplete((Player) sender, args); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionToggleCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionToggleCommand.java index d07e013..5b8c549 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionToggleCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionToggleCommand.java @@ -42,11 +42,11 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) + if (!(sender instanceof Player)) return false; Player player = (Player) sender; - if (Welt.noPermission(player, Permission.world)){ + if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); return false; } @@ -69,7 +69,9 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener { } abstract String getNoPermMessage(); + abstract String getEnableMessage(); + abstract String getDisableMessage(); /** diff --git a/BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java b/BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java index 8331f02..76e98aa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java @@ -56,16 +56,19 @@ public class GuiTraceShow { swInventory.addCloseCallback(clickType -> ShowModeParameterMap.remove(player)); setActiveShow(player, swInventory); - SWItem water = new SWItem(Material.TNT, "§eWasser §7Positionen", Arrays.asList("§7Zeigt alles TNT, welches", "§7im Wasser explodiert ist."), false, clickType -> {}); + SWItem water = new SWItem(Material.TNT, "§eWasser §7Positionen", Arrays.asList("§7Zeigt alles TNT, welches", "§7im Wasser explodiert ist."), false, clickType -> { + }); swInventory.setItem(5, water); swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water)); - SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, "§eInterpolation §7Y-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der Y-Achse."), false, clickType -> {}); + SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, "§eInterpolation §7Y-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der Y-Achse."), false, clickType -> { + }); swInventory.setItem(6, interpolateY); swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY)); Material xzMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_12::getTraceXZMaterial, 8), new VersionedCallable<>(TNTTracer_15::getTraceXZMaterial, 14)); - SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse."), false, clickType -> {}); + SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse."), false, clickType -> { + }); swInventory.setItem(7, interpolateXZ); swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ)); // Water Bucket (-water) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/RoundedTNTPosition.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/RoundedTNTPosition.java index a38459b..7396057 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/RoundedTNTPosition.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/RoundedTNTPosition.java @@ -42,9 +42,9 @@ public class RoundedTNTPosition { } public RoundedTNTPosition(double x, double y, double z) { - this.x = (int)(x * factor); - this.y = (int)(y * factor); - this.z = (int)(z * factor); + this.x = (int) (x * factor); + this.y = (int) (y * factor); + this.z = (int) (z * factor); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTPosition.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTPosition.java index 1529ca8..d8deae6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTPosition.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTPosition.java @@ -49,7 +49,7 @@ public class TNTPosition { return exploded; } - public Record.TNTRecord getRecord(){ + public Record.TNTRecord getRecord() { return record; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java index 6a755b8..bd67938 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStateMachine.java @@ -87,7 +87,7 @@ public class RecordStateMachine { return recorder.getStartTime(); } - public static void postClear(){ + public static void postClear() { if (recorder == null) return; recorder.postClear(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStatus.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStatus.java index e9f69e7..a70e53b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStatus.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordStatus.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.tracer.record; public enum RecordStatus { - RECORD("§aan", true,"§cTNT-Tracer muss gestoppt werden"), + RECORD("§aan", true, "§cTNT-Tracer muss gestoppt werden"), RECORD_AUTO("§aan", true, "§cTNT-Tracer darf nicht aufnehmen"), IDLE("§caus", false, "§cAuto-Tracer gestoppt"), IDLE_AUTO("§eauto", false, "§aAuto-Tracer gestartet"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/TraceAutoHandler.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/TraceAutoHandler.java index ed93e28..58e52e4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/TraceAutoHandler.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/TraceAutoHandler.java @@ -34,13 +34,13 @@ public class TraceAutoHandler implements Listener { private BukkitTask task; private int lastExplosion = 0; // Time since the last explosion in ticks - public void enable(){ + public void enable() { Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); } - public void disable(){ + public void disable() { HandlerList.unregisterAll(this); - if(task != null){ + if (task != null) { task.cancel(); task = null; } @@ -52,13 +52,13 @@ public class TraceAutoHandler implements Listener { return; lastExplosion = 0; - if(task == null){ + if (task == null) { RecordStateMachine.autoRecord(); task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1); } } - private void run(){ + private void run() { lastExplosion++; if (lastExplosion > 80) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/Record.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/Record.java index 8942080..b6ac929 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/Record.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/Record.java @@ -55,7 +55,7 @@ public class Record { return record; } - public void clear(){ + public void clear() { tnt.clear(); } @@ -87,7 +87,7 @@ public class Record { add(tntPrimed, true); } - public List getPositions(){ + public List getPositions() { return positions; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowMode.java index 5a96232..d313189 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowMode.java @@ -23,5 +23,6 @@ import de.steamwar.bausystem.tracer.TNTPosition; public interface ShowMode { void show(TNTPosition position); + void hide(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java index 21c09f1..0c4b88e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java @@ -2,7 +2,6 @@ package de.steamwar.bausystem.tracer.show; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.tracer.TNTPosition; -import de.steamwar.bausystem.tracer.show.mode.*; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -13,7 +12,8 @@ import java.util.HashMap; import java.util.Map; public class TraceShowManager implements Listener { - private TraceShowManager() {} + private TraceShowManager() { + } private static final Map showModes = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/AFKStopper.java b/BauSystem_Main/src/de/steamwar/bausystem/world/AFKStopper.java index 1142bb6..cf8e7bd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/AFKStopper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/AFKStopper.java @@ -32,13 +32,13 @@ public class AFKStopper implements Listener { private int minutesAfk; - public AFKStopper(){ + public AFKStopper() { minutesAfk = 0; Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - switch(minutesAfk){ + switch (minutesAfk) { case 5: - for(Player p : Bukkit.getOnlinePlayers()) + for (Player p : Bukkit.getOnlinePlayers()) p.kickPlayer("§cAuf diesem Server ist seit 5 Minuten nichts passiert."); break; case 4: @@ -50,7 +50,7 @@ public class AFKStopper implements Listener { } @EventHandler - public void onPlayerMove(PlayerMoveEvent event){ + public void onPlayerMove(PlayerMoveEvent event) { minutesAfk = 0; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java index 07db200..b6a28a4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java @@ -39,7 +39,7 @@ import java.util.LinkedList; import java.util.ListIterator; import java.util.Map; -public class AutoLoader extends IAutoLoader implements Listener { +public class AutoLoader extends AbstractAutoLoader implements Listener { private static final Map players = new HashMap<>(); @@ -184,11 +184,11 @@ public class AutoLoader extends IAutoLoader implements Listener { if (lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) return; if (detoloader.useActive) { - new IAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation() + new AbstractAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation() , detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation() , detoloader.isActive()); } else { - new IAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation() + new AbstractAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation() , detoloader.getActivation()); } print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" : @@ -251,9 +251,9 @@ public class AutoLoader extends IAutoLoader implements Listener { return lastActivation; } - class TNTPlaceAction extends IAutoLoader.LoaderAction { + class TNTPlaceAction extends AbstractAutoLoader.LoaderAction { - TNTPlaceAction(IAutoLoader loader, Location location){ + TNTPlaceAction(AbstractAutoLoader loader, Location location){ super(loader, location); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java index 0a93414..ccdc312 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java @@ -77,7 +77,7 @@ public class BauScoreboard implements Listener { int i = strings.size(); HashMap result = new HashMap<>(); - for(String s : strings) + for (String s : strings) result.put(s, i--); return result; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java index f31f51a..72aaebb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ClipboardListener.java @@ -33,10 +33,10 @@ public class ClipboardListener implements Listener { private static final String CLIPBOARD_SCHEMNAME = "//copy"; @EventHandler - public void onLogin(PlayerJoinEvent e){ + public void onLogin(PlayerJoinEvent e) { try { Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, e.getPlayer().getUniqueId()); - if(schematic != null){ + if (schematic != null) { schematic.loadToPlayer(e.getPlayer()); } } catch (Exception ex) { @@ -45,20 +45,20 @@ public class ClipboardListener implements Listener { } @EventHandler - public void onLogout(PlayerQuitEvent e){ + public void onLogout(PlayerQuitEvent e) { UUID playerUUID = e.getPlayer().getUniqueId(); Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID); boolean newSchem = false; - if(schematic == null){ + if (schematic == null) { Schematic.createSchem(CLIPBOARD_SCHEMNAME, playerUUID, "", SchematicType.Normal); schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID); newSchem = true; } - try{ + try { schematic.saveFromPlayer(e.getPlayer()); } catch (Exception ex) { - if(newSchem) + if (newSchem) schematic.remove(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java index a82be18..b3918e8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java @@ -68,7 +68,7 @@ public class Detonator implements Listener { List locs = new ArrayList<>(); for (int i = 0; i < 128; i++) { NamespacedKey key = new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + i); - if(container.has(key, PersistentDataType.INTEGER_ARRAY)) + if (container.has(key, PersistentDataType.INTEGER_ARRAY)) locs.add(container.get(key, PersistentDataType.INTEGER_ARRAY)); } return new Detonator(player, locs.toArray(new int[0][0])); @@ -84,7 +84,7 @@ public class Detonator implements Listener { } public static ItemStack toggleLocation(ItemStack item, Player player, Detoloader detoloader, Location location) { - if(VersionedCallable.call(new VersionedCallable<>(() -> PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).stream().anyMatch(activation -> activation.location.equals(location)), 12), + if (VersionedCallable.call(new VersionedCallable<>(() -> PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).stream().anyMatch(activation -> activation.location.equals(location)), 12), new VersionedCallable<>(() -> hasLocation(item, location), 15))) { DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" : detoloader.getBlock(), Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() - 1); @@ -92,10 +92,10 @@ public class Detonator implements Listener { PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).removeIf(activation -> activation.location.equals(location)); return item; }, 12), new VersionedCallable<>(() -> removeLocation(item, location), 15)); - }else { + } else { DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" : detoloader.getBlock(), Math.min(Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() + 1, 128)); - if(detoloader.getActivation() == 0) + if (detoloader.getActivation() == 0) return VersionedCallable.call(new VersionedCallable<>(() -> { PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(location)); return item; @@ -151,7 +151,7 @@ public class Detonator implements Listener { public static ItemStack pushLocToDetonator(ItemStack item, Detoloader.DetonatorActivation detoloader) { int slot = getFreeSlot(item); - if(slot == -1) + if (slot == -1) throw new SecurityException("Der Detonator ist auf 128 Positionen Limitiert"); ItemMeta meta = item.getItemMeta(); Location block = detoloader.location; @@ -181,9 +181,9 @@ public class Detonator implements Listener { PersistentDataContainer container = meta.getPersistentDataContainer(); for (int i = 0; i < 128; i++) { NamespacedKey key = new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + i); - if(container.has(key, PersistentDataType.INTEGER_ARRAY)) { + if (container.has(key, PersistentDataType.INTEGER_ARRAY)) { int[] locs = container.get(key, PersistentDataType.INTEGER_ARRAY); - if(locs[0] == location.getBlockX() && locs[1] == location.getBlockY() && locs[2] == location.getBlockZ()) + if (locs[0] == location.getBlockX() && locs[1] == location.getBlockY() && locs[2] == location.getBlockZ()) return i; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java index abc569a..fb0b1c6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java @@ -21,7 +21,7 @@ public class DetonatorListener implements Listener { if (VersionedCallable.call(new VersionedCallable<>(() -> event.getItem().isSimilar(Detonator.WAND), 12), new VersionedCallable<>(() -> event.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE), 15))) { Player player = event.getPlayer(); - if(Welt.noPermission(player, Permission.world)){ + if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen"); return; } @@ -37,7 +37,7 @@ public class DetonatorListener implements Listener { if (detoloader == null) { return; } else if (detoloader.activation == -1) { - print(player, detoloader.getBlock(), detoloader.addBack?Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size():0); + print(player, detoloader.getBlock(), detoloader.addBack ? Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() : 0); return; } @@ -50,7 +50,7 @@ public class DetonatorListener implements Listener { player.getInventory().setItemInMainHand(Detonator.setLocation(player, item, new Detoloader.DetonatorActivation(detoloader.activation, event.getClickedBlock().getLocation()))); } print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " gesetzt" : - detoloader.getBlock(), detoloader.addBack?Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size():0); + detoloader.getBlock(), detoloader.addBack ? Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() : 0); } break; case RIGHT_CLICK_AIR: @@ -58,7 +58,7 @@ public class DetonatorListener implements Listener { Detonator.execute(player); break; } - }catch (RuntimeException e) { + } catch (RuntimeException e) { player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage()); player.getInventory().setItemInMainHand(item); } @@ -68,7 +68,7 @@ public class DetonatorListener implements Listener { public static void print(Player player, String message, int size) { if (size == 0) { player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); - }else { + } else { player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + size)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/PredefinedBook.java b/BauSystem_Main/src/de/steamwar/bausystem/world/PredefinedBook.java index a13baec..355fd3b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/PredefinedBook.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/PredefinedBook.java @@ -23,10 +23,10 @@ public class PredefinedBook { } public static List getBooks() { - if(bookCache != null) + if (bookCache != null) return bookCache; List books = new ArrayList<>(); - for (String book:configuration.getKeys(false)) { + for (String book : configuration.getKeys(false)) { ConfigurationSection section = Objects.requireNonNull(configuration.getConfigurationSection(book)); books.add(new PredefinedBook(section)); } @@ -38,7 +38,7 @@ public class PredefinedBook { return configuration.getKeys(false).size(); } - private List lines; + private List lines; private List lore; private String author; private String name; @@ -52,7 +52,7 @@ public class PredefinedBook { } public ItemStack toItemStack() { - if(finishedBook != null) + if (finishedBook != null) return finishedBook; ItemStack book = new ItemStack(getBookMat()); BookMeta meta = (BookMeta) book.getItemMeta(); @@ -94,22 +94,22 @@ public class PredefinedBook { int currentLine = 0; int currentpage = 0; boolean first = true; - for (String line:lines) { + for (String line : lines) { int linesPlus = (int) Math.ceil((double) line.length() / charsPerLine); currentLine += linesPlus; - if(currentLine >= 14 || line.equals("!")) { + if (currentLine >= 14 || line.equals("!")) { currentLine = linesPlus; currentpage++; - if(currentpage > 50) + if (currentpage > 50) throw new IllegalStateException("Book " + name + " has more pages than 50"); pages.add(currentpage, new StringBuilder()); first = true; - if(line.equals("!")) + if (line.equals("!")) continue; } - if(!first) { + if (!first) { pages.get(currentpage).append("\n"); - }else { + } else { first = false; } pages.get(currentpage).append(line); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 01183bf..b41339f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -42,7 +42,7 @@ public class Region { private static boolean buildArea = false; private static boolean extensionArea = false; - static{ + static { YamlConfiguration config = new YamlConfiguration(); try { config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml")); @@ -52,13 +52,13 @@ public class Region { ConfigurationSection prototypes = config.getConfigurationSection("prototypes"); assert prototypes != null; - for(String prototype : prototypes.getKeys(false)){ + for (String prototype : prototypes.getKeys(false)) { new Prototype(Objects.requireNonNull(prototypes.getConfigurationSection(prototype))); } ConfigurationSection regions = config.getConfigurationSection("regions"); assert regions != null; - for(String region : regions.getKeys(false)){ + for (String region : regions.getKeys(false)) { new Region(Objects.requireNonNull(regions.getConfigurationSection(region))); } } @@ -90,7 +90,7 @@ public class Region { private boolean freeze = false; private boolean fire = false; - private Region(ConfigurationSection config){ + private Region(ConfigurationSection config) { name = config.getName(); minX = config.getInt("minX"); minY = config.getInt("minY"); @@ -155,7 +155,7 @@ public class Region { setLinkedRegion(region -> region.fire = fire); } - public boolean inRegion(Location l){ + public boolean inRegion(Location l) { return prototype.inRegion(this, l); } @@ -171,7 +171,7 @@ public class Region { return prototype.buildArea.inRegionExtension(this, l); } - public void fastreset(){ + public void fastreset() { prototype.fastreset(this); } @@ -183,11 +183,11 @@ public class Region { return prototype.hasTestblock(); } - public void resetTestblock(Schematic schem) throws IOException, NoClipboardException{ + public void resetTestblock(Schematic schem) throws IOException, NoClipboardException { prototype.resetTestblock(this, schem); } - public boolean hasProtection(){ + public boolean hasProtection() { return prototype.hasProtection(); } @@ -250,7 +250,7 @@ public class Region { } } - public static class Prototype{ + public static class Prototype { private static final Map prototypes = new HashMap<>(); private final int sizeX; @@ -275,7 +275,7 @@ public class Region { private final String protectSchematic; //nullable - private Prototype(ConfigurationSection config){ + private Prototype(ConfigurationSection config) { sizeX = config.getInt("sizeX"); sizeY = config.getInt("sizeY"); sizeZ = config.getInt("sizeZ"); @@ -304,27 +304,27 @@ public class Region { protectSchematic = config.getString("protection", null); - if(!config.getName().equals("testblock") && !config.getName().equals("buildArea")) + if (!config.getName().equals("testblock") && !config.getName().equals("buildArea")) prototypes.put(config.getName(), this); } - public boolean inRegion(Region region, Location l){ - return inRange(l.getX(), region.minX + offsetX, sizeX) && + public boolean inRegion(Region region, Location l) { + return inRange(l.getX(), region.minX + offsetX, sizeX) && inRange(l.getY(), region.minY + offsetY, sizeY) && inRange(l.getZ(), region.minZ + offsetZ, sizeZ); } public boolean inRegionExtension(Region region, Location l) { - return inRange(l.getX(), region.minX + offsetX - extensionAxisX + 1, sizeX + extensionAxisX * 2 - 1) && + return inRange(l.getX(), region.minX + offsetX - extensionAxisX + 1, sizeX + extensionAxisX * 2 - 1) && inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY - 1) && inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ + 1, sizeZ + extensionNegativeZ - 1 + extensionPositiveZ); } - public void fastreset(Region region){ + public void fastreset(Region region) { File file = new File(schematic); - int x = region.minX + offsetX + sizeX/2; + int x = region.minX + offsetX + sizeX / 2; int y = region.minY + offsetY; - int z = region.minZ + offsetZ + sizeZ/2; + int z = region.minZ + offsetZ + sizeZ / 2; VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8), new VersionedRunnable(() -> Region_15.fastpaste(file, x, y, z, rotate), 15)); } @@ -333,7 +333,7 @@ public class Region { int x = region.minX + offsetX + sizeX / 2; int y = region.minY + offsetY; int z = region.minZ + offsetZ + sizeZ / 2; - if(schem == null) + if (schem == null) paste(new File(schematic), x, y, z, rotate); else paste(schem.load(), x, y, z, rotate); @@ -347,7 +347,7 @@ public class Region { int x = region.minX + offsetX + sizeX / 2; int y = region.minY + testblock.offsetY - 1; int z = region.minZ + offsetZ + sizeZ / 2; - if(schem == null) + if (schem == null) paste(new File(protectSchematic), x, y, z, rotate); else paste(schem.load(), x, y, z, rotate); @@ -361,16 +361,16 @@ public class Region { testblock.reset(region, schem); } - private static boolean inRange(double l, int min, int size){ + private static boolean inRange(double l, int min, int size) { return min <= l && l <= min + size; } - private static void paste(File file, int x, int y, int z, boolean rotate){ //Type of protect + private static void paste(File file, int x, int y, int z, boolean rotate) { //Type of protect VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8), new VersionedRunnable(() -> Region_15.paste(file, x, y, z, rotate), 15)); } - private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){ + private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate) { VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8), new VersionedRunnable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index 64f5cf0..b562a9f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -53,7 +53,7 @@ public class RegionListener implements Listener { Player p = e.getPlayer(); - if (Welt.noPermission(p, Permission.worldedit)){ + if (Welt.noPermission(p, Permission.worldedit)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein WorldEdit benutzen"); e.setCancelled(true); } @@ -63,7 +63,7 @@ public class RegionListener implements Listener { public void onBlockBreak(BlockBreakEvent e) { Player p = e.getPlayer(); - if (Welt.noPermission(p, Permission.build)){ + if (Welt.noPermission(p, Permission.build)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke abbauen"); e.setCancelled(true); } @@ -74,12 +74,12 @@ public class RegionListener implements Listener { if (Core.getVersion() == 12) return; Player p = e.getPlayer(); - try{ - if (Welt.noPermission(p, Permission.build)){ + try { + if (Welt.noPermission(p, Permission.build)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); e.setBuildable(false); } - }catch(NullPointerException ex){ + } catch (NullPointerException ex) { //ignored, caused by worldedit brushes } } @@ -89,12 +89,12 @@ public class RegionListener implements Listener { if (Core.getVersion() == 15) return; Player p = e.getPlayer(); - try{ - if (Welt.noPermission(p, Permission.build)){ + try { + if (Welt.noPermission(p, Permission.build)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); e.setCancelled(true); } - }catch(NullPointerException ex){ + } catch (NullPointerException ex) { //ignored, caused by worldedit brushes } } @@ -102,8 +102,8 @@ public class RegionListener implements Listener { private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"}; private boolean isWorldEditCommand(String command) { - for(String shortcut : shortcutCommands) - if(command.startsWith(shortcut)) + for (String shortcut : shortcutCommands) + if (command.startsWith(shortcut)) return true; return VersionedCallable.call(new VersionedCallable<>(() -> RegionListener_12.isWorldEditCommand(command), 8), @@ -112,9 +112,9 @@ public class RegionListener implements Listener { @EventHandler public void onSignChange(SignChangeEvent event) { - for(int i = 0; i <= 3; ++i) { + for (int i = 0; i <= 3; ++i) { String line = event.getLine(i); - if(line == null) + if (line == null) continue; line = ChatColor.translateAlternateColorCodes('&', line); event.setLine(i, line); @@ -123,7 +123,7 @@ public class RegionListener implements Listener { @EventHandler public void editSign(PlayerInteractEvent event) { - if(event.getAction() != Action.RIGHT_CLICK_BLOCK || + if (event.getAction() != Action.RIGHT_CLICK_BLOCK || !event.getClickedBlock().getType().name().contains("SIGN") || !event.getPlayer().isSneaking() || (event.getItem() != null && event.getItem().getType() != Material.AIR)) @@ -143,7 +143,7 @@ public class RegionListener implements Listener { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getPlugin(), PacketType.Play.Client.UPDATE_SIGN) { @Override public void onPacketReceiving(PacketEvent event) { - if(!event.getPlayer().equals(player)) + if (!event.getPlayer().equals(player)) return; Bukkit.getScheduler().runTask(BauSystem.getPlugin(), () -> { PacketContainer packetContainer = event.getPacket(); @@ -151,7 +151,7 @@ public class RegionListener implements Listener { String[] lines = packetContainer.getStringArrays().read(0); Block signLoc = position.toLocation(player.getWorld()).getBlock(); - if(!signLoc.getType().name().contains("SIGN")) + if (!signLoc.getType().name().contains("SIGN")) return; Sign sign = ((Sign) signLoc.getState()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java index 07cffe3..179ca07 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java @@ -50,7 +50,7 @@ public class ScriptListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onLeftClick(PlayerInteractEvent event) { ItemStack item = event.getItem(); - if(item == null || isNoBook(item) || item.getItemMeta() == null) + if (item == null || isNoBook(item) || item.getItemMeta() == null) return; if (CommandScript.BOOK.getItemMeta() != null && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(CommandScript.BOOK.getItemMeta().getDisplayName())) { @@ -71,7 +71,7 @@ public class ScriptListener implements Listener { new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer()); } - private boolean isNoBook(ItemStack item){ + private boolean isNoBook(ItemStack item) { return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_12.isNoBook(item), 8), new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15)); } @@ -88,7 +88,7 @@ public class ScriptListener implements Listener { public ScriptExecutor(BookMeta bookMeta, Player player) { this.player = player; - for(String page : bookMeta.getPages()) { + for (String page : bookMeta.getPages()) { for (String command : page.split("\n")) { if (command.startsWith("#") || command.trim().isEmpty()) continue; if (command.startsWith(".")) { @@ -241,10 +241,10 @@ public class ScriptListener implements Listener { scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDie ersten beiden Argumente sind Zahlen/Boolsche Wertde oder Variablen."); return -1; } - + int jumpTruePoint = scriptExecutor.jumpPoints.getOrDefault(args[2], -1); int jumpFalsePoint = args.length > 3 ? scriptExecutor.jumpPoints.getOrDefault(args[3], -1) : -1; - + int firstValue; int secondValue; if (isVariable(scriptExecutor, args[0])) { @@ -257,7 +257,7 @@ public class ScriptListener implements Listener { } else { secondValue = parseValue(args[1]); } - + if (firstValue == secondValue) { return jumpTruePoint; } else { @@ -313,7 +313,7 @@ public class ScriptListener implements Listener { try { return Integer.parseInt(value); } catch (NumberFormatException e) { - return 0; + return 0; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java index 8da8dd7..1eaa634 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java @@ -312,7 +312,7 @@ public class TNTSimulator { } private static double clamp(double d) { - return (int)(d * 10000) * 0.0001; + return (int) (d * 10000) * 0.0001; } public void delete() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java index 563e01a..53777f2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java @@ -58,7 +58,8 @@ public class TPSUtils { } public static double getTps(TPSWatcher.TPSType tpsType) { - if (TPSUtils.isWarping()) return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20)); + if (TPSUtils.isWarping()) + return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20)); return TPSWatcher.getTPS(tpsType); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java index 5177f61..7b733ba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java @@ -28,17 +28,18 @@ import org.bukkit.entity.Player; public class Welt { - private Welt(){} + private Welt() { + } - public static boolean noPermission(Player member, Permission perm){ - if(member.getUniqueId().equals(BauSystem.getOwner())) + public static boolean noPermission(Player member, Permission perm) { + if (member.getUniqueId().equals(BauSystem.getOwner())) return false; BauweltMember member1 = BauweltMember.getBauMember(BauSystem.getOwner(), member.getUniqueId()); - if(member1 == null) + if (member1 == null) return true; - switch(perm){ + switch (perm) { case build: return !member1.isBuild(); case worldedit: @@ -52,12 +53,12 @@ public class Welt { } } - private static void sendMessages(Player p, boolean ableTo, BauweltMember target, String what){ + private static void sendMessages(Player p, boolean ableTo, BauweltMember target, String what) { Player z = Bukkit.getPlayer(SteamwarUser.get(target.getMemberID()).getUUID()); if (z != null) { if (ableTo) { z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a " + what); - }else { + } else { z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c " + what); } } @@ -68,17 +69,17 @@ public class Welt { } } - public static void toggleBuild(Player p, BauweltMember target){ + public static void toggleBuild(Player p, BauweltMember target) { target.setBuild(!target.isBuild()); sendMessages(p, target.isBuild(), target, "bauen"); } - public static void toggleWE(Player p, BauweltMember target){ + public static void toggleWE(Player p, BauweltMember target) { target.setWorldEdit(!target.isWorldEdit()); sendMessages(p, target.isWorldEdit(), target, "WorldEdit verwenden"); } - public static void toggleWorld(Player p, BauweltMember target){ + public static void toggleWorld(Player p, BauweltMember target) { target.setWorld(!target.isWorld()); sendMessages(p, target.isWorld(), target, "Einstellungen vornehmen"); }