Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.pszemopl.pplextraefekty.events;
- import org.bukkit.Bukkit;
- import org.bukkit.Material;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import pl.pszemopl.pplextraefekty.configurations.Config;
- import pl.pszemopl.pplextraefekty.utils.ChatUtil;
- public class InventoryClickListener implements Listener {
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onClickMain(InventoryClickEvent event) {
- Player p = (Player) event.getWhoClicked();
- if (ChatUtil.fixColor(Config.NAME).equalsIgnoreCase(event.getClickedInventory().getName())) {
- event.setCancelled(true);
- if (event.getSlot() == Config.SPEED_SLOT) {
- if (p.getInventory().containsAtLeast(new ItemStack(Material.getMaterial(Config.SPEED_CURRENCY)), Config.SPEED_AMOUNT)) {
- p.getInventory().removeItem(new ItemStack(Material.getMaterial(Config.SPEED_CURRENCY), Config.SPEED_AMOUNT));
- p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Config.SPEED_DURATION, 1, true));
- p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Config.SPEED_DURATION, 1, true));
- p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Config.SPEED_DURATION, 0, true));
- p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Config.SPEED_DURATION1, 0, true));
- p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Config.SPEED_DURATION1, 0, true));
- ChatUtil.sendMessage(p, Config.SPEED_BUYMESS);
- Bukkit.getOnlinePlayers().forEach(all -> ChatUtil.sendMessage(all, Config.SPEED_BUYBC.replace("{PLAYER}", p.getName())));
- p.sendTitle(ChatUtil.fixColor(Config.SPEED_BUYTITLE), ChatUtil.fixColor(Config.SPEED_BUYSUBTITLE));
- } else {
- ChatUtil.sendMessage(p, Config.SPEED_LACK);
- }
- }
- if (event.getSlot() == Config.STRENGTH_SLOT) {
- if (p.getInventory().containsAtLeast(new ItemStack(Material.getMaterial(Config.STRENGTH_CURRENCY)), Config.STRENGTH_AMOUNT)) {
- p.getInventory().removeItem(new ItemStack(Material.getMaterial(Config.STRENGTH_CURRENCY), Config.STRENGTH_AMOUNT));
- p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Config.STRENGTH_DURATION, 0, true));
- ChatUtil.sendMessage(p, Config.STRENGTH_BUYMESS);
- Bukkit.getOnlinePlayers().forEach(all -> ChatUtil.sendMessage(all, Config.STRENGTH_BUYBC.replace("{PLAYER}", p.getName())));
- p.sendTitle(ChatUtil.fixColor(Config.STRENGTH_BUYTITLE), ChatUtil.fixColor(Config.STRENGTH_BUYSUBTITLE));
- } else {
- ChatUtil.sendMessage(p, Config.STRENGTH_LACK);
- }
- }
- if (event.getSlot() == Config.HASTE_SLOT) {
- if (p.getInventory().containsAtLeast(new ItemStack(Material.getMaterial(Config.HASTE_CURRENCY)), Config.HASTE_AMOUNT)) {
- p.getInventory().removeItem(new ItemStack(Material.getMaterial(Config.HASTE_CURRENCY), Config.HASTE_AMOUNT));
- p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Config.HASTE_DURATION, 0, true));
- ChatUtil.sendMessage(p, Config.HASTE_BUYMESS);
- Bukkit.getOnlinePlayers().forEach(all -> ChatUtil.sendMessage(all, Config.HASTE_BUYBC.replace("{PLAYER}", p.getName())));
- p.sendTitle(ChatUtil.fixColor(Config.HASTE_BUYTITLE), ChatUtil.fixColor(Config.HASTE_BUYSUBTITLE));
- } else {
- ChatUtil.sendMessage(p, Config.HASTE_LACK);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment