Skip to content

Commit 036e115

Browse files
committed
Bugfixes & Improvements (17.0.6)
1 parent 3f76ff3 commit 036e115

File tree

6 files changed

+108
-42
lines changed

6 files changed

+108
-42
lines changed

pom.xml

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

55
<groupId>com.griefprevention</groupId>
66
<artifactId>GriefPrevention</artifactId>
7-
<version>17.0.5</version>
7+
<version>17.0.6</version>
88

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

src/main/java/com/griefprevention/visualization/impl/SnapOverrideHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ static SnapOverride resolve(@NotNull Block block, boolean submerged)
119119
return SnapOverride.SELF;
120120
}
121121

122+
if (material == Material.DIRT_PATH)
123+
{
124+
return SnapOverride.SELF;
125+
}
126+
122127
if (material == Material.SCAFFOLDING)
123128
{
124129
return SnapOverride.SELF;

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

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -513,23 +513,37 @@ public boolean hasExplicitPermission(@NotNull Player player, @NotNull ClaimPermi
513513
return checkPermission(uuid, permission, event, null);
514514
}
515515

516-
/**
517-
* Check whether a UUID has a certain level of trust with a custom denial message.
518-
*
519-
* @param uuid the UUID being checked for permissions
520-
* @param permission the ClaimPermission level required
521-
* @param event the Event triggering the permission check
522-
* @param denialOverride a custom denial message supplier, or null to use default
523-
* @return the denial message or null if permission is granted
524-
*/
516+
/**
517+
* Check whether a UUID has a certain level of trust with a custom denial message.
518+
*
519+
* @param uuid the UUID being checked for permissions
520+
* @param permission the ClaimPermission level required
521+
* @param event the Event triggering the permission check
522+
* @param denialOverride a custom denial message supplier, or null to use default
523+
* @return the denial message or null if permission is granted
524+
*/
525525
public @Nullable Supplier<String> checkPermission(
526-
@NotNull UUID uuid,
527-
@NotNull ClaimPermission permission,
528-
@Nullable Event event,
529-
@Nullable Supplier<String> denialOverride)
530-
{
531-
return callPermissionCheck(new ClaimPermissionCheckEvent(uuid, this, permission, event), denialOverride);
532-
}
526+
@NotNull UUID uuid,
527+
@NotNull ClaimPermission permission,
528+
@Nullable Event event,
529+
@Nullable Supplier<String> denialOverride)
530+
{
531+
// For wilderness claims, only block if explicitly denied
532+
if (this.isWilderness()) {
533+
return isPermissionDenied(uuid.toString(), permission) ?
534+
(denialOverride != null ? denialOverride : () -> "You don't have permission to do that in the wilderness.") :
535+
null;
536+
}
537+
return callPermissionCheck(new ClaimPermissionCheckEvent(uuid, this, permission, event), denialOverride);
538+
}
539+
540+
/**
541+
* Checks if this claim represents a wilderness (unclaimed) area.
542+
* @return true if this is a wilderness claim, false otherwise
543+
*/
544+
public boolean isWilderness() {
545+
return this.id == null;
546+
}
533547

534548
/**
535549
* Helper method for calling a ClaimPermissionCheckEvent.

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -733,14 +733,17 @@ synchronized void deleteClaimFromSecondaryStorage(Claim claim)
733733
{
734734
root = root.parent;
735735
}
736-
736+
737+
// Remove the claim from its parent's children list
738+
claim.parent.children.remove(claim);
739+
740+
// Save the parent to update the YAML
737741
this.writeClaimToStorage(root);
738-
return;
739742
}
740-
743+
744+
// Always try to delete the claim file if it exists
745+
// (in case it's a top-level claim or the file wasn't properly cleaned up)
741746
String claimID = String.valueOf(claim.id);
742-
743-
//remove from disk
744747
File claimFile = new File(claimDataFolderPath + File.separator + claimID + ".yml");
745748
if (claimFile.exists() && !claimFile.delete())
746749
{

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
import java.io.IOException;
6565
import java.nio.charset.StandardCharsets;
6666
import java.util.ArrayList;
67+
import java.util.Arrays;
6768
import java.util.Collection;
68-
import java.util.Date;
6969
import java.util.HashMap;
7070
import java.util.HashSet;
7171
import java.util.List;
@@ -76,6 +76,7 @@
7676
import java.util.Vector;
7777
import java.util.concurrent.ConcurrentHashMap;
7878
import java.util.concurrent.TimeUnit;
79+
import java.util.Date;
7980
import java.util.function.Supplier;
8081
import java.util.logging.Level;
8182
import java.util.logging.Logger;
@@ -580,6 +581,7 @@ else if (world.getEnvironment() == Environment.NORMAL)
580581
this.config_claims_maxClaimsPerPlayer = config.getInt("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", 0);
581582
this.config_claims_villagerTradingRequiresTrust = config.getBoolean("GriefPrevention.Claims.VillagerTradingRequiresPermission", true);
582583
String commandsRequiringAccessTrust = config.getString("GriefPrevention.Claims.CommandsRequiringAccessTrust", "/sethome");
584+
this.config_claims_commandsRequiringAccessTrust = new ArrayList<>(Arrays.asList(commandsRequiringAccessTrust.split(";")));
583585
this.config_claims_supplyPlayerManual = config.getBoolean("GriefPrevention.Claims.DeliverManuals", true);
584586
this.config_claims_manualDeliveryDelaySeconds = config.getInt("GriefPrevention.Claims.ManualDeliveryDelaySeconds", 30);
585587
this.config_claims_ravagersBreakBlocks = config.getBoolean("GriefPrevention.Claims.RavagersBreakBlocks", true);

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

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,29 +1096,43 @@ void onPlayerPortal(PlayerPortalEvent event)
10961096
}
10971097

10981098
//when a player teleports
1099-
@EventHandler(priority = EventPriority.LOWEST)
1099+
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
11001100
public void onPlayerTeleport(PlayerTeleportEvent event)
11011101
{
1102-
//FEATURE: prevent players from using ender pearls or chorus fruit to gain access to secured claims
1103-
if(!instance.config_claims_enderPearlsRequireAccessTrust) return;
1104-
1105-
TeleportCause cause = event.getCause();
1106-
if(cause != TeleportCause.CHORUS_FRUIT && cause != TeleportCause.ENDER_PEARL) return;
1107-
11081102
Player player = event.getPlayer();
11091103
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
1110-
1104+
1105+
// Get the claim at the destination
11111106
Claim toClaim = this.dataStore.getClaimAt(event.getTo(), false, playerData.lastClaim);
1112-
if(toClaim == null) return;
1113-
1107+
1108+
// Get the claim at the original location
1109+
Claim fromClaim = playerData.lastClaim;
1110+
1111+
// Update the lastClaim to the new location
11141112
playerData.lastClaim = toClaim;
1115-
Supplier<String> noAccessReason = toClaim.checkPermission(player, ClaimPermission.Access, event);
1116-
if(noAccessReason == null) return;
1117-
1118-
GriefPrevention.sendMessage(player, TextMode.Err, noAccessReason.get());
1119-
event.setCancelled(true);
1120-
if (cause == TeleportCause.ENDER_PEARL)
1121-
player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL));
1113+
1114+
// If we're moving from one claim to another, or from a claim to wilderness,
1115+
// we need to update the player's permissions
1116+
if (fromClaim != toClaim) {
1117+
player.updateCommands();
1118+
}
1119+
1120+
// Special handling for ender pearls and chorus fruit to prevent gaining access to secured claims
1121+
if (instance.config_claims_enderPearlsRequireAccessTrust) {
1122+
TeleportCause cause = event.getCause();
1123+
if (cause == TeleportCause.CHORUS_FRUIT || cause == TeleportCause.ENDER_PEARL) {
1124+
if (toClaim != null) {
1125+
Supplier<String> noAccessReason = toClaim.checkPermission(player, ClaimPermission.Access, event);
1126+
if (noAccessReason != null) {
1127+
GriefPrevention.sendMessage(player, TextMode.Err, noAccessReason.get());
1128+
event.setCancelled(true);
1129+
if (cause == TeleportCause.ENDER_PEARL) {
1130+
player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL));
1131+
}
1132+
}
1133+
}
1134+
}
1135+
}
11221136
}
11231137

11241138
//when a player triggers a raid (in a claim)
@@ -1181,6 +1195,32 @@ public void onPlayerLeashEntity(PlayerLeashEntityEvent event)
11811195
}
11821196
}
11831197

1198+
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
1199+
public void onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event) {
1200+
// Only check if the player has moved a full block
1201+
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
1202+
event.getFrom().getBlockZ() == event.getTo().getBlockZ() &&
1203+
event.getFrom().getBlockY() == event.getTo().getBlockY()) {
1204+
return;
1205+
}
1206+
1207+
Player player = event.getPlayer();
1208+
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
1209+
1210+
// Get the claim at the new location
1211+
Claim toClaim = this.dataStore.getClaimAt(event.getTo(), false, playerData.lastClaim);
1212+
Claim fromClaim = playerData.lastClaim;
1213+
1214+
// If we're moving between claims or to/from wilderness
1215+
if (fromClaim != toClaim) {
1216+
// Update the last claim reference
1217+
playerData.lastClaim = toClaim;
1218+
1219+
// Update commands to reflect the new location
1220+
player.updateCommands();
1221+
}
1222+
}
1223+
11841224
//when a player interacts with an entity...
11851225
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
11861226
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
@@ -1985,10 +2025,12 @@ else if (materialInHand == instance.config_claims_investigationTool && hand == E
19852025
ClaimInspectionEvent inspectionEvent = new ClaimInspectionEvent(player, clickedBlock, null);
19862026
Bukkit.getPluginManager().callEvent(inspectionEvent);
19872027
if (inspectionEvent.isCancelled()) return;
1988-
2028+
19892029
GriefPrevention.sendMessage(player, TextMode.Info, Messages.BlockNotClaimed);
1990-
2030+
2031+
// Clear any existing visualization
19912032
playerData.setVisibleBoundaries(null);
2033+
return; // Important: Add this return to prevent further processing
19922034
}
19932035

19942036
//claim case

0 commit comments

Comments
 (0)