Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onClickEvent(InventoryClickEvent e){
- try{
- Player p = (Player) e.getWhoClicked();
- Inventory inv = e.getInventory();
- ItemStack item = e.getCurrentItem();
- ItemMeta itemM = item.getItemMeta();
- String amountInOperation = getAmountInOperation(p.getUniqueId());
- File invFile = new File(playerbank, p.getName() + ".bankshard");
- FileConfiguration invConfig = YamlConfiguration.loadConfiguration(invFile);
- if(inv.getTitle().equals(ChatColor.BLACK + "Bank [" + ChatColor.YELLOW + "I" + ChatColor.BLACK + "/" + ChatColor.YELLOW + "VI" + ChatColor.BLACK + "]")){
- if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§b§lShard(s)")){
- if(e.getClick().equals(ClickType.MIDDLE)){
- if(!(invConfig.getInt("Size") == 63)){
- e.setCancelled(true);
- p.closeInventory();
- code = random.nextInt(99999);
- int newslots = invConfig.getInt("Size") + 9;
- int cost = (int) (invConfig.getInt("Size") * 18 / 2);
- p.sendMessage("");
- p.sendMessage("§8 *** §b§lBank Upgrade Confirmation §8***");
- p.sendMessage("§8 CURRENT Slots: §b" + invConfig.getInt("Size") + " §8NEW Slots: §b" + newslots);
- p.sendMessage(" §8Upgrade Cost: §b" + cost + " Shard(s)");
- p.sendMessage("");
- p.sendMessage("§bEnter the code '§b§l" + code + "§b' to confirm your upgrade.");
- p.sendMessage("");
- p.sendMessage("§c§lWARNING: §cBank upgrades are NOT reversible or refundable.\nType 'cancel' to void this upgrade request.");
- upgradeBank.buildConversation((Conversable)p).begin();
- }else{
- p.sendMessage("§c§lERROR: §cYou have already upgraded your bank to its maximum potential");
- p.closeInventory();
- }
- }else if(e.getClick().equals(ClickType.RIGHT)){
- initialiseInventoryKeyPad("§0Withdrawl - Banknote", p.getUniqueId(), p);
- e.setCancelled(true);
- }else if(e.getClick().equals(ClickType.LEFT)){
- initialiseInventoryKeyPad("§0Withdrawl - Shards", p.getUniqueId(), p);
- e.setCancelled(true);
- }else{
- }
- }
- else if(item.getType()==Material.STAINED_GLASS_PANE && item.getDurability()==(short)7 && itemM.getDisplayName()==" "){
- e.setCancelled(true);
- }else{
- }
- }if(inv.getTitle().contains("§0Withdrawl - Banknote")){
- e.setCancelled(true);
- if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§b§lShard(s)")){
- }
- else if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§aConfirm")){
- if (amountInOperation != null){
- if(econ.getBalance(p) >= Integer.parseInt(amountInOperation)){
- ItemStack items = new ItemStack(Material.PAPER);
- ItemMeta meta = items.getItemMeta();
- meta.setDisplayName("§bBank Note");
- meta.setLore(Arrays.asList(new String[] { "§f§lValue: §f" + amountInOperation + " Shards","§fExchange at any bank for SHARD(s)"}));
- items.setItemMeta(meta);
- p.getInventory().addItem(items);
- clearAmountInOperation(p.getUniqueId());
- p.closeInventory();
- }else{
- p.sendMessage("§c§lERROR: §cYou have insufficient funds to preform this action.");
- p.closeInventory();
- clearAmountInOperation(p.getUniqueId());
- }
- }
- }else if(item.getType()==Material.STAINED_GLASS_PANE && item.getDurability()==(short)7 && itemM.getDisplayName()==" "){
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b0"))
- {
- if (getAmountInOperation(p.getUniqueId()) != null)
- {
- changeAmountOperation(p.getUniqueId(), "0", inv);
- }
- else
- {
- p.sendMessage(ChatColor.RED + "You can't begin with 0.");
- }
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b1")){
- changeAmountOperation(p.getUniqueId(), "1", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b2")){
- changeAmountOperation(p.getUniqueId(), "2", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b3")){
- changeAmountOperation(p.getUniqueId(), "3", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b4")){
- changeAmountOperation(p.getUniqueId(), "4", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b5")){
- changeAmountOperation(p.getUniqueId(), "5", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b6")){
- changeAmountOperation(p.getUniqueId(), "6", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b7")){
- changeAmountOperation(p.getUniqueId(), "7", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b8")){
- changeAmountOperation(p.getUniqueId(), "8", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b9")){
- changeAmountOperation(p.getUniqueId(), "9", inv);
- }
- else if(itemM.getDisplayName().contains("§eCorrection")){
- ;
- clearAmountInOperation(p.getUniqueId());
- changeAmountOperation(p.getUniqueId(), "", inv);
- p.sendMessage(ChatColor.GREEN + "Clears the current amount that was previous selected!");
- }
- else if(itemM.getDisplayName().contains("§cCancel")){
- Inventory playerInventory = getInventoryFromFile(new File(playerbank, p.getName() + ".bankshard"));
- clearAmountInOperation(p.getUniqueId());
- p.openInventory(playerInventory);
- }else{
- }
- }if(inv.getTitle().contains("§0Withdrawl - Shards")){
- e.setCancelled(true);
- if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§b§lShard(s)")){
- }
- else if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§aConfirm")){
- ;
- if (amountInOperation != null){
- if(econ.getBalance(p) >= Integer.parseInt(amountInOperation)){
- ItemStack items = new ItemStack(Material.PRISMARINE_SHARD);
- ItemMeta meta = items.getItemMeta();
- meta.setDisplayName("§fShard");
- items.setAmount(Integer.parseInt(amountInOperation));
- items.setItemMeta(meta);
- p.getInventory().addItem(items);
- econ.withdrawPlayer(p, Integer.parseInt(amountInOperation));
- try {
- invConfig.save(invFile);
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- clearAmountInOperation(p.getUniqueId());
- p.closeInventory();
- }else{
- p.sendMessage("§c§lERROR: §cYou have insufficient funds to preform this action.");
- p.closeInventory();
- clearAmountInOperation(p.getUniqueId());
- }
- }
- }else if(item.getType()==Material.STAINED_GLASS_PANE && item.getDurability()==(short)7 && itemM.getDisplayName()==" "){
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b0"))
- {
- if (getAmountInOperation(p.getUniqueId()) != null)
- {
- changeAmountOperation(p.getUniqueId(), "0", inv);
- }
- else
- {
- p.sendMessage(ChatColor.RED + "You can't begin with 0.");
- }
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b1")){
- changeAmountOperation(p.getUniqueId(), "1", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b2")) {
- changeAmountOperation(p.getUniqueId(), "2", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b3")){
- changeAmountOperation(p.getUniqueId(), "3", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b4")){
- changeAmountOperation(p.getUniqueId(), "4", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b5")){
- changeAmountOperation(p.getUniqueId(), "5", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b6")){
- changeAmountOperation(p.getUniqueId(), "6", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b7")){
- changeAmountOperation(p.getUniqueId(), "7", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b8")){
- changeAmountOperation(p.getUniqueId(), "8", inv);
- }
- else if (itemM.getDisplayName().equalsIgnoreCase("§b9")){
- changeAmountOperation(p.getUniqueId(), "9", inv);
- }
- else if(itemM.getDisplayName().contains("§eCorrection")){
- clearAmountInOperation(p.getUniqueId());
- changeAmountOperation(p.getUniqueId(), "", inv);
- p.sendMessage(ChatColor.GREEN + "Clears the current amount that was previous selected!");
- }
- else if(itemM.getDisplayName().contains("§cCancel")){
- Inventory playerInventory = getInventoryFromFile( new File(playerbank, p.getName() + ".bankshard"));
- clearAmountInOperation(p.getUniqueId());
- p.openInventory(playerInventory);
- }else{
- }
- }
- }catch(Exception ez){
- ez.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement