Пример #1
0
 private void handleEffectsForDimension(int power, int id, DimensionInformation information) {
   WorldServer world = DimensionManager.getWorld(id);
   if (world != null) {
     Set<EffectType> effects = information.getEffectTypes();
     List<EntityPlayer> players = new ArrayList<EntityPlayer>(world.playerEntities);
     for (EntityPlayer player : players) {
       for (EffectType effect : effects) {
         Integer potionEffect = effectsMap.get(effect);
         if (potionEffect != null) {
           Integer amplifier = effectAmplifierMap.get(effect);
           if (amplifier == null) {
             amplifier = 0;
           }
           player.addPotionEffect(
               new PotionEffect(potionEffect, EFFECTS_MAX * MAXTICKS * 3, amplifier, true));
         } else if (effect == EffectType.EFFECT_FLIGHT) {
           BuffProperties.addBuff(player, PlayerBuff.BUFF_FLIGHT, EFFECTS_MAX * MAXTICKS * 2);
         }
       }
       if (power < DimletConfiguration.DIMPOWER_WARN3) {
         // We are VERY low on power. Start bad effects.
         player.addPotionEffect(
             new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
         player.addPotionEffect(
             new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
         player.addPotionEffect(
             new PotionEffect(Potion.poison.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
         player.addPotionEffect(
             new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
       } else if (power < DimletConfiguration.DIMPOWER_WARN2) {
         player.addPotionEffect(
             new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
         player.addPotionEffect(
             new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
         player.addPotionEffect(
             new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 1, true));
       } else if (power < DimletConfiguration.DIMPOWER_WARN1) {
         player.addPotionEffect(
             new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 0, true));
         player.addPotionEffect(
             new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 0, true));
       }
     }
   }
 }