Bonjour, depuis pas très longtemps, j'essaie de créer un plugin minecraft mais une de mes commandes (broadcast) ne marche pas voici mon code:
package fr.stylebleu.terraiaplug.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandTest implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String msg, String[] args) {
if(sender instanceof Player){
Player player = (Player)sender;
if(cmd.getName().equalsIgnoreCase("bc")) {
// /bc --> No args
if(args.length == 0){
player.sendMessage("Erreur: Vous n'avez pas donné d'arguments! --> /bc [arguments]");
}
// /bc --> With args
if(args.length >= 1){
StringBuilder bc = new StringBuilder();
for(String part : args){
bc.append(part + " ");
}
Bukkit.broadcastMessage(" §6[§eBROADCAST§6] §e" + player.getName() + " §6: §f" + bc.toString());
}
return true;
}
}
return false;
}
}
package fr.stylebleu.terraiaplug.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandTest implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String msg, String[] args) {
if(sender instanceof Player){
Player player = (Player)sender;
if(cmd.getName().equalsIgnoreCase("bc")) {
// /bc --> No args
if(args.length == 0){
player.sendMessage("Erreur: Vous n'avez pas donné d'arguments! --> /bc [arguments]");
}
// /bc --> With args
if(args.length >= 1){
StringBuilder bc = new StringBuilder();
for(String part : args){
bc.append(part + " ");
}
Bukkit.broadcastMessage(" §6[§eBROADCAST§6] §e" + player.getName() + " §6: §f" + bc.toString());
}
return true;
}
}
return false;
}
}