Solved Need help with value plugin. minor error

Discussion in 'Plugin Help/Development/Requests' started by yourmaster01, Mar 19, 2015.

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

    yourmaster01

    Hey all i have made a plugin that should get the item that the player is holding and get the price from the config. right now its it is not working and i could use some help.
    Code
    Code:
    @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label,
                String[] args) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
    
                if (label.equalsIgnoreCase("value")) {
                   
                    String item = player.getInventory().getItemInHand().getData().toString();
                    if (item == null) {
                        player.sendMessage(ChatColor.RED + "You are not holding anything!");
                        return false;
                    }
    
                   
                    int price = getConfig().getInt(item);
    
                    if(price==0){
                        player.sendMessage(ChatColor.RED + "No sell data has been set. Please ask an admin for a price.");
                        return false;
                    }
                   
                    //player.sendMessage("Holding "+item);//line for testing
                    player.sendMessage(ChatColor.GREEN + "For 1 " + item
                            + " the price should be "+price);
    
                } else {
                    System.out.print(ChatColor.RED
                            + "This can only be done from in game.");
                }
               
            }
            return false;
    
        }
    Config.yml
    Code:
    #air
    ItemStack{X0(0) x 1}: 1.0
    #Stone
    ItemStack{X1(0) x 1}: 1.0
    #Grass
    ItemStack{X2(0) x 1}: 1.0
    #Dirt
    ItemStack{X3(0) x 1}: 1.0
    #Cobblestone
    ItemStack{X4(0) x 1}: 1.0
    #Oak Plank
    ItemStack{X5(0) x 1}: 1.0
    #Pine Plan
    ItemStack{X5(1) x 1}: 1.0
    #Birch Plank
    ItemStack{X5(2) x 1}: 1.0
    #Jungle Plank
    ItemStack{X5(3) x 1}: 1.0
    #Oak Sapling
    ItemStack{X6(0) x 1}: 1.0
    #Pine Sapling
    ItemStack{X6(1) x 1}: 1.0
    #Birch Sapling
    ItemStack{X6(2) x 1}: 1.0
    #Jungle Sapling
    ItemStack{X6(3) x 1}: 1.0
    #Bedrock
    ItemStack{X7(0) x 1}: 1.0
    #Water
    ItemStack{X8(0) x 1}: 1.0
    #Stationary Water
    ItemStack{X9(0) x 1}: 1.0
    #Lava
    ItemStack{X10(0) x 1}: 1.0
    #Stationary Lava
    ItemStack{X11(0) x 1}: 1.0
    #Sand
    ItemStack{X12(0) x 1}: 1.0
    #Gravel
    ItemStack{X13(0) x 1}: 1.0
    #Gold Ore
    ItemStack{X14(0) x 1}: 1.0
    #Iron Ore
    ItemStack{X15(0) x 1}: 1.0
    #Coal Ore
    ItemStack{X16(0) x 1}: 1.0
    #Oak Log
    ItemStack{X17(0) x 1}: 1.0
    #Pine Log
    ItemStack{X17(1) x 1}: 1.0
    #Birch Log
    ItemStack{X17(2) x 1}: 1.0
    #Jungle Log
    ItemStack{X17(3) x 1}: 1.0
    #Oak Leaves
    ItemStack{X18(0) x 1}: 1.0
    #Pine Leaves
    ItemStack{X18(1) x 1}: 1.0
    #Birch Leaves
    ItemStack{X18(2) x 1}: 1.0
    #Jungle Leaves
    ItemStack{X18(3) x 1}: 1.0
    #Sponge
    ItemStack{X19(0) x 1}: 1.0
    #Glass
    ItemStack{X20(0) x 1}: 1.0
    #Lapis Lazuli Ore
    ItemStack{X21(0) x 1}: 1.0
    #Lapis Lazuli Block
    ItemStack{X22(0) x 1}: 1.0
    #Dispenser
    ItemStack{X23(0) x 1}: 1.0
    #Sandstone
    ItemStack{X24(0) x 1}: 1.0
    #Decorative Sandstone
    ItemStack{X24(1) x 1}: 1.0
    #Smooth Sandstone
    ItemStack{X24(2) x 1}: 1.0
    #Note Block
    ItemStack{X25(0) x 1}: 1.0
    #Bed
    ItemStack{X26(0) x 1}: 1.0
    #Powered Rail
    ItemStack{X27(0) x 1}: 1.0
    #Detector Rail
    ItemStack{X28(0) x 1}: 1.0
    #Sticky Piston
    ItemStack{X29(0) x 1}: 1.0
    #Cobweb
    ItemStack{X30(0) x 1}: 1.0
    
    and so on
     
  2. Offline

    timtower Moderator Moderator

    @yourmaster01 And it is not working how? Is that config generated by the plugin itself? And use getDouble as you have decimals in the config
     
Thread Status:
Not open for further replies.

Share This Page