From 9a45dbf44bee5fa8a77d61ccc9559f6aceb678c9 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 5 Feb 2015 02:23:27 -0500 Subject: [PATCH] gestion plus propre des grades dans le plugin --- resources/plugin.yml | 28 ----------- .../plugin/pandacraftutils/ConfigManager.java | 10 ++-- .../pandacraftutils/commands/CommandAfk.java | 4 +- .../commands/CommandAutomessager.java | 1 - .../pandacraftutils/commands/CommandList.java | 6 +-- .../commands/CommandStaff.java | 3 +- .../commands/Command_Selection.java | 2 +- .../pandacraftutils/modules/AfkManager.java | 24 ++++----- .../modules/AutoMessagesManager.java | 4 +- .../modules/CalculatorManager.java | 2 +- .../modules/ChatAnalysisManager.java | 4 +- .../modules/PacketOutServerInfoListener.java | 20 +++++--- .../modules/StaffQueueManager.java | 3 +- .../modules/WESelectionDisplayManager.java | 2 +- .../pandacraftutils/players/OnlinePlayer.java | 50 +++++++++++++++++++ .../players/OnlinePlayerManager.java | 12 ++--- 16 files changed, 101 insertions(+), 74 deletions(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 86e0cf8..4f1ff3b 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -103,7 +103,6 @@ permissions: pandacraft.me: description: Utiliser la commande me default: true -# à ajouter ############### pandacraft.me.color: description: Utiliser la commande me avec des couleurs default: op @@ -135,17 +134,14 @@ permissions: description: Ne pas être auto AFK default: false -# à ajouter ###################### pandacraft.broadcast: description: Utiliser la commande broadcast et broadcastperm default: op -# à ajouter ###################### pandacraft.automessager: description: Utiliser la commande automessager default: op -# à ajouter ###################### pandacraft.admin: description: Utiliser la commande admin default: op @@ -156,27 +152,3 @@ permissions: default: op - pandacraft.grade.default: - description: Représente le grade Visiteur - default: false - pandacraft.grade.users: - description: Représente le grade Membre - default: false - pandacraft.grade.premium: - description: Représente le grade Premium - default: false - pandacraft.grade.ultimate: - description: Représente le grade Premium plus - default: false - pandacraft.grade.modos: - description: Représente le grade Modos - default: false - pandacraft.grade.admins: - description: Représente le grade Admins - default: false - pandacraft.grade.not_default: - description: Représente tout les joueurs inscrits - default: false - pandacraft.grade.staff: - description: Représente tout le staff - default: false diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java index 679c64d..b891a3f 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java @@ -186,7 +186,7 @@ public class ConfigManager { message = new HashMap(); message.put("message", ChatColor.BLUE+"Bienvenue sur Pandacraft ! :) Pour pouvoir jouer, n'oubliez pas de vous inscrire en cliquant sur le lien en dessous%n &ahttps://www.mc-pandacraft.net/?p=inscription"); - message.put("permissions", "pandacraft.grade.default"); + message.put("permissions", "group.default"); Automessages_messages.add(message); message = new HashMap(); @@ -316,19 +316,19 @@ public class ConfigManager { alias = new HashMap(); alias.put("initialCommand", "/day"); alias.put("replaceWith", "/ptime day"); - alias.put("permissions", "pandacraft.grade.users"); // multiple permission separated with semicolumn + alias.put("permissions", "group.users"); // multiple permission separated with semicolumn CommandAlias_alias.add(alias); alias = new HashMap(); alias.put("initialCommand", "/night"); alias.put("replaceWith", "/ptime night"); - alias.put("permissions", "pandacraft.grade.users"); + alias.put("permissions", "group.users"); CommandAlias_alias.add(alias); alias = new HashMap(); alias.put("initialCommand", "/time"); alias.put("replaceWith", "/ptime"); - alias.put("permissions", "pandacraft.grade.users"); + alias.put("permissions", "group.users"); CommandAlias_alias.add(alias); alias = new HashMap(); @@ -358,7 +358,7 @@ public class ConfigManager { alias = new HashMap(); alias.put("initialCommand", "/inscription"); alias.put("replaceWith", "/mail send marcbal Inscription"); - alias.put("permissions", "pandacraft.grade.not_default"); + alias.put("permissions", "group.users"); CommandAlias_alias.add(alias); /* Map alias = new HashMap(); diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAfk.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAfk.java index c18e503..9a39e8b 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAfk.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAfk.java @@ -67,7 +67,7 @@ public class CommandAfk extends AbstractCommandExecutor { if (execute_self) { Player p = (Player)sender; - OnlinePlayer ap = OnlinePlayerManager.getInstance().get(p); + OnlinePlayer ap = OnlinePlayerManager.get(p); if (ap == null) plugin.getLogger().severe("Cant find AfkPlayer with name "+p.getName()+" when performing command /afk"); else @@ -76,7 +76,7 @@ public class CommandAfk extends AbstractCommandExecutor { } else if (execute_other && other_player != null) { - OnlinePlayer ap = OnlinePlayerManager.getInstance().get(other_player); + OnlinePlayer ap = OnlinePlayerManager.get(other_player); if (ap == null) plugin.getLogger().severe("Cant find AfkPlayer with name "+other_player.getName()+" when performing command /afk "); ap.adminToggleAfk(); diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAutomessager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAutomessager.java index a602713..f58276e 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAutomessager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAutomessager.java @@ -41,7 +41,6 @@ public class CommandAutomessager extends AbstractCommandExecutor { } OnlinePlayerManager - .getInstance() .get((Player)sender) .sendMessageFromServer(messages.get(id).getMessage()); diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandList.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandList.java index e4765a6..c27154c 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandList.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandList.java @@ -158,7 +158,7 @@ public class CommandList extends AbstractCommandExecutor { { try { - int vl = OnlinePlayerManager.getInstance().get(p).getVL(); + int vl = OnlinePlayerManager.get(p).getVL(); int max_vl = ConfigManager.getInstance().ChatAnalysis_maxViolationLevel; aff_list.add("§f"+name+"§r - §7"+vl+"/"+max_vl); @@ -170,7 +170,7 @@ public class CommandList extends AbstractCommandExecutor { } else if (args.length > 0 && args[0].toLowerCase().equals("afk")) { - OnlinePlayer op = OnlinePlayerManager.getInstance().get(p); + OnlinePlayer op = OnlinePlayerManager.get(p); boolean afk = (op != null && op.isAfk()); double afk_time = (op != null)?op.getDurationSinceLastAction():-1; String afkTime; @@ -191,7 +191,7 @@ public class CommandList extends AbstractCommandExecutor { :(p.getGameMode() == GameMode.CREATIVE)?"§bCréa§r" :(p.getGameMode() == GameMode.ADVENTURE)?("§8Aventure§r;vie:§7"+health+"§r;faim:§7"+eat+"§r"+((flyMode)?";§7canFly":"")) :"§oInconnu"; - String afk = (OnlinePlayerManager.getInstance().get(p) != null && OnlinePlayerManager.getInstance().get(p).isAfk())?" §c(Afk)§r":""; + String afk = (OnlinePlayerManager.get(p) != null && OnlinePlayerManager.get(p).isAfk())?" §c(Afk)§r":""; aff_list.add("§f"+name+"§r"+afk+" - §7"+world+"§r - "+gm); } else diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandStaff.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandStaff.java index b435891..8003306 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandStaff.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandStaff.java @@ -4,6 +4,7 @@ import java.util.Date; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.StaffQueueManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.StaffQueueManager.WaitingPlayer; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.util.TimeUtil; import org.apache.commons.lang.StringUtils; @@ -25,7 +26,7 @@ public class CommandStaff extends AbstractCommandExecutor { StaffQueueManager staffManager = plugin.staffQueueManager; - if (sender instanceof Player && !((Player)sender).hasPermission("pandacraft.grade.staff")) + if (sender instanceof Player && !OnlinePlayerManager.get((Player)sender).isInStaff()) { // un joueur qui n'est pas du staff // le joueur est-il déjà en file d'attente ? diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/Command_Selection.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/Command_Selection.java index 9660191..a5d2c10 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/Command_Selection.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/Command_Selection.java @@ -36,7 +36,7 @@ public class Command_Selection extends AbstractCommandExecutor { } Player p = (Player) sender; - OnlinePlayer op = OnlinePlayerManager.getInstance().get(p); + OnlinePlayer op = OnlinePlayerManager.get(p); Player otherP = null; diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AfkManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AfkManager.java index cb8c1ab..fa26174 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AfkManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AfkManager.java @@ -53,7 +53,7 @@ public class AfkManager extends BukkitRunnable implements Listener { @Override public void run() { // methode exécutée toute les secondes - Collection oPlayers = OnlinePlayerManager.getInstance().getAll(); + Collection oPlayers = OnlinePlayerManager.getAll(); for (OnlinePlayer ap : oPlayers.toArray(new OnlinePlayer[oPlayers.size()])) { // parcours de tout les joueurs if (ap == null) @@ -97,7 +97,7 @@ public class AfkManager extends BukkitRunnable implements Listener { if ( (from.getPitch() == to.getPitch() && from.getYaw() == to.getYaw()) || (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ())) return; - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } @@ -127,7 +127,7 @@ public class AfkManager extends BukkitRunnable implements Listener { return; - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } @EventHandler @@ -135,7 +135,7 @@ public class AfkManager extends BukkitRunnable implements Listener { { try { - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } @@ -145,7 +145,7 @@ public class AfkManager extends BukkitRunnable implements Listener { { try { - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } @@ -160,7 +160,7 @@ public class AfkManager extends BukkitRunnable implements Listener { // car un piston "téléporte" le joueur (techniquement parlant, dans le jeu) à 1 bloc de distance if (event.getFrom().getWorld() != event.getTo().getWorld() || event.getFrom().distanceSquared(event.getTo()) > 2*2) - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } @@ -170,7 +170,7 @@ public class AfkManager extends BukkitRunnable implements Listener { { try { - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } @@ -179,7 +179,7 @@ public class AfkManager extends BukkitRunnable implements Listener { { try { - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } @@ -188,7 +188,7 @@ public class AfkManager extends BukkitRunnable implements Listener { { try { - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } @@ -198,7 +198,7 @@ public class AfkManager extends BukkitRunnable implements Listener { { try { - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } @@ -208,7 +208,7 @@ public class AfkManager extends BukkitRunnable implements Listener { { try { - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } @@ -218,7 +218,7 @@ public class AfkManager extends BukkitRunnable implements Listener { { try { - OnlinePlayerManager.getInstance().get(event.getPlayer()).isDoingAction(); + OnlinePlayerManager.get(event.getPlayer()).isDoingAction(); } catch (NullPointerException e) { } } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AutoMessagesManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AutoMessagesManager.java index 29968c6..47d0f08 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AutoMessagesManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AutoMessagesManager.java @@ -37,12 +37,12 @@ public class AutoMessagesManager extends BukkitRunnable { // message // permissions - Collection oPlayers = OnlinePlayerManager.getInstance().getAll(); + Collection oPlayers = OnlinePlayerManager.getAll(); for (OnlinePlayer op : oPlayers) { - int interval_sec = op.getPlayer().hasPermission("pandacraft.grade.default") ? interval_default : interval_players; + int interval_sec = op.isGuest() ? interval_default : interval_players; op.firstAutomessageCkeck(interval_sec); diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/CalculatorManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/CalculatorManager.java index 46bc429..08d28e1 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/CalculatorManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/CalculatorManager.java @@ -34,7 +34,7 @@ public class CalculatorManager implements Listener { if (!message.startsWith("=")) return; - OnlinePlayer op = OnlinePlayerManager.getInstance().get(event.getPlayer()); + OnlinePlayer op = OnlinePlayerManager.get(event.getPlayer()); List history = op.getCalculator_history(); if (message.length() == 1) diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/ChatAnalysisManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/ChatAnalysisManager.java index d691c2b..bf5664d 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/ChatAnalysisManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/ChatAnalysisManager.java @@ -27,7 +27,7 @@ public class ChatAnalysisManager implements Listener { public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { try { - OnlinePlayer op = OnlinePlayerManager.getInstance().get(event.getPlayer()); + OnlinePlayer op = OnlinePlayerManager.get(event.getPlayer()); if (event.getPlayer().hasPermission("pandacraft.antispam.exempt")) return; String message = event.getMessage(); @@ -75,7 +75,7 @@ public class ChatAnalysisManager implements Listener { public void onPlayerCommandPreprocess (PlayerCommandPreprocessEvent event) { try { - OnlinePlayer op = OnlinePlayerManager.getInstance().get(event.getPlayer()); + OnlinePlayer op = OnlinePlayerManager.get(event.getPlayer()); if (event.getPlayer().hasPermission("pandacraft.antispam.exempt")) return; String command_line = event.getMessage(); diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PacketOutServerInfoListener.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PacketOutServerInfoListener.java index ce675e6..b365cfc 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PacketOutServerInfoListener.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PacketOutServerInfoListener.java @@ -16,6 +16,8 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile; import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface; public class PacketOutServerInfoListener { @@ -43,7 +45,7 @@ public class PacketOutServerInfoListener { List plAdmin = new ArrayList(); - List plModo = new ArrayList(); + List plStaff = new ArrayList(); List plPlayerUltimate = new ArrayList(); List plPlayerPremium = new ArrayList(); List plPlayer = new ArrayList(); @@ -55,13 +57,15 @@ public class PacketOutServerInfoListener { // on passe si le joueur est vanish if(EssentialsInterface.isPlayerVanished(p)) continue; - if (p.hasPermission("pandacraft.grade.admins")) + OnlinePlayer op = OnlinePlayerManager.get(p); + + if (op.isInGroup("admins")) plAdmin.add(p); - else if (p.hasPermission("pandacraft.grade.modos")) - plModo.add(p); - else if (p.hasPermission("pandacraft.grade.ultimate")) + else if (op.isInStaff()) + plStaff.add(p); + else if (op.isInGroup("ultimate")) plPlayerUltimate.add(p); - else if (p.hasPermission("pandacraft.grade.premium")) + else if (op.isInGroup("premium")) plPlayerPremium.add(p); else plPlayer.add(p); @@ -73,14 +77,14 @@ public class PacketOutServerInfoListener { List list = new ArrayList(); - if (!plAdmin.isEmpty() || !plModo.isEmpty()) + if (!plAdmin.isEmpty() || !plStaff.isEmpty()) { list.add(new WrappedGameProfile("", "§cStaff connecté :")); for (Player p : plAdmin) { list.add(new WrappedGameProfile("", "§7 - "+p.getDisplayName())); } - for (Player p : plModo) + for (Player p : plStaff) { list.add(new WrappedGameProfile("", "§7 - "+p.getDisplayName())); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/StaffQueueManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/StaffQueueManager.java index 9cf6a09..82946dd 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/StaffQueueManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/StaffQueueManager.java @@ -6,6 +6,7 @@ import java.util.LinkedList; import java.util.Queue; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.util.ScoreBoardUtil; import net.mc_pandacraft.java.util.TimeUtil; @@ -191,7 +192,7 @@ public class StaffQueueManager implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player p = event.getPlayer(); - if (p.hasPermission("pandacraft.grade.staff")) + if (OnlinePlayerManager.get(p).isInStaff()) p.setScoreboard(scoreboardPlayerQueue); plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { updateScoreBoardWaitingList(); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/WESelectionDisplayManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/WESelectionDisplayManager.java index 254f3db..a756120 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/WESelectionDisplayManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/WESelectionDisplayManager.java @@ -36,7 +36,7 @@ public class WESelectionDisplayManager extends BukkitRunnable { try { - for (OnlinePlayer op : OnlinePlayerManager.getInstance().getAll()) + for (OnlinePlayer op : OnlinePlayerManager.getAll()) { Player p = op.getPlayer(); // on vérifie que le joueur soit en ligne diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java index fa01038..f22f772 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java @@ -16,6 +16,8 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import ru.tehkode.permissions.bukkit.PermissionsEx; + public class OnlinePlayer { private final Player player; private final PandacraftUtils plugin = PandacraftUtils.getInstance(); @@ -242,4 +244,52 @@ public class OnlinePlayer { public void sendMessageFromServer(String message) { player.sendMessage(ConfigManager.getInstance().ServerMessages_prefix + message); } + + + + + + + + + /* + * Grades + */ + /** + * Indique si le joueur est dans le groupe Spécifié + * @param group Le groupe par rapport au plugin de permission + * @return true si le joueur est dans le groupe spécifié, false sinon + */ + public boolean isInGroup(String group) { + if (group == null) return false; + return PermissionsEx.getUser(player).inGroup(group); + } + + /** + * Indique si le joueur est un nouveau joueur (si il ne s'est pas inscrit sur le site) + * @return true si le joueur n'est pas inscrit, false sinon + */ + public boolean isGuest() { + return isInGroup("default"); + } + + /** + * Indique si le joueur s'est inscrit sur le site + * @return true si c'est le cas, false sinon + */ + public boolean isRegistered() { + return !isGuest(); + } + + /** + * Indique si le joueur fait parti du staff + * @return true si c'est le cas, false sinon + */ + public boolean isInStaff() { + return isInGroup("admins") || + isInGroup("devs") || + isInGroup("modos") || + isInGroup("archis") || + isInGroup("guides"); + } } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayerManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayerManager.java index d01706c..64efc53 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayerManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayerManager.java @@ -75,17 +75,17 @@ public final class OnlinePlayerManager implements Listener { - public OnlinePlayer get(Player p) { - return players.get(p); + public static OnlinePlayer get(Player p) { + return getInstance().players.get(p); } - public Collection getAll() { - return players.values(); + public static Collection getAll() { + return getInstance().players.values(); } - public boolean contains(Player p) { - return players.containsKey(p); + public static boolean contains(Player p) { + return getInstance().players.containsKey(p); } }