mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +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,21 +835,39 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (entity instanceof Creature) {
|
||||||
if (entity instanceof Animals) {
|
if (mobFlag != null) {
|
||||||
if (animalFlag != null) {
|
int cap = ((Integer) mobFlag.getValue());
|
||||||
int cap = ((Integer) animalFlag.getValue());
|
if (mobs[3] >= cap) {
|
||||||
if (mobs[1] >= cap) {
|
event.setCancelled(true);
|
||||||
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;
|
else {
|
||||||
}
|
if (vehicleFlag != null) {
|
||||||
if (entity instanceof Monster) {
|
int cap = ((Integer) vehicleFlag.getValue());
|
||||||
if (monsterFlag != null) {
|
if (mobs[4] >= cap) {
|
||||||
int cap = ((Integer) monsterFlag.getValue());
|
event.setCancelled(true);
|
||||||
if (mobs[2] >= cap) {
|
return;
|
||||||
event.setCancelled(true);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user