Add content moderation and release validation tools
This commit is contained in:
1 parent
a9d572fff0
commit
7c2e82fc15
63 files changed
+5508
-38
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package dev.itxiaohui.contentguard.admin;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public final class PermissionManager implements Listener {
|
||||
public static final String ADMIN = "itxiaohui.contentguard.admin";
|
||||
public static final String BYPASS = "itxiaohui.contentguard.bypass";
|
||||
public static final String NOTIFY = "itxiaohui.contentguard.notify";
|
||||
public static final String LOGS = "itxiaohui.contentguard.logs";
|
||||
public static final String TEST = "itxiaohui.contentguard.test";
|
||||
|
||||
public record Identity(UUID id, String name, boolean bypass) {}
|
||||
private final ConcurrentHashMap<Player, Identity> online = new ConcurrentHashMap<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
refresh(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
online.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
public void refresh(Player player) {
|
||||
online.put(player, new Identity(player.getUniqueId(), player.getName(), player.hasPermission(BYPASS)));
|
||||
}
|
||||
|
||||
public boolean cachedBypass(Player player) {
|
||||
Identity identity = identity(player);
|
||||
return identity != null && identity.bypass();
|
||||
}
|
||||
|
||||
public Identity identity(Player player) {
|
||||
return online.get(player);
|
||||
}
|
||||
|
||||
public Set<Player> online() {
|
||||
return online.keySet();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user