Mega gros commit de la mort qui tue
This commit is contained in:
parent
99c8711602
commit
dddaa83fe0
@ -44,8 +44,9 @@ commands:
|
|||||||
permission: pandacraft.selection
|
permission: pandacraft.selection
|
||||||
staff:
|
staff:
|
||||||
description: Gère la file d'attente de joueurs qui ont besoin de l'assitance du staff
|
description: Gère la file d'attente de joueurs qui ont besoin de l'assitance du staff
|
||||||
usage: /staff [annuler|<Message>]
|
usage: /staff
|
||||||
permission: pandacraft.staff
|
permission: pandacraft.staff
|
||||||
|
aliases: [ticket]
|
||||||
cubo:
|
cubo:
|
||||||
description: Gère les protections de la map Survie
|
description: Gère les protections de la map Survie
|
||||||
usage: /cubo
|
usage: /cubo
|
||||||
@ -90,6 +91,11 @@ commands:
|
|||||||
description: mystère :3
|
description: mystère :3
|
||||||
usage: /ghost
|
usage: /ghost
|
||||||
permission: pandacraft.ghost
|
permission: pandacraft.ghost
|
||||||
|
tell:
|
||||||
|
description: Envoyer un message privé
|
||||||
|
usage: /tell <Joueur> <Message>
|
||||||
|
permission: pandacraft.tell
|
||||||
|
aliases: [m, msg, t, w, whisper]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -190,6 +196,11 @@ permissions:
|
|||||||
description: Utiliser toutes les listes de commandes muco
|
description: Utiliser toutes les listes de commandes muco
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
|
#### à ajouter
|
||||||
|
pandacraft.tell:
|
||||||
|
description: Utiliser la commande tell
|
||||||
|
default: true
|
||||||
|
|
||||||
|
|
||||||
pandacraft.modo:
|
pandacraft.modo:
|
||||||
description: Utiliser la commande modo
|
description: Utiliser la commande modo
|
||||||
|
@ -13,6 +13,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.listener.XAuthListener;
|
|||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.AutoMessagesManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.AutoMessagesManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CommandAliasManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CommandAliasManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.PrivateMessagesManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.VanillaMessageManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.VanillaMessageManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.PacketOutServerInfoListener;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.PacketOutServerInfoListener;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.SpawnTimeManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.SpawnTimeManager;
|
||||||
@ -93,6 +94,7 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
public HeartThrowManager heartThrowManager;
|
public HeartThrowManager heartThrowManager;
|
||||||
public JailsManager jailsManager;
|
public JailsManager jailsManager;
|
||||||
public GhostManager ghostManager;
|
public GhostManager ghostManager;
|
||||||
|
public PrivateMessagesManager privateMessagesManager;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -144,6 +146,7 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
heartThrowManager = new HeartThrowManager();
|
heartThrowManager = new HeartThrowManager();
|
||||||
jailsManager = new JailsManager();
|
jailsManager = new JailsManager();
|
||||||
ghostManager = new GhostManager();
|
ghostManager = new GhostManager();
|
||||||
|
privateMessagesManager = new PrivateMessagesManager();
|
||||||
|
|
||||||
|
|
||||||
// chargement des écouteurs d'évènement
|
// chargement des écouteurs d'évènement
|
||||||
@ -203,6 +206,7 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
worldBorderManager = null;
|
worldBorderManager = null;
|
||||||
heartThrowManager = null;
|
heartThrowManager = null;
|
||||||
jailsManager = null;
|
jailsManager = null;
|
||||||
|
privateMessagesManager = null;
|
||||||
|
|
||||||
instance = null;
|
instance = null;
|
||||||
|
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
|
||||||
@ -11,7 +16,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|||||||
* Classe parente de toutes les classes devant prendre en charge l'exécution d'une commande Minecraft
|
* Classe parente de toutes les classes devant prendre en charge l'exécution d'une commande Minecraft
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class AbstractCommandExecutor implements CommandExecutor {
|
public abstract class AbstractCommandExecutor implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
protected PandacraftUtils plugin = PandacraftUtils.getInstance();
|
protected PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
@ -26,6 +31,7 @@ public abstract class AbstractCommandExecutor implements CommandExecutor {
|
|||||||
commandName = cName;
|
commandName = cName;
|
||||||
|
|
||||||
plugin.getCommand(commandName).setExecutor(this);
|
plugin.getCommand(commandName).setExecutor(this);
|
||||||
|
plugin.getCommand(commandName).setTabCompleter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCommandName() { return commandName; }
|
public String getCommandName() { return commandName; }
|
||||||
@ -33,6 +39,31 @@ public abstract class AbstractCommandExecutor implements CommandExecutor {
|
|||||||
public abstract boolean onCommand(CommandSender sender, Command cmd, String label,
|
public abstract boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||||
String[] args);
|
String[] args);
|
||||||
|
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <i>Prends en charge les tokens avec des espaces, mais retourne les propositions complets</i>
|
||||||
|
* @param token
|
||||||
|
* @param allProposal
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<String> getTabProposalFromToken(String token, List<String> allProposal) {
|
||||||
|
List<String> ret = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (String s : allProposal)
|
||||||
|
if (StringUtil.startsWithIgnoreCase(s, token))
|
||||||
|
ret.add(s);
|
||||||
|
|
||||||
|
if (ret.isEmpty())
|
||||||
|
ret.addAll(allProposal);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final List<String> NO_PROPOSAL = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -42,6 +73,20 @@ public abstract class AbstractCommandExecutor implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Concatène les chaines de caractères passés dans <code>args</code> (avec <code>" "</code> comme séparateur), en ommettant
|
||||||
|
* celles qui se trouvent avant <code>index</code>.<br/>
|
||||||
|
* Par exemple :</p>
|
||||||
|
* <code>
|
||||||
|
* getLastParams(new String[] {"test", "bouya", "chaka", "bukkit"}, 1);
|
||||||
|
* </code>
|
||||||
|
* <p>retournera la chaine "bouya chaka bukkit"
|
||||||
|
* @param args liste des arguments d'une commandes.<br/>
|
||||||
|
* Le premier élément est l'argument qui suit le nom de la commande.
|
||||||
|
* Usuellement, ce paramètre correspond au paramètre <code>args</code> de la méthode onCommand
|
||||||
|
* @param index
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static String getLastParam(String[] args, int index) {
|
public static String getLastParam(String[] args, int index) {
|
||||||
if (index < 0 || index >= args.length)
|
if (index < 0 || index >= args.length)
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPI;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPI;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPIListener;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPIListener;
|
||||||
@ -8,12 +10,16 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class CommandAdmin extends AbstractCommandExecutor {
|
public class CommandAdmin extends AbstractCommandExecutor {
|
||||||
|
|
||||||
public CommandAdmin() {
|
public CommandAdmin() {
|
||||||
super("admin");
|
super("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
@ -25,7 +31,7 @@ public class CommandAdmin extends AbstractCommandExecutor {
|
|||||||
if (nwAPI.isAlive())
|
if (nwAPI.isAlive())
|
||||||
sender.sendMessage(ChatColor.GREEN+"NetworkAPI écoute au port "+NetworkAPIListener.getInstance().getPort());
|
sender.sendMessage(ChatColor.GREEN+"NetworkAPI écoute au port "+NetworkAPIListener.getInstance().getPort());
|
||||||
else
|
else
|
||||||
sender.sendMessage(ChatColor.GREEN+"NetworkAPI n'est pas démarré. Voir la console pour les détails, ou faites /admin reload ");
|
sender.sendMessage(ChatColor.GREEN+"NetworkAPI n'est pas démarré. Voir la console pour les détails, ou faites /admin reload network");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,4 +55,26 @@ public class CommandAdmin extends AbstractCommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final List<String> FIRST_ARG = ImmutableList.of("reload");
|
||||||
|
public static final List<String> RELOAD_SECOND_ARG = ImmutableList.of("config", "network");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG);
|
||||||
|
}
|
||||||
|
else if (args.length > 1) {
|
||||||
|
if (args[0].equalsIgnoreCase("reload"))
|
||||||
|
if (args.length == 2)
|
||||||
|
return getTabProposalFromToken(args[1], RELOAD_SECOND_ARG);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection.TamedEntityProtectManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection.TamedEntityProtectManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
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.players.OnlinePlayerManager;
|
||||||
@ -46,7 +49,8 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
// si je joueur n'a pas encore sélectionné d'animal
|
// si je joueur n'a pas encore sélectionné d'animal
|
||||||
if (op.getSelectedAnimal() == null) {
|
if (op.getSelectedAnimal() == null) {
|
||||||
p.sendMessage(ChatColor.RED+"Faites d'abord un clic droite sur un animal apprivoisé (cheval, loup ou chat)");
|
p.sendMessage(ChatColor.RED+"Faites d'abord un clic droit sur un animal apprivoisé (cheval, loup ou chat)");
|
||||||
|
p.sendMessage(ChatColor.RED+"Pour désactiver la sélection, faites "+ChatColor.GRAY+"/cubo annuler");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,4 +95,47 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player p = (Player) sender;
|
||||||
|
OnlinePlayer op = OnlinePlayerManager.get(p);
|
||||||
|
|
||||||
|
if (!op.isAnimalSelectionEnabled()) {
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
// la sélection d'un animal est déjà activée
|
||||||
|
List<String> proposal_first_arg = new ArrayList<String>();
|
||||||
|
|
||||||
|
proposal_first_arg.add("annuler");
|
||||||
|
|
||||||
|
|
||||||
|
if (op.getSelectedAnimal() != null)
|
||||||
|
proposal_first_arg.add("donner");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
return getTabProposalFromToken(args[0], proposal_first_arg);
|
||||||
|
}
|
||||||
|
else if (args.length > 1) {
|
||||||
|
if (args.length == 2) {
|
||||||
|
if (args[0].equalsIgnoreCase("donner"))
|
||||||
|
return getTabProposalFromToken(args[1], OnlinePlayerManager.getNamesOnlyVisible(p));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
||||||
@ -50,4 +51,22 @@ public class CommandAutomessager extends AbstractCommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
|
||||||
|
List<AutoMessagesConfigEntry> messages = ConfigManager.getInstance().autoMessagesConfig.getAutoMessages();
|
||||||
|
|
||||||
|
List<String> nb = new ArrayList<String>();
|
||||||
|
for (int i=0; i<messages.size(); i++)
|
||||||
|
nb.add(Integer.toString(i));
|
||||||
|
|
||||||
|
|
||||||
|
return getTabProposalFromToken(args[0], nb);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -11,6 +12,7 @@ public class CommandBroadcast extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
// classe qui gère deux commandes (presque identiques)
|
// classe qui gère deux commandes (presque identiques)
|
||||||
plugin.getCommand("broadcastperm").setExecutor(this);
|
plugin.getCommand("broadcastperm").setExecutor(this);
|
||||||
|
plugin.getCommand("broadcastperm").setTabCompleter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -18,23 +20,40 @@ public class CommandBroadcast extends AbstractCommandExecutor {
|
|||||||
if (args.length == 0) return false;
|
if (args.length == 0) return false;
|
||||||
|
|
||||||
|
|
||||||
if (label.equalsIgnoreCase("broadcast"))
|
if (cmd.getAliases().contains("broadcast"))
|
||||||
{
|
{
|
||||||
plugin.broadcast(ChatColor.translateAlternateColorCodes('&', StringUtils.join(args, ' ')), true);
|
plugin.broadcast(ChatColor.translateAlternateColorCodes('&', getLastParam(args, 0)), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ici, il s'agit de /broadcastperm
|
// ici, il s'agit de /broadcastperm
|
||||||
if (args.length > 2) return false;
|
if (args.length < 2) return false;
|
||||||
|
|
||||||
String perm = args[0];
|
plugin.broadcast(ChatColor.translateAlternateColorCodes('&', getLastParam(args, 1)), true, args[0]);
|
||||||
args[0] = null;
|
|
||||||
|
|
||||||
|
|
||||||
plugin.broadcast(ChatColor.translateAlternateColorCodes('&', StringUtils.join(args, ' ')), true, perm);
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
if (cmd.getAliases().contains("broadcast"))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// ici, il s'agit de /broadcastperm
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
|
||||||
|
// return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
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.players.OnlinePlayerManager;
|
||||||
|
|
||||||
@ -41,4 +43,9 @@ public class CommandCoeur extends AbstractCommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
|
|
||||||
public class CommandCubo extends AbstractCommandExecutor {
|
public class CommandCubo extends AbstractCommandExecutor {
|
||||||
@ -395,9 +396,49 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final List<String> FIRST_ARG = ImmutableList.of("devis", "creer", "info", "selectionner", "supprimer", "ajouter", "enlever", "liste", "vendre", "acheter");
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
if (args.length == 0 || !(sender instanceof Player))
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
|
||||||
|
boolean senderIsStaff = plugin.survivalCuboManager.hasStaffPermission((Player)sender);
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG);
|
||||||
|
}
|
||||||
|
else if (args.length > 1) {
|
||||||
|
if (args[0].equalsIgnoreCase("devis")) {
|
||||||
|
if (args.length == 2 && senderIsStaff)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("creer")) {
|
||||||
|
if (args.length == 3 && senderIsStaff)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("ajouter")) {
|
||||||
|
if (args.length == 2)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("enlever")) {
|
||||||
|
if (args.length == 2)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("liste")) {
|
||||||
|
if (args.length == 2 && senderIsStaff)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("vendre")) {
|
||||||
|
if (args.length == 2)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -592,6 +633,8 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
// affichage des messages de réussite
|
// affichage des messages de réussite
|
||||||
|
sendConsoleMessage(commandSender.getName(), " vient de créer le cubo ", cubo.getId(), " pour le joueur ", newOwner.getName());
|
||||||
|
|
||||||
if (!ownerIsCommandSender) {
|
if (!ownerIsCommandSender) {
|
||||||
newOwner.sendMessage(ChatColor.GOLD+"---------- Création d'un cubo ----------");
|
newOwner.sendMessage(ChatColor.GOLD+"---------- Création d'un cubo ----------");
|
||||||
newOwner.sendMessage(ChatColor.GOLD+"Protection faite par "+ChatColor.RESET+commandSender.getDisplayName());
|
newOwner.sendMessage(ChatColor.GOLD+"Protection faite par "+ChatColor.RESET+commandSender.getDisplayName());
|
||||||
@ -683,6 +726,9 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
plugin.survivalCuboManager.removeCubo(insideCubo);
|
plugin.survivalCuboManager.removeCubo(insideCubo);
|
||||||
|
|
||||||
|
|
||||||
|
sendConsoleMessage(commandSender.getName(), " vient de supprimr le cubo ", insideCubo.getId(), " qui appartenait à ", insideCubo.getOwnerName());
|
||||||
|
|
||||||
|
|
||||||
Player player_cubo = plugin.getServer().getPlayerExact(proprio_cubo);
|
Player player_cubo = plugin.getServer().getPlayerExact(proprio_cubo);
|
||||||
|
|
||||||
commandSender.sendMessage(ChatColor.GREEN+"Le cubo "+ChatColor.GRAY+insideCubo.getId()+ChatColor.GREEN+" a été supprimé");
|
commandSender.sendMessage(ChatColor.GREEN+"Le cubo "+ChatColor.GRAY+insideCubo.getId()+ChatColor.GREEN+" a été supprimé");
|
||||||
@ -716,6 +762,7 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
plugin.survivalCuboManager.saveRegionManager(commandSender.getWorld());
|
plugin.survivalCuboManager.saveRegionManager(commandSender.getWorld());
|
||||||
|
|
||||||
commandSender.sendMessage(ChatColor.GREEN+"Vous venez d'ajouter "+ChatColor.GRAY+newMember+ChatColor.GREEN+" dans le cubo");
|
commandSender.sendMessage(ChatColor.GREEN+"Vous venez d'ajouter "+ChatColor.GRAY+newMember+ChatColor.GREEN+" dans le cubo");
|
||||||
|
sendConsoleMessage(commandSender.getName(), " vient d'ajouter ", newMember, " dans le cubo ", insideCubo.getId(), " qui appartient à ", insideCubo.getOwnerName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -732,6 +779,7 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
plugin.survivalCuboManager.saveRegionManager(commandSender.getWorld());
|
plugin.survivalCuboManager.saveRegionManager(commandSender.getWorld());
|
||||||
|
|
||||||
commandSender.sendMessage(ChatColor.GREEN+"Vous venez de retirer "+ChatColor.GRAY+oldMember+ChatColor.GREEN+" du cubo");
|
commandSender.sendMessage(ChatColor.GREEN+"Vous venez de retirer "+ChatColor.GRAY+oldMember+ChatColor.GREEN+" du cubo");
|
||||||
|
sendConsoleMessage(commandSender.getName(), " vient de retirer ", oldMember, " du cubo ", insideCubo.getId(), " qui appartient à ", insideCubo.getOwnerName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,6 +813,8 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
StatsAchatCubo achatCubo = plugin.survivalCuboManager.getStatsAchatCubo(insideCubo.getWESelection(), newOwner);
|
StatsAchatCubo achatCubo = plugin.survivalCuboManager.getStatsAchatCubo(insideCubo.getWESelection(), newOwner);
|
||||||
|
|
||||||
|
sendConsoleMessage(commandSender.getName(), " vient de mettre en vente le cubo ", insideCubo.getId(), " de ", insideCubo.getOwnerName(), " pour le joueur ", newOwner.getName());
|
||||||
|
|
||||||
newOwner.sendMessage(commandSender.getDisplayName()+ChatColor.GREEN+" vient de mettre en ventre en vente le cubo "+ChatColor.GRAY+insideCubo.getId()+ChatColor.GREEN+" et vous en êtes le destinataire.");
|
newOwner.sendMessage(commandSender.getDisplayName()+ChatColor.GREEN+" vient de mettre en ventre en vente le cubo "+ChatColor.GRAY+insideCubo.getId()+ChatColor.GREEN+" et vous en êtes le destinataire.");
|
||||||
newOwner.sendMessage(ChatColor.GREEN+"Prix du cubo mis en vente : "+ChatColor.GRAY+StringUtil.formatDouble(achatCubo.valeurCuboCree));
|
newOwner.sendMessage(ChatColor.GREEN+"Prix du cubo mis en vente : "+ChatColor.GRAY+StringUtil.formatDouble(achatCubo.valeurCuboCree));
|
||||||
newOwner.sendMessage(ChatColor.GREEN+"Si vous voulez l'acheter, mettez vous dans ce cubo et faites "+ChatColor.GRAY+"/cubo acheter");
|
newOwner.sendMessage(ChatColor.GREEN+"Si vous voulez l'acheter, mettez vous dans ce cubo et faites "+ChatColor.GRAY+"/cubo acheter");
|
||||||
@ -794,6 +844,8 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
EssentialsInterface.getPlayer(commandSender).setMoney(new BigDecimal(achatCubo.soldeCompteApresCreation));
|
EssentialsInterface.getPlayer(commandSender).setMoney(new BigDecimal(achatCubo.soldeCompteApresCreation));
|
||||||
EssentialsInterface.getPlayer(commandSender).save();
|
EssentialsInterface.getPlayer(commandSender).save();
|
||||||
|
|
||||||
|
sendConsoleMessage(commandSender.getName(), " vient d'acheter le cubo ", insideCubo.getId());
|
||||||
|
|
||||||
commandSender.sendMessage(ChatColor.GREEN+"---------- Achat de cubo ----------");
|
commandSender.sendMessage(ChatColor.GREEN+"---------- Achat de cubo ----------");
|
||||||
commandSender.sendMessage(ChatColor.GREEN+"Le cubo a été acheté avec succès");
|
commandSender.sendMessage(ChatColor.GREEN+"Le cubo a été acheté avec succès");
|
||||||
commandSender.sendMessage(ChatColor.GOLD+"Identifiant du cubo : "+ChatColor.GRAY+insideCubo.getId());
|
commandSender.sendMessage(ChatColor.GOLD+"Identifiant du cubo : "+ChatColor.GRAY+insideCubo.getId());
|
||||||
@ -1010,4 +1062,38 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diffuse un message destiné à la console.<br/>
|
||||||
|
* Ce message est préfixé de [Modération].<br/>
|
||||||
|
* Les 1er, 3ème, 5ème, ... paramètres sont colorés en gris, et 2ème, 4ème, 6ème, ... paramètres
|
||||||
|
* sont colorés en blanc. Ces paramètres sont ensuite concaténé pour former le message final.
|
||||||
|
* @param messages
|
||||||
|
*/
|
||||||
|
protected void sendConsoleMessage(String ... messages) {
|
||||||
|
boolean colorToggle = true;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String message : messages) {
|
||||||
|
sb.append(colorToggle?ChatColor.GRAY:ChatColor.RESET);
|
||||||
|
|
||||||
|
sb.append(message);
|
||||||
|
|
||||||
|
colorToggle = !colorToggle;
|
||||||
|
}
|
||||||
|
plugin.getServer().getConsoleSender().sendMessage("["+ChatColor.GREEN+"Cubo"+ChatColor.RESET+"] "+sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class CommandGhost extends AbstractCommandExecutor {
|
public class CommandGhost extends AbstractCommandExecutor {
|
||||||
private static final long timeBetweenThorCommand = 5000;
|
private static final long timeBetweenThorCommand = 5000;
|
||||||
private long timeLastThorCommand = System.currentTimeMillis();
|
private long timeLastThorCommand = System.currentTimeMillis();
|
||||||
@ -87,7 +89,17 @@ public class CommandGhost extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final List<String> FIRST_ARG = ImmutableList.of("thor", "particle");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
||||||
@ -18,6 +19,8 @@ import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
|||||||
import org.bukkit.entity.Damageable;
|
import org.bukkit.entity.Damageable;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class CommandList extends AbstractCommandExecutor {
|
public class CommandList extends AbstractCommandExecutor {
|
||||||
public CommandList()
|
public CommandList()
|
||||||
{
|
{
|
||||||
@ -270,8 +273,21 @@ public class CommandList extends AbstractCommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final List<String> FIRST_ARG = ImmutableList.of("loc", "world", "uuid", "ip", "ping", "afk", "gm", "gamemode", "spam");
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
boolean detailPermission = (!(sender instanceof Player)) || OnlinePlayerManager.get((Player)sender).hasPermission("pandacraft.players.details");
|
||||||
|
|
||||||
|
if (args.length == 1 && detailPermission) {
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
|||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -37,15 +36,12 @@ public class CommandMe extends AbstractCommandExecutor {
|
|||||||
name = ChatColor.ITALIC+"@ ";
|
name = ChatColor.ITALIC+"@ ";
|
||||||
|
|
||||||
// message à afficher
|
// message à afficher
|
||||||
String message;
|
String message = getLastParam(args, 0);
|
||||||
if (!(sender instanceof Player) || ((Player)sender).hasPermission("pandacraft.me.color")) {
|
if (!(sender instanceof Player) || ((Player)sender).hasPermission("pandacraft.me.color")) {
|
||||||
message = ChatColor.translateAlternateColorCodes('&', StringUtils.join(args, ' '));
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
}
|
|
||||||
else {
|
|
||||||
message = StringUtils.join(args, ' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getServer().broadcastMessage(name + message);
|
plugin.broadcast(name + message, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.ModoHistoryElement;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.ModoHistoryElement;
|
||||||
@ -23,6 +24,7 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.DateUtil;
|
import com.earth2me.essentials.utils.DateUtil;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class CommandModo extends AbstractCommandExecutor {
|
public class CommandModo extends AbstractCommandExecutor {
|
||||||
|
|
||||||
@ -254,7 +256,113 @@ public class CommandModo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final List<String> FIRST_ARG = ImmutableList.of("report", "jails", "jail", "unjail", "mute", "unmute", "ban", "unban", "kick", "amende", "1", "2", "3", "4");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG);
|
||||||
|
}
|
||||||
|
else if (args.length > 1) {
|
||||||
|
|
||||||
|
// <Pseudo> <Raison>
|
||||||
|
if (args[0].equalsIgnoreCase("report")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("kick")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("unjail")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("unmute")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("unban")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <Pseudo> <Duree> <Raison>
|
||||||
|
if (args[0].equalsIgnoreCase("jail")) {
|
||||||
|
if (args.length == 2 || args.length > 3)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("mute")) {
|
||||||
|
if (args.length == 2 || args.length > 3)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("ban")) {
|
||||||
|
if (args.length == 2 || args.length > 3)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("amende")) {
|
||||||
|
if (args.length == 2 || args.length > 3)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void showHelp(CommandSender sender, int page) {
|
||||||
|
ArrayList<String> s = new ArrayList<String>();
|
||||||
|
|
||||||
|
s.add(ChatColor.GOLD+"-------- Assistant de modération --------");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (page == 1) {
|
||||||
|
s.add(ChatColor.GOLD+"- Commandes sans sanction :");
|
||||||
|
s.add(ChatColor.GRAY+"/modo report <Pseudo> <Raison>"+ChatColor.WHITE+" faire un rapport d'un joueur, sans appliquer de sanction");
|
||||||
|
s.add(ChatColor.GRAY+"/modo jails"+ChatColor.WHITE+" aller à la prison");
|
||||||
|
s.add(ChatColor.GOLD+"- Aide sur les commandes de sanction :");
|
||||||
|
s.add(ChatColor.GRAY+"/modo 2"+ChatColor.WHITE+" application d'une sanction");
|
||||||
|
s.add(ChatColor.GRAY+"/modo 3"+ChatColor.WHITE+" retrait d'une sanction");
|
||||||
|
s.add(ChatColor.GRAY+"/modo 4"+ChatColor.WHITE+" règles sur les sanctions");
|
||||||
|
}
|
||||||
|
else if (page == 2) {
|
||||||
|
s.add(ChatColor.GOLD+"- Appliquer une sanction :");
|
||||||
|
s.add(ChatColor.GRAY+"/modo jail <Pseudo> <Durée> <Raison>"+ChatColor.WHITE+" emprisonner un <Joueur> pendant une <Durée> en précisant la <Raison>");
|
||||||
|
s.add(ChatColor.GRAY+"/modo mute <Pseudo> <Durée> <Raison>"+ChatColor.WHITE+" rendre muet un <Joueur> pendant une <Durée> en précisant la <Raison>");
|
||||||
|
s.add(ChatColor.GRAY+"/modo ban <Pseudo> <Durée> <Raison>"+ChatColor.WHITE+" bannir un <Joueur> pendant une <Durée> en précisant la <Raison>");
|
||||||
|
s.add(ChatColor.GRAY+"/modo kick <Pseudo> <Raison>"+ChatColor.WHITE+" expulse un <Joueur> en précisant la <Raison>");
|
||||||
|
s.add(ChatColor.GRAY+"/modo amende <Pseudo> <Somme> <Raison>"+ChatColor.WHITE+" expulse un <Joueur> en précisant la <Raison>");
|
||||||
|
}
|
||||||
|
else if (page == 3) {
|
||||||
|
s.add(ChatColor.GOLD+"- Retirer une sanction :");
|
||||||
|
s.add(ChatColor.GRAY+"/modo unjail <Pseudo> <Raison>"+ChatColor.WHITE+" sortir de prison un <Joueur> en précisant la <Raison>");
|
||||||
|
s.add(ChatColor.GRAY+"/modo unmute <Pseudo> <Raison>"+ChatColor.WHITE+" rendre la parole à un <Joueur> en précisant la <Raison>");
|
||||||
|
s.add(ChatColor.GRAY+"/modo unban <Pseudo> <Raison>"+ChatColor.WHITE+" retirer le bannissement d'un <Joueur> en précisant la <Raison>");
|
||||||
|
}
|
||||||
|
else if (page == 4) {
|
||||||
|
s.add(ChatColor.GOLD+"- Règles sur les sanctions :");
|
||||||
|
s.add(ChatColor.WHITE+"- Certains membres du staff on plus ou moins de droits concernant les sanctions (durée de jail, ban et mute)");
|
||||||
|
s.add(ChatColor.WHITE+"- Toutes les sanctions doivent être justifiées. Vous êtes obligé d'indiquer la raison de la sanction dans les commandes");
|
||||||
|
s.add(ChatColor.WHITE+"- Toutes les actions dans la commande "+ChatColor.GRAY+"/modo"+ChatColor.WHITE+" sont enregistrées");
|
||||||
|
s.add(ChatColor.WHITE+"- Rendez vous sur MineAdmin pour les autres règles de Modération");
|
||||||
|
s.add(ChatColor.WHITE+"- Rendez vous sur le site web de Pandacraft pour le règlement du serveur et les sanctions à appliquer");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
s.add(ChatColor.GOLD+"La page "+page+" n'existe pas");
|
||||||
|
}
|
||||||
|
|
||||||
|
s.add(ChatColor.GOLD+"------------------------------------------");
|
||||||
|
|
||||||
|
sender.sendMessage(s.toArray(new String[s.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -710,60 +818,6 @@ public class CommandModo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void showHelp(CommandSender sender, int page) {
|
|
||||||
ArrayList<String> s = new ArrayList<String>();
|
|
||||||
|
|
||||||
s.add(ChatColor.GOLD+"-------- Assistant de modération --------");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (page == 1) {
|
|
||||||
s.add(ChatColor.GOLD+"- Commandes sans sanction :");
|
|
||||||
s.add(ChatColor.GRAY+"/modo report <Pseudo> <Raison>"+ChatColor.WHITE+" faire un rapport d'un joueur, sans appliquer de sanction");
|
|
||||||
s.add(ChatColor.GRAY+"/modo jails"+ChatColor.WHITE+" aller à la prison");
|
|
||||||
s.add(ChatColor.GOLD+"- Aide sur les commandes de sanction :");
|
|
||||||
s.add(ChatColor.GRAY+"/modo 2"+ChatColor.WHITE+" application d'une sanction");
|
|
||||||
s.add(ChatColor.GRAY+"/modo 3"+ChatColor.WHITE+" retrait d'une sanction");
|
|
||||||
s.add(ChatColor.GRAY+"/modo 4"+ChatColor.WHITE+" règles sur les sanctions");
|
|
||||||
}
|
|
||||||
else if (page == 2) {
|
|
||||||
s.add(ChatColor.GOLD+"- Appliquer une sanction :");
|
|
||||||
s.add(ChatColor.GRAY+"/modo jail <Pseudo> <Durée> <Raison>"+ChatColor.WHITE+" emprisonner un <Joueur> pendant une <Durée> en précisant la <Raison>");
|
|
||||||
s.add(ChatColor.GRAY+"/modo mute <Pseudo> <Durée> <Raison>"+ChatColor.WHITE+" rendre muet un <Joueur> pendant une <Durée> en précisant la <Raison>");
|
|
||||||
s.add(ChatColor.GRAY+"/modo ban <Pseudo> <Durée> <Raison>"+ChatColor.WHITE+" bannir un <Joueur> pendant une <Durée> en précisant la <Raison>");
|
|
||||||
s.add(ChatColor.GRAY+"/modo kick <Pseudo> <Raison>"+ChatColor.WHITE+" expulse un <Joueur> en précisant la <Raison>");
|
|
||||||
s.add(ChatColor.GRAY+"/modo amende <Pseudo> <Raison>"+ChatColor.WHITE+" expulse un <Joueur> en précisant la <Raison>");
|
|
||||||
}
|
|
||||||
else if (page == 3) {
|
|
||||||
s.add(ChatColor.GOLD+"- Retirer une sanction :");
|
|
||||||
s.add(ChatColor.GRAY+"/modo unjail <Pseudo> <Raison>"+ChatColor.WHITE+" sortir de prison un <Joueur> en précisant la <Raison>");
|
|
||||||
s.add(ChatColor.GRAY+"/modo unmute <Pseudo> <Raison>"+ChatColor.WHITE+" rendre la parole à un <Joueur> en précisant la <Raison>");
|
|
||||||
s.add(ChatColor.GRAY+"/modo unban <Pseudo> <Raison>"+ChatColor.WHITE+" retirer le bannissement d'un <Joueur> en précisant la <Raison>");
|
|
||||||
}
|
|
||||||
else if (page == 4) {
|
|
||||||
s.add(ChatColor.GOLD+"- Règles sur les sanctions :");
|
|
||||||
s.add(ChatColor.WHITE+"- Certains membres du staff on plus ou moins de droits concernant les sanctions (durée de jail, ban et mute)");
|
|
||||||
s.add(ChatColor.WHITE+"- Toutes les sanctions doivent être justifiées. Vous êtes obligé d'indiquer la raison de la sanction dans les commandes");
|
|
||||||
s.add(ChatColor.WHITE+"- Toutes les actions dans la commande "+ChatColor.GRAY+"/modo"+ChatColor.WHITE+" sont enregistrées");
|
|
||||||
s.add(ChatColor.WHITE+"- Rendez vous sur MineAdmin pour les autres règles de Modération");
|
|
||||||
s.add(ChatColor.WHITE+"- Rendez vous sur le site web de Pandacraft pour le règlement du serveur et les sanctions à appliquer");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
s.add(ChatColor.GOLD+"La page "+page+" n'existe pas");
|
|
||||||
}
|
|
||||||
|
|
||||||
s.add(ChatColor.GOLD+"------------------------------------------");
|
|
||||||
|
|
||||||
sender.sendMessage(s.toArray(new String[s.size()]));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ public class CommandMuco extends AbstractCommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sender instanceof Player) && !OnlinePlayerManager.get((Player)sender).hasPermission("pandacraft.muco."+list_name)) {
|
if ((sender instanceof Player) && !OnlinePlayerManager.get((Player)sender).hasPermission("pandacraft.muco."+list_name)
|
||||||
|
&& !OnlinePlayerManager.get((Player)sender).hasPermission("pandacraft.muco.*")) {
|
||||||
sender.sendMessage(ChatColor.RED+"Vous n'avez pas la permission pour la sous commande '"+list_name+"'");
|
sender.sendMessage(ChatColor.RED+"Vous n'avez pas la permission pour la sous commande '"+list_name+"'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -69,6 +70,19 @@ public class CommandMuco extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
return getTabProposalFromToken(args[0], getMucoLists((sender instanceof Player)?OnlinePlayerManager.get((Player)sender):null));
|
||||||
|
}
|
||||||
|
else if (args.length > 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +96,7 @@ public class CommandMuco extends AbstractCommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.GOLD+"----- Liste des commandes /muco -----");
|
sender.sendMessage(ChatColor.GOLD+"----- Liste des commandes /muco -----");
|
||||||
|
|
||||||
for (String name : list_names) {
|
for (String name : list_names) {
|
||||||
sender.sendMessage(" - "+ChatColor.GRAY+name);
|
sender.sendMessage("- "+ChatColor.GRAY+name);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GOLD+"-----------------------------------");
|
sender.sendMessage(ChatColor.GOLD+"-----------------------------------");
|
||||||
@ -95,7 +109,7 @@ public class CommandMuco extends AbstractCommandExecutor {
|
|||||||
List<String> retList = new ArrayList<String>();
|
List<String> retList = new ArrayList<String>();
|
||||||
|
|
||||||
for (String name : list_names) {
|
for (String name : list_names) {
|
||||||
if (permittedPlayer == null || permittedPlayer.hasPermission("pandacraft.muco."+name))
|
if (permittedPlayer == null || permittedPlayer.hasPermission("pandacraft.muco."+name) || permittedPlayer.hasPermission("pandacraft.muco.*"))
|
||||||
retList.add(name);
|
retList.add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -46,4 +48,11 @@ public class CommandPing extends AbstractCommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.staff.StaffQueueManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.staff.StaffQueueManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.staff.StaffQueueManager.WaitingPlayer;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.staff.StaffQueueManager.WaitingPlayer;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
import net.mc_pandacraft.java.util.TimeUtil;
|
import net.mc_pandacraft.java.util.TimeUtil;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class CommandStaff extends AbstractCommandExecutor {
|
public class CommandStaff extends AbstractCommandExecutor {
|
||||||
|
|
||||||
public CommandStaff() {
|
public CommandStaff() {
|
||||||
@ -23,196 +25,211 @@ public class CommandStaff extends AbstractCommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StaffQueueManager staffManager = plugin.staffQueueManager;
|
StaffQueueManager staffManager = plugin.staffQueueManager;
|
||||||
|
|
||||||
|
|
||||||
if (sender instanceof Player && !OnlinePlayerManager.get((Player)sender).isInStaff())
|
if (sender instanceof Player && !OnlinePlayerManager.get((Player)sender).isInStaff())
|
||||||
{ // un joueur qui n'est pas du staff
|
{ // un joueur qui n'est pas du staff
|
||||||
|
|
||||||
// le joueur est-il déjà en file d'attente ?
|
|
||||||
if (staffManager.getWaitingPlayer((Player)sender) != null) {
|
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("annuler")) {
|
|
||||||
staffManager.removePlayer((Player)sender);
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous avez été retiré de la file d'attente");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (args.length > 0 && args[0].equalsIgnoreCase("position")) {
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous êtes à la position "+staffManager.getPlayerPosition((Player)sender)+" de la file d'attente");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous êtes déjà dans la file d'attente");
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Commande : "+ChatColor.GRAY+"/staff position"+ChatColor.RED+" pour connaitre votre position"+
|
|
||||||
" ou "+ChatColor.GRAY+"/staff annuler"+ChatColor.RED+" pour sortir de la file d'attente");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// le joueur n'a-t-il pas mis un message en argument de la commande
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous n'êtes pas dans la file d'attente");
|
showHelp(sender);
|
||||||
sender.sendMessage(ChatColor.GREEN+"Cette file d'attente sers à demander un service à une personne du staff connecté");
|
|
||||||
sender.sendMessage(ChatColor.RED+"Commande : "+ChatColor.GRAY+"/staff "+ChatColor.ITALIC+"Message"+
|
|
||||||
ChatColor.RED+" pour rentrer dans la file d'attente");
|
|
||||||
sender.sendMessage(ChatColor.RED+"Si votre message n'est pas assez explicite ou détaillée, votre demande pourra être ignoré");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
staffManager.addWaitingPlayer((Player)sender, StringUtils.join(args, " "));
|
Player player = (Player) sender;
|
||||||
sender.sendMessage(ChatColor.GREEN+"Veuillez maintenant patienter quelques instant, le temps que le staff traite le début de la file d'attente ;)");
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous êtes à la position "+staffManager.getPlayerPosition((Player)sender)+" de la file d'attente");
|
WaitingPlayer wp = staffManager.getWaitingPlayer(player);
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("ajouter") && args.length > 1) {
|
||||||
|
if (wp != null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Vous avez déjà envoyé un ticket :");
|
||||||
|
displayTicket(sender, wp, false);
|
||||||
|
sender.sendMessage(ChatColor.RED+"Faites "+ChatColor.GRAY+"/"+alias+" modifier <Message>"+ChatColor.RED+" pour modifier le message du ticket");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = getLastParam(args, 1);
|
||||||
|
|
||||||
|
staffManager.addWaitingPlayer(player, message);
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Votre ticket a été envoyé :)");
|
||||||
|
displayTicket(sender, wp, false);
|
||||||
|
sender.sendMessage(ChatColor.RED+"Faites "+ChatColor.GRAY+"/"+alias+ChatColor.RED+" pour voir les commandes disponibles");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("supprimer")) {
|
||||||
|
if (wp == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Il n'y a pas de ticket à supprimer");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
staffManager.removePlayer(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("modifier") && args.length > 1) {
|
||||||
|
if (wp == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Il n'y a pas de ticket à modifier");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = getLastParam(args, 1);
|
||||||
|
|
||||||
|
wp.setMessage(message);
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Votre ticket a été modifié :");
|
||||||
|
displayTicket(sender, wp, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("position")) {
|
||||||
|
if (wp == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Il n'y a aucun ticket à votre nom");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos = staffManager.getPlayerPosition(player);
|
||||||
|
sender.sendMessage(ChatColor.GOLD+"Votre ticket est à la position "+pos+" de la file d'attente");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.RED+"Mauvaise utilisation : faites "+ChatColor.GRAY+"/"+alias+ChatColor.RED+" pour voir les commandes disponibles");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (sender instanceof Player)
|
|
||||||
{ // un joueur du staff
|
|
||||||
if (args.length == 0) {
|
|
||||||
staffManager.showWaintingList(sender);
|
|
||||||
sender.sendMessage(ChatColor.GOLD+"Pour connaitre les commandes, faites "+ChatColor.GRAY+"/staff ?");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return onCommand_admin_commands(sender, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// -------------
|
||||||
|
// à partir de là, on fait partie du staff
|
||||||
|
// -------------
|
||||||
|
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
staffManager.showWaintingList(sender);
|
||||||
|
sender.sendMessage(ChatColor.GOLD+"Pour connaitre les commandes, faites "+ChatColor.GRAY+"/staff ?");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{ // ce n'est pas un joueur (console)
|
|
||||||
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (sender instanceof Player)
|
||||||
staffManager.showWaintingList(sender);
|
{ // un joueur du staff IG
|
||||||
|
|
||||||
|
Player staffPlayer = (Player) sender;
|
||||||
|
WaitingPlayer selectedWP = staffManager.getSelectedWaitingPlayer((Player)sender);
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("selectionner") && args.length > 1)
|
||||||
|
{
|
||||||
|
if (selectedWP != null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Vous avez déjà sélectionné le joueur "+ChatColor.RESET+selectedWP.getPlayerDisplayName());
|
||||||
|
sender.sendMessage(ChatColor.RED+"Faites "+ChatColor.RESET+"/"+alias+" finir"+ChatColor.RED+" pour en finir avec ce joueur");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
WaitingPlayer wp = staffManager.getWaitingPlayer(args[1]);
|
||||||
|
|
||||||
|
if (wp == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Ce joueur n'est pas dans la file d'attente");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// on vérifie si un membre du staff ne s'occupe pas déjà du joueur
|
||||||
|
if (wp.getStaffPlayerName() != null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+wp.getStaffPlayerName()+" s'occupe déjà de ce joueur");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wp.setStaffPlayer(staffPlayer);
|
||||||
|
|
||||||
|
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
||||||
|
if (p != null && p.isOnline()) {
|
||||||
|
// le joueur est en ligne
|
||||||
|
((Player)sender).teleport(p.getLocation());
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
||||||
|
displayTicket(sender, wp, true);
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Vous avez été téléporté vers ce joueur");
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
||||||
|
|
||||||
|
p.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
||||||
|
p.sendMessage(((Player)sender).getDisplayName()+ChatColor.RESET+ChatColor.GREEN+" s'occupe maintenant de vous :)");
|
||||||
|
p.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// le joueur n'est pas en ligne
|
||||||
|
((Player)sender).teleport(wp.getLocation());
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
||||||
|
displayTicket(sender, wp, true);
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Vous avez été téléporté vers l'endroit concerné par la demande du joueur");
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
if (args[0].equalsIgnoreCase("finir"))
|
||||||
{
|
{
|
||||||
return onCommand_admin_commands(sender, args);
|
if (selectedWP == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Vous ne vous occupez actuellement de personne. Faites "+ChatColor.GRAY+"/staff"+ChatColor.RED+" pour voir si vous pouvez aider un joueur");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
staffManager.removePlayer(selectedWP.getPlayerName());
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN+selectedWP.getPlayerDisplayName()+ChatColor.RESET+ChatColor.GREEN+" a été retiré de la file d'attente");
|
||||||
|
|
||||||
|
Player p = plugin.getServer().getPlayerExact(selectedWP.getPlayerName());
|
||||||
|
if (p != null && p.isOnline()) {
|
||||||
|
p.sendMessage(ChatColor.RED+"Vous avez été retiré de la file d'attente");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("annuler"))
|
||||||
|
{
|
||||||
|
if (selectedWP == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Vous ne vous occupez actuellement de personne. Faites "+ChatColor.GRAY+"/staff"+ChatColor.RED+" pour voir si vous pouvez aider un joueur");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedWP.setStaffPlayer(null);
|
||||||
|
|
||||||
|
Player p = plugin.getServer().getPlayerExact(selectedWP.getPlayerName());
|
||||||
|
if (p != null && p.isOnline()) {
|
||||||
|
p.sendMessage(ChatColor.RED+staffPlayer.getDisplayName()+ChatColor.RED+" n'a pas la possibilité de traiter votre demande :/"
|
||||||
|
+ "Mais ne vous en faites pas, vous avez été remis en file d'attente et un autre membre du staff peut vous prendre en charge ;)");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN+selectedWP.getPlayerDisplayName()+ChatColor.RESET+ChatColor.GREEN+" a été remis en attente");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// les commandes ci dessous peuvent être pris en charge par la console, ou comme un membre du staff IG
|
||||||
|
|
||||||
|
|
||||||
private boolean onCommand_admin_commands(CommandSender sender, String[] args) {
|
|
||||||
|
|
||||||
StaffQueueManager staffManager = plugin.staffQueueManager;
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("?"))
|
if (args[0].equalsIgnoreCase("?"))
|
||||||
{ // affichage de l'aide
|
{ // affichage de l'aide
|
||||||
sender.sendMessage(ChatColor.GOLD+"--- Commandes administratives pour gérer la file d'attente ---");
|
showHelp(sender);
|
||||||
if (sender instanceof Player) {
|
|
||||||
sender.sendMessage(ChatColor.GRAY+"/staff select <Joueur>"+ChatColor.RESET+" : prendre en charge un joueur de la file");
|
|
||||||
sender.sendMessage(ChatColor.GRAY+"/staff finish"+ChatColor.RESET+" : quand vous avez fini de prendre en charge le joueur en cours");
|
|
||||||
sender.sendMessage(ChatColor.GRAY+"/staff cancel"+ChatColor.RESET+" : quand vous ne pouvez pas prendre en charge le joueur en cours");
|
|
||||||
}
|
|
||||||
sender.sendMessage(ChatColor.GRAY+"/staff remove <Joueur>"+ChatColor.RESET+" : retire un joueur de la file sans le prendre en charge");
|
|
||||||
sender.sendMessage(ChatColor.GRAY+"/staff add <Joueur> <Message>"+ChatColor.RESET+" : ajoute un joueur dans la file");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("select") && args.length > 1 && sender instanceof Player)
|
|
||||||
|
if (args[0].equalsIgnoreCase("supprimer") && args.length > 1)
|
||||||
{
|
{
|
||||||
WaitingPlayer wp;
|
WaitingPlayer wp = staffManager.getWaitingPlayer(args[1]);
|
||||||
// on vérifie si le membre du staff n'est pas déjà associé à un joueur
|
|
||||||
if ((wp = staffManager.getSelectedWaitingPlayer((Player)sender)) != null) {
|
|
||||||
sender.sendMessage(ChatColor.RED+"Vous vous occupez déjà d'un joueur. Faites "+ChatColor.GRAY+"/staff finish"+ChatColor.RED+" si vous en avez fini avec "+wp.getPlayerDisplayName());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// on vérifie que le joueur indiqué se trouve dans la file d'attente
|
|
||||||
wp = staffManager.getWaitingPlayer(args[1]);
|
|
||||||
if (wp == null) {
|
if (wp == null) {
|
||||||
sender.sendMessage(ChatColor.RED+"Le joueur n'est pas dans la liste");
|
sender.sendMessage(ChatColor.RED+"Le joueur indiqué n'est pas dans la file");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// on vérifie si un membre du staff ne s'occupe pas déjà du joueur
|
|
||||||
if (wp.getStaffPlayerName() != null) {
|
|
||||||
sender.sendMessage(ChatColor.RED+wp.getStaffPlayerName()+" s'occupe déjà de ce joueur");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wp.setStaffPlayer((Player)sender);
|
|
||||||
|
|
||||||
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
|
||||||
if (p != null && p.isOnline()) {
|
|
||||||
// le joueur est en ligne
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
|
||||||
sender.sendMessage(p.getDisplayName()+ChatColor.RESET+" : "+wp.getMessage()+" - "+ChatColor.ITALIC+"Il y a "+TimeUtil.durationToString((new Date()).getTime() - wp.getDate().getTime()));
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous avez été téléporté vers ce joueur");
|
|
||||||
((Player)sender).teleport(p.getLocation());
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
|
||||||
|
|
||||||
p.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
|
||||||
p.sendMessage(((Player)sender).getDisplayName()+ChatColor.RESET+ChatColor.GREEN+" s'occupe maintenant de vous :)");
|
|
||||||
p.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// le joueur n'est pas en ligne
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
|
||||||
sender.sendMessage(wp.getPlayerName()+ChatColor.RESET+" : "+wp.getMessage());
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous avez été téléporté vers l'endroit concerné par la demande du joueur");
|
|
||||||
((Player)sender).teleport(wp.getLocation());
|
|
||||||
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("finish") && sender instanceof Player)
|
|
||||||
{
|
|
||||||
WaitingPlayer wp = staffManager.getSelectedWaitingPlayer((Player)sender);
|
|
||||||
if (wp == null) {
|
|
||||||
sender.sendMessage(ChatColor.RED+"Vous ne vous occupez actuellement de personne. Faites "+ChatColor.GRAY+"/staff"+ChatColor.RED+" pour voir si vous pouvez aider un joueur");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
staffManager.removePlayer(wp.getPlayerName());
|
staffManager.removePlayer(wp.getPlayerName());
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GREEN+wp.getPlayerName()+ChatColor.RESET+ChatColor.GREEN+" a été retiré de la file d'attente");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("cancel") && sender instanceof Player)
|
|
||||||
{
|
|
||||||
WaitingPlayer wp = staffManager.getSelectedWaitingPlayer((Player)sender);
|
|
||||||
if (wp == null) {
|
|
||||||
sender.sendMessage(ChatColor.RED+"Vous ne vous occupez actuellement de personne. Faites "+ChatColor.GRAY+"/staff"+ChatColor.RED+" pour voir si vous pouvez aider un joueur");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
wp.setStaffPlayer(null);
|
|
||||||
|
|
||||||
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
|
||||||
if (p != null && p.isOnline()) {
|
|
||||||
p.sendMessage(ChatColor.RED+((Player)sender).getDisplayName()+ChatColor.RED+" ne s'occupe plus de vous, mais vous restez en file d'attente");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GREEN+wp.getPlayerName()+ChatColor.RESET+ChatColor.GREEN+" a été remis en attente");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("remove") && args.length > 1)
|
|
||||||
{
|
|
||||||
WaitingPlayer wp = staffManager.getWaitingPlayer(args[1]);
|
|
||||||
if (wp == null) {
|
|
||||||
sender.sendMessage(ChatColor.RED+"Le joueur n'est pas dans la file");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
staffManager.removePlayer(args[1]);
|
|
||||||
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
||||||
if (p != null && p.isOnline()) {
|
if (p != null && p.isOnline()) {
|
||||||
p.sendMessage(ChatColor.RED+"Vous avez été retiré de la file d'attente");
|
p.sendMessage(ChatColor.RED+"Vous avez été retiré de la file d'attente");
|
||||||
@ -223,7 +240,7 @@ public class CommandStaff extends AbstractCommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("add") && args.length > 1)
|
if (args[0].equalsIgnoreCase("ajouter") && args.length > 2)
|
||||||
{
|
{
|
||||||
|
|
||||||
Player p = plugin.getServer().getPlayer(args[1]);
|
Player p = plugin.getServer().getPlayer(args[1]);
|
||||||
@ -235,17 +252,11 @@ public class CommandStaff extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
WaitingPlayer wp = staffManager.getWaitingPlayer(p.getName());
|
WaitingPlayer wp = staffManager.getWaitingPlayer(p.getName());
|
||||||
if (wp != null) {
|
if (wp != null) {
|
||||||
sender.sendMessage(ChatColor.RED+"Le joueur est déjà dans la liste");
|
sender.sendMessage(ChatColor.RED+"Le joueur a déjà son ticket en attente");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = ChatColor.ITALIC+"(Ajouté par "+sender.getName() +") "+ ChatColor.RESET+getLastParam(args, 2);
|
||||||
// on trafique le message pour 2 raisons :
|
|
||||||
// - on retire les paramètres qui ne font pas partie du message ("add" et le nom du joueur ajouté)
|
|
||||||
// - on les replaces par l'info sur le membre du staff qui l'a ajouté à la liste
|
|
||||||
args[0] = ChatColor.ITALIC+"(Ajouté par";
|
|
||||||
args[1] = sender.getName() +")"+ ChatColor.RESET;
|
|
||||||
String message = StringUtils.join(args, " ");
|
|
||||||
|
|
||||||
|
|
||||||
staffManager.addWaitingPlayer(p, message);
|
staffManager.addWaitingPlayer(p, message);
|
||||||
@ -255,8 +266,40 @@ public class CommandStaff extends AbstractCommandExecutor {
|
|||||||
p.sendMessage(ChatColor.GREEN+sender.getName()+" vous a ajouté dans la file d'attente pour traiter votre demande plus tard");
|
p.sendMessage(ChatColor.GREEN+sender.getName()+" vous a ajouté dans la file d'attente pour traiter votre demande plus tard");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.RED+"La commande a mal été tapé");
|
if (args[0].equalsIgnoreCase("modifier") && args.length > 2)
|
||||||
return false;
|
{
|
||||||
|
|
||||||
|
WaitingPlayer wp = staffManager.getWaitingPlayer(args[1]);
|
||||||
|
if (wp == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Le joueur indiqué n'est pas dans la file");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = ChatColor.ITALIC+"(Modifié par "+sender.getName() +") "+ ChatColor.RESET+getLastParam(args, 2);
|
||||||
|
|
||||||
|
wp.setMessage(message);
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN+"Le message de "+ChatColor.RESET+wp.getPlayerDisplayName()+ChatColor.GREEN+" a été modifié");
|
||||||
|
|
||||||
|
Player p = plugin.getServer().getPlayerExact(wp.getPlayerName());
|
||||||
|
if (p != null && p.isOnline()) {
|
||||||
|
p.sendMessage(ChatColor.GOLD+sender.getName()+" a modifié le message de votre ticket "+ChatColor.GRAY+"/staff"+ChatColor.GOLD+" :");
|
||||||
|
displayTicket(p, wp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.RED+"Mauvaise utilisation : faites "+ChatColor.GRAY+"/"+alias+" ?"+ChatColor.RED+" pour voir les commandes disponibles");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -274,4 +317,155 @@ public class CommandStaff extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final List<String> FIRST_ARG_PLAYERS = ImmutableList.of("ajouter", "supprimer", "modifier", "position");
|
||||||
|
public static final List<String> FIRST_ARG_STAFF = ImmutableList.of("?", "ajouter", "modifier", "supprimer", "selectionner", "annuler", "finir");
|
||||||
|
public static final List<String> FIRST_ARG_CONSOLE = ImmutableList.of("?", "ajouter", "modifier", "supprimer");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
StaffQueueManager staffManager = plugin.staffQueueManager;
|
||||||
|
|
||||||
|
if (sender instanceof Player && !OnlinePlayerManager.get((Player)sender).isInStaff())
|
||||||
|
{ // pour les joueurs
|
||||||
|
if (args.length == 1) {
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG_PLAYERS);
|
||||||
|
}
|
||||||
|
if (args.length > 1) {
|
||||||
|
if (args[0].equalsIgnoreCase("ajouter"))
|
||||||
|
return null;
|
||||||
|
if (args[0].equalsIgnoreCase("modifier"))
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sender instanceof Player)
|
||||||
|
{ // pour le staff connecté
|
||||||
|
if (args.length == 1)
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG_STAFF);
|
||||||
|
if (args.length > 1) {
|
||||||
|
if (args[0].equalsIgnoreCase("ajouter")) {
|
||||||
|
if (args.length == 2) {
|
||||||
|
List<String> playerCanBeAdd = OnlinePlayerManager.getNamesOnlyVisible((Player) sender);
|
||||||
|
playerCanBeAdd.removeAll(staffManager.getWaitingPlayerNames());
|
||||||
|
return getTabProposalFromToken(args[1], playerCanBeAdd);
|
||||||
|
}
|
||||||
|
if (args.length > 2)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("modifier")) {
|
||||||
|
if (args.length == 2)
|
||||||
|
return getTabProposalFromToken(args[1], staffManager.getWaitingPlayerNames());
|
||||||
|
if (args.length > 2)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("supprimer"))
|
||||||
|
if (args.length == 2)
|
||||||
|
return getTabProposalFromToken(args[1], staffManager.getWaitingPlayerNames());
|
||||||
|
if (args[0].equalsIgnoreCase("selectionner"))
|
||||||
|
if (args.length == 2)
|
||||||
|
return getTabProposalFromToken(args[1], staffManager.getWaitingPlayerNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // pour la console et le reste (pas les joueurs)
|
||||||
|
if (args.length == 1)
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG_CONSOLE);
|
||||||
|
if (args.length > 1) {
|
||||||
|
if (args[0].equalsIgnoreCase("ajouter")) {
|
||||||
|
if (args.length == 2) {
|
||||||
|
List<String> playerCanBeAdd = OnlinePlayerManager.getNamesOnlyVisible(null);
|
||||||
|
playerCanBeAdd.removeAll(staffManager.getWaitingPlayerNames());
|
||||||
|
return getTabProposalFromToken(args[1], playerCanBeAdd);
|
||||||
|
}
|
||||||
|
if (args.length > 2)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("modifier")) {
|
||||||
|
if (args.length == 2)
|
||||||
|
return getTabProposalFromToken(args[1], staffManager.getWaitingPlayerNames());
|
||||||
|
if (args.length > 2)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("supprimer"))
|
||||||
|
if (args.length == 2)
|
||||||
|
return getTabProposalFromToken(args[1], staffManager.getWaitingPlayerNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void showHelp(CommandSender sender) {
|
||||||
|
|
||||||
|
String[] messages = null;
|
||||||
|
if (sender instanceof Player && !OnlinePlayerManager.get((Player)sender).isInStaff())
|
||||||
|
{ // pour les joueurs
|
||||||
|
String[] m = {
|
||||||
|
ChatColor.GOLD+"----- Ticket / file d'attente staff -----",
|
||||||
|
ChatColor.GOLD+"Les tickets vous permettent de demander assistance à un membre du staff",
|
||||||
|
ChatColor.GRAY+"/staff ajouter <Message>"+ChatColor.GOLD+" pour ajouter un ticket dans la file d'attente",
|
||||||
|
ChatColor.GRAY+"/staff supprimer"+ChatColor.GOLD+" pour supprimer votre ticket de la file d'attente",
|
||||||
|
ChatColor.GRAY+"/staff modifier <Message>"+ChatColor.GOLD+" pour modifier le message de votre ticket",
|
||||||
|
ChatColor.GRAY+"/staff position"+ChatColor.GOLD+" pour connaitre votre position dans la file d'attente",
|
||||||
|
ChatColor.GOLD+"------------------------------------------"
|
||||||
|
};
|
||||||
|
messages = m;
|
||||||
|
}
|
||||||
|
else if (sender instanceof Player)
|
||||||
|
{ // pour le staff connecté
|
||||||
|
String[] m = {
|
||||||
|
ChatColor.GOLD+"----- Ticket / file d'attente staff -----",
|
||||||
|
ChatColor.GRAY+"/staff"+ChatColor.GOLD+" pour voir la liste des tickets",
|
||||||
|
ChatColor.GRAY+"/staff ajouter <Pseudo> <Message>"+ChatColor.GOLD+" pour ajouter un ticket dans la file d'attente",
|
||||||
|
ChatColor.GRAY+"/staff supprimer <Pseudo>"+ChatColor.GOLD+" pour supprimer le ticket d'un joueur de la file d'attente",
|
||||||
|
ChatColor.GRAY+"/staff modifier <Pseudo> <Message>"+ChatColor.GOLD+" pour modifier le message du ticket d'un joueur",
|
||||||
|
ChatColor.GRAY+"/staff selectionner <Pseudo>"+ChatColor.GOLD+" pour prendre en charge un joueur en attente",
|
||||||
|
ChatColor.GRAY+"/staff annuler"+ChatColor.GOLD+" quand vous ne pouvez pas régler le problème du joueur que vous avez pris en charge",
|
||||||
|
ChatColor.GRAY+"/staff finir"+ChatColor.GOLD+" quand vous avez réglé le problème du joueur que vous avez pris en charge",
|
||||||
|
ChatColor.GOLD+"------------------------------------------"
|
||||||
|
};
|
||||||
|
messages = m;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // pour la console et le reste (pas les joueurs)
|
||||||
|
String[] m = {
|
||||||
|
ChatColor.GOLD+"----- Ticket / file d'attente staff -----",
|
||||||
|
ChatColor.GRAY+"/staff"+ChatColor.GOLD+" pour voir la liste des tickets",
|
||||||
|
ChatColor.GRAY+"/staff ajouter <Pseudo> <Message>"+ChatColor.GOLD+" pour ajouter un ticket dans la file d'attente",
|
||||||
|
ChatColor.GRAY+"/staff supprimer <Pseudo>"+ChatColor.GOLD+" pour supprimer le ticket d'un joueur de la file d'attente",
|
||||||
|
ChatColor.GRAY+"/staff modifier <Pseudo> <Message>"+ChatColor.GOLD+" pour modifier le message du ticket d'un joueur",
|
||||||
|
ChatColor.GOLD+"---------------------------------------------"
|
||||||
|
};
|
||||||
|
messages = m;
|
||||||
|
}
|
||||||
|
sender.sendMessage(messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void displayTicket(CommandSender sender, WaitingPlayer wp, boolean withPlayerName) {
|
||||||
|
String out = (withPlayerName) ? wp.getPlayerDisplayName()+ChatColor.RESET+" : " : "";
|
||||||
|
|
||||||
|
out += wp.getMessage()+" - "+ChatColor.ITALIC+"Il y a "+TimeUtil.durationToString((new Date()).getTime() - wp.getDate().getTime());
|
||||||
|
|
||||||
|
sender.sendMessage(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
|||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.management.ThreadInfo;
|
import java.lang.management.ThreadInfo;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -18,11 +19,12 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class CommandSystem extends AbstractCommandExecutor {
|
public class CommandSystem extends AbstractCommandExecutor {
|
||||||
public CommandSystem()
|
public CommandSystem()
|
||||||
{
|
{
|
||||||
@ -41,7 +43,7 @@ public class CommandSystem extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (args.length > 0 && (args[0].equalsIgnoreCase("world") || args[0].equalsIgnoreCase("worlds")))
|
if (args.length > 0 && args[0].equalsIgnoreCase("world"))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (args.length > 1 && plugin.getServer().getWorld(args[1]) != null)
|
if (args.length > 1 && plugin.getServer().getWorld(args[1]) != null)
|
||||||
@ -105,7 +107,7 @@ public class CommandSystem extends AbstractCommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (args.length > 0 && (args[0].equalsIgnoreCase("thread") || args[0].equalsIgnoreCase("threads")))
|
else if (args.length > 0 && args[0].equalsIgnoreCase("thread"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -161,16 +163,6 @@ public class CommandSystem extends AbstractCommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.RED+"Erreur lors de l'exécution de la commande.");
|
sender.sendMessage(ChatColor.RED+"Erreur lors de l'exécution de la commande.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
else if (args.length > 0 && args[0].equalsIgnoreCase("tps_graph"))
|
|
||||||
{
|
|
||||||
if (!(sender instanceof ConsoleCommandSender))
|
|
||||||
sender.sendMessage("Graph envoyé sur la console");
|
|
||||||
|
|
||||||
|
|
||||||
ConsoleCommandSender console = plugin.getServer().getConsoleSender();
|
|
||||||
console.sendMessage(plugin.tpsAnalysisManager.getStringTPSHistory(20*20));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -222,4 +214,66 @@ public class CommandSystem extends AbstractCommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final List<String> FIRST_ARG = ImmutableList.of("world", "thread");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
return getTabProposalFromToken(args[0], FIRST_ARG);
|
||||||
|
}
|
||||||
|
else if (args.length > 1) {
|
||||||
|
if (args[0].equalsIgnoreCase("world"))
|
||||||
|
if (args.length == 2)
|
||||||
|
return getTabProposalFromToken(args[1], getWorldList());
|
||||||
|
if (args[0].equalsIgnoreCase("thread"))
|
||||||
|
return autosuggestThread(getLastParam(args, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PROPOSAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private List<String> getWorldList() {
|
||||||
|
List<String> worldsStr = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (World w : plugin.getServer().getWorlds())
|
||||||
|
worldsStr.add(w.getName());
|
||||||
|
|
||||||
|
return worldsStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getThreadsList() {
|
||||||
|
List<String> threadsStr = new ArrayList<String>();
|
||||||
|
|
||||||
|
ThreadInfo[] threadsInfo = ManagementFactory.getThreadMXBean().dumpAllThreads(false, false);
|
||||||
|
|
||||||
|
for (ThreadInfo th : threadsInfo)
|
||||||
|
threadsStr.add(th.getThreadName());
|
||||||
|
|
||||||
|
return threadsStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<String> autosuggestThread(String multiWordToken) {
|
||||||
|
List<String> threadsList = getTabProposalFromToken(multiWordToken, getThreadsList());
|
||||||
|
|
||||||
|
String[] wordsToken = multiWordToken.split(" ");
|
||||||
|
|
||||||
|
for (int i = 0; i<threadsList.size(); i++) {
|
||||||
|
String[] wordsProposal = threadsList.get(i).split(" ");
|
||||||
|
threadsList.set(i, getLastParam(wordsProposal, wordsToken.length-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return threadsList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
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.OnlinePlayerManager;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandTell extends AbstractCommandExecutor {
|
||||||
|
|
||||||
|
public CommandTell() {
|
||||||
|
super("tell");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||||
|
String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 0 && sender instanceof Player) {
|
||||||
|
plugin.privateMessagesManager.displayUnreadMessages((Player)sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (args.length == 0) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Seul un joueur en ligne peut lire ses messages non lus.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (args.length >= 2) {
|
||||||
|
onCommandSend(sender, args[0], getLastParam(args, 1));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void onCommandSend(CommandSender sender, String target, String message) {
|
||||||
|
|
||||||
|
if (sender instanceof Player && OnlinePlayerManager.get((Player) sender).getEssentialsUser().isMuted()) {
|
||||||
|
sender.sendMessage(ChatColor.RED+"Vous ne pouvez pas envoyer de message quand vous êtes muet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
plugin.privateMessagesManager.inputMessage(new MessageSender(sender), target, message);
|
||||||
|
} catch (MessageSendingException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MPGroupElement extends SQLElement {
|
public class MPGroupElement extends SQLElement {
|
||||||
|
|
||||||
private String groupName;
|
private String groupName;
|
||||||
@ -46,4 +49,11 @@ public class MPGroupElement extends SQLElement {
|
|||||||
groupName = name;
|
groupName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<MPGroupUserElement> getUsers() throws SQLException {
|
||||||
|
return ((MPGroupUserTable)ORM.getTable("mp_group_user"))
|
||||||
|
.getAll("groupId = "+getId(), "id ASC", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class MPGroupUserElement extends SQLElement {
|
public class MPGroupUserElement extends SQLElement {
|
||||||
|
|
||||||
private int groupId;
|
private int groupId;
|
||||||
@ -52,4 +54,17 @@ public class MPGroupUserElement extends SQLElement {
|
|||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public MPWebSessionElement getWebSessionData() throws SQLException {
|
||||||
|
return ((MPWebSessionTable)ORM.getTable("mp_web_session"))
|
||||||
|
.getFirst("playerName LIKE '"+getPlayerName()+"'", "id ASC");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.commands.AbstractCommandExecutor;
|
||||||
|
|
||||||
public class MPGroupUserTable extends SQLTable<MPGroupUserElement> {
|
public class MPGroupUserTable extends SQLTable<MPGroupUserElement> {
|
||||||
|
|
||||||
public MPGroupUserTable() throws SQLException {
|
public MPGroupUserTable() throws SQLException {
|
||||||
@ -25,4 +27,12 @@ public class MPGroupUserTable extends SQLTable<MPGroupUserElement> {
|
|||||||
sqlResult.getString("playerName"));
|
sqlResult.getString("playerName"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public MPGroupUserElement getPlayerInGroup(MPGroupElement group, String player) throws SQLException {
|
||||||
|
if (!AbstractCommandExecutor.isValidPlayerName(player))
|
||||||
|
return null;
|
||||||
|
return getFirst("groupId = "+group.getId()+" AND playerName = '"+player+"'", "id");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Représente un message dans la base de donnée<br/>
|
* Représente un message dans la base de donnée<br/>
|
||||||
* <br/>
|
* <br/>
|
||||||
@ -21,7 +23,7 @@ public class MPMessageElement extends SQLElement {
|
|||||||
private String destNick = null;
|
private String destNick = null;
|
||||||
private Integer destGroup = null;
|
private Integer destGroup = null;
|
||||||
private String message;
|
private String message;
|
||||||
private boolean read;
|
private boolean wasRead;
|
||||||
private boolean deleted = false;
|
private boolean deleted = false;
|
||||||
private boolean serverSync;
|
private boolean serverSync;
|
||||||
|
|
||||||
@ -77,7 +79,7 @@ public class MPMessageElement extends SQLElement {
|
|||||||
destNick,
|
destNick,
|
||||||
(destGroup==null)?null:destGroup.toString(),
|
(destGroup==null)?null:destGroup.toString(),
|
||||||
message,
|
message,
|
||||||
(read)?"1":"0",
|
(wasRead)?"1":"0",
|
||||||
(deleted)?"1":"0",
|
(deleted)?"1":"0",
|
||||||
(serverSync)?"1":"0"
|
(serverSync)?"1":"0"
|
||||||
};
|
};
|
||||||
@ -96,7 +98,7 @@ public class MPMessageElement extends SQLElement {
|
|||||||
"destNick",
|
"destNick",
|
||||||
"destGroup",
|
"destGroup",
|
||||||
"message",
|
"message",
|
||||||
"read",
|
"wasRead",
|
||||||
"deleted",
|
"deleted",
|
||||||
"serverSync"
|
"serverSync"
|
||||||
};
|
};
|
||||||
@ -110,7 +112,7 @@ public class MPMessageElement extends SQLElement {
|
|||||||
public String getDestNick() { return destNick; }
|
public String getDestNick() { return destNick; }
|
||||||
public Integer getDestGroup() { return destGroup; }
|
public Integer getDestGroup() { return destGroup; }
|
||||||
public String getMessage() { return message; }
|
public String getMessage() { return message; }
|
||||||
public boolean isRead() { return read; }
|
public boolean isRead() { return wasRead; }
|
||||||
public boolean isDeleted() { return deleted; }
|
public boolean isDeleted() { return deleted; }
|
||||||
public boolean isServerSync() { return serverSync; }
|
public boolean isServerSync() { return serverSync; }
|
||||||
|
|
||||||
@ -146,8 +148,18 @@ public class MPMessageElement extends SQLElement {
|
|||||||
message = msg;
|
message = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRead(boolean r) { read = r; }
|
public void setRead(boolean r) { wasRead = r; }
|
||||||
public void setDeleted(boolean del) { deleted = del; }
|
public void setDeleted(boolean del) { deleted = del; }
|
||||||
public void setServerSync(boolean sync) { serverSync = sync; }
|
public void setServerSync(boolean sync) { serverSync = sync; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public MPGroupElement getDestGroupElement() throws SQLException {
|
||||||
|
if (getDestGroup() == null) return null;
|
||||||
|
|
||||||
|
return ((MPGroupTable)ORM.getTable("mp_group")).get(getDestGroup());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.commands.AbstractCommandExecutor;
|
||||||
|
|
||||||
public class MPMessageTable extends SQLTable<MPMessageElement> {
|
public class MPMessageTable extends SQLTable<MPMessageElement> {
|
||||||
|
|
||||||
@ -19,7 +22,7 @@ public class MPMessageTable extends SQLTable<MPMessageElement> {
|
|||||||
+ "destNick VARCHAR(16) NULL,"
|
+ "destNick VARCHAR(16) NULL,"
|
||||||
+ "destGroup INT NULL,"
|
+ "destGroup INT NULL,"
|
||||||
+ "message VARCHAR(512) NOT NULL,"
|
+ "message VARCHAR(512) NOT NULL,"
|
||||||
+ "read TINYINT NOT NULL,"
|
+ "wasRead TINYINT NOT NULL,"
|
||||||
+ "deleted TINYINT NOT NULL,"
|
+ "deleted TINYINT NOT NULL,"
|
||||||
+ "serverSync TINYINT NOT NULL";
|
+ "serverSync TINYINT NOT NULL";
|
||||||
}
|
}
|
||||||
@ -34,14 +37,14 @@ public class MPMessageTable extends SQLTable<MPMessageElement> {
|
|||||||
sqlResult.getString("viewerNick"),
|
sqlResult.getString("viewerNick"),
|
||||||
sqlResult.getString("sourceNick"),
|
sqlResult.getString("sourceNick"),
|
||||||
sqlResult.getString("message"),
|
sqlResult.getString("message"),
|
||||||
sqlResult.getBoolean("read"),
|
sqlResult.getBoolean("wasRead"),
|
||||||
sqlResult.getBoolean("serverSync"));
|
sqlResult.getBoolean("serverSync"));
|
||||||
el.setDestNick(sqlResult.getString("destNick"));
|
el.setDestNick(sqlResult.getString("destNick"));
|
||||||
|
|
||||||
int group = sqlResult.getInt("destGroup");
|
int group = sqlResult.getInt("destGroup");
|
||||||
el.setDestGroup(sqlResult.wasNull()?null:group);
|
el.setDestGroup(sqlResult.wasNull()?null:group);
|
||||||
|
|
||||||
el.setDestNick(sqlResult.getString("destNick"));
|
el.setDeleted(sqlResult.getBoolean("deleted"));
|
||||||
|
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
@ -49,4 +52,18 @@ public class MPMessageTable extends SQLTable<MPMessageElement> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<MPMessageElement> getAllUnsyncMessage() throws SQLException {
|
||||||
|
return getAll("serverSync = 0", "time ASC", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<MPMessageElement> getAllUnreadForPlayer(String player) throws SQLException {
|
||||||
|
if (!AbstractCommandExecutor.isValidPlayerName(player)) return null;
|
||||||
|
|
||||||
|
return getAll("viewerNick = "+player+" AND read = 0", "time ASC", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,16 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ORM = Object-Relational Mapping
|
* <b>ORM = Object-Relational Mapping</b><br/>
|
||||||
|
* Liste des tables avec leur classes :
|
||||||
|
* <ul>
|
||||||
|
* <li><code>"modo_history" : ModoHistoryTable</code></li>
|
||||||
|
* <li><code>"staff_ticket" : StaffTicketTable</code></li>
|
||||||
|
* <li><code>"mp_message" : MPMessageTable</code></li>
|
||||||
|
* <li><code>"mp_group" : MPGroupTable</code></li>
|
||||||
|
* <li><code>"mp_group_user" : MPGroupUserTable</code></li>
|
||||||
|
* <li><code>"mp_web_session" : MPWebSessionTable</code></li>
|
||||||
|
* </ul>
|
||||||
* @author Marc Baloup
|
* @author Marc Baloup
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -24,6 +33,8 @@ public final class ORM {
|
|||||||
|
|
||||||
tables.put("modo_history", new ModoHistoryTable());
|
tables.put("modo_history", new ModoHistoryTable());
|
||||||
|
|
||||||
|
tables.put("staff_ticket", new StaffTicketTable());
|
||||||
|
|
||||||
tables.put("mp_message", new MPMessageTable());
|
tables.put("mp_message", new MPMessageTable());
|
||||||
tables.put("mp_group", new MPGroupTable());
|
tables.put("mp_group", new MPGroupTable());
|
||||||
tables.put("mp_group_user", new MPGroupUserTable());
|
tables.put("mp_group_user", new MPGroupUserTable());
|
||||||
@ -40,7 +51,12 @@ public final class ORM {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère l'instance de la classe associé à la table demandé en paramètre.<br/>
|
||||||
|
* <b>Il est conseillé de caster le retour de cette méthode par la classe associé à la table demandé.</b>
|
||||||
|
* @param name nom de la table telle qu'elle est enregistrée dans la classe ORM
|
||||||
|
* @return ta table dont le nom est passé en paramètre
|
||||||
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public synchronized static SQLTable getTable(String name) {
|
public synchronized static SQLTable getTable(String name) {
|
||||||
return tables.get(name);
|
return tables.get(name);
|
||||||
|
@ -59,6 +59,13 @@ public abstract class SQLTable<T extends SQLElement> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public T get(int id) throws SQLException {
|
public T get(int id) throws SQLException {
|
||||||
Statement stmt = db.getConnection().createStatement();
|
Statement stmt = db.getConnection().createStatement();
|
||||||
String sql = "SELECT * FROM "+tableName+" WHERE id = "+id+";";
|
String sql = "SELECT * FROM "+tableName+" WHERE id = "+id+";";
|
||||||
@ -73,11 +80,17 @@ public abstract class SQLTable<T extends SQLElement> {
|
|||||||
|
|
||||||
|
|
||||||
public List<T> getAll() throws SQLException {
|
public List<T> getAll() throws SQLException {
|
||||||
|
|
||||||
return getAll(null, null, null, null);
|
return getAll(null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public T getFirst(String where, String orderBy) throws SQLException {
|
||||||
|
List<T> elts = getAll(where, orderBy, 1, null);
|
||||||
|
return (elts.size() == 0)? null : elts.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<T> getAll(String where, String orderBy, Integer limit, Integer offset) throws SQLException {
|
public List<T> getAll(String where, String orderBy, Integer limit, Integer offset) throws SQLException {
|
||||||
Statement stmt = db.getConnection().createStatement();
|
Statement stmt = db.getConnection().createStatement();
|
||||||
String sql = "SELECT * FROM "+tableName;
|
String sql = "SELECT * FROM "+tableName;
|
||||||
|
@ -0,0 +1,104 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.NullArgumentException;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class StaffTicketElement extends SQLElement {
|
||||||
|
|
||||||
|
|
||||||
|
private String playerName;
|
||||||
|
private String message;
|
||||||
|
private long creationTime;
|
||||||
|
private String staffPlayer = null;
|
||||||
|
private String locWorld;
|
||||||
|
private double locX;
|
||||||
|
private double locY;
|
||||||
|
private double locZ;
|
||||||
|
|
||||||
|
|
||||||
|
public StaffTicketElement(String pName, String m, long creaTime, Location loc) {
|
||||||
|
super("pandacraft_staff_ticket");
|
||||||
|
setPlayerName(pName);
|
||||||
|
setMessage(m);
|
||||||
|
setCreationTime(creaTime);
|
||||||
|
setLocation(loc);
|
||||||
|
|
||||||
|
}
|
||||||
|
protected StaffTicketElement(int id, String pName, String m, long creaTime, String locW, double x, double y, double z) {
|
||||||
|
super("pandacraft_staff_ticket", id);
|
||||||
|
setPlayerName(pName);
|
||||||
|
setMessage(m);
|
||||||
|
setCreationTime(creaTime);
|
||||||
|
locWorld = locW;
|
||||||
|
locX = x;
|
||||||
|
locY = y;
|
||||||
|
locZ = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getValues() {
|
||||||
|
return new String[] {
|
||||||
|
playerName,
|
||||||
|
message,
|
||||||
|
Long.toString(creationTime),
|
||||||
|
staffPlayer,
|
||||||
|
locWorld,
|
||||||
|
Double.toString(locX),
|
||||||
|
Double.toString(locY),
|
||||||
|
Double.toString(locZ)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getFieldsName() {
|
||||||
|
return new String[] {
|
||||||
|
"playerName",
|
||||||
|
"message",
|
||||||
|
"creationTime",
|
||||||
|
"staffPlayer",
|
||||||
|
"locWorld",
|
||||||
|
"locX",
|
||||||
|
"locY",
|
||||||
|
"locZ"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public String getPlayerName() {
|
||||||
|
return playerName;
|
||||||
|
}
|
||||||
|
public void setPlayerName(String playerName) {
|
||||||
|
if (playerName == null) throw new NullArgumentException("playerName");
|
||||||
|
this.playerName = playerName;
|
||||||
|
}
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
public void setMessage(String message) {
|
||||||
|
if (message == null) throw new NullArgumentException("message");
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
public long getCreationTime() {
|
||||||
|
return creationTime;
|
||||||
|
}
|
||||||
|
public void setCreationTime(long creationTime) {
|
||||||
|
this.creationTime = creationTime;
|
||||||
|
}
|
||||||
|
public String getStaffPlayer() {
|
||||||
|
return staffPlayer;
|
||||||
|
}
|
||||||
|
public void setStaffPlayer(String staffPlayer) {
|
||||||
|
this.staffPlayer = staffPlayer;
|
||||||
|
}
|
||||||
|
public Location getLocation() {
|
||||||
|
return new Location(Bukkit.getWorld(locWorld), locX, locY, locZ);
|
||||||
|
}
|
||||||
|
public void setLocation(Location loc) {
|
||||||
|
if (loc == null) throw new NullArgumentException("loc");
|
||||||
|
locWorld = loc.getWorld().getName();
|
||||||
|
locX = loc.getX();
|
||||||
|
locY = loc.getY();
|
||||||
|
locZ = loc.getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class StaffTicketTable extends SQLTable<StaffTicketElement> {
|
||||||
|
|
||||||
|
|
||||||
|
public StaffTicketTable() throws SQLException {
|
||||||
|
super("pandacraft_staff_ticket");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String createTableParameters() {
|
||||||
|
return "id INT AUTO_INCREMENT PRIMARY KEY,"
|
||||||
|
+ "playerName VARCHAR(16) NOT NULL,"
|
||||||
|
+ "message VARCHAR(1024) NOT NULL,"
|
||||||
|
+ "creationTime BIGINT NOT NULL,"
|
||||||
|
+ "staffPlayer VARCHAR(16) NULL,"
|
||||||
|
+ "locWorld VARCHAR(64) NOT NULL,"
|
||||||
|
+ "locX DOUBLE NOT NULL,"
|
||||||
|
+ "locY DOUBLE NOT NULL,"
|
||||||
|
+ "locZ DOUBLE NOT NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StaffTicketElement getElementInstance(ResultSet sqlResult)
|
||||||
|
throws SQLException {
|
||||||
|
StaffTicketElement el = new StaffTicketElement(
|
||||||
|
sqlResult.getInt("id"),
|
||||||
|
sqlResult.getString("playerName"),
|
||||||
|
sqlResult.getString("message"),
|
||||||
|
sqlResult.getLong("creationTime"),
|
||||||
|
sqlResult.getString("locWorld"),
|
||||||
|
sqlResult.getDouble("locX"),
|
||||||
|
sqlResult.getDouble("locY"),
|
||||||
|
sqlResult.getDouble("locZ"));
|
||||||
|
el.setStaffPlayer(sqlResult.getString("staffPlayer"));
|
||||||
|
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,409 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import mkremins.fanciful.FancyMessage;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.commands.AbstractCommandExecutor;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.MPGroupElement;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.MPGroupTable;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.MPGroupUserElement;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.MPGroupUserTable;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.MPMessageElement;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.MPMessageTable;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.ORM;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class PrivateMessagesManager extends BukkitRunnable {
|
||||||
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public PrivateMessagesManager()
|
||||||
|
{
|
||||||
|
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 2L, 10L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
// récupération des messages non synchronisé :
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<MPMessageElement> messages = ((MPMessageTable)ORM.getTable("mp_message")).getAllUnsyncMessage();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (MPMessageElement message : messages) {
|
||||||
|
if (message.getViewerNick().equals(message.getSourceNick()))
|
||||||
|
tryDisplayMessageToConsole(message);
|
||||||
|
|
||||||
|
tryDisplayMessage(message);
|
||||||
|
|
||||||
|
message.setServerSync(true);
|
||||||
|
message.save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
plugin.getLogger().severe("Impossible de récupérer les messages privés de la base de donnée");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sender l'origine du message
|
||||||
|
* @param message le message
|
||||||
|
* @throws MessageSendingException
|
||||||
|
*/
|
||||||
|
public void respondMessage(MessageSender sender, String message) throws MessageSendingException {
|
||||||
|
OnlinePlayer op = OnlinePlayerManager.get(Bukkit.getPlayer(sender.senderName));
|
||||||
|
if (op.getLastMessageTarget() == null)
|
||||||
|
throw new MessageSendingException("Vous n'avez pas encore envoyé de message. Utilisez /msg");
|
||||||
|
inputMessage(sender, op.getLastMessageTarget(), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sender l'origine du message
|
||||||
|
* @param dest pseudo du destinataire ou "g:" suivi du nom du groupe destinataire (insensible à la casse)
|
||||||
|
* @param message le message
|
||||||
|
* @throws MessageSendingException
|
||||||
|
*/
|
||||||
|
public void inputMessage(MessageSender sender, String dest, String message) throws MessageSendingException {
|
||||||
|
if (dest.startsWith("g:") || dest.startsWith("G:")) {
|
||||||
|
// groupe
|
||||||
|
String groupe = dest.substring(2);
|
||||||
|
|
||||||
|
if (!AbstractCommandExecutor.isValidPlayerName(groupe))
|
||||||
|
throw new MessageSendingException("Le nom du groupe n'est pas valide (lettres, chiffres, §7_§r et entre 2 et 16 caractères)");
|
||||||
|
|
||||||
|
MPGroupElement groupEl = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
groupEl = ((MPGroupTable)ORM.getTable("mp_group")).getFirst("groupName LIKE '"+groupe+ "'", "id");
|
||||||
|
|
||||||
|
if (groupEl == null)
|
||||||
|
throw new MessageSendingException("Ce groupe n'existe pas");
|
||||||
|
|
||||||
|
// on vérifie si le joueur source est dans le groupe
|
||||||
|
if (sender.isPlayer()) {
|
||||||
|
MPGroupUserElement userInGroup = ((MPGroupUserTable)ORM.getTable("mp_group_user")).getPlayerInGroup(groupEl, sender.senderName);
|
||||||
|
|
||||||
|
if (userInGroup == null)
|
||||||
|
throw new MessageSendingException("Vous n'êtes pas dans ce groupe");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<MPGroupUserElement> groupUsers = groupEl.getUsers();
|
||||||
|
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
int secKey = new Random().nextInt();
|
||||||
|
|
||||||
|
for (MPGroupUserElement userInGroup : groupUsers) {
|
||||||
|
MPMessageElement messEl = new MPMessageElement(time, secKey, userInGroup.getPlayerName(), sender.senderName, message, (userInGroup.getPlayerName().equalsIgnoreCase(sender.senderName)), true);
|
||||||
|
messEl.setDestGroup(groupEl.getId());
|
||||||
|
messEl.save();
|
||||||
|
tryDisplayMessage(messEl);
|
||||||
|
if (userInGroup.getPlayerName().equalsIgnoreCase(sender.senderName))
|
||||||
|
tryDisplayMessageToConsole(messEl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender.isPlayer())
|
||||||
|
OnlinePlayerManager.get(plugin.getServer().getPlayer(sender.senderName)).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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// joueur
|
||||||
|
OffPlayer offP = new OffPlayer(dest);
|
||||||
|
if (offP.getBukkitOfflinePlayer() == null) {
|
||||||
|
throw new MessageSendingException("Le joueur n'a jamais existé");
|
||||||
|
}
|
||||||
|
|
||||||
|
String destUserName = offP.getCastCorrectedName();
|
||||||
|
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
int secKey = new Random().nextInt();
|
||||||
|
|
||||||
|
|
||||||
|
if (sender.isPlayer()) {
|
||||||
|
MPMessageElement el = new MPMessageElement(time, secKey, sender.senderName, sender.senderName, message, true, true);
|
||||||
|
el.setDestNick(destUserName);
|
||||||
|
el.save();
|
||||||
|
tryDisplayMessage(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
MPMessageElement elCible = new MPMessageElement(time, secKey, destUserName, sender.senderName, message, true, true);
|
||||||
|
elCible.setDestNick(destUserName);
|
||||||
|
elCible.save();
|
||||||
|
tryDisplayMessage(elCible);
|
||||||
|
|
||||||
|
|
||||||
|
tryDisplayMessageToConsole(elCible);
|
||||||
|
|
||||||
|
if (sender.isPlayer())
|
||||||
|
OnlinePlayerManager.get(plugin.getServer().getPlayer(sender.senderName)).setLastMessageTarget(destUserName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param player le joueur qui veut voir ses messages non lus
|
||||||
|
* @return vrai si le joueur a bien des messages non lu, faux sinon. Retourne vrai en cas d'erreur lors de la récupération des messages
|
||||||
|
*/
|
||||||
|
public boolean displayUnreadMessages(Player player) {
|
||||||
|
try {
|
||||||
|
List<MPMessageElement> messages = ((MPMessageTable)ORM.getTable("mp_message")).getAllUnreadForPlayer(player.getName());
|
||||||
|
if (messages.size() == 0) {
|
||||||
|
player.sendMessage(ChatColor.GRAY+"Vous n'avez pas de messages non lus");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(MPMessageElement mess : messages)
|
||||||
|
tryDisplayMessage(mess);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
player.sendMessage(ChatColor.RED+"Impossible de lire les messages non lus");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tente d'afficher le message dans le cas où le joueur cible est en ligne. Si ce
|
||||||
|
* joueur est en ligne, le message est marqué comme lu. Si le joueur cible ignore
|
||||||
|
* la source du message, la copie du message est supprimé de la base.
|
||||||
|
* @param message le message à afficher
|
||||||
|
*/
|
||||||
|
private void tryDisplayMessage(MPMessageElement message) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
OnlinePlayer op = OnlinePlayerManager.get(new OffPlayer(message.getViewerNick()).getBukkitOnlinePlayer());
|
||||||
|
|
||||||
|
if (op == null) return; // la cible n'est pas en ligne
|
||||||
|
|
||||||
|
MessageSender sender = new MessageSender(message.getSourceNick());
|
||||||
|
|
||||||
|
boolean isIgnoring = sender.isPlayer() && op.getEssentialsUser().isIgnoredPlayer(new OffPlayer(message.getSourceNick()).getEssentialsUser());
|
||||||
|
|
||||||
|
|
||||||
|
if (isIgnoring) {
|
||||||
|
message.delete();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message.setRead(true);
|
||||||
|
message.save();
|
||||||
|
|
||||||
|
// le message est affiché sur l'écran de la source du message
|
||||||
|
boolean dispToSender = (message.getViewerNick().equalsIgnoreCase(message.getSourceNick()));
|
||||||
|
|
||||||
|
|
||||||
|
Date d = new Date(message.getTime());
|
||||||
|
DateFormat date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRANCE);
|
||||||
|
DateFormat hour = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.FRANCE);
|
||||||
|
|
||||||
|
String affDate = date.format(d) + " à " + hour.format(d);
|
||||||
|
|
||||||
|
|
||||||
|
List<String> tooltipLines = Arrays.asList(new String[] {
|
||||||
|
ChatColor.GRAY+"(Cliquez pour répondre)",
|
||||||
|
ChatColor.GRAY+affDate,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (dispToSender) {
|
||||||
|
|
||||||
|
String destAff = (message.getDestGroup() == null)?
|
||||||
|
new OffPlayer(message.getDestNick()).getDisplayName():
|
||||||
|
"g:"+message.getDestGroupElement().getGroupName();
|
||||||
|
|
||||||
|
String destCommand = (message.getDestGroup() == null)?
|
||||||
|
message.getDestNick():
|
||||||
|
"g:"+message.getDestGroupElement().getGroupName();
|
||||||
|
|
||||||
|
|
||||||
|
new FancyMessage()
|
||||||
|
.then("§6<§rmoi§6 → §r"+destAff+"§r§6>")
|
||||||
|
.suggest("/m "+destCommand+" ")
|
||||||
|
.tooltip(tooltipLines)
|
||||||
|
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()))
|
||||||
|
.send(op.getPlayer());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
|
||||||
|
String senderAff = new MessageSender(message.getSourceNick()).getDisplayName();
|
||||||
|
|
||||||
|
|
||||||
|
String destAff = (message.getDestGroup() == null)?
|
||||||
|
((message.getDestNick().equalsIgnoreCase(message.getViewerNick()))?
|
||||||
|
"moi":
|
||||||
|
new OffPlayer(message.getDestNick()).getDisplayName()):
|
||||||
|
"g:"+message.getDestGroupElement().getGroupName();
|
||||||
|
|
||||||
|
String destCommand = (message.getDestGroup() == null)?
|
||||||
|
message.getSourceNick():
|
||||||
|
"g:"+message.getDestGroupElement().getGroupName();
|
||||||
|
|
||||||
|
|
||||||
|
new FancyMessage()
|
||||||
|
.then("§6<§r"+senderAff+"§r§6 → §r"+destAff+"§r§6>")
|
||||||
|
.suggest("/m "+destCommand+" ")
|
||||||
|
.tooltip(tooltipLines)
|
||||||
|
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()))
|
||||||
|
.send(op.getPlayer());
|
||||||
|
|
||||||
|
// op.getPlayer().playSound(op.getPlayer().getLocation(), Sound.ORB_PICKUP, 1, 0.3F);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
plugin.getLogger().severe("Impossible d'afficher un message");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void tryDisplayMessageToConsole(MPMessageElement message) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
String senderAff = new MessageSender(message.getSourceNick()).getDisplayName();
|
||||||
|
|
||||||
|
|
||||||
|
String destAff = (message.getDestGroup() == null)?
|
||||||
|
new OffPlayer(message.getDestNick()).getDisplayName():
|
||||||
|
"g:"+message.getDestGroupElement().getGroupName();
|
||||||
|
|
||||||
|
|
||||||
|
plugin.getServer().getConsoleSender().sendMessage("§6<§r"+senderAff+"§r§6 → §r"+destAff+"§r§6> §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()));
|
||||||
|
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
plugin.getLogger().severe("Impossible d'afficher un message");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static class MessageSender {
|
||||||
|
public final String senderName;
|
||||||
|
|
||||||
|
|
||||||
|
public MessageSender(String pName) {
|
||||||
|
senderName = pName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageSender() {
|
||||||
|
this((String)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageSender(OffPlayer p) {
|
||||||
|
this(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageSender(CommandSender sender) {
|
||||||
|
this((sender instanceof Player)?sender.getName():null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayer() {
|
||||||
|
return senderName != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
if (isPlayer())
|
||||||
|
return new OffPlayer(senderName).getDisplayName();
|
||||||
|
else
|
||||||
|
return ChatColor.GOLD+"Système"+ChatColor.RESET;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class MessageSendingException extends Exception {
|
||||||
|
private MessageSendingException(String mess) {
|
||||||
|
super(mess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -68,19 +68,5 @@ public class TPSAnalysisManager implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getStringTPSHistory(int nb_tick)
|
|
||||||
{
|
|
||||||
double[] history = getTPSHistory(nb_tick);
|
|
||||||
String s = "{MineAdmin_Graph}{";
|
|
||||||
boolean first = true;
|
|
||||||
for(double d : history)
|
|
||||||
{
|
|
||||||
if (first) first = false; else s = s.concat(",");
|
|
||||||
s = s.concat((Math.round(d*100)/100D)+"");
|
|
||||||
}
|
|
||||||
|
|
||||||
s = s.concat("}");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.staff;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.staff;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.ORM;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.StaffTicketElement;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.StaffTicketTable;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
import net.mc_pandacraft.java.util.ScoreBoardUtil;
|
import net.mc_pandacraft.java.util.ScoreBoardUtil;
|
||||||
import net.mc_pandacraft.java.util.TimeUtil;
|
import net.mc_pandacraft.java.util.TimeUtil;
|
||||||
@ -31,6 +36,26 @@ public class StaffQueueManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public StaffQueueManager() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
StaffTicketTable dbTable = (StaffTicketTable) ORM.getTable("staff_ticket");
|
||||||
|
|
||||||
|
List<StaffTicketElement> elmts = dbTable.getAll(null, "creationTime ASC, id ASC", null, null);
|
||||||
|
|
||||||
|
for (StaffTicketElement el : elmts)
|
||||||
|
playerQueue.add(new WaitingPlayer(el));
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateScoreBoardWaitingList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// le joueur ajouté doit-être en ligne
|
// le joueur ajouté doit-être en ligne
|
||||||
public void addWaitingPlayer(Player p, String m) {
|
public void addWaitingPlayer(Player p, String m) {
|
||||||
@ -78,6 +103,7 @@ public class StaffQueueManager {
|
|||||||
if (wp != null)
|
if (wp != null)
|
||||||
{
|
{
|
||||||
playerQueue.remove(wp);
|
playerQueue.remove(wp);
|
||||||
|
wp.deleteFromDB();
|
||||||
updateScoreBoardWaitingList();
|
updateScoreBoardWaitingList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,6 +200,19 @@ public class StaffQueueManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<String> getWaitingPlayerNames() {
|
||||||
|
List<String> l = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (WaitingPlayer wp : playerQueue) {
|
||||||
|
l.add(wp.getPlayerName());
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -226,16 +265,36 @@ public class StaffQueueManager {
|
|||||||
|
|
||||||
private String player;
|
private String player;
|
||||||
private String message;
|
private String message;
|
||||||
private Date creationDate = new Date();
|
private Date creationDate;
|
||||||
private Location location; // localisation du joueur au moment où il fait /staff
|
private Location location; // localisation du joueur au moment où il fait /staff
|
||||||
private String staffPlayer = null;
|
private String staffPlayer = null;
|
||||||
|
|
||||||
|
private int dbId;
|
||||||
|
|
||||||
|
|
||||||
public WaitingPlayer(String p, String m, Location l) {
|
public WaitingPlayer(String p, String m, Location l) {
|
||||||
|
|
||||||
player = p;
|
player = p;
|
||||||
message = m;
|
message = m;
|
||||||
|
creationDate = new Date();
|
||||||
location = l;
|
location = l;
|
||||||
|
|
||||||
|
StaffTicketElement dbEl = new StaffTicketElement(p, m, creationDate.getTime(), l);
|
||||||
|
dbEl.save();
|
||||||
|
|
||||||
|
dbId = dbEl.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private WaitingPlayer(StaffTicketElement dbEl) {
|
||||||
|
|
||||||
|
player = dbEl.getPlayerName();
|
||||||
|
message = dbEl.getMessage();
|
||||||
|
creationDate = new Date(dbEl.getCreationTime());
|
||||||
|
location = dbEl.getLocation();
|
||||||
|
|
||||||
|
staffPlayer = dbEl.getStaffPlayer();
|
||||||
|
|
||||||
|
dbId = dbEl.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -258,6 +317,21 @@ public class StaffQueueManager {
|
|||||||
|
|
||||||
public String getMessage() { return message; }
|
public String getMessage() { return message; }
|
||||||
|
|
||||||
|
public void setMessage(String m) {
|
||||||
|
if (m == null) return;
|
||||||
|
message = m;
|
||||||
|
|
||||||
|
try {
|
||||||
|
StaffTicketElement el = ((StaffTicketTable)ORM.getTable("staff_ticket")).get(dbId);
|
||||||
|
|
||||||
|
el.setMessage(message);
|
||||||
|
el.save();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Date getDate() { return creationDate; }
|
public Date getDate() { return creationDate; }
|
||||||
|
|
||||||
public Location getLocation() { return location; }
|
public Location getLocation() { return location; }
|
||||||
@ -265,8 +339,26 @@ public class StaffQueueManager {
|
|||||||
public void setStaffPlayer(Player p) {
|
public void setStaffPlayer(Player p) {
|
||||||
if (p == null) staffPlayer = null;
|
if (p == null) staffPlayer = null;
|
||||||
else staffPlayer = p.getName();
|
else staffPlayer = p.getName();
|
||||||
|
|
||||||
|
try {
|
||||||
|
StaffTicketElement el = ((StaffTicketTable)ORM.getTable("staff_ticket")).get(dbId);
|
||||||
|
|
||||||
|
el.setStaffPlayer(staffPlayer);
|
||||||
|
el.save();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
updateScoreBoardWaitingList();
|
updateScoreBoardWaitingList();
|
||||||
}
|
}
|
||||||
public String getStaffPlayerName() { return staffPlayer; }
|
public String getStaffPlayerName() { return staffPlayer; }
|
||||||
|
|
||||||
|
public void deleteFromDB() {
|
||||||
|
try {
|
||||||
|
((StaffTicketTable)ORM.getTable("staff_ticket")).get(dbId).delete();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,10 @@ public class OffPlayer {
|
|||||||
return playerName;
|
return playerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCastCorrectedName() {
|
||||||
|
return getEssentialsUser().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,6 +313,26 @@ public class OnlinePlayer extends OffPlayer {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String lastMessageTarget = null;
|
||||||
|
|
||||||
|
public String getLastMessageTarget() { return lastMessageTarget; }
|
||||||
|
|
||||||
|
public void setLastMessageTarget(String messTarget) {
|
||||||
|
lastMessageTarget = messTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utils
|
* Utils
|
||||||
*/
|
*/
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.players;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.players;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
@ -78,7 +79,7 @@ public final class OnlinePlayerManager {
|
|||||||
return getInstance().players.get(p);
|
return getInstance().players.get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static Collection<OnlinePlayer> getAll() {
|
public synchronized static List<OnlinePlayer> getAll() {
|
||||||
return new ArrayList<OnlinePlayer>(getInstance().players.values());
|
return new ArrayList<OnlinePlayer>(getInstance().players.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +88,8 @@ public final class OnlinePlayerManager {
|
|||||||
return getInstance().players.containsKey(p);
|
return getInstance().players.containsKey(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<OnlinePlayer> getAllNotVanished() {
|
public static List<OnlinePlayer> getAllNotVanished() {
|
||||||
Collection<OnlinePlayer> players = getAll();
|
List<OnlinePlayer> players = getAll();
|
||||||
|
|
||||||
for (OnlinePlayer op : players.toArray(new OnlinePlayer[players.size()])) {
|
for (OnlinePlayer op : players.toArray(new OnlinePlayer[players.size()])) {
|
||||||
if (op.isVanished())
|
if (op.isVanished())
|
||||||
@ -98,4 +99,31 @@ public final class OnlinePlayerManager {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<String> getNamesOnlyVisible(Player p) {
|
||||||
|
List<OnlinePlayer> players = getAll();
|
||||||
|
List<String> playerList = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (OnlinePlayer op : players)
|
||||||
|
if (p == null || p.canSee(op.getPlayer()))
|
||||||
|
playerList.add(op.getName());
|
||||||
|
|
||||||
|
return playerList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static class OnlinePlayerOrderer implements Comparator<OnlinePlayer> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(OnlinePlayer arg0, OnlinePlayer arg1) {
|
||||||
|
return arg0.getName().compareToIgnoreCase(arg1.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user