mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Add option for roads to respect a plot area's flags and implement to PlayerEvents
This commit is contained in:
parent
d5d18a60fb
commit
761803f777
@ -42,6 +42,7 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
import com.plotsquared.core.plot.PlotHandler;
|
import com.plotsquared.core.plot.PlotHandler;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.PlotInventory;
|
import com.plotsquared.core.plot.PlotInventory;
|
||||||
|
import com.plotsquared.core.plot.flag.FlagContainer;
|
||||||
import com.plotsquared.core.plot.flag.implementations.AnimalAttackFlag;
|
import com.plotsquared.core.plot.flag.implementations.AnimalAttackFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.AnimalCapFlag;
|
import com.plotsquared.core.plot.flag.implementations.AnimalCapFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.AnimalInteractFlag;
|
import com.plotsquared.core.plot.flag.implementations.AnimalInteractFlag;
|
||||||
@ -227,8 +228,8 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class PlayerEvents extends PlotListener implements Listener {
|
public class PlayerEvents extends PlotListener implements Listener {
|
||||||
|
|
||||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE
|
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
|
||||||
= new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||||
|
|
||||||
private boolean pistonBlocks = true;
|
private boolean pistonBlocks = true;
|
||||||
private float lastRadius;
|
private float lastRadius;
|
||||||
@ -343,6 +344,10 @@ 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()
|
||||||
|
.getFlag(RedstoneFlag.class).getValue()) {
|
||||||
|
event.setNewCurrent(0);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.getFlag(RedstoneFlag.class)) {
|
if (!plot.getFlag(RedstoneFlag.class)) {
|
||||||
@ -565,11 +570,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plot == null) {
|
if (plot == null && !area.isRoadRespectingGlobalFlags()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> blockedCommands = plot.getFlag(BlockedCmdsFlag.class);
|
List<String> blockedCommands = plot != null ?
|
||||||
|
plot.getFlag(BlockedCmdsFlag.class) :
|
||||||
|
area.getFlagContainer().getFlag(BlockedCmdsFlag.class).getValue();
|
||||||
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];
|
||||||
@ -614,10 +621,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (pattern.matcher(msg).matches()) {
|
if (pattern.matcher(msg).matches()) {
|
||||||
String perm;
|
String perm;
|
||||||
if (plot.isAdded(plotPlayer.getUUID())) {
|
if (plot != null && plot.isAdded(plotPlayer.getUUID())) {
|
||||||
perm = "plots.admin.command.blocked-cmds.shared";
|
perm = "plots.admin.command.blocked-cmds.shared";
|
||||||
} else {
|
} else if (!area.isRoadRespectingGlobalFlags()) {
|
||||||
perm = "plots.admin.command.blocked-cmds.other";
|
perm = "plots.admin.command.blocked-cmds.other";
|
||||||
|
} else {
|
||||||
|
perm = "plots.admin.command.blocked-cmds.road";
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, perm)) {
|
if (!Permissions.hasPermission(plotPlayer, perm)) {
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.COMMAND_BLOCKED);
|
MainUtil.sendMessage(plotPlayer, Captions.COMMAND_BLOCKED);
|
||||||
@ -1683,12 +1692,22 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
if (event.getClick() == ClickType.CREATIVE) {
|
if (event.getClick() == ClickType.CREATIVE) {
|
||||||
final Plot plot = pp.getCurrentPlot();
|
final Plot plot = pp.getCurrentPlot();
|
||||||
if (plot != null &&
|
if (plot != null) {
|
||||||
plot.getFlag(PreventCreativeCopyFlag.class) &&
|
if (plot.getFlag(PreventCreativeCopyFlag.class) && !plot
|
||||||
!plot.isAdded(player.getUniqueId()) &&
|
.isAdded(player.getUniqueId()) && !Permissions
|
||||||
!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||||
final ItemStack newStack = new ItemStack(newItem.getType(), newItem.getAmount());
|
final ItemStack newStack =
|
||||||
event.setCursor(newStack);
|
new ItemStack(newItem.getType(), newItem.getAmount());
|
||||||
|
event.setCursor(newStack);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PlotArea area = pp.getPlotAreaAbs();
|
||||||
|
if (area != null && area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
||||||
|
.getFlag(PreventCreativeCopyFlag.class).getValue()) {
|
||||||
|
final ItemStack newStack =
|
||||||
|
new ItemStack(newItem.getType(), newItem.getAmount());
|
||||||
|
event.setCursor(newStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1805,7 +1824,9 @@ 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 (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
if (!area.isRoadRespectingGlobalFlags() && !area.getFlagContainer()
|
||||||
|
.getFlag(MiscInteractFlag.class).getValue() && !Permissions
|
||||||
|
.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);
|
||||||
}
|
}
|
||||||
@ -1818,7 +1839,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner() && !area.isRoadRespectingGlobalFlags() && !area.getFlagContainer()
|
||||||
|
.getFlag(MiscInteractFlag.class).getValue()) {
|
||||||
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");
|
||||||
@ -2514,57 +2536,66 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null && !area.isRoadRespectingGlobalFlags()) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
Captions.PERMISSION_ADMIN_INTERACT_ROAD);
|
Captions.PERMISSION_ADMIN_INTERACT_ROAD);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.hasOwner()) {
|
} else if (plot != null && !plot.hasOwner()) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED);
|
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if ((plot != null && !plot.isAdded(pp.getUUID())) || area
|
||||||
|
.isRoadRespectingGlobalFlags()) {
|
||||||
final Entity entity = event.getRightClicked();
|
final Entity entity = event.getRightClicked();
|
||||||
final com.sk89q.worldedit.world.entity.EntityType entityType =
|
final com.sk89q.worldedit.world.entity.EntityType entityType =
|
||||||
BukkitAdapter.adapt(entity.getType());
|
BukkitAdapter.adapt(entity.getType());
|
||||||
|
|
||||||
if (EntityCategories.HOSTILE.contains(entityType) && plot
|
FlagContainer flagContainer;
|
||||||
.getFlag(HostileInteractFlag.class)) {
|
if (plot == null) {
|
||||||
|
flagContainer = area.getFlagContainer();
|
||||||
|
} else {
|
||||||
|
flagContainer = plot.getFlagContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EntityCategories.HOSTILE.contains(entityType) && flagContainer
|
||||||
|
.getFlag(HostileInteractFlag.class).getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityCategories.ANIMAL.contains(entityType) && plot
|
if (EntityCategories.ANIMAL.contains(entityType) && flagContainer
|
||||||
.getFlag(AnimalInteractFlag.class)) {
|
.getFlag(AnimalInteractFlag.class).getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This actually makes use of the interface, so we don't use the
|
// This actually makes use of the interface, so we don't use the
|
||||||
// category
|
// category
|
||||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot
|
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && flagContainer
|
||||||
.getFlag(TamedInteractFlag.class)) {
|
.getFlag(TamedInteractFlag.class).getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityCategories.VEHICLE.contains(entityType) && plot
|
if (EntityCategories.VEHICLE.contains(entityType) && flagContainer
|
||||||
.getFlag(VehicleUseFlag.class)) {
|
.getFlag(VehicleUseFlag.class).getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityCategories.PLAYER.contains(entityType) && plot
|
if (EntityCategories.PLAYER.contains(entityType) && flagContainer
|
||||||
.getFlag(PlayerInteractFlag.class)) {
|
.getFlag(PlayerInteractFlag.class).getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityCategories.VILLAGER.contains(entityType) && plot
|
if (EntityCategories.VILLAGER.contains(entityType) && flagContainer
|
||||||
.getFlag(VillagerInteractFlag.class)) {
|
.getFlag(VillagerInteractFlag.class).getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((EntityCategories.HANGING.contains(entityType) || EntityCategories.OTHER
|
if ((EntityCategories.HANGING.contains(entityType) || EntityCategories.OTHER
|
||||||
.contains(entityType)) && plot.getFlag(MiscInteractFlag.class)) {
|
.contains(entityType)) && flagContainer.getFlag(MiscInteractFlag.class)
|
||||||
|
.getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2713,12 +2744,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
Plot plot;
|
Plot plot;
|
||||||
String stub;
|
String stub;
|
||||||
|
boolean isPlot = true;
|
||||||
if (dplot == null && vplot == null) {
|
if (dplot == null && vplot == null) {
|
||||||
if (dArea == null) {
|
if (dArea == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot = null;
|
plot = null;
|
||||||
stub = "road";
|
stub = "road";
|
||||||
|
isPlot = false;
|
||||||
} else {
|
} else {
|
||||||
// Prioritize plots for close to seamless pvp zones
|
// Prioritize plots for close to seamless pvp zones
|
||||||
if (victim.getTicksLived() > damager.getTicksLived()) {
|
if (victim.getTicksLived() > damager.getTicksLived()) {
|
||||||
@ -2748,6 +2781,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
stub = "unowned";
|
stub = "unowned";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FlagContainer areaFlags = vArea.getFlagContainer();
|
||||||
|
boolean roadFlags = vArea.isRoadRespectingGlobalFlags();
|
||||||
|
|
||||||
Player player;
|
Player player;
|
||||||
if (damager instanceof Player) { // attacker is player
|
if (damager instanceof Player) { // attacker is player
|
||||||
@ -2781,8 +2816,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (EntityCategories.HANGING.contains(entityType)) { // hanging
|
if (EntityCategories.HANGING.contains(entityType)) { // hanging
|
||||||
if (plot != null && (plot.getFlag(HangingBreakFlag.class)) || plot
|
if ((plot.getFlag(HangingBreakFlag.class)) || plot.isAdded(plotPlayer.getUUID())) {
|
||||||
.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)) {
|
||||||
@ -2809,8 +2843,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (EntityCategories.HOSTILE.contains(entityType)) {
|
} else if (EntityCategories.HOSTILE.contains(entityType)) {
|
||||||
if (plot != null && (plot.getFlag(HostileAttackFlag.class) || plot
|
if (isPlot) {
|
||||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
if (plot.getFlag(HostileAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||||
|
.isAdded(plotPlayer.getUUID())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (roadFlags && (areaFlags.getFlag(HostileAttackFlag.class).getValue()
|
||||||
|
|| areaFlags.getFlag(PveFlag.class).getValue())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2819,8 +2858,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (EntityCategories.TAMEABLE.contains(entityType)) { // victim is tameable
|
} else if (EntityCategories.TAMEABLE.contains(entityType)) { // victim is tameable
|
||||||
if (plot != null && (plot.getFlag(TamedAttackFlag.class) || plot
|
if (isPlot) {
|
||||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
if (plot.getFlag(TamedAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||||
|
.isAdded(plotPlayer.getUUID())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (roadFlags && (areaFlags.getFlag(TamedAttackFlag.class).getValue()
|
||||||
|
|| areaFlags.getFlag(PveFlag.class).getValue())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2829,7 +2873,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (EntityCategories.PLAYER.contains(entityType)) {
|
} else if (EntityCategories.PLAYER.contains(entityType)) {
|
||||||
if (plot != null) {
|
if (isPlot) {
|
||||||
if (!plot.getFlag(PvpFlag.class) && !Permissions
|
if (!plot.getFlag(PvpFlag.class) && !Permissions
|
||||||
.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||||
@ -2838,6 +2882,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else if (roadFlags && areaFlags.getFlag(PvpFlag.class).getValue()) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||||
@ -2845,8 +2891,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (EntityCategories.ANIMAL.contains(entityType)) { // victim is animal
|
} else if (EntityCategories.ANIMAL.contains(entityType)) { // victim is animal
|
||||||
if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot
|
if (isPlot) {
|
||||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
if (plot.getFlag(AnimalAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||||
|
.isAdded(plotPlayer.getUUID())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (roadFlags && (areaFlags.getFlag(AnimalAttackFlag.class).getValue()
|
||||||
|
|| areaFlags.getFlag(PveFlag.class).getValue())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2858,8 +2909,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
.contains(entityType)) { // Vehicles are managed in vehicle destroy event
|
.contains(entityType)) { // Vehicles are managed in vehicle destroy event
|
||||||
return true;
|
return true;
|
||||||
} else { // victim is something else
|
} else { // victim is something else
|
||||||
if (plot != null && (plot.getFlag(PveFlag.class) || plot
|
if (isPlot) {
|
||||||
.isAdded(plotPlayer.getUUID()))) {
|
if (plot != null && (plot.getFlag(PveFlag.class) || plot
|
||||||
|
.isAdded(plotPlayer.getUUID()))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (roadFlags && areaFlags.getFlag(PveFlag.class).getValue()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||||
@ -2880,6 +2935,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (vplot == null && roadFlags && areaFlags.getFlag(PveFlag.class).getValue()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
|
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
|
||||||
&& !(victim instanceof Creature)));
|
&& !(victim instanceof Creature)));
|
||||||
}
|
}
|
||||||
@ -2980,8 +3038,17 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (event.getEntityType() != EntityType.PLAYER) {
|
if (event.getEntityType() != EntityType.PLAYER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = BukkitUtil.getLocation(event.getEntity()).getOwnedPlot();
|
Location location = BukkitUtil.getLocation(event.getEntity());
|
||||||
|
PlotArea area = location.getPlotArea();
|
||||||
|
if (area == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
|
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
||||||
|
.getFlag(InvincibleFlag.class).getValue()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.getFlag(InvincibleFlag.class)) {
|
if (plot.getFlag(InvincibleFlag.class)) {
|
||||||
@ -2992,8 +3059,17 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
Location location = pp.getLocation();
|
||||||
|
PlotArea area = location.getPlotArea();
|
||||||
|
if (area == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
|
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
||||||
|
.getFlag(ItemDropFlag.class).getValue()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID uuid = pp.getUUID();
|
UUID uuid = pp.getUUID();
|
||||||
@ -3009,8 +3085,17 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (ent instanceof Player) {
|
if (ent instanceof Player) {
|
||||||
Player player = (Player) ent;
|
Player player = (Player) ent;
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
Location location = pp.getLocation();
|
||||||
|
PlotArea area = location.getPlotArea();
|
||||||
|
if (area == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
|
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
||||||
|
.getFlag(DropProtectionFlag.class).getValue()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID uuid = pp.getUUID();
|
UUID uuid = pp.getUUID();
|
||||||
@ -3021,8 +3106,20 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler public void onDeath(final PlayerDeathEvent event) {
|
@EventHandler public void onDeath(final PlayerDeathEvent event) {
|
||||||
final Plot plot = BukkitUtil.getPlayer(event.getEntity()).getCurrentPlot();
|
Location location = BukkitUtil.getLocation(event.getEntity());
|
||||||
if (plot != null && plot.getFlag(KeepInventoryFlag.class)) {
|
PlotArea area = location.getPlotArea();
|
||||||
|
if (area == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = location.getOwnedPlot();
|
||||||
|
if (plot == null) {
|
||||||
|
if (area.isRoadRespectingGlobalFlags() && area.getFlagContainer()
|
||||||
|
.getFlag(KeepInventoryFlag.class).getValue()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (plot.getFlag(KeepInventoryFlag.class)) {
|
||||||
event.setKeepInventory(true);
|
event.setKeepInventory(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,7 @@ public abstract class PlotArea {
|
|||||||
@Getter private GameMode gameMode = GameModes.CREATIVE;
|
@Getter private GameMode gameMode = GameModes.CREATIVE;
|
||||||
@Getter private Map<String, Expression<Double>> prices = new HashMap<>();
|
@Getter private Map<String, Expression<Double>> prices = new HashMap<>();
|
||||||
@Getter(AccessLevel.PROTECTED) private List<String> schematics = new ArrayList<>();
|
@Getter(AccessLevel.PROTECTED) private List<String> schematics = new ArrayList<>();
|
||||||
|
@Getter private boolean roadRespectingGlobalFlags = false;
|
||||||
private boolean worldBorder = false;
|
private boolean worldBorder = false;
|
||||||
private boolean useEconomy = false;
|
private boolean useEconomy = false;
|
||||||
private int hash;
|
private int hash;
|
||||||
@ -370,6 +371,7 @@ public abstract class PlotArea {
|
|||||||
this.spawnEggs = config.getBoolean("event.spawn.egg");
|
this.spawnEggs = config.getBoolean("event.spawn.egg");
|
||||||
this.spawnCustom = config.getBoolean("event.spawn.custom");
|
this.spawnCustom = config.getBoolean("event.spawn.custom");
|
||||||
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
|
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
|
||||||
|
this.roadRespectingGlobalFlags = config.getBoolean("road.respect-global-flags");
|
||||||
loadConfiguration(config);
|
loadConfiguration(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,6 +415,7 @@ public abstract class PlotArea {
|
|||||||
options.put("world.max_height", this.getMaxBuildHeight());
|
options.put("world.max_height", this.getMaxBuildHeight());
|
||||||
options.put("world.min_height", this.getMinBuildHeight());
|
options.put("world.min_height", this.getMinBuildHeight());
|
||||||
options.put("world.gamemode", this.getGameMode().getName().toLowerCase());
|
options.put("world.gamemode", this.getGameMode().getName().toLowerCase());
|
||||||
|
options.put("road.respect-global-flags", this.isRoadRespectingGlobalFlags());
|
||||||
|
|
||||||
if (this.getType() != PlotAreaType.NORMAL) {
|
if (this.getType() != PlotAreaType.NORMAL) {
|
||||||
options.put("generator.terrain", this.getTerrain());
|
options.put("generator.terrain", this.getTerrain());
|
||||||
|
Loading…
Reference in New Issue
Block a user