Skip to content

Commit 0e9d3b4

Browse files
committed
fix EnderPearlsRequireAccessTrust not working
1 parent 47730bc commit 0e9d3b4

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>com.griefprevention</groupId>
1010
<artifactId>GriefPrevention</artifactId>
11-
<version>17.2.1</version>
11+
<version>17.2.2</version>
1212

1313
<name>GriefPrevention</name>
1414
<description>The official self-service anti-griefing Bukkit plugin for Minecraft servers since 2011.</description>

src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ void onPlayerPortal(PlayerPortalEvent event) {
10541054
}
10551055

10561056
// when a player teleports
1057-
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
1057+
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
10581058
public void onPlayerTeleport(PlayerTeleportEvent event) {
10591059
Player player = event.getPlayer();
10601060
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
@@ -1065,32 +1065,34 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
10651065
// Get the claim at the original location
10661066
Claim fromClaim = playerData.lastClaim;
10671067

1068-
// Update the lastClaim to the new location
1069-
playerData.lastClaim = toClaim;
1070-
1071-
// If we're moving from one claim to another, or from a claim to wilderness,
1072-
// we need to update the player's permissions
1073-
if (fromClaim != toClaim) {
1074-
player.updateCommands();
1075-
}
1076-
10771068
// Special handling for ender pearls and chorus fruit to prevent gaining access
1078-
// to secured claims
1069+
// to secured claims. Must run before updating lastClaim so we don't corrupt
1070+
// player state when cancelling. Use ProtectionHelper for proper 3D claim and
1071+
// parent inheritance handling.
10791072
if (instance.config_claims_enderPearlsRequireAccessTrust) {
10801073
TeleportCause cause = event.getCause();
10811074
if (cause == TeleportCause.CHORUS_FRUIT || cause == TeleportCause.ENDER_PEARL) {
1082-
if (toClaim != null) {
1083-
Supplier<String> noAccessReason = toClaim.checkPermission(player, ClaimPermission.Access, event);
1084-
if (noAccessReason != null) {
1085-
GriefPrevention.sendMessage(player, TextMode.Err, noAccessReason.get());
1086-
event.setCancelled(true);
1087-
if (cause == TeleportCause.ENDER_PEARL && instance.config_claims_refundDeniedEnderPearls) {
1088-
player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL));
1089-
}
1075+
Supplier<String> noAccessReason = ProtectionHelper.checkPermission(player, event.getTo(),
1076+
ClaimPermission.Access, event);
1077+
if (noAccessReason != null) {
1078+
GriefPrevention.sendMessage(player, TextMode.Err, noAccessReason.get());
1079+
event.setCancelled(true);
1080+
if (cause == TeleportCause.ENDER_PEARL && instance.config_claims_refundDeniedEnderPearls) {
1081+
player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL));
10901082
}
1083+
return; // Don't update lastClaim when teleport is cancelled
10911084
}
10921085
}
10931086
}
1087+
1088+
// Update the lastClaim to the new location (only when teleport proceeds)
1089+
playerData.lastClaim = toClaim;
1090+
1091+
// If we're moving from one claim to another, or from a claim to wilderness,
1092+
// we need to update the player's permissions
1093+
if (fromClaim != toClaim) {
1094+
player.updateCommands();
1095+
}
10941096
}
10951097

10961098
// when a player triggers a raid (in a claim)

0 commit comments

Comments
 (0)