Ajout d'une commande pour voir les messages automatiques, manuellement
This commit is contained in:
parent
b917f40f6d
commit
f95a459bde
@ -60,6 +60,11 @@ commands:
|
||||
usage: /broadcastperm <permission> <message>
|
||||
permission: pandacraft.broadcast
|
||||
aliases: [bcperm, bcastperm, shoutperm]
|
||||
automessager:
|
||||
description: Afficher un des messages automatique
|
||||
usage: /automessager [id]
|
||||
permission: pandacraft.automessager
|
||||
aliases: [am]
|
||||
|
||||
|
||||
|
||||
@ -130,6 +135,11 @@ permissions:
|
||||
pandacraft.broadcast:
|
||||
description: Utiliser la commande broadcast et broadcastperm
|
||||
default: op
|
||||
|
||||
# à ajouter ######################
|
||||
pandacraft.automessager:
|
||||
description: Utiliser la commande automessager
|
||||
default: op
|
||||
|
||||
|
||||
pandacraft.antispam.exempt:
|
||||
|
@ -0,0 +1,53 @@
|
||||
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.AutoMessagesManager.AutoMessage;
|
||||
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 CommandAutomessager extends AbstractCommandExecutor {
|
||||
|
||||
public CommandAutomessager() {
|
||||
super("automessager");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
||||
String[] args) {
|
||||
|
||||
List<AutoMessage> messages = plugin.autoMessagesManager.getMessagesFromConfig();
|
||||
|
||||
if (args.length == 0 || !(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.GOLD+"Il y a "+messages.size()+" messages (de 0 à "+(messages.size()-1)+")");
|
||||
return true;
|
||||
}
|
||||
|
||||
int id;
|
||||
try {
|
||||
id = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage("§cLa valeur indiquée doit être un chiffre");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id < 0 || id >= messages.size()) {
|
||||
sender.sendMessage("§cLe message numéro "+id+" n'existe pas");
|
||||
return false;
|
||||
}
|
||||
|
||||
OnlinePlayerManager
|
||||
.getInstance()
|
||||
.get((Player)sender)
|
||||
.sendMessageFromServer(messages.get(id).getMessage());
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,7 @@ public class AutoMessagesManager extends BukkitRunnable {
|
||||
|
||||
public AutoMessagesManager()
|
||||
{
|
||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, this, 0L, 20L);
|
||||
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 0L, 20L);
|
||||
}
|
||||
|
||||
|
||||
@ -54,6 +54,8 @@ public class AutoMessagesManager extends BukkitRunnable {
|
||||
int id = op.getAutomessage_last_message_id();
|
||||
boolean atLeastOnePermitted = true;
|
||||
int c = 0;
|
||||
|
||||
// on cherche le prochain message à afficher
|
||||
do {
|
||||
id++;
|
||||
c++;
|
||||
|
Loading…
Reference in New Issue
Block a user