Advertisement
Dark_FX

dfgdfgfdgdfgdfg

Jan 26th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.64 KB | None | 0 0
  1. @EventHandler
  2. public void onClickEvent(InventoryClickEvent e){
  3. try{
  4. Player p = (Player) e.getWhoClicked();
  5. Inventory inv = e.getInventory();
  6. ItemStack item = e.getCurrentItem();
  7. ItemMeta itemM = item.getItemMeta();
  8. String amountInOperation = getAmountInOperation(p.getUniqueId());
  9. File invFile = new File(playerbank, p.getName() + ".bankshard");
  10. FileConfiguration invConfig = YamlConfiguration.loadConfiguration(invFile);
  11. if(inv.getTitle().equals(ChatColor.BLACK + "Bank [" + ChatColor.YELLOW + "I" + ChatColor.BLACK + "/" + ChatColor.YELLOW + "VI" + ChatColor.BLACK + "]")){
  12. if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§b§lShard(s)")){
  13. if(e.getClick().equals(ClickType.MIDDLE)){
  14. if(!(invConfig.getInt("Size") == 63)){
  15. e.setCancelled(true);
  16. p.closeInventory();
  17. code = random.nextInt(99999);
  18. int newslots = invConfig.getInt("Size") + 9;
  19. int cost = (int) (invConfig.getInt("Size") * 18 / 2);
  20. p.sendMessage("");
  21. p.sendMessage("§8 *** §b§lBank Upgrade Confirmation §8***");
  22. p.sendMessage("§8 CURRENT Slots: §b" + invConfig.getInt("Size") + " §8NEW Slots: §b" + newslots);
  23. p.sendMessage(" §8Upgrade Cost: §b" + cost + " Shard(s)");
  24. p.sendMessage("");
  25. p.sendMessage("§bEnter the code '§b§l" + code + "§b' to confirm your upgrade.");
  26. p.sendMessage("");
  27. p.sendMessage("§c§lWARNING: §cBank upgrades are NOT reversible or refundable.\nType 'cancel' to void this upgrade request.");
  28. upgradeBank.buildConversation((Conversable)p).begin();
  29. }else{
  30. p.sendMessage("§c§lERROR: §cYou have already upgraded your bank to its maximum potential");
  31. p.closeInventory();
  32. }
  33. }else if(e.getClick().equals(ClickType.RIGHT)){
  34. initialiseInventoryKeyPad("§0Withdrawl - Banknote", p.getUniqueId(), p);
  35. e.setCancelled(true);
  36. }else if(e.getClick().equals(ClickType.LEFT)){
  37. initialiseInventoryKeyPad("§0Withdrawl - Shards", p.getUniqueId(), p);
  38. e.setCancelled(true);
  39. }else{
  40.  
  41. }
  42. }
  43. else if(item.getType()==Material.STAINED_GLASS_PANE && item.getDurability()==(short)7 && itemM.getDisplayName()==" "){
  44. e.setCancelled(true);
  45. }else{
  46.  
  47. }
  48. }if(inv.getTitle().contains("§0Withdrawl - Banknote")){
  49. e.setCancelled(true);
  50. if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§b§lShard(s)")){
  51. }
  52. else if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§aConfirm")){
  53. if (amountInOperation != null){
  54. if(econ.getBalance(p) >= Integer.parseInt(amountInOperation)){
  55. ItemStack items = new ItemStack(Material.PAPER);
  56. ItemMeta meta = items.getItemMeta();
  57. meta.setDisplayName("§bBank Note");
  58. meta.setLore(Arrays.asList(new String[] { "§f§lValue: §f" + amountInOperation + " Shards","§fExchange at any bank for SHARD(s)"}));
  59. items.setItemMeta(meta);
  60. p.getInventory().addItem(items);
  61. clearAmountInOperation(p.getUniqueId());
  62. p.closeInventory();
  63. }else{
  64. p.sendMessage("§c§lERROR: §cYou have insufficient funds to preform this action.");
  65. p.closeInventory();
  66. clearAmountInOperation(p.getUniqueId());
  67. }
  68. }
  69. }else if(item.getType()==Material.STAINED_GLASS_PANE && item.getDurability()==(short)7 && itemM.getDisplayName()==" "){
  70. }
  71. else if (itemM.getDisplayName().equalsIgnoreCase("§b0"))
  72. {
  73. if (getAmountInOperation(p.getUniqueId()) != null)
  74. {
  75. changeAmountOperation(p.getUniqueId(), "0", inv);
  76. }
  77. else
  78. {
  79. p.sendMessage(ChatColor.RED + "You can't begin with 0.");
  80. }
  81. }
  82. else if (itemM.getDisplayName().equalsIgnoreCase("§b1")){
  83. changeAmountOperation(p.getUniqueId(), "1", inv);
  84. }
  85. else if (itemM.getDisplayName().equalsIgnoreCase("§b2")){
  86. changeAmountOperation(p.getUniqueId(), "2", inv);
  87. }
  88. else if (itemM.getDisplayName().equalsIgnoreCase("§b3")){
  89. changeAmountOperation(p.getUniqueId(), "3", inv);
  90. }
  91. else if (itemM.getDisplayName().equalsIgnoreCase("§b4")){
  92. changeAmountOperation(p.getUniqueId(), "4", inv);
  93. }
  94. else if (itemM.getDisplayName().equalsIgnoreCase("§b5")){
  95. changeAmountOperation(p.getUniqueId(), "5", inv);
  96. }
  97. else if (itemM.getDisplayName().equalsIgnoreCase("§b6")){
  98. changeAmountOperation(p.getUniqueId(), "6", inv);
  99. }
  100. else if (itemM.getDisplayName().equalsIgnoreCase("§b7")){
  101. changeAmountOperation(p.getUniqueId(), "7", inv);
  102. }
  103. else if (itemM.getDisplayName().equalsIgnoreCase("§b8")){
  104. changeAmountOperation(p.getUniqueId(), "8", inv);
  105. }
  106. else if (itemM.getDisplayName().equalsIgnoreCase("§b9")){
  107. changeAmountOperation(p.getUniqueId(), "9", inv);
  108. }
  109. else if(itemM.getDisplayName().contains("§eCorrection")){
  110. ;
  111. clearAmountInOperation(p.getUniqueId());
  112. changeAmountOperation(p.getUniqueId(), "", inv);
  113. p.sendMessage(ChatColor.GREEN + "Clears the current amount that was previous selected!");
  114. }
  115. else if(itemM.getDisplayName().contains("§cCancel")){
  116. Inventory playerInventory = getInventoryFromFile(new File(playerbank, p.getName() + ".bankshard"));
  117. clearAmountInOperation(p.getUniqueId());
  118. p.openInventory(playerInventory);
  119. }else{
  120. }
  121. }if(inv.getTitle().contains("§0Withdrawl - Shards")){
  122. e.setCancelled(true);
  123. if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§b§lShard(s)")){
  124. }
  125. else if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§aConfirm")){
  126. ;
  127. if (amountInOperation != null){
  128. if(econ.getBalance(p) >= Integer.parseInt(amountInOperation)){
  129. ItemStack items = new ItemStack(Material.PRISMARINE_SHARD);
  130. ItemMeta meta = items.getItemMeta();
  131. meta.setDisplayName("§fShard");
  132. items.setAmount(Integer.parseInt(amountInOperation));
  133. items.setItemMeta(meta);
  134. p.getInventory().addItem(items);
  135. econ.withdrawPlayer(p, Integer.parseInt(amountInOperation));
  136. try {
  137. invConfig.save(invFile);
  138. } catch (IOException e1) {
  139. e1.printStackTrace();
  140. }
  141. clearAmountInOperation(p.getUniqueId());
  142. p.closeInventory();
  143. }else{
  144. p.sendMessage("§c§lERROR: §cYou have insufficient funds to preform this action.");
  145. p.closeInventory();
  146. clearAmountInOperation(p.getUniqueId());
  147. }
  148. }
  149. }else if(item.getType()==Material.STAINED_GLASS_PANE && item.getDurability()==(short)7 && itemM.getDisplayName()==" "){
  150. }
  151. else if (itemM.getDisplayName().equalsIgnoreCase("§b0"))
  152. {
  153. if (getAmountInOperation(p.getUniqueId()) != null)
  154. {
  155. changeAmountOperation(p.getUniqueId(), "0", inv);
  156. }
  157. else
  158. {
  159. p.sendMessage(ChatColor.RED + "You can't begin with 0.");
  160. }
  161. }
  162. else if (itemM.getDisplayName().equalsIgnoreCase("§b1")){
  163. changeAmountOperation(p.getUniqueId(), "1", inv);
  164. }
  165. else if (itemM.getDisplayName().equalsIgnoreCase("§b2")) {
  166. changeAmountOperation(p.getUniqueId(), "2", inv);
  167. }
  168. else if (itemM.getDisplayName().equalsIgnoreCase("§b3")){
  169. changeAmountOperation(p.getUniqueId(), "3", inv);
  170. }
  171. else if (itemM.getDisplayName().equalsIgnoreCase("§b4")){
  172. changeAmountOperation(p.getUniqueId(), "4", inv);
  173. }
  174. else if (itemM.getDisplayName().equalsIgnoreCase("§b5")){
  175. changeAmountOperation(p.getUniqueId(), "5", inv);
  176. }
  177. else if (itemM.getDisplayName().equalsIgnoreCase("§b6")){
  178. changeAmountOperation(p.getUniqueId(), "6", inv);
  179. }
  180. else if (itemM.getDisplayName().equalsIgnoreCase("§b7")){
  181. changeAmountOperation(p.getUniqueId(), "7", inv);
  182. }
  183. else if (itemM.getDisplayName().equalsIgnoreCase("§b8")){
  184. changeAmountOperation(p.getUniqueId(), "8", inv);
  185. }
  186. else if (itemM.getDisplayName().equalsIgnoreCase("§b9")){
  187. changeAmountOperation(p.getUniqueId(), "9", inv);
  188. }
  189. else if(itemM.getDisplayName().contains("§eCorrection")){
  190. clearAmountInOperation(p.getUniqueId());
  191. changeAmountOperation(p.getUniqueId(), "", inv);
  192. p.sendMessage(ChatColor.GREEN + "Clears the current amount that was previous selected!");
  193. }
  194. else if(itemM.getDisplayName().contains("§cCancel")){
  195. Inventory playerInventory = getInventoryFromFile( new File(playerbank, p.getName() + ".bankshard"));
  196.  
  197. clearAmountInOperation(p.getUniqueId());
  198. p.openInventory(playerInventory);
  199. }else{
  200.  
  201. }
  202. }
  203. }catch(Exception ez){
  204. ez.printStackTrace();
  205.  
  206. }
  207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement