Eclipse error when registering event?

Discussion in 'Plugin Development' started by CameronK, May 7, 2011.

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

    CameronK

    I was just trying to make a simple plugin....if someone used /fly, they were kicked.


    Can anybody tell me WTF is wrong? I've been going two hours and getting all these freakin' errors that make no sense.....I'm not great at Java, but I dunno what's going on.

    [​IMG]

    The error says...

    "Syntax error on tokens, TypeArgument1 expected instead".


    Wut?
     
  2. Offline

    chernobyl360

    well i only get these errors from not adding certain things to the code. it varies at times, having spaces in place where they shouldnt be, missing *;* stuff like that. but from looking at your pic here. i already see a double space between the comma and the word "this" *event.priority.normal, this);*
     
  3. Offline

    Acrobot

    I see that you:
    • Use player_command - there is no player_command for a long time now
    • You have Event.Priority.Normal - change it to Priority.Normal
     
  4. Offline

    halvors

    @Acrobot
    What's the differenc between Event.Priority.Normal and Priority.Normal
     
  5. Offline

    Acrobot

  6. Offline

    halvors

  7. Offline

    CameronK

    Well then the "most recent" tutorial is a bust. *facepalms*

    I had "player_command" when I was messing around with that function, trying to fix it. Didn't do anything, forgot to change it back.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 16, 2016
  8. Offline

    chernobyl360

    So what do you use in place of PLAYER_COMMAND?
     
  9. Offline

    iPhysX

    Code:
    public boolean onCommand(CommandSender sender, Command cmd,
                String commandLabel, String[] args) {
            Player player = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("fly")) {
                if (args.length >= 1) {
    player.remove();
    }
    }

    im not sure, but something like that?
    im not really sure how to kick people:/
     
  10. Offline

    CameronK

    I fixed this now...

    Code:
    getCommand("fly").setExecutor(new CommandExecutor() {
                @Override
                public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
                    if(!sender.isOp()) {
                        Server s = getServer();
                        Player cmdsender = (Player) sender;
                        s.broadcastMessage("[CommandKick] " + cmdsender + " wanted to fly. Well, they did. *kick*");
                        sender.sendMessage("[CommandKick] Alright then. Goodbye!");
                        cmdsender.kickPlayer("[CommandKick] You wanted to fly...");
                    } else {
                        sender.sendMessage("[ " + ChatColor.RED + "CommandKick" + ChatColor.WHITE + "] You executed the " + label + " command, but your OP status prevented you from being kicked.");
                    }
                    return true;
                }
            });
    but I can't figure out hot to convert the CommandSender type to a string (so that it doesn't say "CraftEntity{name=CameronK} in place of cmdsender/sender).
     
  11. Offline

    iPhysX

  12. Offline

    CameronK

    Do you have any idea how to change that? I'm probably asking the most basic of n00b questions....lol
     
  13. Offline

    iPhysX

    swap

    Code:
    s.broadcastMessage("[CommandKick] " + cmdsender +


    with

    Code:
    s.broadcastMessage("[CommandKick] " + player.getName() +


    and add

    Code:
    Player player = (sender) player;


    under

    onCommand(){


     
  14. Offline

    CameronK

    *EPICFACEPALM* i am a complete moron. Cheers man! :D
     
  15. Offline

    iPhysX

    i have added more :/
     
  16. Offline

    CameronK

    I saw :)

    Code:
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
                    Player player = (sender) player;
    would obviously do nothing (player doesn't exist) as it can't be resolved to a variable (or so says Eclipse). It wants me to switch the type to an entity....

    Player player = (Player) player; still returns the craftplayer{name=CameronK}

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 16, 2016
Thread Status:
Not open for further replies.

Share This Page