Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //At the top of the code:
- public static Economy econ = null;
- public static Permission perms = null;
- public void onEnable() {
- if (!setupEconomy() ) {
- getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
- getServer().getPluginManager().disablePlugin(this);
- return;
- }
- getConfig().options().copyDefaults(true);
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- settings.setup(this);
- }
- private boolean setupEconomy() {
- if (getServer().getPluginManager().getPlugin("Vault") == null) {
- return false;
- }
- RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
- if (rsp == null) {
- return false;
- }
- Economy econ = rsp.getProvider();
- return econ !=null;
- }
- //The vote shop inventory:
- public static Inventory voteShop() {
- Inventory i = Bukkit.createInventory(null, 9, "Vote Shop");
- ItemStack air = new ItemStack(Material.AIR, 1);
- List<String> l = new ArrayList<String>();
- ItemStack bow = new ItemStack(Material.BOW, 1);
- ItemMeta bowmeta = bow.getItemMeta();
- bowmeta.setDisplayName(ChatColor.GOLD+"Teleportation Bow");
- bowmeta.setLore(Arrays.asList(ChatColor.GREEN+"20 Points"));
- bow.setItemMeta(bowmeta);
- ItemStack wardrobe = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
- ItemMeta wardrobemeta = wardrobe.getItemMeta();
- wardrobemeta.setDisplayName(ChatColor.GOLD+"Wardrobe");
- wardrobemeta.setLore(Arrays.asList(ChatColor.GREEN+"10 Points"));
- wardrobe.setItemMeta(wardrobemeta);
- {
- i.setItem(2, bow);
- i.setItem(3, wardrobe);
- }
- return i;
- }
- //In my interact event:
- @SuppressWarnings("deprecation")
- @EventHandler
- public void clickEvent(PlayerInteractEvent e) {
- Player p = e.getPlayer();
- Action a = e.getAction();
- PlayerInventory pi = p.getInventory();
- if (!p.hasPermission("hub.hub")) {
- return;
- }
- if (h.getType() == Material.NETHER_STAR) {
- p.sendMessage(""+ChatColor.DARK_AQUA+ChatColor.BOLD+">> "+ChatColor.GOLD+ChatColor.BOLD+"Opening Shop...");
- p.openInventory(voteShop());
- ItemStack nstar = new ItemStack(Material.NETHER_STAR);
- ItemMeta nstarmeta = nstar.getItemMeta();
- nstarmeta.setDisplayName(ChatColor.GOLD+"Your Vote Points:");
- nstarmeta.setLore(Arrays.asList(ChatColor.GREEN+""+econ.getBalance(p.getName())));
- voteShop().setItem(0, nstar);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement