diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index b69bcf9ff..176bef2f1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1132,6 +1132,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen return; } break; + case SPAWNER: + if (!area.MOB_SPAWNER_SPAWNING) { + event.setCancelled(true); + return; + } + break; } final Plot plot = area.getOwnedPlotAbs(loc); if (plot == null) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Trust.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Trust.java index bc88ae3f3..6d37ca4f4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Trust.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Trust.java @@ -20,8 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.UUID; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; @@ -34,6 +32,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; +import java.util.UUID; + @CommandDeclaration( command = "trust", aliases = { "t" }, @@ -77,7 +77,6 @@ public class Trust extends SubCommand { MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } - if (plot.getTrusted().contains(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 5c1f0af79..337668069 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -208,7 +208,7 @@ public class FlagManager { } public static Flag getSettingFlagAbs(final PlotSettings settings, final String flag) { - if (settings.flags == null || settings.flags.isEmpty()) { + if (settings.flags.isEmpty()) { return null; } return settings.flags.get(flag); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java index 38538919f..7532c8a1c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java @@ -54,6 +54,7 @@ public abstract class PlotArea { public boolean AUTO_MERGE = false; public boolean ALLOW_SIGNS = true; public boolean MOB_SPAWNING = false; + public boolean MOB_SPAWNER_SPAWNING = false; public int PLOT_BIOME = 1; public boolean PLOT_CHAT = false; public boolean SCHEMATIC_CLAIM_SPECIFY = false; @@ -198,6 +199,7 @@ public abstract class PlotArea { TYPE = config.getInt("generator.type"); } MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); + MOB_SPAWNER_SPAWNING = config.getBoolean("mob_spawner_spawning"); AUTO_MERGE = config.getBoolean("plot.auto_merge"); MAX_PLOT_MEMBERS = config.getInt("limits.max-members"); ALLOW_SIGNS = config.getBoolean("plot.create_signs"); @@ -292,6 +294,7 @@ public abstract class PlotArea { public void saveConfiguration(final ConfigurationSection config) { final HashMap options = new HashMap<>(); options.put("natural_mob_spawning", MOB_SPAWNING); + options.put("mob_spawner_spawning", MOB_SPAWNER_SPAWNING); options.put("plot.auto_merge", AUTO_MERGE); options.put("plot.create_signs", ALLOW_SIGNS); options.put("plot.biome", "FOREST"); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java index 21291b108..b285a4e82 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -175,114 +175,111 @@ public class MainListener { if (plotworld == null) { return; } - event.filterEntities(new Predicate() { - @Override - public boolean test(Entity entity) { - if (entity instanceof Player) { - return true; - } - final Location loc = SpongeUtil.getLocation(entity); - final Plot plot = loc.getPlot(); - if (plot == null) { - if (loc.isPlotRoad()) { - return false; - } - return true; - } - // Player player = this. getCause(event.getCause()); - // TODO selectively cancel depending on spawn reason - // - Not sure if possible to get spawn reason (since there are no callbacks) - // if (player != null && !plotworld.SPAWN_EGGS) { - // return false; - // return true; - // } - - if (entity.getType() == EntityTypes.ITEM) { - if (FlagManager.isPlotFlagFalse(plot, "item-drop")) { - return false; - } - return true; - } - int[] mobs = null; - if (entity instanceof Living) { - if (!plotworld.MOB_SPAWNING) { - return false; - } - final Flag mobCap = FlagManager.getPlotFlagRaw(plot, "mob-cap"); - if (mobCap != null) { - final Integer cap = (Integer) mobCap.getValue(); - if (cap == 0) { - return false; - } - mobs = plot.countEntities(); - if (mobs[3] >= cap) { - return false; - } - } - if ((entity instanceof Ambient) || (entity instanceof Animal)) { - final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap"); - if (animalFlag != null) { - final int cap = ((Integer) animalFlag.getValue()); - if (cap == 0) { - return false; - } - if (mobs == null) { - mobs = plot.countEntities(); - } - if (mobs[1] >= cap) { - return false; - } - } - } - if (entity instanceof Monster) { - final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap"); - if (monsterFlag != null) { - final int cap = ((Integer) monsterFlag.getValue()); - if (cap == 0) { - return false; - } - if (mobs == null) { - mobs = plot.countEntities(); - } - if (mobs[2] >= cap) { - return false; - } - } - } - return true; - } - if ((entity instanceof Minecart) || (entity instanceof Boat)) { - final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap"); - if (vehicleFlag != null) { - final int cap = ((Integer) vehicleFlag.getValue()); - if (cap == 0) { - return false; - } - mobs = plot.countEntities(); - if (mobs[4] >= cap) { - return false; - } - } - } - final Flag entityCap = FlagManager.getPlotFlagRaw(plot, "entity-cap"); - if (entityCap != null) { - final Integer cap = (Integer) entityCap.getValue(); - if (cap == 0) { - return false; - } - if (mobs == null) { - mobs = plot.countEntities(); - } - if (mobs[0] >= cap) { - return false; - } - } - if (entity instanceof PrimedTNT) { - Vector3d pos = entity.getLocation().getPosition(); - entity.setRotation(new Vector3d(MathMan.roundInt(pos.getX()), MathMan.roundInt(pos.getY()), MathMan.roundInt(pos.getZ()))); + event.filterEntities((Predicate) entity -> { + if (entity instanceof Player) { + return true; + } + final Location loc = SpongeUtil.getLocation(entity); + final Plot plot = loc.getPlot(); + if (plot == null) { + if (loc.isPlotRoad()) { + return false; } return true; } + // Player player = this. getCause(event.getCause()); + // TODO selectively cancel depending on spawn reason + // - Not sure if possible to get spawn reason (since there are no callbacks) + // if (player != null && !plotworld.SPAWN_EGGS) { + // return false; + // return true; + // } + + if (entity.getType() == EntityTypes.ITEM) { + if (FlagManager.isPlotFlagFalse(plot, "item-drop")) { + return false; + } + return true; + } + int[] mobs = null; + if (entity instanceof Living) { + if (!plotworld.MOB_SPAWNING) { + return false; + } + final Flag mobCap = FlagManager.getPlotFlagRaw(plot, "mob-cap"); + if (mobCap != null) { + final Integer cap = (Integer) mobCap.getValue(); + if (cap == 0) { + return false; + } + mobs = plot.countEntities(); + if (mobs[3] >= cap) { + return false; + } + } + if ((entity instanceof Ambient) || (entity instanceof Animal)) { + final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap"); + if (animalFlag != null) { + final int cap = ((Integer) animalFlag.getValue()); + if (cap == 0) { + return false; + } + if (mobs == null) { + mobs = plot.countEntities(); + } + if (mobs[1] >= cap) { + return false; + } + } + } + if (entity instanceof Monster) { + final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap"); + if (monsterFlag != null) { + final int cap = ((Integer) monsterFlag.getValue()); + if (cap == 0) { + return false; + } + if (mobs == null) { + mobs = plot.countEntities(); + } + if (mobs[2] >= cap) { + return false; + } + } + } + return true; + } + if ((entity instanceof Minecart) || (entity instanceof Boat)) { + final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap"); + if (vehicleFlag != null) { + final int cap = ((Integer) vehicleFlag.getValue()); + if (cap == 0) { + return false; + } + mobs = plot.countEntities(); + if (mobs[4] >= cap) { + return false; + } + } + } + final Flag entityCap = FlagManager.getPlotFlagRaw(plot, "entity-cap"); + if (entityCap != null) { + final Integer cap = (Integer) entityCap.getValue(); + if (cap == 0) { + return false; + } + if (mobs == null) { + mobs = plot.countEntities(); + } + if (mobs[0] >= cap) { + return false; + } + } + if (entity instanceof PrimedTNT) { + Vector3d pos = entity.getLocation().getPosition(); + entity.setRotation(new Vector3d(MathMan.roundInt(pos.getX()), MathMan.roundInt(pos.getY()), MathMan.roundInt(pos.getZ()))); + } + return true; }); }