Add ObserverTraceCommand.enable
Add ObserverTraceCommand.disable Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
cc5137c45b
Commit
9c050370a9
@ -328,6 +328,8 @@ LOADTIMER_SUMARY_STATS_FREQ=§7Belade Frequenz: §e{0}/m§8, §7Schuss Frequenz:
|
||||
|
||||
# Observer
|
||||
OBSERVER_HELP = §7Rechts-Klicke einen Observer um den Trace zu bekommen. Hierfür müssen Flammenpartikel an sein. Die Partikel werden im Block angezeigt.
|
||||
OBSERVER_ENABLE = §7Observer Trace gestartet
|
||||
OBSERVER_DISABLE = §7Observer Trace gestoppt
|
||||
OBSERVER_DELETE = §7Observer Trace gelöscht
|
||||
OBSERVER_RETRACE_DONE = §7Observer Trace neu berechnet
|
||||
OBSERVER_RETRACE_NO-TRACE = §7Kein Observer Trace zum neu berechnen
|
||||
|
@ -49,6 +49,9 @@ public class ObserverTracer {
|
||||
}
|
||||
|
||||
public void show() {
|
||||
if (!ObserverTracerListener.enabled.contains(player)) {
|
||||
return;
|
||||
}
|
||||
for (Point p : seen) {
|
||||
Location location = p.toLocation(player);
|
||||
spawnParticle(player, location, location.getBlock());
|
||||
|
@ -38,8 +38,21 @@ public class ObserverTracerCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.sendPrefixless("OBSERVER_HELP", p);
|
||||
}
|
||||
|
||||
@Register(value = "enable")
|
||||
public void enable(Player p) {
|
||||
ObserverTracerListener.enabled.add(p);
|
||||
BauSystem.MESSAGE.send("OBSERVER_ENABLE", p);
|
||||
}
|
||||
|
||||
@Register(value = "disable")
|
||||
public void disable(Player p) {
|
||||
ObserverTracerListener.enabled.remove(p);
|
||||
ObserverTracerListener.observerTracerMap.remove(p);
|
||||
BauSystem.MESSAGE.send("OBSERVER_DISABLE", p);
|
||||
}
|
||||
|
||||
@Register(value = "delete")
|
||||
public void hide(Player p) {
|
||||
public void delete(Player p) {
|
||||
ObserverTracerListener.observerTracerMap.remove(p);
|
||||
BauSystem.MESSAGE.send("OBSERVER_DELETE", p);
|
||||
}
|
||||
|
@ -29,14 +29,18 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked(LinkageType.LISTENER)
|
||||
public class ObserverTracerListener implements Listener {
|
||||
|
||||
static Set<Player> enabled = new HashSet<>();
|
||||
static Map<Player, ObserverTracer> observerTracerMap = new HashMap<>();
|
||||
|
||||
public ObserverTracerListener() {
|
||||
@ -47,6 +51,9 @@ public class ObserverTracerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (!enabled.contains(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
@ -76,8 +83,14 @@ public class ObserverTracerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
enabled.add(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
enabled.remove(event.getPlayer());
|
||||
observerTracerMap.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren