From 0e00b9f660847cc3b2e004344ea604aca166136e Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Tue, 23 Dec 2014 15:48:07 +0100 Subject: [PATCH] Correction de bug de la file d'attente /staff --- .gitignore | 4 +- make_jar.jardesc | 2 +- resources/plugin.yml | 2 +- .../pandacraftutils/PandacraftUtils.java | 3 ++ .../staff_player_help/CommandStaff.java | 43 ++++++++++--------- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 1d23e8e..c61b191 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -bin/* -jar_export/* +/bin/ +/jar_export/ *Thumbs.db diff --git a/make_jar.jardesc b/make_jar.jardesc index 1628ba4..548fd15 100644 --- a/make_jar.jardesc +++ b/make_jar.jardesc @@ -1,6 +1,6 @@ - + diff --git a/resources/plugin.yml b/resources/plugin.yml index 4eecef6..678c557 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: PandacraftUtils main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils -version: 2.4 +version: 2.5 diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java index 40b5345..8d14410 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java @@ -12,6 +12,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.me.CommandM import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.ping.CommandPing; import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.setblock.CommandSetblock; import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.speed_message.CommandSpeedMessage; +import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.staff_player_help.CommandStaff; import net.mc_pandacraft.java.plugin.pandacraftutils.spawntime.SpawnTimeManager; import net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid.CommandWandSelection; import net.mc_pandacraft.java.plugin.pandacraftutils.system_analyzer.CommandSystem; @@ -28,6 +29,7 @@ public class PandacraftUtils extends JavaPlugin { public CommandMe commandMe; public CommandSpeedMessage commandSpeedMessage; public CommandWandSelection commandWandSelection; + public CommandStaff commandStaff; public SpawnTimeManager spawnTimeManager; @@ -53,6 +55,7 @@ public class PandacraftUtils extends JavaPlugin { commandMe = new CommandMe(this); commandSpeedMessage = new CommandSpeedMessage(this); // messages rapides commandWandSelection = new CommandWandSelection(this); + commandStaff = new CommandStaff(this); spawnTimeManager = new SpawnTimeManager(this); chatAnalysisManager = new ChatAnalysisManager(this); diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/simple_commands/staff_player_help/CommandStaff.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/simple_commands/staff_player_help/CommandStaff.java index d3c2172..ff8a1b9 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/simple_commands/staff_player_help/CommandStaff.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/simple_commands/staff_player_help/CommandStaff.java @@ -7,6 +7,7 @@ import java.util.Queue; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import net.mc_pandacraft.java.util.TimeUtil; +import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -82,7 +83,7 @@ public class CommandStaff implements CommandExecutor, Listener { return true; } - playerQueue.add(new WaitingPlayer(((Player)sender).getName(), String.join(" ", args), ((Player)sender).getLocation())); + playerQueue.add(new WaitingPlayer(((Player)sender).getName(), StringUtils.join(args, " "), ((Player)sender).getLocation())); updateScoreBoardWaitingList(); 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 "+getPlayerPosition((Player)sender)+" de la file d'attente"); @@ -156,9 +157,9 @@ public class CommandStaff implements CommandExecutor, Listener { ((Player)sender).teleport(p.getLocation()); sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------"); - sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------"); + p.sendMessage(ChatColor.GREEN+"-----------------------------------------------"); p.sendMessage(((Player)sender).getDisplayName()+ChatColor.RESET+ChatColor.GREEN+" s'occupe maintenant de vous :)"); - sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------"); + p.sendMessage(ChatColor.GREEN+"-----------------------------------------------"); } else { @@ -168,10 +169,6 @@ public class CommandStaff implements CommandExecutor, Listener { 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+"-----------------------------------------------"); - - sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------"); - p.sendMessage(((Player)sender).getDisplayName()+ChatColor.RESET+ChatColor.GREEN+" s'occupe maintenant de vous :)"); - sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------"); return true; } @@ -223,7 +220,7 @@ public class CommandStaff implements CommandExecutor, Listener { // - 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 = String.join(" ", args); + String message = StringUtils.join(args, " "); playerQueue.add(new WaitingPlayer(p.getName(),message, p.getLocation())); @@ -235,6 +232,7 @@ public class CommandStaff implements CommandExecutor, Listener { p.sendMessage(ChatColor.GREEN+sender.getName()+" vous a ajouté dans la file d'attente pour traiter votre demande plus tard"); return true; } + sender.sendMessage(ChatColor.RED+"La commande a mal été tapé"); return false; } @@ -274,9 +272,9 @@ public class CommandStaff implements CommandExecutor, Listener { int i = 0; for (WaitingPlayer wp : playerQueue) { + i++; if (wp != null && wp.getPlayerName().equalsIgnoreCase(p.getName())) return i; - i++; } return -1; } @@ -300,7 +298,7 @@ public class CommandStaff implements CommandExecutor, Listener { private void showWaintingList(CommandSender sender) { - sender.sendMessage(ChatColor.BOLD+"----- File d'attente des joueurs pour le staff -----"); + sender.sendMessage(ChatColor.BOLD+"-- File d'attente des joueurs pour le staff --"); int i=0; for (WaitingPlayer wp : playerQueue) { @@ -315,7 +313,7 @@ public class CommandStaff implements CommandExecutor, Listener { sender.sendMessage(i+". "+name+ChatColor.RESET+" : "+wp.getMessage()+" - " +ChatColor.ITALIC+"Il y a "+TimeUtil.durationToString((new Date()).getTime() - wp.getDate().getTime())); } - sender.sendMessage(ChatColor.BOLD+"-----------------------------------------------"); + sender.sendMessage(ChatColor.BOLD+"-------------------------------------------"); } @@ -331,9 +329,10 @@ public class CommandStaff implements CommandExecutor, Listener { if (obj != null) obj.unregister(); + obj = scoreboardPlayerQueue.registerNewObjective("file_attente", "dummy"); - obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(ChatColor.GOLD+"File d'attente staff"); + obj.setDisplaySlot(DisplaySlot.SIDEBAR); int i=0; for (WaitingPlayer wp : playerQueue) { @@ -344,18 +343,16 @@ public class CommandStaff implements CommandExecutor, Listener { if (p == null || !p.isOnline()) name = wp.getPlayerName(); else - name = p.getDisplayName(); + name = p.getPlayerListName(); - String line = i+". "+name; - int boardPos = playerQueue.size()-i; + String line = i+"."+name; + int boardPos = playerQueue.size()-i+1; - Score score = obj.getScore(plugin.getServer().getOfflinePlayer(line)); + Score score = obj.getScore(plugin.getServer().getOfflinePlayer(line.substring(0, (line.length()>16)?16:line.length()))); score.setScore(boardPos); } - - } @@ -375,13 +372,17 @@ public class CommandStaff implements CommandExecutor, Listener { Player p = event.getPlayer(); if (p.hasPermission("pandacraft.grade.staff")) p.setScoreboard(scoreboardPlayerQueue); - updateScoreBoardWaitingList(); + plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { + @Override public void run() { updateScoreBoardWaitingList(); } + }, 2L); + } @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - // lancer l'update un ou deux tick plus tard si ça ne marche pas comme ça - updateScoreBoardWaitingList(); + plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { + @Override public void run() { updateScoreBoardWaitingList(); } + }, 2L); }