This commit is contained in:
boy0001 2015-04-15 00:33:57 +10:00
parent ae9ae154f2
commit 964fd0f5e9
2 changed files with 37 additions and 16 deletions

View File

@ -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));
}

View File

@ -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,6 +835,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return;
}
}
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) {
@ -842,7 +852,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
}
return;
}
if (entity instanceof Monster) {
else if (entity instanceof Monster) {
if (monsterFlag != null) {
int cap = ((Integer) monsterFlag.getValue());
if (mobs[2] >= cap) {
@ -851,6 +861,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
}
}
}
else {
if (vehicleFlag != null) {
int cap = ((Integer) vehicleFlag.getValue());
if (mobs[4] >= cap) {
event.setCancelled(true);
return;
}
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)