mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Merge branch 'features/v5/road-respect-flags' into v5
This commit is contained in:
commit
9e9db0f1df
@ -43,6 +43,7 @@ import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotHandler;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
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.AnimalCapFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.AnimalInteractFlag;
|
||||
@ -226,8 +227,8 @@ import java.util.regex.Pattern;
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE
|
||||
= new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
|
||||
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||
|
||||
private boolean pistonBlocks = true;
|
||||
private float lastRadius;
|
||||
@ -342,6 +343,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
if (area.isRoadFlags() && area.getRoadFlag(RedstoneFlag.class)) {
|
||||
event.setNewCurrent(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!plot.getFlag(RedstoneFlag.class)) {
|
||||
@ -361,7 +365,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
disable = PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs()) == null;
|
||||
disable =
|
||||
PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs())
|
||||
== null;
|
||||
}
|
||||
}
|
||||
if (disable) {
|
||||
@ -373,7 +379,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
if (disable) {
|
||||
event.setNewCurrent(0);
|
||||
plot.debug("Redstone event was cancelled because no trusted player was in the plot");
|
||||
plot.debug(
|
||||
"Redstone event was cancelled because no trusted player was in the plot");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -464,7 +471,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||
if (!plot.equals(newPlot)) {
|
||||
event.setCancelled(true);
|
||||
plot.debug("Prevented piston update because of invalid edge piston detection");
|
||||
plot.debug(
|
||||
"Prevented piston update because of invalid edge piston detection");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -569,11 +577,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (plot == null) {
|
||||
if (plot == null && !area.isRoadFlags()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> blockedCommands = plot.getFlag(BlockedCmdsFlag.class);
|
||||
List<String> blockedCommands = plot != null ?
|
||||
plot.getFlag(BlockedCmdsFlag.class) :
|
||||
area.getFlag(BlockedCmdsFlag.class);
|
||||
if (!blockedCommands.isEmpty() && !Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
String part = parts[0];
|
||||
@ -618,10 +628,10 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
if (pattern.matcher(msg).matches()) {
|
||||
String perm;
|
||||
if (plot.isAdded(plotPlayer.getUUID())) {
|
||||
if (plot != null && plot.isAdded(plotPlayer.getUUID())) {
|
||||
perm = "plots.admin.command.blocked-cmds.shared";
|
||||
} else {
|
||||
perm = "plots.admin.command.blocked-cmds.other";
|
||||
perm = "plots.admin.command.blocked-cmds.road";
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, perm)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.COMMAND_BLOCKED);
|
||||
@ -638,11 +648,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
final UUID uuid;
|
||||
if (Settings.UUID.OFFLINE) {
|
||||
if (Settings.UUID.FORCE_LOWERCASE) {
|
||||
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" +
|
||||
event.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
uuid = UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + event.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
} else {
|
||||
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" +
|
||||
event.getName()).getBytes(Charsets.UTF_8));
|
||||
uuid = UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
} else {
|
||||
uuid = event.getUniqueId();
|
||||
@ -1328,8 +1338,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
return;
|
||||
}
|
||||
plot.debug(player.getName() + " could not break " + block.getType() +
|
||||
" because it was not in the break flag");
|
||||
plot.debug(player.getName() + " could not break " + block.getType()
|
||||
+ " because it was not in the break flag");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1438,7 +1448,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
plot.debug(event.getBlock().getType() + " could not update because disable-physics = true");
|
||||
plot.debug(event.getBlock().getType()
|
||||
+ " could not update because disable-physics = true");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1719,13 +1730,24 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
if (event.getClick() == ClickType.CREATIVE) {
|
||||
final Plot plot = pp.getCurrentPlot();
|
||||
if (plot != null &&
|
||||
plot.getFlag(PreventCreativeCopyFlag.class) &&
|
||||
!plot.isAdded(player.getUniqueId()) &&
|
||||
!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||
final ItemStack newStack = new ItemStack(newItem.getType(), newItem.getAmount());
|
||||
event.setCursor(newStack);
|
||||
plot.debug(player.getName() + " could not creative-copy an item because prevent-creative-copy = true");
|
||||
if (plot != null) {
|
||||
if (plot.getFlag(PreventCreativeCopyFlag.class) && !plot
|
||||
.isAdded(player.getUniqueId()) && !Permissions
|
||||
.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||
final ItemStack newStack =
|
||||
new ItemStack(newItem.getType(), newItem.getAmount());
|
||||
event.setCursor(newStack);
|
||||
plot.debug(player.getName()
|
||||
+ " could not creative-copy an item because prevent-creative-copy = true");
|
||||
}
|
||||
} else {
|
||||
PlotArea area = pp.getPlotAreaAbs();
|
||||
if (area != null && area.isRoadFlags() && area
|
||||
.getRoadFlag(PreventCreativeCopyFlag.class)) {
|
||||
final ItemStack newStack =
|
||||
new ItemStack(newItem.getType(), newItem.getAmount());
|
||||
event.setCursor(newStack);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1842,7 +1864,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Plot plot = location.getPlotAbs();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class)
|
||||
&& !Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -1855,7 +1878,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!plot.hasOwner() && !area.isRoadFlags() && !area
|
||||
.getRoadFlag(MiscInteractFlag.class)) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.interact.unowned");
|
||||
@ -1873,7 +1897,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.interact.other");
|
||||
e.setCancelled(true);
|
||||
plot.debug(pp.getName() + " could not interact with " + entity.getType() + " bcause misc-interact = false");
|
||||
plot.debug(pp.getName() + " could not interact with " + entity.getType()
|
||||
+ " bcause misc-interact = false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2205,7 +2230,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null || !plot.getFlag(BlockBurnFlag.class)) {
|
||||
plot.debug("Block burning was cancelled because block-burn = false");
|
||||
if (plot != null) {
|
||||
plot.debug("Block burning was cancelled because block-burn = false");
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -2510,7 +2537,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
event.setCancelled(true);
|
||||
plot.debug(p.getName() + " could not break hanging entity because hanging-break = false");
|
||||
plot.debug(p.getName()
|
||||
+ " could not break hanging entity because hanging-break = false");
|
||||
}
|
||||
}
|
||||
} else if (remover instanceof Projectile) {
|
||||
@ -2539,7 +2567,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
event.setCancelled(true);
|
||||
plot.debug(player.getName() + " could not break hanging entity because hanging-break = false");
|
||||
plot.debug(player.getName()
|
||||
+ " could not break hanging entity because hanging-break = false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2560,57 +2589,66 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Player p = event.getPlayer();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (plot == null && !area.isRoadFlags()) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_INTERACT_ROAD);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.hasOwner()) {
|
||||
} else if (plot != null && !plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
} else if ((plot != null && !plot.isAdded(pp.getUUID())) || area
|
||||
.isRoadFlags()) {
|
||||
final Entity entity = event.getRightClicked();
|
||||
final com.sk89q.worldedit.world.entity.EntityType entityType =
|
||||
BukkitAdapter.adapt(entity.getType());
|
||||
|
||||
if (EntityCategories.HOSTILE.contains(entityType) && plot
|
||||
.getFlag(HostileInteractFlag.class)) {
|
||||
FlagContainer flagContainer;
|
||||
if (plot == null) {
|
||||
flagContainer = area.getRoadFlagContainer();
|
||||
} else {
|
||||
flagContainer = plot.getFlagContainer();
|
||||
}
|
||||
|
||||
if (EntityCategories.HOSTILE.contains(entityType) && flagContainer
|
||||
.getFlag(HostileInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.ANIMAL.contains(entityType) && plot
|
||||
.getFlag(AnimalInteractFlag.class)) {
|
||||
if (EntityCategories.ANIMAL.contains(entityType) && flagContainer
|
||||
.getFlag(AnimalInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This actually makes use of the interface, so we don't use the
|
||||
// category
|
||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot
|
||||
.getFlag(TamedInteractFlag.class)) {
|
||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && flagContainer
|
||||
.getFlag(TamedInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.VEHICLE.contains(entityType) && plot
|
||||
.getFlag(VehicleUseFlag.class)) {
|
||||
if (EntityCategories.VEHICLE.contains(entityType) && flagContainer
|
||||
.getFlag(VehicleUseFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.PLAYER.contains(entityType) && plot
|
||||
.getFlag(PlayerInteractFlag.class)) {
|
||||
if (EntityCategories.PLAYER.contains(entityType) && flagContainer
|
||||
.getFlag(PlayerInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.VILLAGER.contains(entityType) && plot
|
||||
.getFlag(VillagerInteractFlag.class)) {
|
||||
if (EntityCategories.VILLAGER.contains(entityType) && flagContainer
|
||||
.getFlag(VillagerInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((EntityCategories.HANGING.contains(entityType) || EntityCategories.OTHER
|
||||
.contains(entityType)) && plot.getFlag(MiscInteractFlag.class)) {
|
||||
.contains(entityType)) && flagContainer.getFlag(MiscInteractFlag.class)
|
||||
.getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2658,7 +2696,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.vehicle.break.other");
|
||||
event.setCancelled(true);
|
||||
plot.debug(pp.getName() + " could not break vehicle because vehicle-break = false");
|
||||
plot.debug(pp.getName()
|
||||
+ " could not break vehicle because vehicle-break = false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2760,12 +2799,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
Plot plot;
|
||||
String stub;
|
||||
boolean isPlot = true;
|
||||
if (dplot == null && vplot == null) {
|
||||
if (dArea == null) {
|
||||
return true;
|
||||
}
|
||||
plot = null;
|
||||
stub = "road";
|
||||
isPlot = false;
|
||||
} else {
|
||||
// Prioritize plots for close to seamless pvp zones
|
||||
if (victim.getTicksLived() > damager.getTicksLived()) {
|
||||
@ -2795,6 +2836,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
stub = "unowned";
|
||||
}
|
||||
}
|
||||
boolean roadFlags = vArea != null ? vArea.isRoadFlags() : dArea.isRoadFlags();
|
||||
PlotArea area = vArea != null ? vArea : dArea;
|
||||
|
||||
Player player;
|
||||
if (damager instanceof Player) { // attacker is player
|
||||
@ -2828,8 +2871,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
if (EntityCategories.HANGING.contains(entityType)) { // hanging
|
||||
if (plot != null && (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 (!Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
@ -2854,47 +2897,63 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.destroy." + stub);
|
||||
if (plot != null) {
|
||||
plot.debug(player.getName() + " could not break armor stand because misc-break = false");
|
||||
plot.debug(player.getName()
|
||||
+ " could not break armor stand because misc-break = false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (EntityCategories.HOSTILE.contains(entityType)) {
|
||||
if (plot != null && (plot.getFlag(HostileAttackFlag.class) || plot
|
||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
if (isPlot) {
|
||||
if (plot.getFlag(HostileAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && (area.getRoadFlag(HostileAttackFlag.class) || area
|
||||
.getFlag(PveFlag.class))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
if (plot != null) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR hostile-attack = false");
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false OR hostile-attack = false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (EntityCategories.TAMEABLE.contains(entityType)) { // victim is tameable
|
||||
if (plot != null && (plot.getFlag(TamedAttackFlag.class) || plot
|
||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
if (isPlot) {
|
||||
if (plot.getFlag(TamedAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && (area.getRoadFlag(TamedAttackFlag.class) || area
|
||||
.getFlag(PveFlag.class))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
if (plot != null) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR tamned-attack = false");
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false OR tamned-attack = false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (EntityCategories.PLAYER.contains(entityType)) {
|
||||
if (plot != null) {
|
||||
if (isPlot) {
|
||||
if (!plot.getFlag(PvpFlag.class) && !Permissions
|
||||
.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pvp." + stub);
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false");
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && area.getRoadFlag(PvpFlag.class)) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
@ -2902,29 +2961,38 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
} else if (EntityCategories.ANIMAL.contains(entityType)) { // victim is animal
|
||||
if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot
|
||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR animal-attack = false");
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
return false;
|
||||
if (isPlot) {
|
||||
if (plot.getFlag(AnimalAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false OR animal-attack = false");
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && (area.getRoadFlag(AnimalAttackFlag.class) || area
|
||||
.getFlag(PveFlag.class))) {
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (EntityCategories.VEHICLE
|
||||
.contains(entityType)) { // Vehicles are managed in vehicle destroy event
|
||||
return true;
|
||||
} else { // victim is something else
|
||||
if (plot != null && (plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
if (isPlot) {
|
||||
if (plot.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && area.getRoadFlag(PveFlag.class)) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
if (plot != null) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false");
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2941,6 +3009,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (vplot == null && roadFlags && area.getRoadFlag(PveFlag.class)) {
|
||||
return true;
|
||||
}
|
||||
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
|
||||
&& !(victim instanceof Creature)));
|
||||
}
|
||||
@ -3030,7 +3101,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Block block = event.getBlockPlaced();
|
||||
if (block.getType().hasGravity()) {
|
||||
sendBlockChange(block.getLocation(), block.getBlockData());
|
||||
plot.debug(event.getBlock().getType() + " did not fall because of disable-physics = true");
|
||||
plot.debug(event.getBlock().getType()
|
||||
+ " did not fall because of disable-physics = true");
|
||||
}
|
||||
}
|
||||
} else if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
@ -3044,12 +3116,21 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (event.getEntityType() != EntityType.PLAYER) {
|
||||
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 (area.isRoadFlags() && area.getRoadFlag(InvincibleFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(InvincibleFlag.class)) {
|
||||
plot.debug(event.getEntity().getName() + " could not take damage because invincible = true");
|
||||
plot.debug(
|
||||
event.getEntity().getName() + " could not take damage because invincible = true");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -3057,8 +3138,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BukkitPlayer 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 (area.isRoadFlags() && area.getRoadFlag(ItemDropFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
UUID uuid = pp.getUUID();
|
||||
@ -3075,24 +3164,46 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (ent instanceof Player) {
|
||||
Player player = (Player) ent;
|
||||
BukkitPlayer 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 (area.isRoadFlags() && area.getRoadFlag(DropProtectionFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
UUID uuid = pp.getUUID();
|
||||
if (!plot.isAdded(uuid) && plot.getFlag(DropProtectionFlag.class)) {
|
||||
plot.debug(player.getName() + " could not pick up item because of drop-protection = true");
|
||||
plot.debug(
|
||||
player.getName() + " could not pick up item because of drop-protection = true");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler public void onDeath(final PlayerDeathEvent event) {
|
||||
final Plot plot = BukkitUtil.getPlayer(event.getEntity()).getCurrentPlot();
|
||||
if (plot != null && plot.getFlag(KeepInventoryFlag.class)) {
|
||||
plot.debug(event.getEntity().getName() + " kept their inventory because of keep-inventory = true");
|
||||
event.setKeepInventory(true);
|
||||
Location location = BukkitUtil.getLocation(event.getEntity());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
if (area.isRoadFlags() && area.getRoadFlag(KeepInventoryFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(KeepInventoryFlag.class)) {
|
||||
if (plot.getFlag(KeepInventoryFlag.class)) {
|
||||
plot.debug(event.getEntity().getName()
|
||||
+ " kept their inventory because of keep-inventory = true");
|
||||
event.setKeepInventory(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -118,6 +118,7 @@ public abstract class PlotArea {
|
||||
@Getter private GameMode gameMode = GameModes.CREATIVE;
|
||||
@Getter private Map<String, Expression<Double>> prices = new HashMap<>();
|
||||
@Getter(AccessLevel.PROTECTED) private List<String> schematics = new ArrayList<>();
|
||||
@Getter private boolean roadFlags = false;
|
||||
private boolean worldBorder = false;
|
||||
private boolean useEconomy = false;
|
||||
private int hash;
|
||||
@ -127,7 +128,9 @@ public abstract class PlotArea {
|
||||
/**
|
||||
* Area flag container
|
||||
*/
|
||||
@Getter private FlagContainer flagContainer =
|
||||
@Getter private final FlagContainer flagContainer =
|
||||
new FlagContainer(GlobalFlagContainer.getInstance());
|
||||
@Getter private final FlagContainer roadFlagContainer =
|
||||
new FlagContainer(GlobalFlagContainer.getInstance());
|
||||
|
||||
public PlotArea(@NotNull final String worldName, @Nullable final String id,
|
||||
@ -370,6 +373,40 @@ public abstract class PlotArea {
|
||||
this.spawnEggs = config.getBoolean("event.spawn.egg");
|
||||
this.spawnCustom = config.getBoolean("event.spawn.custom");
|
||||
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
|
||||
|
||||
List<String> roadflags = config.getStringList("flags.default");
|
||||
if (roadflags.isEmpty()) {
|
||||
roadflags = config.getStringList("road.flags");
|
||||
if (roadflags.isEmpty()) {
|
||||
roadflags = new ArrayList<>();
|
||||
ConfigurationSection section = config.getConfigurationSection("road.flags");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
for (String key : keys) {
|
||||
if (!"default".equals(key)) {
|
||||
roadflags.add(key + ';' + section.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.getRoadFlagContainer().addAll(parseFlags(roadflags));
|
||||
|
||||
StringBuilder roadFlagBuilder = new StringBuilder();
|
||||
Collection<PlotFlag<?, ?>> roadFlagCollection = this.getFlagContainer().getFlagMap().values();
|
||||
if (roadFlagCollection.isEmpty()) {
|
||||
roadFlagBuilder.append(Captions.NONE.getTranslated());
|
||||
} else {
|
||||
roadFlags = true;
|
||||
String prefix = " ";
|
||||
for (final PlotFlag<?, ?> flag : roadFlagCollection) {
|
||||
Object value = flag.toString();
|
||||
roadFlagBuilder.append(prefix).append(CaptionUtility
|
||||
.format(null, Captions.PLOT_FLAG_LIST.getTranslated(), flag.getName(),
|
||||
CaptionUtility.formatRaw(null, value.toString(), "")));
|
||||
prefix = ", ";
|
||||
}
|
||||
}
|
||||
PlotSquared.log(Captions.PREFIX + "&3 - road flags: &7" + roadFlagBuilder.toString());
|
||||
|
||||
loadConfiguration(config);
|
||||
}
|
||||
|
||||
@ -413,6 +450,7 @@ public abstract class PlotArea {
|
||||
options.put("world.max_height", this.getMaxBuildHeight());
|
||||
options.put("world.min_height", this.getMinBuildHeight());
|
||||
options.put("world.gamemode", this.getGameMode().getName().toLowerCase());
|
||||
options.put("road.flags.default", null);
|
||||
|
||||
if (this.getType() != PlotAreaType.NORMAL) {
|
||||
options.put("generator.terrain", this.getTerrain());
|
||||
@ -434,6 +472,9 @@ public abstract class PlotArea {
|
||||
config.set("flags.use",
|
||||
"63,64,68,69,71,77,96,143,167,193,194,195,196,197,77,143,69,70,72,147,148,107,183,184,185,186,187,132");
|
||||
}
|
||||
if (!config.contains("road.flags")) {
|
||||
config.set("road.flags.liquid-flow", false);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull @Override public String toString() {
|
||||
@ -1069,4 +1110,52 @@ public abstract class PlotArea {
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value associated with the specified road 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 getRoadFlag(final Class<? extends PlotFlag<T, ?>> flagClass) {
|
||||
return this.roadFlagContainer.getFlag(flagClass).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value associated with the specified road 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 getRoadFlag(final V flag) {
|
||||
final Class<?> flagClass = flag.getClass();
|
||||
final PlotFlag<?, ?> flagInstance = this.roadFlagContainer.getFlagErased(flagClass);
|
||||
return FlagContainer.<T, V>castUnsafe(flagInstance).getValue();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user