diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/MinecartLimit.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/MinecartLimit.java index 2b26ba456..26c84c808 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/MinecartLimit.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/MinecartLimit.java @@ -1,5 +1,6 @@ package me.moomoo.anarchyexploitfixes.modules.chunklimits; +import io.papermc.paper.tag.EntityTags; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; import me.moomoo.anarchyexploitfixes.config.Config; @@ -8,7 +9,6 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Vehicle; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -16,15 +16,11 @@ import org.bukkit.event.Listener; import org.bukkit.event.vehicle.VehicleCreateEvent; -import java.util.Arrays; -import java.util.HashSet; import java.util.logging.Level; -import java.util.stream.Collectors; public class MinecartLimit implements AnarchyExploitFixesModule, Listener { private final AnarchyExploitFixes plugin; - private final HashSet MINECART_TYPES; private ScheduledTask scheduledTask; private final long checkPeriod; private final int maxMinecartsPerChunk; @@ -33,9 +29,6 @@ public class MinecartLimit implements AnarchyExploitFixesModule, Listener { public MinecartLimit() { shouldEnable(); this.plugin = AnarchyExploitFixes.getInstance(); - this.MINECART_TYPES = Arrays.stream(EntityType.values()) - .filter(type -> type.name().toUpperCase().contains("MINECART")) - .collect(Collectors.toCollection(HashSet::new)); Config config = AnarchyExploitFixes.getConfiguration(); config.addComment("chunk-limits.minecart-limit.enable", "Limit the amount of minecarts to prevent lag."); @@ -75,11 +68,11 @@ public void disable() { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) private void onCreate(VehicleCreateEvent event) { Vehicle vehicle = event.getVehicle(); - if (!MINECART_TYPES.contains(vehicle.getType())) return; + if (!EntityTags.MINECARTS.isTagged(vehicle.getType())) return; int minecartCount = 0; for (Entity entity : vehicle.getChunk().getEntities()) { - if (!MINECART_TYPES.contains(entity.getType())) continue; + if (!EntityTags.MINECARTS.isTagged(entity.getType())) continue; minecartCount++; if (minecartCount <= maxMinecartsPerChunk) continue; @@ -102,7 +95,7 @@ private void run() { int minecartCount = 0; for (Entity entity : chunk.getEntities()) { - if (!MINECART_TYPES.contains(entity.getType())) continue; + if (!EntityTags.MINECARTS.isTagged(entity.getType())) continue; minecartCount++; if (minecartCount <= maxMinecartsPerChunk) continue; diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/VehicleLimit.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/VehicleLimit.java index a5772fbfe..330406c99 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/VehicleLimit.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/VehicleLimit.java @@ -1,5 +1,6 @@ package me.moomoo.anarchyexploitfixes.modules.chunklimits; +import io.papermc.paper.tag.EntityTags; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; import me.moomoo.anarchyexploitfixes.config.Config; @@ -16,10 +17,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.vehicle.VehicleCreateEvent; -import java.util.Arrays; import java.util.HashSet; import java.util.logging.Level; -import java.util.stream.Collectors; public class VehicleLimit implements AnarchyExploitFixesModule, Listener { @@ -35,10 +34,10 @@ public VehicleLimit() { this.plugin = AnarchyExploitFixes.getInstance(); this.VEHICLE_TYPES = new HashSet<>(); // Used to cache entity types of vehicles for faster operations // Prefill with known types; - this.VEHICLE_TYPES.addAll(Arrays.stream(EntityType.values()).filter(entityType -> { - final String name = entityType.name().toUpperCase(); - return name.contains("MINECART") && name.contains("BOAT"); - }).collect(Collectors.toSet())); + this.VEHICLE_TYPES.add(EntityType.BOAT); + this.VEHICLE_TYPES.add(EntityType.CHEST_BOAT); + this.VEHICLE_TYPES.addAll(EntityTags.HORSES.getValues()); + this.VEHICLE_TYPES.addAll(EntityTags.MINECARTS.getValues()); Config config = AnarchyExploitFixes.getConfiguration(); config.addComment("chunk-limits.vehicle-limit.enable", "Limit the amount of vehicles to prevent some lag machines involving boats and a dispenser."); diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/VehicleLimit.java b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/VehicleLimit.java index 129af5671..f0aeadcee 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/VehicleLimit.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/VehicleLimit.java @@ -34,7 +34,7 @@ public VehicleLimit() { // Prefill with known types; this.VEHICLE_TYPES.addAll(Arrays.stream(EntityType.values()).filter(entityType -> { final String name = entityType.name().toUpperCase(); - return name.contains("MINECART") && name.contains("BOAT"); + return name.contains("MINECART") || name.contains("BOAT") || name.contains("HORSE"); }).collect(Collectors.toSet())); Config config = AnarchyExploitFixes.getConfiguration(); config.addComment("chunk-limits.vehicle-limit.enable",