Solved Bukkit .player .inventory etc. Help

Discussion in 'Plugin Development' started by SuperEvan200, Feb 27, 2013.

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

    SuperEvan200

    Hi I'm very new at developing. Now I have this:
    Code:
            if(commandLabel.equalsIgnoreCase("command")){
                player. 
    For player. (I'm using eclipse) I don't get a box full of suggestions. Is there a full list of everything I can put there? Usually on tutorials this box pops up with alot of suggestions.
    I also now you can do .inventory, etc. Is there a list for this too? If so, please reply with the link. It would help me alot.

    Also, using a command, how can I set a player prefix?

    Thanks. :)
     
  2. Offline

    chasechocolate

    You need to make a player variable:
    Code:java
    1. if(sender instanceof Player){
    2. //A player ran the command
    3. Player player = (Player) sender;
    4. } else {
    5. //The command was run by console
    6. }

    As for prefixes, you can use:
    Code:java
    1. String prefix = ChatColor.RED + "[Admin] " + ChatColor.RESET;
    2. player.setDisplayName(prefix + player.getDisplayName());
     
  3. Offline

    SuperEvan200

    Thanks for the help! :D I had some trouble at first but after messing around with my current code and the ones you gave me I figured it out.
    Code:
        String prefix = ChatColor.RED + "[Admin] " + ChatColor.RESET;
     
        public boolean onCommand(CommandSender sender, Command cmd,  String commandLabel, String[] args){
            Player player = (Player) sender;
            if(commandLabel.equalsIgnoreCase("player")){
                player.setDisplayName(prefix + player.getDisplayName());
            }
            return false;
    Also fixed my problem with no suggestion box. I just had to press CTRL + SPACE after .player.
     
Thread Status:
Not open for further replies.

Share This Page