diff --git a/pom.xml b/pom.xml
index 5d0f2f3..27c8999 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
es.ponnythelight
ChunkEntityLimiter
- 1.1.3-SNAPSHOT
+ 1.1.4-SNAPSHOT
jar
ChunkEntityLimiter
diff --git a/src/main/java/es/ponnythelight/listeners/checkListener.java b/src/main/java/es/ponnythelight/listeners/checkListener.java
index ab372b9..268b122 100644
--- a/src/main/java/es/ponnythelight/listeners/checkListener.java
+++ b/src/main/java/es/ponnythelight/listeners/checkListener.java
@@ -9,11 +9,13 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
+import org.bukkit.entity.Vehicle;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
+import org.bukkit.event.vehicle.VehicleCreateEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import java.util.Arrays;
@@ -140,19 +142,6 @@ public void playerDropItem(PlayerDropItemEvent e) {
AtomicInteger counti = new AtomicInteger();
-// en.stream().forEach(k -> {
-//
-// if (k.getType().equals(EntityType.DROPPED_ITEM)) {
-// counti.getAndIncrement();
-//
-// if (counti.get() >= config.getInt("Config.dropped-items-per-chunk")) {
-// System.out.println("Spawn");
-// e.setCancelled(true);
-// return player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("Messages.prefix") + config.getString("Messages.max-dropped-items")));
-// }
-//
-// }
-// });
for (Entity i : en) {
if (i.getType().equals(EntityType.DROPPED_ITEM)) {
@@ -168,5 +157,56 @@ public void playerDropItem(PlayerDropItemEvent e) {
}
}
+ @EventHandler
+ public void PlayerInteract(VehicleCreateEvent e) {
+ Configuration config = plugin.getConfig();
+ Vehicle v = e.getVehicle();
+
+ Chunk chunk = v.getLocation().getChunk();
+
+ List en = Arrays.asList(chunk.getEntities());
+ AtomicInteger countp = new AtomicInteger();
+
+ en.forEach(k -> {
+ if (k.getType().equals(EntityType.MINECART)) {
+ countp.getAndIncrement();
+
+ if (countp.get() >= config.getInt("Config.entities-per-chunk")) {
+ e.setCancelled(true);
+ }
+ } else if (k.getType().equals(EntityType.MINECART_CHEST)) {
+ countp.getAndIncrement();
+
+ if (countp.get() >= config.getInt("Config.entities-per-chunk")) {
+ e.setCancelled(true);
+ }
+ } else if (k.getType().equals(EntityType.MINECART_FURNACE)) {
+ countp.getAndIncrement();
+
+ if (countp.get() >= config.getInt("Config.entities-per-chunk")) {
+ e.setCancelled(true);
+ }
+ } else if (k.getType().equals(EntityType.MINECART_HOPPER)) {
+ countp.getAndIncrement();
+
+ if (countp.get() >= config.getInt("Config.entities-per-chunk")) {
+ e.setCancelled(true);
+ }
+ } else if (k.getType().equals(EntityType.MINECART_TNT)) {
+ countp.getAndIncrement();
+
+ if (countp.get() >= config.getInt("Config.entities-per-chunk")) {
+ e.setCancelled(true);
+ }
+ } else if (k.getType().equals(EntityType.MINECART_MOB_SPAWNER)) {
+ countp.getAndIncrement();
+
+ if (countp.get() >= config.getInt("Config.entities-per-chunk")) {
+ e.setCancelled(true);
+ }
+ }
+ });
+ }
+
}