My /announce command only broadcasts 1st argument, rather than all of them.
For more clarity: If you type /broadcast I love apples
it should broadcast "I love apples", but it only broadcasts "i"
I've tried a lot of different code but never seemed to get it right. I can't post my old code here as it's very much overwritten into oblivion.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(command.getName().equalsIgnoreCase("announce")){
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length < 1) {
player.sendMessage(ChatColor.DARK_RED + "Usage: /announce <text>");
return true;
} else if(args.length >= 1) {
String logToChat = args[0];
Bukkit.broadcastMessage(logToChat);
}
The output should be the text after the /announce command. Due to my poor programming skills, it only detects the 1st word (as an argument) and prints that word only.