mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 18:24:43 +02:00
Pull/2693 (#2694)
* Commit WIP flag work.
* More ported flag types, and additions to the flag API.
* Make PlotFlag more generic to allow generic flag creation
* Pull Captions methods into a Caption interface.
* Port MusicFlag
* Port flight flag
* Port UntrustedVisitFlag
* Port DenyExitFlag
* Remove paper suggestion
* Make ListFlag lists immutable
* Update Flag containers. Add javadocs. Add missing methods.
* Port description flag
* Port greeting and farewell flags
* Port weather flag
* Move getExample implementation to BooleanFlag
* Port reserved flags
* Port all boolean flags.
* Remove unused flag types
* Invert liquid-flow flag
* Find the real (legacy) flag name
* Change NOITFY -> NOTIFY in Captions
* Make IntegerFlag extendable
* Port integer flags
* Update Flag command to current API state
* Begin remaking flag command
* Create DoubleFlag + extract common parsing stuff
* Supply arguments in flag parse exceptions
* Implement missing flag subcommands
* Update Flag command to current API state
* Implement PriceFlag
* Port deny-teleport
* Port gamemode flags
* Port BreakFlag
* Port PlaceFlag
* Port UseFlag
* Remove old unused flag constants
* Port blocked-cmds flag
* Fix entity util
* Port TimeFlag
* Use CaptionUtility for formatting
* Port keep flag
* Fix imports
* Reformat code
* Remove unused classes
* Fix MainUtil.java
* Remove FlagCmd
* Add flag info header and footer
* Comment out flag related stuff in SchematicHandler
* Remove FlagManager
* Finalize Plot.java
* Finalize PlotArea.java
* Finalize PlotListener
* Fix API issues
* Fix a bunch of compile errors
* Fix `/plot flag remove`
* Fix initialization of GlobalFlagContainer
* Apply API changes to events
* Update SQLManager to new API
* Invert default value for DenyExitFlag
* Replace flag.getValue().toString() with flag.toString()
* Make FlagContainer instance in Plot final
* Fix various command issues
* Clean up PlotSettings
* Don't show internal flags in flag list
* Fix `/plot flag add`
* Remove the info inventory as it's 100% broken
* Add plot info entries and fix up the default format
* Fix default flag state in Captions
* 781c200
part 2
* Fix odd grammar in captions
* Fix odd grammar in captions v2
* Add create table statements for plot_flags
* Remove old flag references in SQLManager
* Use the new plot_flags table
* Add tab completion to `/plot flag`
* Improve parse error handling
* Make flag permission check recognize parse exceptions
* Initial progress towards flag conversion
* Fix minor issues
* Don't validate flags during flag conversion
* Allow unrecognized flags to be parsed
* Filter out internal flags from command sugguestions
* Use the wrong caption when there's no plot description set
* Limit command suggestions for boolean flags
* Make blocktypelistflags accept blockcategories
* Require categories to be prefixed with '#' and fix some minor display issues
* Fix plot database conversion
* Update PlotFlagEvent.java
Updated return description
* Fix command annotation wrapping
* Add FLAG_UPDATE event for FlagContainer listeners
* Make getParentContainer nullable
* Document castUnsafe in FlagContainer
* Document FlagContainer constructors
* Add missing documentation to FlagContainer
* Document FlagParseException
* Fix wording in FlagContainer javadoc
* Document InternalFlag
* Document PlotFlag
* Minor changes
* Remove revisit comments
Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
Co-authored-by: NotMyFault <mc.cache@web.de>
Co-authored-by: Matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:

committed by
GitHub

parent
b99631f1bd
commit
9868648fcb
@ -1,6 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -8,10 +8,9 @@ import org.bukkit.event.HandlerList;
|
||||
/**
|
||||
* Called when a Flag is added to a plot.
|
||||
*/
|
||||
public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||
public class PlotFlagAddEvent extends PlotFlagEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Flag flag;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
@ -20,24 +19,14 @@ public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||
* @param flag Flag that was added
|
||||
* @param plot Plot to which the flag was added
|
||||
*/
|
||||
public PlotFlagAddEvent(Flag flag, Plot plot) {
|
||||
super(plot);
|
||||
this.flag = flag;
|
||||
public PlotFlagAddEvent(PlotFlag<?, ?> flag, Plot plot) {
|
||||
super(plot, flag);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag involved.
|
||||
*
|
||||
* @return Flag
|
||||
*/
|
||||
public Flag getFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
@Override public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
|
||||
public abstract class PlotFlagEvent extends PlotEvent {
|
||||
private final PlotFlag<?, ?> flag;
|
||||
|
||||
protected PlotFlagEvent(Plot plot, PlotFlag<?, ?> flag) {
|
||||
super(plot);
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
* @return the flag involved
|
||||
*/
|
||||
public PlotFlag<?, ?> getFlag() {
|
||||
return flag;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.bukkit.events;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -8,10 +8,9 @@ import org.bukkit.event.HandlerList;
|
||||
/**
|
||||
* Called when a flag is removed from a plot
|
||||
*/
|
||||
public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
|
||||
public class PlotFlagRemoveEvent extends PlotFlagEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Flag flag;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
@ -20,24 +19,14 @@ public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
|
||||
* @param flag Flag that was removed
|
||||
* @param plot Plot from which the flag was removed
|
||||
*/
|
||||
public PlotFlagRemoveEvent(Flag flag, Plot plot) {
|
||||
super(plot);
|
||||
this.flag = flag;
|
||||
public PlotFlagRemoveEvent(PlotFlag<?, ?> flag, Plot plot) {
|
||||
super(plot, flag);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
* @return Flag
|
||||
*/
|
||||
public Flag getFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
@Override public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.bukkit.listeners;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
@ -118,7 +118,7 @@ public class EntitySpawnListener implements Listener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
|
@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.bukkit.listeners;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ForcefieldFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -80,7 +80,7 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
public static void handleForcefield(Player player, PlotPlayer plotPlayer, Plot plot) {
|
||||
if (Flags.FORCEFIELD.isTrue(plot)) {
|
||||
if (plot.getFlag(ForcefieldFlag.class)) {
|
||||
UUID uuid = plotPlayer.getUUID();
|
||||
if (plot.isAdded(uuid)) {
|
||||
Set<PlotPlayer> players = getNearbyPlayers(player, plot);
|
||||
|
@ -7,10 +7,63 @@ import com.github.intellectualsites.plotsquared.bukkit.util.UpdateUtility;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalAttackFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalCapFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockedCmdsFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DisablePhysicsFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.EntityCapFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GrassGrowFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HangingBreakFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HangingPlaceFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileAttackFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileCapFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileInteractFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceFormFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceMeltFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.KelpGrowFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.LiquidFlowFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscBreakFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscCapFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscInteractFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobCapFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MycelGrowFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlayerInteractFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PveFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PvpFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.RedstoneFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowFormFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowMeltFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.SoilDryFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedAttackFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UseFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleCapFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VillagerInteractFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VineGrowFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
|
||||
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EntityUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
@ -135,7 +188,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
@ -185,7 +237,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public static boolean checkEntity(Entity entity, Plot plot) {
|
||||
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot
|
||||
.getArea().DEFAULT_FLAGS.isEmpty()) {
|
||||
.getArea().getFlagContainer().getFlagMap().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
@ -220,11 +272,13 @@ import java.util.regex.Pattern;
|
||||
case UNKNOWN:
|
||||
case WITHER_SKULL:
|
||||
// non moving / unmovable
|
||||
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP);
|
||||
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED);
|
||||
case ARMOR_STAND:
|
||||
case ITEM_FRAME:
|
||||
case PAINTING:
|
||||
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
|
||||
return EntityUtil.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
MiscCapFlag.MISC_CAP_UNLIMITED);
|
||||
// misc
|
||||
case BOAT:
|
||||
case MINECART:
|
||||
@ -234,7 +288,9 @@ import java.util.regex.Pattern;
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
|
||||
return EntityUtil.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
|
||||
case BAT:
|
||||
case CHICKEN:
|
||||
case CAT:
|
||||
@ -267,8 +323,10 @@ import java.util.regex.Pattern;
|
||||
case WOLF:
|
||||
case ZOMBIE_HORSE:
|
||||
// animal
|
||||
return EntityUtil
|
||||
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
|
||||
return EntityUtil.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
MobCapFlag.MOB_CAP_UNLIMITED,
|
||||
AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
||||
case BLAZE:
|
||||
case CAVE_SPIDER:
|
||||
case CREEPER:
|
||||
@ -303,26 +361,39 @@ import java.util.regex.Pattern;
|
||||
case RAVAGER:
|
||||
// monster
|
||||
return EntityUtil
|
||||
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
|
||||
.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
MobCapFlag.MOB_CAP_UNLIMITED,
|
||||
HostileCapFlag.HOSTILE_CAP_UNLIMITED);
|
||||
default:
|
||||
if (entity instanceof LivingEntity) {
|
||||
if (entity instanceof Animals || entity instanceof WaterMob) {
|
||||
return EntityUtil
|
||||
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
|
||||
return EntityUtil.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
MobCapFlag.MOB_CAP_UNLIMITED,
|
||||
AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
||||
} else if (entity instanceof Monster) {
|
||||
return EntityUtil
|
||||
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
|
||||
return EntityUtil.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
MobCapFlag.MOB_CAP_UNLIMITED,
|
||||
HostileCapFlag.HOSTILE_CAP_UNLIMITED);
|
||||
} else {
|
||||
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP);
|
||||
return EntityUtil.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
MobCapFlag.MOB_CAP_UNLIMITED);
|
||||
}
|
||||
}
|
||||
if (entity instanceof Vehicle) {
|
||||
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
|
||||
return EntityUtil.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
|
||||
}
|
||||
if (entity instanceof Hanging) {
|
||||
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
|
||||
return EntityUtil.checkEntity(plot,
|
||||
EntityCapFlag.ENTITY_CAP_UNLIMITED,
|
||||
MiscCapFlag.MISC_CAP_UNLIMITED);
|
||||
}
|
||||
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP);
|
||||
return EntityUtil.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,7 +480,7 @@ import java.util.regex.Pattern;
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Flags.REDSTONE.isFalse(plot)) {
|
||||
if (!plot.getFlag(RedstoneFlag.class)) {
|
||||
event.setNewCurrent(0);
|
||||
return;
|
||||
}
|
||||
@ -463,7 +534,7 @@ import java.util.regex.Pattern;
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Flags.REDSTONE.isFalse(plot)) {
|
||||
if (!plot.getFlag(RedstoneFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
@ -485,7 +556,7 @@ import java.util.regex.Pattern;
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
|
||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
@ -631,10 +702,10 @@ import java.util.regex.Pattern;
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
|
||||
if (flag.isPresent() && !Permissions
|
||||
|
||||
List<String> blockedCommands = plot.getFlag(BlockedCmdsFlag.class);
|
||||
if (!blockedCommands.isEmpty() && !Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
List<String> blockedCommands = flag.get();
|
||||
String part = parts[0];
|
||||
if (parts[0].contains(":")) {
|
||||
part = parts[0].split(":")[1];
|
||||
@ -771,12 +842,12 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
final boolean result = Flags.DENY_TELEPORT.allowsTeleport(pp, plot);
|
||||
final boolean result = DenyTeleportFlag.allowsTeleport(pp, plot);
|
||||
// there is one possibility to still allow teleportation:
|
||||
// to is identical to the plot's home location, and untrusted-visit is true
|
||||
// i.e. untrusted-visit can override deny-teleport
|
||||
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
||||
if (!result && !(Flags.UNTRUSTED_VISIT.isTrue(plot) && plot.getHome().equals(BukkitUtil.getLocationFull(to)))) {
|
||||
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHome().equals(BukkitUtil.getLocationFull(to)))) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
event.setCancelled(true);
|
||||
@ -1078,11 +1149,13 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK);
|
||||
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
||||
Block block = event.getBlock();
|
||||
if (destroy.isPresent() && destroy.get()
|
||||
.contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||
return;
|
||||
final BlockType blockType = BukkitAdapter.asBlockType(block.getType());
|
||||
for (final BlockTypeWrapper blockTypeWrapper : destroy) {
|
||||
if (blockTypeWrapper.accepts(blockType)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
@ -1091,7 +1164,7 @@ import java.util.regex.Pattern;
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
event.setCancelled(true);
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
@ -1129,7 +1202,7 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot != null) {
|
||||
if (Flags.EXPLOSION.isTrue(plot)) {
|
||||
if (plot.getFlag(ExplosionFlag.class)) {
|
||||
List<MetadataValue> meta = event.getEntity().getMetadata("plot");
|
||||
Plot origin;
|
||||
if (meta.isEmpty()) {
|
||||
@ -1204,7 +1277,7 @@ import java.util.regex.Pattern;
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area != null) {
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot != null && Flags.MOB_BREAK.isTrue(plot)) {
|
||||
if (plot != null && plot.getFlag(MobPlaceFlag.class)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -1233,7 +1306,7 @@ import java.util.regex.Pattern;
|
||||
Player player = (Player) entity;
|
||||
if (!plot.hasOwner()) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (Flags.ICE_FORM.isTrue(plot)) {
|
||||
if (plot.getFlag(IceFormFlag.class)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -1241,7 +1314,7 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
if (Flags.ICE_FORM.isTrue(plot)) {
|
||||
if (plot.getFlag(IceFormFlag.class)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -1249,7 +1322,7 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!Flags.ICE_FORM.isTrue(plot)) {
|
||||
if (!plot.getFlag(IceFormFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -1272,22 +1345,22 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
switch (event.getSource().getType()) {
|
||||
case GRASS:
|
||||
if (Flags.GRASS_GROW.isFalse(plot)) {
|
||||
if (!plot.getFlag(GrassGrowFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
case MYCELIUM:
|
||||
if (Flags.MYCEL_GROW.isFalse(plot)) {
|
||||
if (!plot.getFlag(MycelGrowFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
case VINE:
|
||||
if (Flags.VINE_GROW.isFalse(plot)) {
|
||||
if (!plot.getFlag(VineGrowFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
case KELP:
|
||||
if (Flags.KELP_GROW.isFalse(plot)) {
|
||||
if (!plot.getFlag(KelpGrowFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
@ -1313,14 +1386,14 @@ import java.util.regex.Pattern;
|
||||
switch (event.getNewState().getType()) {
|
||||
case SNOW:
|
||||
case SNOW_BLOCK:
|
||||
if (Flags.SNOW_FORM.isFalse(plot)) {
|
||||
if (!plot.getFlag(SnowFormFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
case ICE:
|
||||
case FROSTED_ICE:
|
||||
case PACKED_ICE:
|
||||
if (Flags.ICE_FORM.isFalse(plot)) {
|
||||
if (!plot.getFlag(IceFormFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -1351,10 +1424,9 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK);
|
||||
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
||||
Block block = event.getBlock();
|
||||
if (destroy.isPresent() && destroy.get()
|
||||
.contains(BukkitAdapter.asBlockType(block.getType())) || Permissions
|
||||
if (destroy.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType()))) || Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
return;
|
||||
}
|
||||
@ -1385,17 +1457,17 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
switch (block.getType()) {
|
||||
case ICE:
|
||||
if (Flags.ICE_MELT.isFalse(plot)) {
|
||||
if (!plot.getFlag(IceMeltFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
case SNOW:
|
||||
if (Flags.SNOW_MELT.isFalse(plot)) {
|
||||
if (!plot.getFlag(SnowMeltFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
case FARMLAND:
|
||||
if (Flags.SOIL_DRY.isFalse(plot)) {
|
||||
if (!plot.getFlag(SoilDryFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
@ -1414,7 +1486,7 @@ import java.util.regex.Pattern;
|
||||
Plot plot = area.getOwnedPlot(tLocation);
|
||||
Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
||||
if (plot != null) {
|
||||
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
|
||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
|
||||
@ -1422,7 +1494,7 @@ import java.util.regex.Pattern;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (Flags.LIQUID_FLOW.isFalse(plot)) {
|
||||
if (!plot.getFlag(LiquidFlowFlag.class)) {
|
||||
switch (to.getType()) {
|
||||
case WATER:
|
||||
case LAVA:
|
||||
@ -1816,7 +1888,7 @@ import java.util.regex.Pattern;
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
e.setCancelled(true);
|
||||
@ -1834,7 +1906,7 @@ import java.util.regex.Pattern;
|
||||
if (plot.isAdded(uuid)) {
|
||||
return;
|
||||
}
|
||||
if (Flags.MISC_INTERACT.isTrue(plot)) {
|
||||
if (plot.getFlag(MiscInteractFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
|
||||
@ -1866,7 +1938,7 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot == null || !plot.getFlag(Flags.EXPLOSION).orElse(false)) {
|
||||
if (plot == null || !plot.getFlag(ExplosionFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
event.blockList().removeIf(
|
||||
@ -2119,7 +2191,7 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null || plot.getFlag(Flags.DISABLE_PHYSICS, false)) {
|
||||
if (plot == null || plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -2155,7 +2227,7 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null || !plot.getFlag(Flags.BLOCK_BURN, false)) {
|
||||
if (plot == null || !plot.getFlag(BlockBurnFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -2198,7 +2270,7 @@ import java.util.regex.Pattern;
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (Flags.BLOCK_IGNITION.isFalse(plot)) {
|
||||
} else if (!plot.getFlag(BlockIgnitionFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
@ -2207,7 +2279,7 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
if (ignitingEntity != null) {
|
||||
if (!plot.getFlag(Flags.BLOCK_IGNITION, false)) {
|
||||
if (!plot.getFlag(BlockIgnitionFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -2233,11 +2305,11 @@ import java.util.regex.Pattern;
|
||||
Block ignitingBlock = event.getIgnitingBlock();
|
||||
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
|
||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
|
||||
!plot.getFlag(Flags.BLOCK_IGNITION, false) || plotIgnited == null
|
||||
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null
|
||||
|| !plotIgnited.equals(plot)) ||
|
||||
(igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|
||||
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
|
||||
!plot.getFlag(Flags.BLOCK_IGNITION).orElse(false) || plotIgnited == null
|
||||
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null
|
||||
|| !plotIgnited.equals(plot))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -2273,8 +2345,12 @@ import java.util.regex.Pattern;
|
||||
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
event.setCancelled(true);
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
if (Flags.USE.contains(plot, BukkitAdapter.asItemType(block.getType()))) {
|
||||
return;
|
||||
List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
|
||||
final BlockType blockType = BukkitAdapter.asBlockType(block.getType());
|
||||
for (final BlockTypeWrapper blockTypeWrapper : use) {
|
||||
if (blockTypeWrapper.accepts(blockType)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return;
|
||||
@ -2282,7 +2358,7 @@ import java.util.regex.Pattern;
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
@ -2333,10 +2409,13 @@ import java.util.regex.Pattern;
|
||||
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
event.setCancelled(true);
|
||||
} else if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<Set<BlockType>> use = plot.getFlag(Flags.USE);
|
||||
List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
|
||||
Block block = event.getBlockClicked();
|
||||
if (use.isPresent() && use.get().contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||
return;
|
||||
final BlockType blockType = BukkitAdapter.asBlockType(block.getType());
|
||||
for (final BlockTypeWrapper blockTypeWrapper : use) {
|
||||
if (blockTypeWrapper.accepts(blockType)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return;
|
||||
@ -2344,7 +2423,7 @@ import java.util.regex.Pattern;
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
@ -2404,7 +2483,7 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
if (!plot.isAdded(pp.getUUID())) {
|
||||
if (!plot.getFlag(Flags.HANGING_PLACE, false)) {
|
||||
if (!plot.getFlag(HangingPlaceFlag.class)) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
@ -2445,7 +2524,7 @@ import java.util.regex.Pattern;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
if (plot.getFlag(Flags.HANGING_BREAK, false)) {
|
||||
if (plot.getFlag(HangingBreakFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
@ -2474,7 +2553,7 @@ import java.util.regex.Pattern;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.isAdded(player.getUUID())) {
|
||||
if (!plot.getFlag(Flags.HANGING_BREAK, false)) {
|
||||
if (!plot.getFlag(HangingBreakFlag.class)) {
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION_EVENT,
|
||||
@ -2514,26 +2593,26 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
Entity entity = event.getRightClicked();
|
||||
if (entity instanceof Monster && plot.getFlag(Flags.HOSTILE_INTERACT, false)) {
|
||||
if (entity instanceof Monster && plot.getFlag(HostileInteractFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Animals && plot.getFlag(Flags.ANIMAL_INTERACT, false)) {
|
||||
if (entity instanceof Animals && plot.getFlag(AnimalInteractFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot
|
||||
.getFlag(Flags.TAMED_INTERACT, false)) {
|
||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot.getFlag(
|
||||
TamedInteractFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Vehicle && plot.getFlag(Flags.VEHICLE_USE, false)) {
|
||||
if (entity instanceof Vehicle && plot.getFlag(VehicleUseFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Player && plot.getFlag(Flags.PLAYER_INTERACT, false)) {
|
||||
if (entity instanceof Player && plot.getFlag(PlayerInteractFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Villager && plot.getFlag(Flags.VILLAGER_INTERACT, false)) {
|
||||
if (entity instanceof Villager && plot.getFlag(VillagerInteractFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof ItemFrame && plot.getFlag(Flags.MISC_INTERACT, false)) {
|
||||
if (entity instanceof ItemFrame && plot.getFlag(MiscInteractFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||
@ -2573,7 +2652,7 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
if (!plot.isAdded(pp.getUUID())) {
|
||||
if (plot.getFlag(Flags.VEHICLE_BREAK, false)) {
|
||||
if (plot.getFlag(VehicleBreakFlag.class)) {
|
||||
return;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
|
||||
@ -2739,9 +2818,9 @@ import java.util.regex.Pattern;
|
||||
if (player != null) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (victim instanceof Hanging) { // hanging
|
||||
if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
if (plot != null && (plot.getFlag(HangingBreakFlag.class)) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
return false;
|
||||
@ -2755,7 +2834,7 @@ import java.util.regex.Pattern;
|
||||
return false;
|
||||
}
|
||||
} else if (victim.getType() == EntityType.ARMOR_STAND) {
|
||||
if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot
|
||||
if (plot != null && (plot.getFlag(MiscBreakFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
return true;
|
||||
}
|
||||
@ -2766,8 +2845,8 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
} else if (victim instanceof Monster
|
||||
|| victim instanceof EnderDragon) { // victim is monster
|
||||
if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot
|
||||
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
if (plot != null && (plot.getFlag(HostileAttackFlag.class) || plot.getFlag(PveFlag.class) ||
|
||||
plot.isAdded(plotPlayer.getUUID()))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
@ -2776,8 +2855,8 @@ import java.util.regex.Pattern;
|
||||
return false;
|
||||
}
|
||||
} else if (victim instanceof Tameable) { // victim is tameable
|
||||
if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot
|
||||
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
if (plot != null && (plot.getFlag(TamedAttackFlag.class) || plot.getFlag(PveFlag.class) ||
|
||||
plot.isAdded(plotPlayer.getUUID()))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
@ -2787,7 +2866,7 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
} else if (victim instanceof Player) {
|
||||
if (plot != null) {
|
||||
if (Flags.PVP.isFalse(plot) && !Permissions
|
||||
if (!plot.getFlag(PvpFlag.class) && !Permissions
|
||||
.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pvp." + stub);
|
||||
@ -2802,8 +2881,8 @@ import java.util.regex.Pattern;
|
||||
return false;
|
||||
}
|
||||
} else if (victim instanceof Creature) { // victim is animal
|
||||
if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot
|
||||
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot.getFlag(PveFlag.class)
|
||||
|| plot.isAdded(plotPlayer.getUUID()))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
@ -2814,7 +2893,7 @@ import java.util.regex.Pattern;
|
||||
} else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event
|
||||
return true;
|
||||
} else { // victim is something else
|
||||
if (plot != null && (plot.getFlag(Flags.PVE, false) || plot
|
||||
if (plot != null && (plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
return true;
|
||||
}
|
||||
@ -2827,7 +2906,7 @@ import java.util.regex.Pattern;
|
||||
return true;
|
||||
} else if (dplot != null && (!dplot.equals(vplot) || Objects
|
||||
.equals(dplot.guessOwner(), vplot.guessOwner()))) {
|
||||
return vplot != null && Flags.PVE.isTrue(vplot);
|
||||
return vplot != null && vplot.getFlag(PveFlag.class);
|
||||
}
|
||||
//disable the firework damage. too much of a headache to support at the moment.
|
||||
if (vplot != null) {
|
||||
@ -2836,7 +2915,7 @@ import java.util.regex.Pattern;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ((vplot != null && Flags.PVE.isTrue(vplot)) || !(damager instanceof Arrow
|
||||
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
|
||||
&& !(victim instanceof Creature)));
|
||||
}
|
||||
|
||||
@ -2896,10 +2975,10 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
Set<BlockType> place = plot.getFlag(Flags.PLACE, null);
|
||||
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
||||
if (place != null) {
|
||||
Block block = event.getBlock();
|
||||
if (place.contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||
if (place.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2909,7 +2988,7 @@ import java.util.regex.Pattern;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
@ -2917,7 +2996,7 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (plot.getFlag(Flags.DISABLE_PHYSICS, false)) {
|
||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
Block block = event.getBlockPlaced();
|
||||
if (block.getType().hasGravity()) {
|
||||
sendBlockChange(block.getLocation(), block.getBlockData());
|
||||
|
@ -3,8 +3,13 @@ package com.github.intellectualsites.plotsquared.bukkit.listeners;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.IntervalFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DropProtectionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FeedFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HealFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.InstabreakFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.InvincibleFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ItemDropFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.types.TimedFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -28,7 +33,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener {
|
||||
@ -90,7 +94,7 @@ import java.util.UUID;
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Flags.INSTABREAK.isTrue(plot)) {
|
||||
if (plot.getFlag(InstabreakFlag.class)) {
|
||||
Block block = event.getBlock();
|
||||
BlockBreakEvent call = new BlockBreakEvent(block, player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(call);
|
||||
@ -108,7 +112,7 @@ import java.util.UUID;
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Flags.INVINCIBLE.isTrue(plot)) {
|
||||
if (plot.getFlag(InvincibleFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -122,7 +126,7 @@ import java.util.UUID;
|
||||
}
|
||||
UUID uuid = pp.getUUID();
|
||||
if (!plot.isAdded(uuid)) {
|
||||
if (Flags.ITEM_DROP.isFalse(plot)) {
|
||||
if (!plot.getFlag(ItemDropFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -131,12 +135,14 @@ import java.util.UUID;
|
||||
@EventHandler public void onPlotEnter(PlayerEnterPlotEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Plot plot = event.getPlot();
|
||||
Optional<IntervalFlag.Interval> feed = plot.getFlag(Flags.FEED);
|
||||
feed.ifPresent(value -> feedRunnable
|
||||
.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20)));
|
||||
Optional<IntervalFlag.Interval> heal = plot.getFlag(Flags.HEAL);
|
||||
heal.ifPresent(value -> healRunnable
|
||||
.put(player.getUniqueId(), new Interval(value.getVal1(), value.getVal2(), 20)));
|
||||
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
|
||||
if (feed.getInterval() != 0 && feed.getValue() != 0) {
|
||||
feedRunnable.put(player.getUniqueId(), new Interval(feed.getInterval(), feed.getValue(), 20));
|
||||
}
|
||||
TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
|
||||
if (heal.getInterval() != 0 && heal.getValue() != 0) {
|
||||
healRunnable.put(player.getUniqueId(), new Interval(heal.getInterval(), heal.getValue(), 20));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
@ -166,7 +172,7 @@ import java.util.UUID;
|
||||
return;
|
||||
}
|
||||
UUID uuid = pp.getUUID();
|
||||
if (!plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) {
|
||||
if (!plot.isAdded(uuid) && plot.getFlag(DropProtectionFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import com.github.intellectualsites.plotsquared.bukkit.events.PlotMergeEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotRateEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.events.PlotUnlinkEvent;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
@ -75,11 +75,11 @@ public final class BukkitEventUtil extends EventUtil {
|
||||
return callEvent(new PlotDeleteEvent(plot));
|
||||
}
|
||||
|
||||
@Override public boolean callFlagAdd(Flag flag, Plot plot) {
|
||||
@Override public boolean callFlagAdd(PlotFlag<?, ?> flag, Plot plot) {
|
||||
return callEvent(new PlotFlagAddEvent(flag, plot));
|
||||
}
|
||||
|
||||
@Override public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
|
||||
@Override public boolean callFlagRemove(PlotFlag<?, ?> flag, Plot plot, Object value) {
|
||||
return callEvent(new PlotFlagRemoveEvent(flag, plot));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user