Beispiel #1
0
 @EventHandler
 public void onPlayerMove(PlayerMoveEvent e) {
   if (plugin.worldEnabledFallout(e.getPlayer().getWorld().getName())) {
     if (e.getTo().getWorld().getBlockAt(e.getTo()).getType() == Material.WATER
         || e.getTo().getWorld().getBlockAt(e.getTo()).getType() == Material.STATIONARY_WATER) {
       if (plugin.getConfig().getDouble("maxRadiationWashable")
           >= plugin.getRadiationManager().getPlayerRadiation(e.getPlayer()))
         plugin.getRadiationManager().setPlayerRadiation(e.getPlayer(), 0.0);
     }
   }
 }
Beispiel #2
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);
    }
  }