From b688a8e9280425ff9701b72a6144936d11b8abbe Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Tue, 12 May 2015 03:32:20 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20de=20bug=20dans=20les=20tooltips?= =?UTF-8?q?=20des=20messages=20priv=C3=A9s=20+=20les=20messages=20envoy?= =?UTF-8?q?=C3=A9s=20=C3=A0=20soi-m=C3=AAme=20ne=20sont=20affich=C3=A9s=20?= =?UTF-8?q?qu'une=20seule=20fois?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/PrivateMessagesManager.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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);