Skip to content

Commit

Permalink
Merge branch 'main' into postplotclearevent
Browse files Browse the repository at this point in the history
  • Loading branch information
David-M-GitHub authored Jan 9, 2024
2 parents 530e037 + 8c44b2d commit 57856da
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 50 deletions.
1 change: 1 addition & 0 deletions Bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ tasks.named<ShadowJar>("shadowJar") {
exclude(dependency("org.checkerframework:"))
}

relocate("net.kyori.option", "com.plotsquared.core.configuration.option")
relocate("net.kyori.adventure", "com.plotsquared.core.configuration.adventure")
relocate("net.kyori.examination", "com.plotsquared.core.configuration.examination")
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ public void onPhysicsEvent(BlockPhysicsEvent event) {
final BlockFace facing = piston.getFacing();
location = location.add(facing.getModX(), facing.getModY(), facing.getModZ());
Plot newPlot = area.getOwnedPlotAbs(location);
if (!plot.equals(newPlot)) {
if (plot.equals(newPlot)) {
return;
}
if (!plot.isMerged() || !plot.getConnectedPlots().contains(newPlot)) {
event.setCancelled(true);
plot.debug("Prevented piston update because of invalid edge piston detection");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,17 @@ public void onPlayerDyeSign(PlayerInteractEvent event) {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, EditSignFlag.class, false)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, EditSignFlag.class, false)
&& !event.getPlayer().hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString())) {
event.setCancelled(true);
}
return;
}
if (plot.isAdded(event.getPlayer().getUniqueId())) {
return; // allow for added players
}
if (!plot.getFlag(EditSignFlag.class)) {
if (!plot.getFlag(EditSignFlag.class)
&& !event.getPlayer().hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString())) {
plot.debug(event.getPlayer().getName() + " could not color the sign because of edit-sign = false");
event.setCancelled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.EditSignFlag;
Expand All @@ -46,15 +47,17 @@ public void onPlayerSignOpenEvent(PlayerSignOpenEvent event) {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, EditSignFlag.class, false)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, EditSignFlag.class, false)
&& !event.getPlayer().hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString())) {
event.setCancelled(true);
}
return;
}
if (plot.isAdded(event.getPlayer().getUniqueId())) {
return; // allow for added players
}
if (!plot.getFlag(EditSignFlag.class)) {
if (!plot.getFlag(EditSignFlag.class)
&& !event.getPlayer().hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString())) {
plot.debug(event.getPlayer().getName() + " could not edit the sign because of edit-sign = false");
event.setCancelled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ public boolean plotEntry(final PlotPlayer<?> player, final Plot plot) {
public boolean plotExit(final PlotPlayer<?> player, Plot plot) {
try (final MetaDataAccess<Plot> lastPlot = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
final Plot previous = lastPlot.remove();
this.eventDispatcher.callLeave(player, plot);

List<StatusEffect> effects = playerEffects.remove(player.getUUID());
if (effects != null) {
Expand Down Expand Up @@ -467,6 +466,8 @@ public boolean plotExit(final PlotPlayer<?> player, Plot plot) {
feedRunnable.remove(player.getUUID());
healRunnable.remove(player.getUUID());
}
} finally {
this.eventDispatcher.callLeave(player, plot);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public enum Permission implements ComponentLike {
PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED("plots.admin.vehicle.break.unowned"),
PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER("plots.admin.vehicle.break.other"),
PERMISSION_ADMIN_PVE("plots.admin.pve"),
PERMISSION_ADMIN_PLACE_VEHICLE_ROAD("plots.admin.vehicle.place.road"),
PERMISSION_ADMIN_PLACE_VEHICLE_UNOWNED("plots.admin.vehicle.place.unowned"),
PERMISSION_ADMIN_PLACE_VEHICLE_OTHER("plots.admin.vehicle.place.other"),
PERMISSION_ADMIN_PVP("plots.admin.pvp"),
PERMISSION_ADMIN_BUILD_ROAD("plots.admin.build.road"),
PERMISSION_ADMIN_PROJECTILE_ROAD("plots.admin.projectile.road"),
Expand Down
73 changes: 30 additions & 43 deletions Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,10 @@ public boolean checkPlayerBlockEvent(
return true;
}
}
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD, notifyPerms);
}
if (!plot.hasOwner()) {
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED, notifyPerms);
}
final List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
for (final BlockTypeWrapper blockTypeWrapper : use) {
Expand All @@ -405,7 +401,7 @@ public boolean checkPlayerBlockEvent(
return true;
}
}
if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), false)) {
if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER, false)) {
return true;
}
// we check for the EditSignFlag in the PlayerSignOpenEvent again, but we must not cancel the interact event
Expand All @@ -430,14 +426,10 @@ public boolean checkPlayerBlockEvent(
return true;
}
}
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), false
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD, false);
}
if (!plot.hasOwner()) {
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), false
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED, false);
}
if (plot.getFlag(DeviceInteractFlag.class)) {
return true;
Expand All @@ -449,21 +441,14 @@ public boolean checkPlayerBlockEvent(
return true;
}
}
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(),
false
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER, false);
}
case SPAWN_MOB -> {
if (plot == null) {
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD, notifyPerms);
}
if (!plot.hasOwner()) {
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED, notifyPerms);
}
if (plot.getFlag(MobPlaceFlag.class)) {
return true;
Expand All @@ -475,10 +460,7 @@ public boolean checkPlayerBlockEvent(
return true;
}
}
if (player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(),
false
)) {
if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER, false)) {
return true;
}
if (notifyPerms) {
Expand All @@ -498,14 +480,10 @@ public boolean checkPlayerBlockEvent(
}
case PLACE_MISC -> {
if (plot == null) {
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD, notifyPerms);
}
if (!plot.hasOwner()) {
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms
);
return player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED, notifyPerms);
}
if (plot.getFlag(MiscPlaceFlag.class)) {
return true;
Expand All @@ -517,10 +495,7 @@ public boolean checkPlayerBlockEvent(
return true;
}
}
if (player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(),
false
)) {
if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER, false)) {
return true;
}
if (notifyPerms) {
Expand All @@ -540,16 +515,28 @@ public boolean checkPlayerBlockEvent(
}
case PLACE_VEHICLE -> {
if (plot == null) {
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms
);
return player.hasPermission(Permission.PERMISSION_ADMIN_PLACE_VEHICLE_ROAD, notifyPerms);
}
if (!plot.hasOwner()) {
return player.hasPermission(
Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms
return player.hasPermission(Permission.PERMISSION_ADMIN_PLACE_VEHICLE_UNOWNED, notifyPerms);
}
if (plot.getFlag(VehiclePlaceFlag.class)) {
return true;
}
if (player.hasPermission(Permission.PERMISSION_ADMIN_PLACE_VEHICLE_OTHER, false)) {
return true;
}
if (notifyPerms) {
player.sendMessage(
TranslatableCaption.of("commandconfig.flag_tutorial_usage"),
TagResolver.resolver(
"flag",
Tag.inserting(
PlotFlag.getFlagNameComponent(VehiclePlaceFlag.class)
)
)
);
}
return plot.getFlag(VehiclePlaceFlag.class);
}
default -> {
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
}

group = "com.intellectualsites.plotsquared"
version = "7.3.1-SNAPSHOT"
version = "7.3.2-SNAPSHOT"

if (!File("$rootDir/.git").exists()) {
logger.lifecycle("""
Expand Down

0 comments on commit 57856da

Please sign in to comment.