Reduce TNT minecart lag

This commit is contained in:
mathiascode 2020-02-20 16:50:21 +02:00
parent 6694621deb
commit 8ff92bb4d4
2 changed files with 25 additions and 2 deletions

View file

@ -114,6 +114,7 @@ public final class Main extends JavaPlugin {
"essentials:warp",
"essentials:warps",
"essentials:whisper",
"essentials:world",
"action",
"adventure",
"adventuremode",
@ -181,6 +182,7 @@ public final class Main extends JavaPlugin {
"warp",
"warps",
"whisper",
"world",
"essentials:eaction",
"essentials:eadventure",
@ -257,6 +259,7 @@ public final class Main extends JavaPlugin {
"essentials:ewarp",
"essentials:ewarps",
"essentials:ewhisper",
"essentials:eworld",
"eaction",
"eadventure",
"eadventuremode",
@ -332,6 +335,7 @@ public final class Main extends JavaPlugin {
"ewarp",
"ewarps",
"ewhisper",
"eworld",
"extras:bcraw",
"extras:broadcastraw",

View file

@ -7,20 +7,31 @@ import org.bukkit.World;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.*;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.EnderDragon;
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;
import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.SpawnerSpawnEvent;
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;
import org.bukkit.event.weather.LightningStrikeEvent;
public class EntitySpawn implements Listener {
private void applyEntityChanges(Entity entity) {
@ -221,6 +232,14 @@ public class EntitySpawn implements Listener {
checkShouldRemoveEntities(world);
}
}
@EventHandler
void onEntityExplode(EntityExplodeEvent event) {
if (EntityType.MINECART_TNT.equals(event.getEntityType()) &&
event.getEntity().getWorld().getEntitiesByClass(ExplosiveMinecart.class).size() > 80) {
event.setCancelled(true);
}
}
@EventHandler
void onEntitySpawn(EntitySpawnEvent event) {