Need Coding Help!

Discussion in 'Plugin Development' started by JiNJaProductionz, Apr 22, 2014.

Thread Status:
Not open for further replies.
  1. Hey I have a major problem.
    I have a /flyme plugin with args on and off.
    It works when i have /flyme on/off but when i do /flyme it shows the player.sendMessage(); crap but it says international error. Below is the plugin code.

    Code:java
    1. package me.Dylan.FlyMe3;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class FlyMe3 extends JavaPlugin {
    10.  
    11. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    12. if(cmd.getName().equalsIgnoreCase("flyme")){
    13. Player player = (Player) sender;
    14. player.sendMessage(ChatColor.DARK_BLUE + "============================");
    15. player.sendMessage(ChatColor.RED + "/flyme " + ChatColor.GOLD + "on");
    16. player.sendMessage(ChatColor.RED + "/flyme " + ChatColor.GOLD + "off");
    17. player.sendMessage(ChatColor.DARK_GREEN + "Plugin By JiNJaProductionz!");
    18. player.sendMessage(ChatColor.DARK_BLUE + "============================");
    19. }
    20.  
    21. Player player = (Player) sender;
    22. if(args[0].equalsIgnoreCase("on")){
    23. if(player.hasPermission("flyme.flyme")){
    24. player.sendMessage(ChatColor.RED + "[" + ChatColor.DARK_AQUA + "Fly" + ChatColor.RED + "] " + ChatColor.GREEN + "Flight Activated!");
    25. player.setAllowFlight(true);
    26. }else if(args[0].equalsIgnoreCase("off")){
    27. if(player.hasPermission("flyme.flyme")){
    28. player.sendMessage(ChatColor.RED + "[" + ChatColor.DARK_AQUA + "Fly" + ChatColor.RED + "] " + ChatColor.RED + "Flight De-activated!");
    29. player.setAllowFlight(false);
    30. }
    31. }else{
    32. player.sendMessage(ChatColor.RED + "[" + ChatColor.DARK_AQUA + "Fly" + ChatColor.RED + "] " + ChatColor.DARK_RED + "You Do Not Have Permission To Do That");
    33. }
    34. }
    35. return false;
    36.  
    37. }
    38. }
    39.  


    Here is the plugin.yml!
    Code:
    name: FlyMe
    main: me.Dylan.FlyMe3.FlyMe3
    version: 3.0
    author: JiNJaProductionz
    description: Fly!
     
    commands:
      flyme:
        description: Toggle Fly.
    Here is the error log!
    Code:
    http://gyazo.com/4b175d276fec107e4e0bb2e26c7426ce
    Please help!
     
  2. Offline

    Iroh

    Moved to plugin dev.
     
  3. Thank you
     
  4. Offline

    CandyCranium

    You put one of the curly brackets in the wrong area. Count all of them correctly and it should work.
     
  5. That wasn't it 8 "{" 8 "}"
     
  6. Offline

    thomasb454

    You need to check if the argument length is less that 1.

    so
    if(args.length < 1) {
    //send message
    return false;
    }
     
  7. Offline

    CandyCranium

    JiNJaProductionz likes this.
  8. OMFG THANK YOU SO MUCH!!!!! <3
     
  9. Offline

    thomasb454


    No problem.
    Please mark this thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page