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 a227145..846dd40 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -2,25 +2,69 @@ package de.steamwar.bausystem.world; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Powerable; +import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; class AutoLoader_15 { - private AutoLoader_15(){} + private AutoLoader_15() { + } - static boolean tntPlaceActionPerform(Location location){ + static boolean tntPlaceActionPerform(Location location) { Material m = location.getBlock().getType(); - if(m != Material.AIR && m != Material.WATER) + if (m != Material.AIR && m != Material.WATER) return false; location.getBlock().setType(Material.TNT); return true; } - static boolean setRedstone(Location location, boolean active){ + static boolean setRedstone(Location location, boolean active) { + Block block = location.getBlock(); + BlockData data = block.getBlockData(); + if (!(data instanceof Powerable)) + return false; + + Powerable powerable = (Powerable) data; + powerable.setPowered(active); + block.setBlockData(powerable); + block.getState().update(true); return true; } - static void onPlayerInteract(IAutoLoader loader, PlayerInteractEvent event){ - loader.print("§cDer AutoLoader ist in der 1.14 noch nicht fertig implementiert", false); + static void onPlayerInteract(IAutoLoader loader, PlayerInteractEvent event) { + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) + return; + + Block block = event.getClickedBlock(); + assert block != null; + BlockData data = block.getBlockData(); + if (!(data instanceof Powerable)) + return; + Powerable powerable = (Powerable) data; + Material material = block.getType(); + + if (material == Material.LEVER) { + if (powerable.isPowered()) { + new IAutoLoader.RedstoneActivation(loader, block.getLocation(), loader.getLastActivation(), false); + loader.print("§eHebel zurückgesetzt", true); + } else { + new IAutoLoader.RedstoneActivation(loader, block.getLocation(), 1, true); + loader.print("§eHebel betätigt", true); + } + } else if (material == Material.STONE_BUTTON) { + new IAutoLoader.TemporaryActivation(loader, block.getLocation(), 20); + loader.print("§eKnopf betätigt", true); + } else if (material.name().contains("PRESSURE_PLATE")){ + new IAutoLoader.TemporaryActivation(loader, block.getLocation(), 20); + loader.print("§eDruckplatte betätigt", true); + } else if (material.name().contains("BUTTON")) { + new IAutoLoader.TemporaryActivation(loader, block.getLocation(), 30); + loader.print("§eKnopf betätigt", true); + } else { + loader.print("§eUnbekannter Block betätigt (nicht aufgenommen)", false); + } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSlow.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSlow.java deleted file mode 100644 index 4eb2adc..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSlow.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Welt; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class CommandSlow implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) - return false; - Player player = (Player) sender; - - if(args.length == 0){ - player.sendMessage(BauSystem.PREFIX + "§8/§7slow §8[§eTPS§8]"); - return false; - } - - if(Welt.noPermission(player, Permission.world)){ - player.sendMessage(BauSystem.PREFIX + "§cDu darst hier die Geschwindigkeit nicht verstellen"); - return false; - } - - float tps; - try{ - tps = Float.parseFloat(args[0]); - }catch(NumberFormatException e){ - player.sendMessage(BauSystem.PREFIX + "§cDu solltest eine Zahl angeben..."); - return false; - } - - if(tps > 20){ - player.sendMessage(BauSystem.PREFIX + "§cTut mir leid, aber das ist nicht möglich (TPS > 20)"); - return false; - } - - if(tps == 20){ - - } - - return false; - } -}