mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
New config settings for Protect:
protect.prevent.tnt-playerdamage protect.prevent.fireball-fire protect.prevent.fireball-playerdamage
This commit is contained in:
parent
83b71eef5e
commit
3d232e13d9
@ -342,7 +342,10 @@ protect:
|
||||
lightning-fire-spread: true
|
||||
portal-creation: false
|
||||
tnt-explosion: false
|
||||
tnt-playerdamage: false
|
||||
fireball-explosion: false
|
||||
fireball-fire: false
|
||||
fireball-playerdamage: false
|
||||
creeper-explosion: false
|
||||
creeper-playerdamage: false
|
||||
creeper-blockdamage: false
|
||||
|
@ -53,6 +53,7 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect
|
||||
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.ENTITY_TARGET, entityListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.EXPLOSION_PRIME, entityListener, Priority.Highest, this);
|
||||
|
||||
final EssentialsProtectWeatherListener weatherListener = new EssentialsProtectWeatherListener(this);
|
||||
pm.registerEvent(Type.LIGHTNING_STRIKE, weatherListener, Priority.Highest, this);
|
||||
|
@ -18,8 +18,10 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.entity.CraftTNTPrimed;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@ -30,6 +32,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
|
||||
|
||||
public class EssentialsProtectEntityListener extends EntityListener
|
||||
@ -118,6 +121,24 @@ public class EssentialsProtectEntityListener extends EntityListener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (eAttack instanceof Fireball && prot.getSettingBool(ProtectConfig.prevent_fireball_playerdmg)
|
||||
&& !(target instanceof Player
|
||||
&& user.isAuthorized("essentials.protect.damage.fireball")
|
||||
&& !user.isAuthorized("essentials.protect.damage.disable")))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (eAttack instanceof TNTPrimed && prot.getSettingBool(ProtectConfig.prevent_tnt_playerdmg)
|
||||
&& !(target instanceof Player
|
||||
&& user.isAuthorized("essentials.protect.damage.tnt")
|
||||
&& !user.isAuthorized("essentials.protect.damage.disable")))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event instanceof EntityDamageByProjectileEvent
|
||||
@ -314,4 +335,14 @@ public class EssentialsProtectEntityListener extends EntityListener
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof CraftFireball
|
||||
&& prot.getSettingBool(ProtectConfig.prevent_fireball_fire))
|
||||
{
|
||||
event.setFire(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,10 @@ public enum ProtectConfig
|
||||
prevent_portal_creation("protect.prevent.portal-creation", false),
|
||||
prevent_block_on_rail("protect.protect.prevent-block-on-rails", false),
|
||||
prevent_tnt_explosion("protect.prevent.tnt-explosion", false),
|
||||
prevent_tnt_playerdmg("protect.prevent.tnt-playerdamage", false),
|
||||
prevent_fireball_explosion("protect.prevent.fireball-explosion", false),
|
||||
prevent_fireball_fire("protect.prevent.fireball-fire", false),
|
||||
prevent_fireball_playerdmg("protect.prevent.fireball-playerdamage", false),
|
||||
prevent_creeper_explosion("protect.prevent.creeper-explosion", true),
|
||||
prevent_creeper_playerdmg("protect.prevent.creeper-playerdamage", false),
|
||||
prevent_creeper_blockdmg("protect.prevent.creeper-blockdamage", false),
|
||||
|
Loading…
Reference in New Issue
Block a user