Petit correctif d'affichage concernant les messages de groupe
This commit is contained in:
parent
b688a8e928
commit
516a93e69a
@ -2,6 +2,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.PrivateMessagesManager.MessageSender;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.PrivateMessagesManager.MessageSendingException;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OffPlayer;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||
|
||||
@ -22,21 +23,29 @@ public class CommandReply extends AbstractCommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||
String[] args) {
|
||||
|
||||
if (args.length == 0 && sender instanceof Player) {
|
||||
OnlinePlayer op = OnlinePlayerManager.get((Player) sender);
|
||||
String lastTarget = op.getLastMessageTarget();
|
||||
if (lastTarget == null)
|
||||
sender.sendMessage(ChatColor.RED+"Vous n'avez pas encore envoyé de message");
|
||||
else
|
||||
sender.sendMessage(ChatColor.GRAY+"/"+label+ChatColor.GOLD+" pour envoyer un message à "+ChatColor.GRAY+lastTarget);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED+"Seul un joueur en ligne peut utiliser la commande /"+label);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
OnlinePlayer op = OnlinePlayerManager.get((Player) sender);
|
||||
String lastTarget = op.getLastMessageTarget();
|
||||
if (lastTarget == null)
|
||||
sender.sendMessage(ChatColor.RED+"Vous n'avez pas encore envoyé de message privé");
|
||||
else {
|
||||
if (lastTarget.toLowerCase().startsWith("g:"))
|
||||
sender.sendMessage(ChatColor.GRAY+"/"+label+ChatColor.GOLD+" pour envoyer un message au groupe "+ChatColor.GRAY+lastTarget.substring(2));
|
||||
else
|
||||
sender.sendMessage(ChatColor.GRAY+"/"+label+ChatColor.GOLD+" pour envoyer un message à "+ChatColor.RESET+new OffPlayer(lastTarget).getDisplayName());
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
onCommandReply(sender, getLastParam(args, 0));
|
||||
return true;
|
||||
|
@ -192,7 +192,8 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
||||
messEl.setDestGroup(groupEl.getId());
|
||||
messEl.save();
|
||||
tryDisplayMessage(messEl);
|
||||
if (userInGroup.getPlayerName().equalsIgnoreCase(sender.senderName))
|
||||
if (userInGroup.getPlayerName().equalsIgnoreCase(sender.senderName)
|
||||
|| (!(sender.isPlayer()) && userInGroup == groupUsers.get(0))) // affiche aussi les messages provenant de la console, vers les groupes
|
||||
tryDisplayMessageToConsole(messEl);
|
||||
}
|
||||
|
||||
@ -202,6 +203,7 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
||||
op.setLastMessageTarget("g:"+groupEl.getGroupName());
|
||||
}
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
throw new MessageSendingException("Erreur lors de la récupération du groupe ou de ses membres");
|
||||
@ -367,7 +369,7 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
||||
"moi":
|
||||
new OffPlayer(message.getDestNick()).getDisplayName()
|
||||
):
|
||||
"g:"+message.getDestGroupElement().getGroupName();
|
||||
ChatColor.GOLD+"g:"+message.getDestGroupElement().getGroupName();
|
||||
|
||||
String destCommand = (message.getDestGroup() == null)?
|
||||
message.getDestNick():
|
||||
@ -379,7 +381,7 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
||||
.then("§6<§rmoi§6 → §r"+destAff+"§r§6>")
|
||||
.suggest("/m "+destCommand+" ")
|
||||
.tooltip(tooltipLines)
|
||||
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()))
|
||||
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()).replace("§r", "§r§6"))
|
||||
.color(ChatColor.GOLD)
|
||||
.send(op.getPlayer());
|
||||
}
|
||||
@ -393,7 +395,7 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
||||
((message.getDestNick().equalsIgnoreCase(message.getViewerNick()))?
|
||||
"moi":
|
||||
new OffPlayer(message.getDestNick()).getDisplayName()):
|
||||
"g:"+message.getDestGroupElement().getGroupName();
|
||||
ChatColor.GOLD+"g:"+message.getDestGroupElement().getGroupName();
|
||||
|
||||
String destCommand = (message.getDestGroup() == null)?
|
||||
message.getSourceNick():
|
||||
@ -407,7 +409,7 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
||||
if (message.getSourceNick() != null)
|
||||
fm.suggest("/m "+destCommand+" ");
|
||||
fm.tooltip(tooltipLines)
|
||||
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()))
|
||||
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()).replace("§r", "§r§6"))
|
||||
.color(ChatColor.GOLD)
|
||||
.send(op.getPlayer());
|
||||
|
||||
@ -439,7 +441,7 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
||||
"g:"+message.getDestGroupElement().getGroupName();
|
||||
|
||||
|
||||
plugin.getServer().getConsoleSender().sendMessage("§6<§r"+senderAff+"§r§6 → §r"+destAff+"§r§6> §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()));
|
||||
plugin.getServer().getConsoleSender().sendMessage("§6<§r"+senderAff+"§r§6 → §r"+destAff+"§r§6> §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()).replace("§r", "§r§6"));
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user