Delete _trash/2026-05-07T19-39-23-130Z/src/main/java/net/viper/status/modules/chat/VanishProvider.java via Git Manager GUI
This commit is contained in:
@@ -1,71 +0,0 @@
|
|||||||
package net.viper.status.modules.chat;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Zentrale Schnittstelle zwischen dem VanishModule und dem ChatModule.
|
|
||||||
*
|
|
||||||
* Das VanishModule (oder jedes andere Modul) ruft {@link #setVanished} auf
|
|
||||||
* um Spieler als unsichtbar zu markieren. Das ChatModule prüft via
|
|
||||||
* {@link #isVanished} bevor es Join-/Leave-Nachrichten sendet oder
|
|
||||||
* Privat-Nachrichten zulässt.
|
|
||||||
*
|
|
||||||
* Verwendung im VanishModule:
|
|
||||||
* VanishProvider.setVanished(player.getUniqueId(), true); // beim Verschwinden
|
|
||||||
* VanishProvider.setVanished(player.getUniqueId(), false); // beim Erscheinen / Disconnect
|
|
||||||
*/
|
|
||||||
public final class VanishProvider {
|
|
||||||
|
|
||||||
private VanishProvider() {}
|
|
||||||
|
|
||||||
/** Intern verwaltete Menge aller aktuell unsichtbaren Spieler-UUIDs. */
|
|
||||||
private static final Set<UUID> vanishedPlayers =
|
|
||||||
Collections.newSetFromMap(new ConcurrentHashMap<>());
|
|
||||||
|
|
||||||
// ===== Schreib-API (wird vom VanishModule aufgerufen) =====
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Markiert einen Spieler als sichtbar oder unsichtbar.
|
|
||||||
*
|
|
||||||
* @param uuid UUID des Spielers
|
|
||||||
* @param vanished true = unsichtbar, false = sichtbar
|
|
||||||
*/
|
|
||||||
public static void setVanished(UUID uuid, boolean vanished) {
|
|
||||||
if (vanished) {
|
|
||||||
vanishedPlayers.add(uuid);
|
|
||||||
} else {
|
|
||||||
vanishedPlayers.remove(uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entfernt einen Spieler beim Disconnect aus der Vanish-Liste.
|
|
||||||
* Sollte vom ChatModule (onDisconnect) aufgerufen werden, damit
|
|
||||||
* kein toter Eintrag verbleibt.
|
|
||||||
*/
|
|
||||||
public static void cleanup(UUID uuid) {
|
|
||||||
vanishedPlayers.remove(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===== Lese-API (wird vom ChatModule aufgerufen) =====
|
|
||||||
|
|
||||||
/** @return true wenn der Spieler aktuell als unsichtbar markiert ist. */
|
|
||||||
public static boolean isVanished(ProxiedPlayer player) {
|
|
||||||
return player != null && vanishedPlayers.contains(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return true wenn der Spieler mit der angegebenen UUID unsichtbar ist. */
|
|
||||||
public static boolean isVanished(UUID uuid) {
|
|
||||||
return uuid != null && vanishedPlayers.contains(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Snapshot der aktuell unsichtbaren Spieler (für Debugging / Logs). */
|
|
||||||
public static Set<UUID> getVanishedPlayers() {
|
|
||||||
return Collections.unmodifiableSet(vanishedPlayers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user