diff --git a/src/main/java/pw/kaboom/extras/modules/block/BlockCheck.java b/src/main/java/pw/kaboom/extras/modules/block/BlockCheck.java index fa9501d..51046f7 100644 --- a/src/main/java/pw/kaboom/extras/modules/block/BlockCheck.java +++ b/src/main/java/pw/kaboom/extras/modules/block/BlockCheck.java @@ -49,6 +49,12 @@ public final class BlockCheck implements Listener { } }*/ + /*@Subscribe + public void onEditSessionEvent(final EditSessionEvent event) { + event.setExtent(new NullExtent()); + + }*/ + @EventHandler void onSignChange(final SignChangeEvent event) { try { diff --git a/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java b/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java index 4858cbf..8bb057c 100644 --- a/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java +++ b/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java @@ -4,8 +4,6 @@ import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.attribute.Attribute; -import org.bukkit.attribute.AttributeInstance; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.EnderDragon; @@ -13,7 +11,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LightningStrike; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Slime; import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.Vehicle; @@ -28,25 +25,18 @@ import org.bukkit.event.vehicle.VehicleCreateEvent; import org.bukkit.event.weather.LightningStrikeEvent; import com.destroystokyo.paper.event.block.TNTPrimeEvent; -import com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason; import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent; import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent; import com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent; public final class EntitySpawn implements Listener { private void applyEntityChanges(final Entity entity) { - if (entity instanceof LivingEntity) { - final LivingEntity mob = (LivingEntity) entity; - - limitFollowAttribute(mob); - } - switch (entity.getType()) { case AREA_EFFECT_CLOUD: final AreaEffectCloud cloud = (AreaEffectCloud) entity; limitAreaEffectCloudRadius(cloud); - break; + return; case MAGMA_CUBE: case SLIME: final Slime slime = (Slime) entity; @@ -100,8 +90,8 @@ public final class EntitySpawn implements Listener { } private boolean isOutsideBoundaries(final double x, final double y, final double z) { - int maxValue = 30000000; - int minValue = -30000000; + final int maxValue = 30000000; + final int minValue = -30000000; if (x > maxValue || x < minValue @@ -128,22 +118,13 @@ public final class EntitySpawn implements Listener { } } - private void limitFollowAttribute(final LivingEntity mob) { - final AttributeInstance followAttribute = mob.getAttribute(Attribute.GENERIC_FOLLOW_RANGE); - - if (followAttribute != null - && followAttribute.getBaseValue() > 40) { - followAttribute.setBaseValue(40); - } - } - public static Location limitLocation(final Location location) { double x = location.getX(); double y = location.getY(); double z = location.getZ(); - int maxValue = 30000000; - int minValue = -30000000; + final int maxValue = 30000000; + final int minValue = -30000000; if (x > maxValue) { x = maxValue; @@ -321,10 +302,16 @@ public final class EntitySpawn implements Listener { @EventHandler void onTNTPrime(final TNTPrimeEvent event) { - if (event.getBlock().getWorld().getEntitiesByClass(TNTPrimed.class).size() > 120) { - if (PrimeReason.EXPLOSION.equals(event.getReason())) { + switch (event.getReason()) { + case EXPLOSION: + case FIRE: + case REDSTONE: + if (event.getBlock().getWorld().getEntitiesByClass(TNTPrimed.class).size() > 120) { event.setCancelled(true); } + return; + default: + break; } } diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerTeleport.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerTeleport.java index cb5ae2e..e1f8d3e 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerTeleport.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerTeleport.java @@ -1,13 +1,25 @@ package pw.kaboom.extras.modules.player; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; - +import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerTeleportEvent; import pw.kaboom.extras.modules.entity.EntitySpawn; public final class PlayerTeleport implements Listener { + @EventHandler + void onPlayerChangedWorld(final PlayerChangedWorldEvent event) { + final Player player = event.getPlayer(); + + if (player.getMaxHealth() <= 0) { + player.setMaxHealth(Double.POSITIVE_INFINITY); + player.setHealth(20); + player.setMaxHealth(20); + } + } + @EventHandler void onPlayerTeleport(final PlayerTeleportEvent event) { event.setTo(EntitySpawn.limitLocation(event.getTo()));