Fixing Detonator #158
@ -60,8 +60,8 @@ public class Detonator implements Listener {
|
||||
WAND.setItemMeta(im);
|
||||
}
|
||||
|
||||
public static Detonator getDetonator(Player player){
|
||||
if(!players.containsKey(player))
|
||||
public static Detonator getDetonator(Player player) {
|
||||
if (!players.containsKey(player))
|
||||
return new Detonator(player);
|
||||
return players.get(player);
|
||||
}
|
||||
@ -73,14 +73,14 @@ public class Detonator implements Listener {
|
||||
}
|
||||
|
||||
public static void deleteDetonator(Player player) {
|
||||
if(players.containsKey(player))
|
||||
if (players.containsKey(player))
|
||||
HandlerList.unregisterAll(players.remove(player));
|
||||
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
for (Detoloader.DetonatorActivation activation: getLocations()) {
|
||||
for (Detoloader.DetonatorActivation activation : getLocations()) {
|
||||
|
||||
YoyoNow
hat
Die Zeile kann weg Die Zeile kann weg
|
||||
if(activation.activation == -1) {
|
||||
if (activation.activation == -1) {
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||
boolean powered = AutoLoader_12.getLever(activation.location.getBlock());
|
||||
AutoLoader_12.setRedstone(activation.location, !powered);
|
||||
@ -92,12 +92,10 @@ public class Detonator implements Listener {
|
||||
} else {
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||
AutoLoader_12.setRedstone(activation.location, true);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () ->
|
||||
AutoLoader_12.setRedstone(activation.location, false), activation.activation);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> AutoLoader_12.setRedstone(activation.location, false), activation.activation);
|
||||
}, 12), new VersionedRunnable(() -> {
|
||||
AutoLoader_15.setRedstone(activation.location, true);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () ->
|
||||
AutoLoader_15.setRedstone(activation.location, false), activation.activation);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> AutoLoader_15.setRedstone(activation.location, false), activation.activation);
|
||||
}, 15));
|
||||
}
|
||||
}
|
||||
@ -106,7 +104,7 @@ public class Detonator implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if(!event.getPlayer().equals(player))
|
||||
if (!event.getPlayer().equals(player))
|
||||
return;
|
||||
|
||||
if (event.getItem() == null) return;
|
||||
@ -115,12 +113,10 @@ public class Detonator implements Listener {
|
||||
switch (event.getAction()) {
|
||||
case LEFT_CLICK_BLOCK:
|
||||
Detoloader detoloader = VersionedCallable.call(
|
||||
new VersionedCallable<>(() ->
|
||||
AutoLoader_12.onPlayerInteractLoader(event), 12),
|
||||
new VersionedCallable<>(() ->
|
||||
AutoLoader_15.onPlayerInteractLoader(event), 15));
|
||||
new VersionedCallable<>(() -> AutoLoader_12.onPlayerInteractLoader(event), 12),
|
||||
new VersionedCallable<>(() -> AutoLoader_15.onPlayerInteractLoader(event), 15));
|
||||
|
||||
if(detoloader == null) {
|
||||
if (detoloader == null) {
|
||||
return;
|
||||
} else if (detoloader.activation == -1) {
|
||||
print(detoloader.getBlock(), detoloader.addBack);
|
||||
@ -128,25 +124,25 @@ public class Detonator implements Listener {
|
||||
}
|
||||
|
||||
|
||||
if(event.getPlayer().isSneaking()) {
|
||||
if(locs.stream().filter(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation())).collect(Collectors.toList()).size() == 1) {
|
||||
if (event.getPlayer().isSneaking()) {
|
||||
if (locs.stream().filter(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation())).collect(Collectors.toList()).size() == 1) {
|
||||
locs.removeIf(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation()));
|
||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" :
|
||||
detoloader.getBlock(), detoloader.addBack);
|
||||
}else {
|
||||
if(detoloader.getActivation() == 0) {
|
||||
} else {
|
||||
if (detoloader.getActivation() == 0) {
|
||||
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
||||
}else {
|
||||
} else {
|
||||
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
||||
}
|
||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" :
|
||||
detoloader.getBlock(), detoloader.addBack);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
locs.clear();
|
||||
if(detoloader.getActivation() == 0) {
|
||||
if (detoloader.getActivation() == 0) {
|
||||
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
||||
}else {
|
||||
} else {
|
||||
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
||||
}
|
||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " getsetzt" :
|
||||
YoyoNow
hat
Zeilenumbruch weg! Zeilenumbruch weg!
|
||||
@ -163,7 +159,7 @@ public class Detonator implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if(event.getPlayer().equals(player))
|
||||
if (event.getPlayer().equals(player))
|
||||
deleteDetonator(player);
|
||||
}
|
||||
|
||||
@ -179,8 +175,8 @@ public class Detonator implements Listener {
|
||||
locs.clear();
|
||||
}
|
||||
|
||||
void print(String message, boolean withSize){
|
||||
if(withSize)
|
||||
void print(String message, boolean withSize) {
|
||||
if (withSize)
|
||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getLocations().size()));
|
||||
else
|
||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Kannst du das hier auch noch callen, wenn ich den Detonator aus dem Inventar werfe bzw lösche oder geht das nicht? Oder mach es so, dass du nur immer einen detonator hast. Außerdem bitte auch beim leaven des Servers Detonator#deleteDetonator(Player) aufrufen. Da sonst memory leaks aufkommen können.
Wird es schon.
habe ich im code nicht gesehen. Also diese Methode wird nicht direkt aufgerufen oder?