|
|
|
@@ -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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|