Solved How do I set this config to get 345 instead of COMPASS

Discussion in 'Plugin Development' started by TECGaming360, May 10, 2014.

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

    TECGaming360

    I want to get this so people can type the ID instead!
    Code:
    @EventHandler
        public void onDropItem(PlayerDropItemEvent e) {
            Player player = e.getPlayer();
            if (e.getItemDrop().getItemStack().getType() == Material.getMaterial(KeepthatItem.plugin.getConfig().getString("undropable Item")))
            {
                e.setCancelled(true);
                player.sendMessage(ChatColor.YELLOW + "[" + ChatColor.AQUA + "KeepthatItem" + ChatColor.YELLOW + "]" + ChatColor.RED + KeepthatItem.plugin.getConfig().getString("Drop Message"));
            }
        }
     
  2. Offline

    TGRHavoc

    TECGaming360
    Can't you do Material.getMaterial(int ID) ?
    So you would do plugin.getConfig().getInt("path") instead of plugin.getConfig().getString()
     
  3. Offline

    TECGaming360

    it tells me to set as matchMaterial
     
  4. Offline

    TGRHavoc

    TECGaming360
    Well, to be honest I don't think you should use the item ID as I believe that Mojang are removing them in a later version... Correct me if I'm wrong..
     
  5. Offline

    TECGaming360

    well is people type compass other than COMPASS will it still work?
     
  6. Offline

    TGRHavoc

    TECGaming360
    Yes, if you force it to uppercase.
    Something like (Not tested):
    Code:java
    1. String material = plugin.getConfig().getString("undroppableItem").toUppercase();
     
  7. Offline

    TECGaming360

    Seprate question, the way my code is above in the config say it was set like this

    undropable item: comapss

    Will it ignore spaces or do i have to set it so it does?
     
  8. Offline

    TGRHavoc

    TECGaming360
    Don't really know. I would always use either an underscore (_) or I would give it a name using the "naming rules" of Java (undropabbleItem).
     
  9. Offline

    TECGaming360

    It ignores spaces but why is my instructions gone like i put instructions in config like
    #Set up Item
    but its gone.?>
     
  10. Offline

    TGRHavoc

    TECGaming360
    Don't know. I've experienced this as well with custom configs.. Think it's because Bukkit is saving the config and it ignores the comments (that's why they're there)
     
  11. Offline

    TopTobster5

    TECGaming360 When you are saving new information to a config, comments are lost. The only comments it knows how to save are headers.
     
Thread Status:
Not open for further replies.

Share This Page