Fixing some Things
Dieser Commit ist enthalten in:
Ursprung
2a1e4578d6
Commit
b1672be384
@ -49,6 +49,7 @@ class AutoLoader_15 {
|
||||
if (!(data instanceof Powerable))
|
||||
return false;
|
||||
|
||||
|
||||
Powerable powerable = (Powerable) data;
|
||||
powerable.setPowered(active);
|
||||
block.setBlockData(powerable);
|
||||
@ -59,7 +60,7 @@ class AutoLoader_15 {
|
||||
block.setBlockData(openable);
|
||||
}
|
||||
|
||||
if (data instanceof Switch){
|
||||
if (data instanceof Switch) {
|
||||
Switch swtch = (Switch) data;
|
||||
Block relative;
|
||||
switch(swtch.getFace()){
|
||||
@ -74,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;
|
||||
@ -97,11 +98,7 @@ class AutoLoader_15 {
|
||||
Material material = block.getType();
|
||||
|
||||
if (material == Material.LEVER) {
|
||||
if (powerable.isPowered()) {
|
||||
return new Detoloader("Hebel", 0).setActive(false);
|
||||
} else {
|
||||
return new Detoloader("Hebel", 0).setActive(true);
|
||||
}
|
||||
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")){
|
||||
@ -118,6 +115,8 @@ class AutoLoader_15 {
|
||||
}
|
||||
|
||||
static boolean getLever(Block block) {
|
||||
return ((Powerable)block.getBlockData()).isPowered();
|
||||
if(!(block.getBlockData() instanceof Powerable))
|
||||
return false;
|
||||
return ((Powerable) block.getBlockData()).isPowered();
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ import java.util.stream.Collectors;
|
||||
public class Detonator implements Listener {
|
||||
|
||||
public static final ItemStack WAND;
|
||||
private static final Map<Player, Detonator> PLAYERS = new HashMap<>();
|
||||
private static final Map<Player, Detonator> players = new HashMap<>();
|
||||
|
||||
private final Set<Detoloader.DetonatorActivation> locs = new HashSet<>();
|
||||
private final Player player;
|
||||
@ -61,19 +61,20 @@ public class Detonator implements Listener {
|
||||
}
|
||||
|
||||
public static Detonator getDetonator(Player player){
|
||||
if(!PLAYERS.containsKey(player))
|
||||
if(!players.containsKey(player))
|
||||
return new Detonator(player);
|
||||
return PLAYERS.get(player);
|
||||
return players.get(player);
|
||||
}
|
||||
|
||||
public Detonator(Player player) {
|
||||
this.player = player;
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
PLAYERS.put(player, this);
|
||||
players.put(player, this);
|
||||
}
|
||||
|
||||
public static void deleteDetonator(Player player) {
|
||||
HandlerList.unregisterAll(PLAYERS.remove(player));
|
||||
if(players.containsKey(player))
|
||||
HandlerList.unregisterAll(players.remove(player));
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
@ -86,12 +87,7 @@ public class Detonator implements Listener {
|
||||
|
||||
}, 12), new VersionedRunnable(() -> {
|
||||
boolean powered;
|
||||
try {
|
||||
powered = AutoLoader_15.getLever(activation.location.getBlock());
|
||||
} catch (ClassCastException e) {
|
||||
locs.remove(activation);
|
||||
return;
|
||||
}
|
||||
powered = AutoLoader_15.getLever(activation.location.getBlock());
|
||||
AutoLoader_15.setRedstone(activation.location, !powered);
|
||||
}, 15));
|
||||
} else {
|
||||
@ -113,6 +109,7 @@ public class Detonator implements Listener {
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if(!event.getPlayer().equals(player))
|
||||
return;
|
||||
|
||||
if (event.getItem() == null) return;
|
||||
if (event.getItem().isSimilar(WAND)) {
|
||||
event.setCancelled(true);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren