@EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerDrinkPotion(PlayerItemConsumeEvent event) {
   Player player = event.getPlayer();
   if (event.getItem().getType() == Material.POTION && !FOPM_TFM_Util.isHighRank(player)) {
     player.sendMessage(ChatColor.GREEN + "Please use /potion to add potion effects, thank you!");
     event.setCancelled(true);
   }
 }
예제 #2
0
 public void onItemDamage(PlayerItemConsumeEvent e) {
   if (ItemManager.toRPGItem(e.getItem()) != null) {
     RPGItem rpgitem = ItemManager.toRPGItem(e.getItem());
     if (rpgitem.getMaxDurability() > 0) {
       e.getItem().setDurability((short) -1);
     }
   }
 }
예제 #3
0
 @EventHandler
 public void onEat(PlayerItemConsumeEvent e) {
   if (e.getItem() != null) {
     final Player p = e.getPlayer();
     ItemStack item = e.getItem();
     if (Slimefun.hasUnlocked(p, item, true)) {
       if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MONSTER_JERKY, true)) {
         PlayerInventory.consumeItemInHand(p);
         e.setItem(new ItemStack(Material.APPLE));
       } else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.FORTUNE_COOKIE, true))
         p.sendMessage(
             Messages.local
                 .getTranslation("messages.fortune-cookie")
                 .get(
                     CSCoreLib.randomizer()
                         .nextInt(
                             Messages.local.getTranslation("messages.fortune-cookie").size())));
       else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BEEF_JERKY, true))
         p.setSaturation((Integer) Slimefun.getItemValue("BEEF_JERKY", "Saturation"));
       else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.GRILLED_CHEESE, true))
         p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 8, 0));
       else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BUTTERED_POTATO, true))
         p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 8, 0));
       else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MEDICINE, true)) {
         if (p.hasPotionEffect(PotionEffectType.POISON))
           p.removePotionEffect(PotionEffectType.POISON);
         if (p.hasPotionEffect(PotionEffectType.WITHER))
           p.removePotionEffect(PotionEffectType.WITHER);
         if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
         if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING))
           p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
         if (p.hasPotionEffect(PotionEffectType.WEAKNESS))
           p.removePotionEffect(PotionEffectType.WEAKNESS);
         if (p.hasPotionEffect(PotionEffectType.CONFUSION))
           p.removePotionEffect(PotionEffectType.CONFUSION);
         if (p.hasPotionEffect(PotionEffectType.BLINDNESS))
           p.removePotionEffect(PotionEffectType.BLINDNESS);
         p.setFireTicks(0);
       } else if (item.getType() == Material.POTION) {
         SlimefunItem sfItem = SlimefunItem.getByItem(item);
         if (sfItem != null && sfItem instanceof Juice) {
           Bukkit.getScheduler()
               .scheduleSyncDelayedTask(
                   main.instance,
                   new Runnable() {
                     @Override
                     public void run() {
                       p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1));
                     }
                   },
                   1L);
         }
       }
     } else e.setCancelled(true);
   }
 }
예제 #4
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
   String playerName = event.getPlayer().getName();
   if (ultimateGames.getPlayerManager().isPlayerInArena(playerName)) {
     Arena arena = ultimateGames.getPlayerManager().getPlayerArena(playerName);
     if (arena.getStatus() == ArenaStatus.RUNNING) {
       arena.getGame().getGamePlugin().onPlayerItemConsume(arena, event);
     } else {
       event.setCancelled(true);
     }
   } else if (ultimateGames.getPlayerManager().isPlayerSpectatingArena(playerName)) {
     event.setCancelled(true);
   }
 }
예제 #5
0
 @EventHandler
 public void potion(PlayerItemConsumeEvent event) {
   if (event.getItem().getType().equals(Material.POTION)) {
     if (event.getItem().getDurability() == 8233) {
       if (!event.getPlayer().isOp()) {
         event.setCancelled(true);
         event.getPlayer().sendMessage(ChatColor.GRAY + "Strength 2 potions are banned!");
       }
     }
     if (event.getItem().getDurability() == 8238 || event.getItem().getDurability() == 8270) {
       if (!event.getPlayer().isOp()) {
         event.setCancelled(true);
         event.getPlayer().sendMessage(ChatColor.GRAY + "Invisibility potions are banned!");
       }
     }
   }
 }
예제 #6
0
 @EventHandler
 public void onPlayerEatEvent(PlayerItemConsumeEvent event) {
   if ((isEnabled())
       && (UHCutils.getMainConfig().getBoolean("features.potionNerfs.disableAbsorb"))) {
     ItemStack localItemStack = event.getItem();
     if (localItemStack.getType().equals(Material.GOLDEN_APPLE)) {
       final String name = event.getPlayer().getName();
       Bukkit.getScheduler()
           .scheduleSyncDelayedTask(
               UHCutils.getUHCutils(),
               new Runnable() {
                 public void run() {
                   Player p = Bukkit.getPlayerExact(name);
                   p.removePotionEffect(PotionEffectType.ABSORPTION);
                 }
               });
     }
   }
 }
예제 #7
0
  @EventHandler
  public void onPlayerEat(final PlayerItemConsumeEvent e) {
    boolean isCure = false;

    for (String s : plugin.getConfig().getStringList("radiationCures")) {
      if (e.getItem().getType().equals(Material.matchMaterial(s))) {
        isCure = true;
        break;
      }
    }

    if (isCure) plugin.getRadiationManager().setPlayerRadiation(e.getPlayer(), 0.0);

    if (plugin.getRadiationManager().getPlayerRadiation(e.getPlayer()) >= 6.0 && !e.isCancelled()) {
      final int oldLevel = e.getPlayer().getFoodLevel();

      plugin
          .getServer()
          .getScheduler()
          .scheduleSyncDelayedTask(
              plugin,
              new Runnable() {
                @Override
                public void run() {
                  e.getPlayer().setFoodLevel(oldLevel);
                  Item dropped =
                      e.getPlayer()
                          .getWorld()
                          .dropItem(
                              e.getPlayer().getLocation(), new ItemStack(Material.ROTTEN_FLESH));
                  dropped.setVelocity(
                      e.getPlayer()
                          .getLocation()
                          .add(0, 1, 0)
                          .getDirection()
                          .normalize()
                          .multiply(1));
                }
              },
              3);
    }
  }
예제 #8
0
  @EventHandler
  public void playerEatEvent(PlayerItemConsumeEvent e) {
    if (!Minegusta.getServer().containsWorld(e.getPlayer().getWorld())) return;

    ElfPower fruit = ElfPower.consumeFruit(e);

    ElfInfect food = ElfInfect.elfInfect(e);

    if (fruit.isPlayer() && fruit.isElf() && fruit.isFruit()) {
      fruit.applyFoodRegenBoost();
    }

    if (food.isHuman() && food.hasLore() && food.isVeganStew()) {
      food.makeElf();
    }
  }
예제 #9
0
 public NatureBoost(PlayerItemConsumeEvent e) {
   this.p = e.getPlayer();
   this.isCancelled = e.isCancelled();
 }
예제 #10
0
 @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
 public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
   if (!allowPlayer(event.getPlayer())) return;
   onConsume(event.getPlayer(), event.getItem());
 }