mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Fixes #266
This commit is contained in:
		@@ -709,7 +709,7 @@ public class PlotSquared {
 | 
			
		||||
        final List<String> booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone", "keep");
 | 
			
		||||
        final List<String> intervalFlags = Arrays.asList("feed", "heal");
 | 
			
		||||
        final List<String> stringFlags = Arrays.asList("greeting", "farewell");
 | 
			
		||||
        final List<String> intFlags = Arrays.asList("mob-cap", "animal-cap", "hostile-cap");
 | 
			
		||||
        final List<String> intFlags = Arrays.asList("entity-cap", "mob-cap", "animal-cap", "hostile-cap", "vehicle-cap");
 | 
			
		||||
        for (final String flag : stringFlags) {
 | 
			
		||||
            FlagManager.addFlag(new AbstractFlag(flag));
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@ import org.bukkit.entity.Projectile;
 | 
			
		||||
import org.bukkit.entity.SmallFireball;
 | 
			
		||||
import org.bukkit.entity.Tameable;
 | 
			
		||||
import org.bukkit.entity.ThrownPotion;
 | 
			
		||||
import org.bukkit.entity.Vehicle;
 | 
			
		||||
import org.bukkit.entity.minecart.RideableMinecart;
 | 
			
		||||
import org.bukkit.event.EventHandler;
 | 
			
		||||
import org.bukkit.event.EventPriority;
 | 
			
		||||
@@ -809,9 +810,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
 | 
			
		||||
        }
 | 
			
		||||
        Plot plot = MainUtil.getPlot(loc);
 | 
			
		||||
        if (plot != null && plot.owner != null) {
 | 
			
		||||
            Flag entityFlag = FlagManager.getPlotFlag(plot, "mob-cap");
 | 
			
		||||
            Flag entityFlag = FlagManager.getPlotFlag(plot, "entity-cap");
 | 
			
		||||
            Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap");
 | 
			
		||||
            Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap");
 | 
			
		||||
            Flag mobFlag = FlagManager.getPlotFlag(plot, "mob-cap");
 | 
			
		||||
            Flag vehicleFlag = FlagManager.getPlotFlag(plot, "vehicle-cap");
 | 
			
		||||
            if (!(entity instanceof Creature)) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
@@ -824,7 +827,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            int[] mobs = ChunkManager.manager.countEntities(plot);
 | 
			
		||||
            if (entity instanceof Creature) {
 | 
			
		||||
            if (entity instanceof Creature || entity instanceof Vehicle) {
 | 
			
		||||
                if (entityFlag != null) {
 | 
			
		||||
                    int cap = ((Integer) entityFlag.getValue());
 | 
			
		||||
                    if (mobs[0] >= cap) {
 | 
			
		||||
@@ -832,21 +835,39 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (entity instanceof Animals) {
 | 
			
		||||
                if (animalFlag != null) {
 | 
			
		||||
                    int cap = ((Integer) animalFlag.getValue());
 | 
			
		||||
                    if (mobs[1] >= cap) {
 | 
			
		||||
                        event.setCancelled(true);
 | 
			
		||||
                if (entity instanceof Creature) {
 | 
			
		||||
                    if (mobFlag != null) {
 | 
			
		||||
                        int cap = ((Integer) mobFlag.getValue());
 | 
			
		||||
                        if (mobs[3] >= cap) {
 | 
			
		||||
                            event.setCancelled(true);
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    if (entity instanceof Animals) {
 | 
			
		||||
                        if (animalFlag != null) {
 | 
			
		||||
                            int cap = ((Integer) animalFlag.getValue());
 | 
			
		||||
                            if (mobs[1] >= cap) {
 | 
			
		||||
                                event.setCancelled(true);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (entity instanceof Monster) {
 | 
			
		||||
                        if (monsterFlag != null) {
 | 
			
		||||
                            int cap = ((Integer) monsterFlag.getValue());
 | 
			
		||||
                            if (mobs[2] >= cap) {
 | 
			
		||||
                                event.setCancelled(true);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (entity instanceof Monster) {
 | 
			
		||||
                if (monsterFlag != null) {
 | 
			
		||||
                    int cap = ((Integer) monsterFlag.getValue());
 | 
			
		||||
                    if (mobs[2] >= cap) {
 | 
			
		||||
                        event.setCancelled(true);
 | 
			
		||||
                else {
 | 
			
		||||
                    if (vehicleFlag != null) {
 | 
			
		||||
                        int cap = ((Integer) vehicleFlag.getValue());
 | 
			
		||||
                        if (mobs[4] >= cap) {
 | 
			
		||||
                            event.setCancelled(true);
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user