Need Help, SHOULD be simple :)

Discussion in 'Plugin Development' started by iiHeroo, Oct 7, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    iiHeroo

    Code:java
    1. package org.horrgs.me;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10. import org.bukkit.ChatColor;
    11.  
    12. public class Broadcast extends JavaPlugin {
    13.  
    14. public final Logger logger = Logger.getLogger("Minecraft");
    15. public static Broadcast plugin;
    16.  
    17. @Override
    18. public void onDisable() {
    19. }
    20.  
    21. @Override
    22. public void onEnable() {
    23. getConfig();
    24. saveDefaultConfig();
    25. }
    26.  
    27. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    28. Player player = (Player) sender;
    29. if(cmd.getName().equalsIgnoreCase("zbroadcast"))
    30. if(sender instanceof Player) {
    31. }
    32. }
    33. String prefix = ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("Prefix"));
    34. String string = "";
    35. {
    36. for (String str : args)
    37. {
    38. if (!string.isEmpty())
    39. {
    40. string.concat(" " + str);
    41. String msg;
    42. Bukkit.broadcastMessage(prefix + ChatColor.GOLD + msg);
    43. } else {
    44. string.concat(str);
    45. }
    46. }
    47. }
    48. }


    The line that I know the error is, is line:36 Mainly, it says the "args" is

    - "args" can't be resolved to a variable
    - Can only iterate over an array or an instance of java.lang.Iterable
     
  2. Offline

    Pizza371

    iiHeroo args isn't a variable delcared? It's outside of the onCommand method?
     
  3. Offline

    iiHeroo


    oh..... I'm stupid..... well.. now the command won't execute properly, but I can fix that on my own, hopefully xD.
     
  4. Offline

    PatoTheBest

    Why do you close the instanceof player right after you opened it? and why do you have Player player = (Player) sender; just floating around? Tell me what do you want your plugin to do and i'll help you.
     
  5. Offline

    xTrollxDudex

    iiHeroo
    You forgot to add a opening brace on line 29 so the onCommand ends early. In other words, that's out of the method :p
     
  6. Offline

    iiHeroo


    Well it was a "Test" plugin, so the "Player player = (Player) sender; is still there, and, all I was trying to do was make a broadcast command with a prefix you get from the config. And I know that troll dude, but uh, why did you edit your comment so many times ? http://gyazo.com/dad1c9a60dfd106cb9a4ddb1047f9323
     
  7. Offline

    Pizza371

    iiHeroo haha 6,969 he edited it alright. look a little closer XD *facepalm*
     
  8. Offline

    PatoTheBest

    haha lol
     
  9. Offline

    Garris0n


    xTrollxDudex has a lot of free time to edit his posts. If you look at his post history, he spends about an hour per post editing each one 6,969 times to ensure that his posts are up to Troll standards. The council of Trollania requires that each Troll edit their post at least 69 times, but TrollDude is a bit of an overachiever.
     
    Ultimate_n00b likes this.
  10. Offline

    iiHeroo


    xD ! xTrollxDudex you are now king of Trollania !
     
  11. Offline

    PatoTheBest

    I had the idea first:p and I told xTrollzDudez that he needed to have it because his name is troll XD
     
  12. Offline

    JPG2000

    Garris0n Actually, your wrong. The council of Trollania no longer requires you to edit 69 times (Law 69, Section 6, Paragrah 9), but it is a offense, and you can go to Trolliaprisona if you don't edit that many times. I looked on TrollApidia, and he's already been to jail, for selling Trolldrugs, but I hear he's on rehab.

    Anywho, xTrollxDudex, I thought I may let you know, Im thinking of joining the Trollania councel. And when I do, I'll try my best to remove the law.
     
  13. Offline

    Garris0n

    I've been considering becoming a Trollawyer to defend the grand people of Trollania, however I'm not sure if I want to get myself into such a demanding trofession. But xTrollxDudex make sure you never try Trollamphetamine or Treroin, that stuff will mess you up.
     
  14. Offline

    JPG2000

    Garris0n Your best best is to become a Trollawyer. I wish I could, but my past addiction of Trollroids, and Trollacilyan will stop me. How ever, I do agree with you, that what you said, ESPECIALL Treroin, will ruin you for good. xTrollxDudex, never take Treroin, if you do, I gurantee all of the Trurs infront of the Trollhouse will send you to prison.
     
  15. Offline

    xTrollxDudex

    true dat.
    Hmm. 3 more people to add to my list of trolled's :p
     
Thread Status:
Not open for further replies.

Share This Page