SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
Chaoscaot 2021-01-05 17:36:57 +01:00
Ursprung 94cb735bd4
Commit 9150a3a4c7

Datei anzeigen

@ -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()) {
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,38 +113,36 @@ 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) {
} else if (detoloader.activation == -1) {
print(detoloader.getBlock(), detoloader.addBack);
return;
}
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" :
@ -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));