Hello all, I am trying to create a 'Broadcasting' plugin for my server. It is identical to the bukkit /say, but I want to remove the [Server]. I am trying to make a stringBuilder that will save what the player says that is announcer and out put that via Bukkit.broadcastMessage(str); EX: /announce Hi Output: Hi EDIT: Needs to be accessible via console! public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String args) { Player player = (Player) sender; if(!player.hasPermission("vannounce.announce")) { returntrue; } if(cmd.getName().equalsIgnoreCase("announce")) { Bukkit.broadcast(args, "vannounce.announce"); }
Code: if(args.length>0){ String message = ""; for(String word : args){ message+=word+" "; } Bukkit.broadcastMessage(message.trim()); return true; }
'Args' in the for is erroring: cannot iterate: Update: if(!player.hasPermission("vannounce.announce")) { returntrue; } if(cmd.getName().equalsIgnoreCase("announce")) { if(args.length()>0){ String message = ""; for(String word : args){ message+=word+" "; } Bukkit.broadcastMessage(message.trim()); returntrue; } bump EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Use String message = args.toString(); On iPod, can't check. You have to make String[] a String. Edit: I think args should be a String[], but not sure.