Help! error!!

Discussion in 'Plugin Development' started by isaiah8139 - BSwear, Feb 7, 2016.

Thread Status:
Not open for further replies.
  1. I've been getting errors when I compile my plugin.
    The error is:
    Code:
    shortcuts.java:28 error: reached end of file while parsing
    }
    ^
    1 error
    
    Here is my plugin
    Code:
    package isaiah.shortcuts;
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.Command;
    import org.bukkit.entity.Player;
    import java.util.List;
    import org.bukkit.permissions.Permission;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.*;
    
    public class shortcuts extends JavaPlugin implements CommandExecutor, Listener {
    
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
    Player player = (Player) sender;
    if (alias.equalsIgnoreCase("shop")) { Bukkit.dispatchCommand(sender, "warp shop"); }
    else if (alias.equalsIgnoreCase("info")) { Bukkit.dispatchCommand(sender, "warp info"); }
    else if (alias.equalsIgnoreCase("c")) { Bukkit.dispatchCommand(sender, "gamemode 1"); }
    else if (alias.equalsIgnoreCase("s")) { Bukkit.dispatchCommand(sender, "gamemode 0"); }
    else if (alias.equalsIgnoreCase("rules")) { Bukkit.dispatchCommand(sender, "warp rules"); }
    else if (alias.equalsIgnoreCase("removelag")) { Bukkit.dispatchCommand(sender, "lagg gc"); }
    else if (alias.equalsIgnoreCase("help")) { Bukkit.dispatchCommand(sender, "warp info"); }
    else if (alias.equalsIgnoreCase("who")) { Bukkit.dispatchCommand(sender, "list"); }
        }
    }
    the plugin is subpost to be short cuts for commands (for example: /shop = /warp shop)

    my Bukkit profile:
    http://dev.bukkit.org/profiles/IsaiahPatton/
     
    Last edited: Feb 10, 2016
  2. Offline

    TahuAuditore

    I think
    Code:
    package isaiah.shortcuts;
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.Command;
    import org.bukkit.entity.Player;
    import java.util.List;
    public class shortcuts extends JavaPlugin implements Listener {
    public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
    Player player = (Player) sender;
    if (alias.equalsIgnoreCase("shop")) { Bukkit.dispatchCommand(sender, "warp shop"); }
    else if (alias.equalsIgnoreCase("info")) { Bukkit.dispatchCommand(sender, "warp info"); }
    else if (alias.equalsIgnoreCase("c")) { Bukkit.dispatchCommand(sender, "gamemode 1"); }
    else if (alias.equalsIgnoreCase("s")) { Bukkit.dispatchCommand(sender, "gamemode 0"); }
    else if (alias.equalsIgnoreCase("help")) { Bukkit.dispatchCommand(sender, "warp help"); }
        }
    }
    is right.
     
  3. now:
    Code:
    shortcuts.java:18 error missing return statement
        }
       ^
    1 error
    
     
  4. Offline

    Xerox262

    You need to return a boolean in the onCommand method, either return true or return false.
     
  5. Offline

    teej107

    If only he read the error. He would've known :p
     
    cococow123, 0566 and Xerox262 like this.
  6. How? (i'm new to java)
     
  7. Offline

    Xerox262

    Before the end brace for the method, type
    return true;
     
  8. Offline

    teej107

    You should continue learning Java first. Don't try to tackle Bukkit when you don't have a good enough and comfortable knowledge of Java.
     
    Xerox262 likes this.
  9. My outher plugin has 400+ downloads not even 2 mouths old yet.

    http://dev.bukkit.org/bukkit-plugins/bswear/
     
  10. Offline

    timtower Administrator Administrator Moderator

    But even with that you say this:
    Over a return statement.
     
    0566 likes this.
  11. Offline

    teej107

    0566 likes this.
  12. Offline

    mcdorli

    That doesn't count as java knowledge. You're probably usong and editor, so it shpuld say, what's wrong.
     
Thread Status:
Not open for further replies.

Share This Page