diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PrivateMessagesManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PrivateMessagesManager.java index ea02db7..4323fc5 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PrivateMessagesManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PrivateMessagesManager.java @@ -227,7 +227,7 @@ public class PrivateMessagesManager extends BukkitRunnable { int secKey = new Random().nextInt(); - if (sender.isPlayer()) { + if (sender.isPlayer() && !destUserName.equalsIgnoreCase(sender.senderName)) { MPMessageElement el = new MPMessageElement(time, secKey, sender.senderName, sender.senderName, message, true, true); el.setDestNick(destUserName); el.save(); @@ -301,12 +301,12 @@ public class PrivateMessagesManager extends BukkitRunnable { private void tryDisplayMessage(MPMessageElement message) { try { - - OnlinePlayer op = OnlinePlayerManager.get(new OffPlayer(message.getViewerNick()).getBukkitOnlinePlayer()); + + OffPlayer offP = new OffPlayer(message.getViewerNick()); MessageSender sender = new MessageSender(message.getSourceNick()); - boolean isIgnoring = sender.isPlayer() && op.getEssentialsUser().isIgnoredPlayer(new OffPlayer(message.getSourceNick()).getEssentialsUser()); + boolean isIgnoring = sender.isPlayer() && offP.getEssentialsUser().isIgnoredPlayer(new OffPlayer(message.getSourceNick()).getEssentialsUser()); if (isIgnoring) { @@ -314,6 +314,8 @@ public class PrivateMessagesManager extends BukkitRunnable { return; } + OnlinePlayer op = OnlinePlayerManager.get(offP.getBukkitOnlinePlayer()); + if (op == null) return; // la cible n'est pas en ligne if (!op.isAuthenticated()) return; // la cible n'a pas fait son /login @@ -337,7 +339,7 @@ public class PrivateMessagesManager extends BukkitRunnable { List tooltipLines = new ArrayList(); tooltipLines.add(ChatColor.GRAY+affDate); - tooltipLines.add(ChatColor.GRAY+"de "+ChatColor.RESET+new OffPlayer(message.getSourceNick()).getDisplayName()+ChatColor.GRAY+" ("+displayablePlayerStatus(getPlayerStatut(message.getSourceNick()))+ChatColor.GRAY+")"); + tooltipLines.add(ChatColor.GRAY+"de "+ChatColor.RESET+new MessageSender(message.getSourceNick()).getDisplayName()+ChatColor.GRAY+" ("+displayablePlayerStatus(getPlayerStatut(message.getSourceNick()))+ChatColor.GRAY+")"); if (message.getDestGroup() == null) // vers un joueur tooltipLines.add(ChatColor.GRAY+"vers "+ChatColor.RESET+new OffPlayer(message.getDestNick()).getDisplayName()+ChatColor.GRAY+" ("+displayablePlayerStatus(getPlayerStatut(message.getDestNick()))+ChatColor.GRAY+")"); else { // vers un groupe @@ -484,8 +486,15 @@ public class PrivateMessagesManager extends BukkitRunnable { - + /** + * + * @param playerName le pseudo du joueur, insensible à la casse. + * @return Le statut du joueur passé en paramètre.
+ * null si le paramètre est null. + */ private PlayerStatut getPlayerStatut(String playerName) { + if (playerName == null) + return null; if (!AbstractCommandExecutor.isValidPlayerName(playerName)) return PlayerStatut.OFFLINE; OnlinePlayer op = OnlinePlayerManager.get(playerName);