Inventory Help! (Need help ASAP)

Discussion in 'Plugin Development' started by ColaCraft, Jun 5, 2013.

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

    ColaCraft

    Hey guys, nothing special here, just a couple of issues with my code.

    This is supposed to be opening a fake inventory showing what armor the (target) user is wearing.

    PHP:
    package me.PorterK.SeeArmor;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
     
    import java.util.logging.Logger;
     
    public class 
    main extends JavaPlugin {
     
        private final 
    Logger log Logger.getLogger("Minecraft");
        private final 
    String logTag "[SeeArmor] " ChatColor.RESET;
     
        private 
    FileConfiguration config;
        private 
    PluginDescriptionFile pdfFile;
     
        @
    Override
        
    public void onEnable(){
            
    this.pdfFile this.getDescription();
            
    this.config this.getConfig();
            
    log.infologTag pdfFile.getName() + " v" pdfFile.getVersion() + " enabled!");
        }
     
        @
    Override
        
    public void onDisable(){
            
    log.infologTag pdfFile.getName() + " v" pdfFile.getVersion() + " disabled!");
        }
        public 
    boolean onCommand(CommandSender senderCommand cmdString labelString[] args){
            if(
    cmd.getName().equalsIgnoreCase("seearmor")) {
             
                if(
    args[0] != null){
                
    Player target Bukkit.getServer().getPlayer(args[0]);
                
    Player p = (Playersender;
            
    ItemStack helm = new ItemStack(target.getInventory().getItem(103));
            
    ItemStack chest = new ItemStack (target.getInventory().getItem(102));
            
    ItemStack leg = new ItemStack (target.getInventory().getItem(101));
            
    ItemStack boots = new ItemStack (target.getInventory().getItem(100));
         
            
    Inventory custom Bukkit.getServer().createInventory(p9target "'s Armor!");
            
    custom.setItem(0helm);
            
    custom.setItem(1chest);
            
    custom.setItem(2leg);
            
    custom.setItem(3boots);
         
         
            
    p.openInventory(custom);
                }else{
                    
    sender.sendMessage(ChatColor.DARK_RED "Impropper usage! " ChatColor.YELLOW "/seearmor <user>");
                }
                return 
    true;
        }
            return 
    false;
        }
    }
    When you type /seearmor <user> it returns with the "else" statement.

    Thanks!

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. Offline

    ColaCraft

    Sigh, double bump
     
  3. if(args[0] != null){

    It can never be null, or it would not exist, in what case it throws a error, or it just exists
     
  4. Offline

    ColaCraft


    Even when I put in a second argument, it just throws back the "Incorrect Syntax!" thing.
     
Thread Status:
Not open for further replies.

Share This Page