Guest User

e

a guest
Mar 2nd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. package pl.pszemopl.pplextraefekty.events;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Material;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.inventory.InventoryClickEvent;
  9. import org.bukkit.inventory.ItemStack;
  10. import org.bukkit.potion.PotionEffect;
  11. import org.bukkit.potion.PotionEffectType;
  12. import pl.pszemopl.pplextraefekty.configurations.Config;
  13. import pl.pszemopl.pplextraefekty.utils.ChatUtil;
  14.  
  15. public class InventoryClickListener implements Listener {
  16. @SuppressWarnings("deprecation")
  17. @EventHandler
  18. public void onClickMain(InventoryClickEvent event) {
  19. Player p = (Player) event.getWhoClicked();
  20. if (ChatUtil.fixColor(Config.NAME).equalsIgnoreCase(event.getClickedInventory().getName())) {
  21. event.setCancelled(true);
  22. if (event.getSlot() == Config.SPEED_SLOT) {
  23. if (p.getInventory().containsAtLeast(new ItemStack(Material.getMaterial(Config.SPEED_CURRENCY)), Config.SPEED_AMOUNT)) {
  24. p.getInventory().removeItem(new ItemStack(Material.getMaterial(Config.SPEED_CURRENCY), Config.SPEED_AMOUNT));
  25. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Config.SPEED_DURATION, 1, true));
  26. p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Config.SPEED_DURATION, 1, true));
  27. p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Config.SPEED_DURATION, 0, true));
  28. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Config.SPEED_DURATION1, 0, true));
  29. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Config.SPEED_DURATION1, 0, true));
  30. ChatUtil.sendMessage(p, Config.SPEED_BUYMESS);
  31. Bukkit.getOnlinePlayers().forEach(all -> ChatUtil.sendMessage(all, Config.SPEED_BUYBC.replace("{PLAYER}", p.getName())));
  32. p.sendTitle(ChatUtil.fixColor(Config.SPEED_BUYTITLE), ChatUtil.fixColor(Config.SPEED_BUYSUBTITLE));
  33. } else {
  34. ChatUtil.sendMessage(p, Config.SPEED_LACK);
  35. }
  36. }
  37. if (event.getSlot() == Config.STRENGTH_SLOT) {
  38. if (p.getInventory().containsAtLeast(new ItemStack(Material.getMaterial(Config.STRENGTH_CURRENCY)), Config.STRENGTH_AMOUNT)) {
  39. p.getInventory().removeItem(new ItemStack(Material.getMaterial(Config.STRENGTH_CURRENCY), Config.STRENGTH_AMOUNT));
  40. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Config.STRENGTH_DURATION, 0, true));
  41. ChatUtil.sendMessage(p, Config.STRENGTH_BUYMESS);
  42. Bukkit.getOnlinePlayers().forEach(all -> ChatUtil.sendMessage(all, Config.STRENGTH_BUYBC.replace("{PLAYER}", p.getName())));
  43. p.sendTitle(ChatUtil.fixColor(Config.STRENGTH_BUYTITLE), ChatUtil.fixColor(Config.STRENGTH_BUYSUBTITLE));
  44. } else {
  45. ChatUtil.sendMessage(p, Config.STRENGTH_LACK);
  46. }
  47. }
  48. if (event.getSlot() == Config.HASTE_SLOT) {
  49. if (p.getInventory().containsAtLeast(new ItemStack(Material.getMaterial(Config.HASTE_CURRENCY)), Config.HASTE_AMOUNT)) {
  50. p.getInventory().removeItem(new ItemStack(Material.getMaterial(Config.HASTE_CURRENCY), Config.HASTE_AMOUNT));
  51. p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Config.HASTE_DURATION, 0, true));
  52. ChatUtil.sendMessage(p, Config.HASTE_BUYMESS);
  53. Bukkit.getOnlinePlayers().forEach(all -> ChatUtil.sendMessage(all, Config.HASTE_BUYBC.replace("{PLAYER}", p.getName())));
  54. p.sendTitle(ChatUtil.fixColor(Config.HASTE_BUYTITLE), ChatUtil.fixColor(Config.HASTE_BUYSUBTITLE));
  55. } else {
  56. ChatUtil.sendMessage(p, Config.HASTE_LACK);
  57. }
  58. }
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment