Fix ObserverTracerListener
Fix ObserverTracer Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
2a4f980813
Commit
2c88381146
@ -39,31 +39,23 @@ public class ObserverTracer {
|
||||
|
||||
private Player player;
|
||||
private Block block;
|
||||
private Set<Location> seen = new HashSet<>();
|
||||
Set<Location> seen = new HashSet<>();
|
||||
private List<Block> blockList = new ArrayList<>();
|
||||
|
||||
private int retrace = 0;
|
||||
|
||||
public ObserverTracer(Player player, Block block) {
|
||||
this.player = player;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
retrace++;
|
||||
if (retrace > 4) {
|
||||
retrace = 0;
|
||||
seen.clear();
|
||||
blockList.clear();
|
||||
trace();
|
||||
return;
|
||||
}
|
||||
for (Location l : seen) {
|
||||
spawnParticle(player, l, l.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
public void trace() {
|
||||
seen.clear();
|
||||
blockList.clear();
|
||||
if (block.getType() != Material.OBSERVER) {
|
||||
return;
|
||||
}
|
||||
|
@ -47,15 +47,19 @@ public class ObserverTracerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.getMaterial() == Material.OBSERVER) {
|
||||
if (event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
if (observerTracerMap.containsKey(event.getPlayer())) {
|
||||
ObserverTracer observerTracer = observerTracerMap.get(event.getPlayer());
|
||||
if (observerTracer.seen.contains(event.getClickedBlock().getLocation())) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), observerTracer::trace, 1L);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock().getType() == Material.OBSERVER) {
|
||||
ObserverTracer observerTracer = new ObserverTracer(event.getPlayer(), event.getClickedBlock());
|
||||
observerTracer.trace();
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren