mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-29 16:46:45 +01:00
Fixes #266
This commit is contained in:
parent
ae9ae154f2
commit
964fd0f5e9
@ -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> 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> intervalFlags = Arrays.asList("feed", "heal");
|
||||||
final List<String> stringFlags = Arrays.asList("greeting", "farewell");
|
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) {
|
for (final String flag : stringFlags) {
|
||||||
FlagManager.addFlag(new AbstractFlag(flag));
|
FlagManager.addFlag(new AbstractFlag(flag));
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import org.bukkit.entity.Projectile;
|
|||||||
import org.bukkit.entity.SmallFireball;
|
import org.bukkit.entity.SmallFireball;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.ThrownPotion;
|
import org.bukkit.entity.ThrownPotion;
|
||||||
|
import org.bukkit.entity.Vehicle;
|
||||||
import org.bukkit.entity.minecart.RideableMinecart;
|
import org.bukkit.entity.minecart.RideableMinecart;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -809,9 +810,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
Plot plot = MainUtil.getPlot(loc);
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
if (plot != null && plot.owner != null) {
|
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 animalFlag = FlagManager.getPlotFlag(plot, "animal-cap");
|
||||||
Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-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)) {
|
if (!(entity instanceof Creature)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -824,7 +827,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int[] mobs = ChunkManager.manager.countEntities(plot);
|
int[] mobs = ChunkManager.manager.countEntities(plot);
|
||||||
if (entity instanceof Creature) {
|
if (entity instanceof Creature || entity instanceof Vehicle) {
|
||||||
if (entityFlag != null) {
|
if (entityFlag != null) {
|
||||||
int cap = ((Integer) entityFlag.getValue());
|
int cap = ((Integer) entityFlag.getValue());
|
||||||
if (mobs[0] >= cap) {
|
if (mobs[0] >= cap) {
|
||||||
@ -832,6 +835,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
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 (entity instanceof Animals) {
|
||||||
if (animalFlag != null) {
|
if (animalFlag != null) {
|
||||||
@ -842,7 +852,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity instanceof Monster) {
|
else if (entity instanceof Monster) {
|
||||||
if (monsterFlag != null) {
|
if (monsterFlag != null) {
|
||||||
int cap = ((Integer) monsterFlag.getValue());
|
int cap = ((Integer) monsterFlag.getValue());
|
||||||
if (mobs[2] >= cap) {
|
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)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
Loading…
Reference in New Issue
Block a user