mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Add PlotArea#getFlag
This commit is contained in:
parent
761803f777
commit
22c26fe962
@ -344,8 +344,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
if (area.isRoadRespectingGlobalFlags() && area.
|
||||||
.getFlag(RedstoneFlag.class).getValue()) {
|
getFlag(RedstoneFlag.class)) {
|
||||||
event.setNewCurrent(0);
|
event.setNewCurrent(0);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -576,7 +576,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
List<String> blockedCommands = plot != null ?
|
List<String> blockedCommands = plot != null ?
|
||||||
plot.getFlag(BlockedCmdsFlag.class) :
|
plot.getFlag(BlockedCmdsFlag.class) :
|
||||||
area.getFlagContainer().getFlag(BlockedCmdsFlag.class).getValue();
|
area.getFlag(BlockedCmdsFlag.class);
|
||||||
if (!blockedCommands.isEmpty() && !Permissions
|
if (!blockedCommands.isEmpty() && !Permissions
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||||
String part = parts[0];
|
String part = parts[0];
|
||||||
@ -1702,8 +1702,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PlotArea area = pp.getPlotAreaAbs();
|
PlotArea area = pp.getPlotAreaAbs();
|
||||||
if (area != null && area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
if (area != null && area.isRoadRespectingGlobalFlags() && area
|
||||||
.getFlag(PreventCreativeCopyFlag.class).getValue()) {
|
.getFlag(PreventCreativeCopyFlag.class)) {
|
||||||
final ItemStack newStack =
|
final ItemStack newStack =
|
||||||
new ItemStack(newItem.getType(), newItem.getAmount());
|
new ItemStack(newItem.getType(), newItem.getAmount());
|
||||||
event.setCursor(newStack);
|
event.setCursor(newStack);
|
||||||
@ -1824,9 +1824,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Plot plot = location.getPlotAbs();
|
Plot plot = location.getPlotAbs();
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!area.isRoadRespectingGlobalFlags() && !area.getFlagContainer()
|
if (!area.isRoadRespectingGlobalFlags() && !area.getFlag(MiscInteractFlag.class)
|
||||||
.getFlag(MiscInteractFlag.class).getValue() && !Permissions
|
&& !Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||||
.hasPermission(pp, "plots.admin.interact.road")) {
|
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -1839,8 +1838,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner() && !area.isRoadRespectingGlobalFlags() && !area.getFlagContainer()
|
if (!plot.hasOwner() && !area.isRoadRespectingGlobalFlags() && !area
|
||||||
.getFlag(MiscInteractFlag.class).getValue()) {
|
.getFlag(MiscInteractFlag.class)) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
"plots.admin.interact.unowned");
|
"plots.admin.interact.unowned");
|
||||||
@ -2781,8 +2780,10 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
stub = "unowned";
|
stub = "unowned";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FlagContainer areaFlags = vArea.getFlagContainer();
|
boolean roadFlags = vArea != null ?
|
||||||
boolean roadFlags = vArea.isRoadRespectingGlobalFlags();
|
vArea.isRoadRespectingGlobalFlags() :
|
||||||
|
dArea.isRoadRespectingGlobalFlags();
|
||||||
|
PlotArea area = vArea != null ? vArea : dArea;
|
||||||
|
|
||||||
Player player;
|
Player player;
|
||||||
if (damager instanceof Player) { // attacker is player
|
if (damager instanceof Player) { // attacker is player
|
||||||
@ -2816,7 +2817,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (EntityCategories.HANGING.contains(entityType)) { // hanging
|
if (EntityCategories.HANGING.contains(entityType)) { // hanging
|
||||||
if ((plot.getFlag(HangingBreakFlag.class)) || plot.isAdded(plotPlayer.getUUID())) {
|
if (plot != null && (plot.getFlag(HangingBreakFlag.class) || plot
|
||||||
|
.isAdded(plotPlayer.getUUID()))) {
|
||||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||||
if (!Permissions
|
if (!Permissions
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
@ -2848,8 +2850,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
.isAdded(plotPlayer.getUUID())) {
|
.isAdded(plotPlayer.getUUID())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (roadFlags && (areaFlags.getFlag(HostileAttackFlag.class).getValue()
|
} else if (roadFlags && (area.getFlag(HostileAttackFlag.class) || area
|
||||||
|| areaFlags.getFlag(PveFlag.class).getValue())) {
|
.getFlag(PveFlag.class))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2863,8 +2865,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
.isAdded(plotPlayer.getUUID())) {
|
.isAdded(plotPlayer.getUUID())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (roadFlags && (areaFlags.getFlag(TamedAttackFlag.class).getValue()
|
} else if (roadFlags && (area.getFlag(TamedAttackFlag.class) || area
|
||||||
|| areaFlags.getFlag(PveFlag.class).getValue())) {
|
.getFlag(PveFlag.class))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2882,7 +2884,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (roadFlags && areaFlags.getFlag(PvpFlag.class).getValue()) {
|
} else if (roadFlags && area.getFlag(PvpFlag.class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||||
@ -2896,8 +2898,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
.isAdded(plotPlayer.getUUID())) {
|
.isAdded(plotPlayer.getUUID())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (roadFlags && (areaFlags.getFlag(AnimalAttackFlag.class).getValue()
|
} else if (roadFlags && (area.getFlag(AnimalAttackFlag.class) || area
|
||||||
|| areaFlags.getFlag(PveFlag.class).getValue())) {
|
.getFlag(PveFlag.class))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2910,11 +2912,10 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
} else { // victim is something else
|
} else { // victim is something else
|
||||||
if (isPlot) {
|
if (isPlot) {
|
||||||
if (plot != null && (plot.getFlag(PveFlag.class) || plot
|
if (plot.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID())) {
|
||||||
.isAdded(plotPlayer.getUUID()))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (roadFlags && areaFlags.getFlag(PveFlag.class).getValue()) {
|
} else if (roadFlags && area.getFlag(PveFlag.class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2935,7 +2936,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vplot == null && roadFlags && areaFlags.getFlag(PveFlag.class).getValue()) {
|
if (vplot == null && roadFlags && area.getFlag(PveFlag.class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
|
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
|
||||||
@ -3045,8 +3046,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
if (area.isRoadRespectingGlobalFlags() && area.getFlag(InvincibleFlag.class)) {
|
||||||
.getFlag(InvincibleFlag.class).getValue()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -3066,8 +3066,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
if (area.isRoadRespectingGlobalFlags() && area.getFlag(ItemDropFlag.class)) {
|
||||||
.getFlag(ItemDropFlag.class).getValue()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -3092,8 +3091,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
if (area.isRoadRespectingGlobalFlags() && area.getFlag(DropProtectionFlag.class)) {
|
||||||
.getFlag(DropProtectionFlag.class).getValue()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -3113,8 +3111,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
if (area.isRoadRespectingGlobalFlags() && area.getFlag(KeepInventoryFlag.class)) {
|
||||||
.getFlag(KeepInventoryFlag.class).getValue()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1072,4 +1072,28 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value associated with the specified flag. This will look at
|
||||||
|
* the default values stored in {@link GlobalFlagContainer}.
|
||||||
|
*
|
||||||
|
* @param flagClass The flag type (Class)
|
||||||
|
* @return The flag value
|
||||||
|
*/
|
||||||
|
public <T> T getFlag(final Class<? extends PlotFlag<T, ?>> flagClass) {
|
||||||
|
return this.flagContainer.getFlag(flagClass).getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value associated with the specified flag. This will look at
|
||||||
|
* the default values stored in {@link GlobalFlagContainer}.
|
||||||
|
*
|
||||||
|
* @param flag The flag type (Any instance of the flag)
|
||||||
|
* @return The flag value
|
||||||
|
*/
|
||||||
|
public <T, V extends PlotFlag<T, ?>> T getFlag(final V flag) {
|
||||||
|
final Class<?> flagClass = flag.getClass();
|
||||||
|
final PlotFlag<?, ?> flagInstance = this.flagContainer.getFlagErased(flagClass);
|
||||||
|
return FlagContainer.<T, V>castUnsafe(flagInstance).getValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user