Changes
Dieser Commit ist enthalten in:
Ursprung
94cb735bd4
Commit
9150a3a4c7
@ -60,8 +60,8 @@ public class Detonator implements Listener {
|
|||||||
WAND.setItemMeta(im);
|
WAND.setItemMeta(im);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Detonator getDetonator(Player player){
|
public static Detonator getDetonator(Player player) {
|
||||||
if(!players.containsKey(player))
|
if (!players.containsKey(player))
|
||||||
return new Detonator(player);
|
return new Detonator(player);
|
||||||
return players.get(player);
|
return players.get(player);
|
||||||
}
|
}
|
||||||
@ -73,14 +73,14 @@ public class Detonator implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteDetonator(Player player) {
|
public static void deleteDetonator(Player player) {
|
||||||
if(players.containsKey(player))
|
if (players.containsKey(player))
|
||||||
HandlerList.unregisterAll(players.remove(player));
|
HandlerList.unregisterAll(players.remove(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute() {
|
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(() -> {
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
boolean powered = AutoLoader_12.getLever(activation.location.getBlock());
|
boolean powered = AutoLoader_12.getLever(activation.location.getBlock());
|
||||||
AutoLoader_12.setRedstone(activation.location, !powered);
|
AutoLoader_12.setRedstone(activation.location, !powered);
|
||||||
@ -92,12 +92,10 @@ public class Detonator implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
AutoLoader_12.setRedstone(activation.location, true);
|
AutoLoader_12.setRedstone(activation.location, true);
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () ->
|
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> AutoLoader_12.setRedstone(activation.location, false), activation.activation);
|
||||||
AutoLoader_12.setRedstone(activation.location, false), activation.activation);
|
|
||||||
}, 12), new VersionedRunnable(() -> {
|
}, 12), new VersionedRunnable(() -> {
|
||||||
AutoLoader_15.setRedstone(activation.location, true);
|
AutoLoader_15.setRedstone(activation.location, true);
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () ->
|
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> AutoLoader_15.setRedstone(activation.location, false), activation.activation);
|
||||||
AutoLoader_15.setRedstone(activation.location, false), activation.activation);
|
|
||||||
}, 15));
|
}, 15));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +104,7 @@ public class Detonator implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if(!event.getPlayer().equals(player))
|
if (!event.getPlayer().equals(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getItem() == null) return;
|
if (event.getItem() == null) return;
|
||||||
@ -115,12 +113,10 @@ public class Detonator implements Listener {
|
|||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case LEFT_CLICK_BLOCK:
|
case LEFT_CLICK_BLOCK:
|
||||||
Detoloader detoloader = VersionedCallable.call(
|
Detoloader detoloader = VersionedCallable.call(
|
||||||
new VersionedCallable<>(() ->
|
new VersionedCallable<>(() -> AutoLoader_12.onPlayerInteractLoader(event), 12),
|
||||||
AutoLoader_12.onPlayerInteractLoader(event), 12),
|
new VersionedCallable<>(() -> AutoLoader_15.onPlayerInteractLoader(event), 15));
|
||||||
new VersionedCallable<>(() ->
|
|
||||||
AutoLoader_15.onPlayerInteractLoader(event), 15));
|
|
||||||
|
|
||||||
if(detoloader == null) {
|
if (detoloader == null) {
|
||||||
return;
|
return;
|
||||||
} else if (detoloader.activation == -1) {
|
} else if (detoloader.activation == -1) {
|
||||||
print(detoloader.getBlock(), detoloader.addBack);
|
print(detoloader.getBlock(), detoloader.addBack);
|
||||||
@ -128,25 +124,25 @@ public class Detonator implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(event.getPlayer().isSneaking()) {
|
if (event.getPlayer().isSneaking()) {
|
||||||
if(locs.stream().filter(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation())).collect(Collectors.toList()).size() == 1) {
|
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()));
|
locs.removeIf(detonatorActivation -> detonatorActivation.location.equals(event.getClickedBlock().getLocation()));
|
||||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" :
|
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" :
|
||||||
detoloader.getBlock(), detoloader.addBack);
|
detoloader.getBlock(), detoloader.addBack);
|
||||||
}else {
|
} else {
|
||||||
if(detoloader.getActivation() == 0) {
|
if (detoloader.getActivation() == 0) {
|
||||||
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
||||||
}else {
|
} else {
|
||||||
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
||||||
}
|
}
|
||||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" :
|
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" :
|
||||||
detoloader.getBlock(), detoloader.addBack);
|
detoloader.getBlock(), detoloader.addBack);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
locs.clear();
|
locs.clear();
|
||||||
if(detoloader.getActivation() == 0) {
|
if (detoloader.getActivation() == 0) {
|
||||||
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation()));
|
||||||
}else {
|
} else {
|
||||||
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
||||||
}
|
}
|
||||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " getsetzt" :
|
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " getsetzt" :
|
||||||
@ -163,7 +159,7 @@ public class Detonator implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
if(event.getPlayer().equals(player))
|
if (event.getPlayer().equals(player))
|
||||||
deleteDetonator(player);
|
deleteDetonator(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,8 +175,8 @@ public class Detonator implements Listener {
|
|||||||
locs.clear();
|
locs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(String message, boolean withSize){
|
void print(String message, boolean withSize) {
|
||||||
if(withSize)
|
if (withSize)
|
||||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getLocations().size()));
|
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getLocations().size()));
|
||||||
else
|
else
|
||||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren