Config Help

Discussion in 'Plugin Development' started by HenoLima, Mar 23, 2014.

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

    HenoLima

    This is the stacktrace:
    [​IMG]
    Main Class :
    Code:java
    1. public void onEnable(){
    2. loadConfiguration();
    3.  
    4. getServer().getPluginManager().registerEvents(new Pet(this), this);
    5. getServer().getPluginManager().registerEvents(new TokenShop(this), this);
    6.  
    7.  
    8. }
    9.  
    10.  
    11.  
    12. public void onDisable(){
    13.  
    14. saveConfig();
    15. }
    16.  
    17.  
    18.  
    19.  
    20.  
    21.  
    22.  
    23.  
    24.  
    25. public static ItemStack setName(ItemStack is, String name){
    26. ItemMeta m = is.getItemMeta();
    27. m.setDisplayName(name);
    28. is.setItemMeta(m);
    29. return is;
    30. }
    31.  
    32. public static void createDisplay(Material material, Inventory inv, int Slot, String name, String lore) {
    33. ItemStack item = new ItemStack(material);
    34. ItemMeta meta = item.getItemMeta();
    35. meta.setDisplayName(name);
    36. ArrayList<String> Lore = new ArrayList<String>();
    37. Lore.add(lore);
    38. meta.setLore(Lore);
    39. item.setItemMeta(meta);
    40.  
    41. inv.setItem(Slot, item);
    42.  
    43. }
    44.  
    45.  
    46. public void playFirework(Location location, Color color) {
    47. Firework firework = location.getWorld().spawn(location, Firework.class);
    48. FireworkMeta fMeta = firework.getFireworkMeta();
    49. fMeta.addEffect(FireworkEffect.builder().withColor(color).build());
    50. firework.setFireworkMeta(fMeta);
    51. firework.detonate();
    52. }
    53. public ItemStack tokenitem = new ItemStack(Material.NETHER_STAR, 1);
    54. public ItemStack weedseeds = new ItemStack(Material.SEEDS, 20);
    55. public ItemStack poppyseeds = new ItemStack(Material.COCOA, 5);
    56. public static ItemStack pet = new ItemStack(Drugs.setName(new ItemStack(Material.BONE, 1), "Wolf Pet"));
    57.  
    58.  
    59.  
    60.  
    61.  
    62. public void loadConfiguration(){
    63. //See "Creating you're defaults"
    64. getConfig().addDefault("ZeGeorge.Money", 99999999);
    65. getConfig().addDefault("AfghanKush", 1000);
    66. getConfig().options().copyDefaults(true); // NOTE: You do not have to use "plugin." if the class extends the java plugin
    67. //Save the config whenever you manipulate it
    68. saveConfig();
    69. }
    70.  
    71. }
    72.  
    73.  
    74.  


    And the class where i got the error

    Code:
    public class TokenShop implements Listener {
        public static  Drugs plugin;
        public TokenShop(Drugs instance){
            plugin = instance;
        }
     
     
        //TOKEN SHOP
        public static Inventory tokenshop = Bukkit.createInventory(null, 27, ChatColor.RED+""+ChatColor.BOLD+"Token Shop");
     
        static{
            Drugs.createDisplay(Material.SEEDS, tokenshop, 0, ChatColor.RED+"African Kush" + ChatColor.GREEN+" "+ChatColor.BOLD+Integer.toString(plugin.getConfig().getInt("AfghanKush"))+" GEMS",  ChatColor.GRAY+"This is a rare kush , it makes lots of weeed!"  +  ChatColor.AQUA+" Rare");
         
            }
        @EventHandler
        public void onInventoryClick(InventoryClickEvent event) {
        Player player = (Player) event.getWhoClicked(); // The player that clicked the item
        ItemStack clicked = event.getCurrentItem(); // The item that was clicked
        Inventory inventory = event.getInventory(); // The inventory that was clicked in
        int PlMoney = plugin.getConfig().getInt(player.getName()+".Money");
     
        if(clicked.getType() == Material.NETHER_STAR && clicked.getItemMeta().getDisplayName().equals(ChatColor.BOLD+"Token Shop")){
            event.setCancelled(true);
        }
     
        if (inventory.getName().equals(tokenshop.getName())) { // The inventory is our custom Inventory
     
            if (clicked.getType() == Material.SEEDS && clicked.getItemMeta().getDisplayName().equals(ChatColor.RED+"African Kush"+ChatColor.GREEN+" "+ChatColor.BOLD+Integer.toString(plugin.getConfig().getInt("AfghanKush"))+"GEMS")){ // The item that the player clicked it dirt
     
     
                event.setCancelled(true); // Make it so the dirt is back in its original spot
         
                if(plugin.getConfig().getInt(player.getName()+".Money") < plugin.getConfig().getInt("AfricanKush")){
         
                    player.sendMessage(ChatColor.RED+"Im sorry but you don't have enough money to buy that!");
         
                }else{
                 
                    PlMoney = PlMoney - 1000;
                 
                    player.sendMessage(ChatColor.RED+"YOUR NEW BALANCE IS "+ String.valueOf(PlMoney) + " GEMS");
     
                    player.closeInventory();    // Closes there inventory
     
                    player.getInventory().addItem(new ItemStack(Drugs.setName(new ItemStack(Material.SEEDS), ChatColor.RED+"African Kush")));
     
                }
     
            }
     
            // Adds Item
         
     
     
        }
     
     
        }
     
     
     
     
     
     
     
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onHeld(PlayerInteractEvent event){
            Player p = event.getPlayer();
            ItemStack i = event.getItem();
            if(p.getItemInHand().getType() == Material.NETHER_STAR && p.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.BOLD+"Token Shop")){
                  p.openInventory(tokenshop);
                p.playEffect(p.getLocation(), Effect.BLAZE_SHOOT, 4);
                plugin.playFirework(event.getPlayer().getLocation(), Color.AQUA);
           
            }
         
       
     
        }
        @EventHandler
        public void OnRespawn(PlayerRespawnEvent e){
            Player p = e.getPlayer();
            p.getInventory().addItem(Drugs.setName(plugin.tokenitem, ChatColor.BOLD+"Token Shop"));
         
        }
     
     
     
    }
    
    So as far you can read from the code im trying to make a inventory menu , when i interact with the TOKEN SHOP item it opens the inventory ( which is not and i don't know why ) and i am trying to sell a item named AfricanKush (Named AfganKush in config) but it won't do nothing...it won't even open the inventory,..any help? Thanks!
     
Thread Status:
Not open for further replies.

Share This Page