예제 #1
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);
    }
  }
예제 #2
0
 public NatureBoost(PlayerItemConsumeEvent e) {
   this.p = e.getPlayer();
   this.isCancelled = e.isCancelled();
 }