mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 12:35:15 +01:00
Apply API changes to events
This commit is contained in:
parent
161bf3db23
commit
9adaa4ae79
@ -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 Flag
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -8,25 +8,31 @@ 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.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;
|
||||
@ -42,6 +48,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Tamed
|
||||
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;
|
||||
@ -223,7 +230,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()) {
|
||||
@ -258,11 +265,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:
|
||||
@ -272,7 +281,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:
|
||||
@ -305,8 +316,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:
|
||||
@ -341,26 +354,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2763,7 +2789,7 @@ import java.util.regex.Pattern;
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (victim instanceof Hanging) { // hanging
|
||||
if (plot != null && (plot.getFlag(HangingBreakFlag.class)) || plot
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
.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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -1085,6 +1085,15 @@ public class Plot {
|
||||
PlotAnalysis.analyzePlot(this, whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all flags applied to this plot
|
||||
*
|
||||
* @return all applied flags
|
||||
*/
|
||||
public Set<PlotFlag<?, ?>> getFlags() {
|
||||
return ImmutableSet.copyOf(flagContainer.getFlagMap().values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a flag for this plot
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user