mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Added mob cap flag
This commit is contained in:
parent
8a63b8937f
commit
91b7b41cfc
@ -676,6 +676,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");
|
final List<String> booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit");
|
||||||
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");
|
||||||
for (final String flag : stringFlags) {
|
for (final String flag : stringFlags) {
|
||||||
FlagManager.addFlag(new AbstractFlag(flag));
|
FlagManager.addFlag(new AbstractFlag(flag));
|
||||||
}
|
}
|
||||||
@ -685,6 +686,9 @@ public class PlotSquared {
|
|||||||
for (final String flag : booleanFlags) {
|
for (final String flag : booleanFlags) {
|
||||||
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue()));
|
||||||
}
|
}
|
||||||
|
for (final String flag : intFlags) {
|
||||||
|
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue()));
|
||||||
|
}
|
||||||
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
||||||
|
@ -90,6 +90,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.CmdConfirm;
|
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
@ -704,6 +705,18 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot != null && plot.owner != null) {
|
||||||
|
Flag capFlag = FlagManager.getPlotFlag(plot, "mob-cap");
|
||||||
|
if (capFlag == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int cap = ((Integer) capFlag.getValue());
|
||||||
|
int mobs = ChunkManager.manager.countEntities(plot);
|
||||||
|
if (mobs >= cap) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
Loading…
Reference in New Issue
Block a user