i need to use the getConfig i know this is a noob question but this isn't my main class how would i getConfig() here? Code:java @EventHandlerpublic void onInventoryClick(InventoryClickEvent e){ final Player player = (Player) e.getWhoClicked(); if (!(e.getInventory().getName().equalsIgnoreCase(inv.getName()))) return; if(e.getCurrentItem() == null) return; if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Launch Firework")){//FIREWORK! e.setCancelled(true); player.closeInventory(); player.chat("/donationfirework"); }
its not working I'm probably doing it wrong.... Code:java if (e.getCurrentItem().getItemMeta().getDisplayName().contains(MenuInv.getConfig().getString(""))){
xTigerRebornx Here it is Code:java public class Menu implements Listener{ private Inventory inv; private ItemStack f, sj, st, ft, dk, c1, c2, c3, c4; public Menu(Plugin p) { inv = Bukkit.getServer().createInventory(null, 9,ChatColor.DARK_RED + "Master" +ChatColor.GREEN +"Kraft"+ChatColor.BLUE +" DonatorMenu" ); f = createItem(DyeColor.BLUE, ChatColor.BLUE + "Launch Firework"); sj = createItem(DyeColor.RED, ChatColor.RED + "SuperJump"); st = createItem(DyeColor.YELLOW, ChatColor.YELLOW + "SmokeTrail"); ft = createItem(DyeColor.ORANGE, ChatColor.GOLD + "FireTrail"); dk = createItem(DyeColor.PURPLE, ChatColor.DARK_PURPLE + "Kit"); c1 = createItem(DyeColor.LIGHT_BLUE, ChatColor.WHITE + p.getConfig().getString("custom block1 name")); c2 = createItem(DyeColor.LIGHT_BLUE, ChatColor.WHITE + p.getConfig().getString("custom block1 name")); c3 = createItem(DyeColor.LIGHT_BLUE, ChatColor.WHITE + p.getConfig().getString("custom block1 name")); c4 = createItem(DyeColor.LIGHT_BLUE, ChatColor.WHITE + p.getConfig().getString("custom block1 name")); inv.setItem(0, f); inv.setItem(1, sj); inv.setItem(2, st); inv.setItem(3, ft); inv.setItem(4, dk); inv.setItem(5, c1); inv.setItem(6, c2); inv.setItem(7, c3); inv.setItem(8, c4); Bukkit.getServer().getPluginManager().registerEvents(this, p); } private ItemStack createItem(DyeColor dc, String name){ ItemStack i = new Wool(dc).toItemStack(1); ItemMeta im = i.getItemMeta(); im.setDisplayName(name); im.setLore(Arrays.asList( ChatColor.AQUA + "Click To Do This")); i.setItemMeta(im); return i; } public void show(Player p) { p.openInventory(inv); } @EventHandlerpublic void onInventoryClick(InventoryClickEvent e){ final Player player = (Player) e.getWhoClicked(); if (!(e.getInventory().getName().equalsIgnoreCase(inv.getName()))) return; if(e.getCurrentItem() == null) return; if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Launch Firework")){//FIREWORK! e.setCancelled(true); player.closeInventory(); player.chat("/donationfirework"); } if (e.getCurrentItem().getItemMeta().getDisplayName().contains("SuperJump")){ e.setCancelled(true); player.closeInventory(); player.chat("/donationjump"); } if (e.getCurrentItem().getItemMeta().getDisplayName().contains("SmokeTrail")){ e.setCancelled(true); player.closeInventory(); player.chat("/donationsmoke"); } if (e.getCurrentItem().getItemMeta().getDisplayName().contains("FireTrail")){ player.closeInventory(); e.setCancelled(true); player.chat("/donationfire"); } if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Kit")){ e.setCancelled(true); player.closeInventory(); player.chat("/donationkit"); } if (e.getCurrentItem().getItemMeta().getDisplayName().contains("FactionHome")){ e.setCancelled(true); player.closeInventory(); player.chat("/f home"); } if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Nothing")){ e.setCancelled(true); player.closeInventory(); player.sendMessage(ChatColor.RED + "This Block Dose Not Do Anything Yet!"); } if (e.getCurrentItem().getItemMeta().getDisplayName().contains(MenuInv.getConfig().getString(""))){ e.setCancelled(true); player.closeInventory(); player.sendMessage(ChatColor.RED + "This Block Dose Not Do Anything Yet!"); } } }
It's satire, but it makes a good point. I could easily manipulate a poll to make it appear that 1/5th of Americans believe Obama is a cactus.
hi_guy_5 For your constructor, pass in MenuInv (I am guessing this is your main class) and store it in a variable inside the listener I.E. Code: MenuInv pl; public MyListener(MenuInv pl){ this.pl = pl; } This would allow MyListener access to everything in pl when given a valid instance, so you can use pl.getConfig() to access your main config
@ xTigerRebornx Is This What You Said? (just Checkin) Code:java MenuInv pl; @EventHandlerpublic void onInventoryClick(InventoryClickEvent e, MenuInv pl){ this.pl = pl;