Skip to content

Commit aa27bae

Browse files
committed
fix: Remove sellclaim alias and GPFlags bloat
1 parent 555e6ff commit aa27bae

File tree

9 files changed

+34
-9
lines changed

9 files changed

+34
-9
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.20</version>
7+
<version>17.0.21</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/FakeBlockVisualization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private boolean isLiquidLike(@NotNull Block block)
8181
((Lightable) fakeData).setLit(true);
8282
yield createElementAdder(fakeData, type, false);
8383
}
84-
case CONFLICT_ZONE_3D -> createElementAdder(Material.REDSTONE_BLOCK.createBlockData(), type, true);
84+
case CONFLICT_ZONE_3D -> createElementAdder(Material.REDSTONE_ORE.createBlockData(), type, true);
8585
case RESTORE_NATURE -> {
8686
// Special handling - corners need directional facing, handled in draw()
8787
// Return a dummy adder that will be overridden

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private void createBlockDisplay(Player player, IntVector pos, BlockData blockDat
334334
// For 3D subdivisions and 2D subdivisions, use exact coordinates without terrain snapping
335335
Material mat = blockData.getMaterial();
336336
boolean isExactPlacement = mat == Material.WHITE_WOOL || mat == Material.IRON_BLOCK ||
337-
mat == Material.REDSTONE_BLOCK || mat == Material.NETHERRACK;
337+
mat == Material.REDSTONE_ORE || mat == Material.NETHERRACK;
338338

339339
int y;
340340
if (isExactPlacement) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public abstract class DataStore {
9393
final static String bannedWordsFilePath = dataLayerFolderPath + File.separator + "bannedWords.txt";
9494

9595
// the latest version of the data schema implemented here
96-
protected static final int latestSchemaVersion = 3;
96+
protected static final int latestSchemaVersion = 5;
9797

9898
// reading and writing the schema version to the data store
9999
abstract int getSchemaVersionFromStorage();

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public class DatabaseDataStore extends DataStore
4747
private static final String SQL_UPDATE_NAME =
4848
"UPDATE griefprevention_playerdata SET name = ? WHERE name = ?";
4949
private static final String SQL_UPDATE_CLAIM =
50-
"UPDATE griefprevention_claimdata SET owner = ?, lessercorner = ?, greatercorner = ?, builders = ?, containers = ?, accessors = ?, managers = ?, inheritnothing = ?, parentid = ?, expiration = ? WHERE id = ?";
50+
"UPDATE griefprevention_claimdata SET owner = ?, lessercorner = ?, greatercorner = ?, builders = ?, containers = ?, accessors = ?, managers = ?, inheritnothing = ?, parentid = ?, expiration = ?, explosivesallowed = ? WHERE id = ?";
5151
private static final String SQL_INSERT_CLAIM =
52-
"INSERT INTO griefprevention_claimdata (id, owner, lessercorner, greatercorner, builders, containers, accessors, managers, inheritnothing, parentid, expiration) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
52+
"INSERT INTO griefprevention_claimdata (id, owner, lessercorner, greatercorner, builders, containers, accessors, managers, inheritnothing, parentid, expiration, explosivesallowed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
5353
private static final String SQL_DELETE_CLAIM =
5454
"DELETE FROM griefprevention_claimdata WHERE id = ?";
5555
private static final String SQL_SELECT_PLAYER_DATA =
@@ -74,6 +74,8 @@ public class DatabaseDataStore extends DataStore
7474
"SELECT * FROM griefprevention_claimdata WHERE id = ?";
7575
private static final String SQL_UPDATE_SCHEMA_ADD_EXPIRATION =
7676
"ALTER TABLE griefprevention_claimdata ADD COLUMN IF NOT EXISTS expiration BIGINT DEFAULT 0";
77+
private static final String SQL_UPDATE_SCHEMA_ADD_EXPLOSIVES =
78+
"ALTER TABLE griefprevention_claimdata ADD COLUMN IF NOT EXISTS explosivesallowed BOOLEAN DEFAULT 0";
7779

7880
private Connection databaseConnection = null;
7981

@@ -270,6 +272,12 @@ void initialize() throws Exception
270272
statement.execute(SQL_UPDATE_SCHEMA_ADD_EXPIRATION);
271273
}
272274

275+
if (this.getSchemaVersion() <= 4)
276+
{
277+
statement = this.databaseConnection.createStatement();
278+
statement.execute(SQL_UPDATE_SCHEMA_ADD_EXPLOSIVES);
279+
}
280+
273281
//load claims data into memory
274282

275283
results = statement.executeQuery("SELECT * FROM griefprevention_claimdata");
@@ -362,8 +370,11 @@ else if (this.getSchemaVersion() < 1)
362370
String managersString = results.getString("managers");
363371
List<String> managerNames = Arrays.asList(managersString.split(";"));
364372
managerNames = this.convertNameListToUUIDList(managerNames);
373+
boolean explosivesAllowed = results.getBoolean("explosivesallowed");
374+
365375
Claim claim = new Claim(lesserBoundaryCorner, greaterBoundaryCorner, ownerID, builderNames, containerNames, accessorNames, managerNames, inheritNothing, claimID, false);
366376
claim.setExpirationDate(expirationDate);
377+
claim.areExplosivesAllowed = explosivesAllowed;
367378

368379
if (removeClaim)
369380
{
@@ -463,6 +474,7 @@ synchronized private void writeClaimData(Claim claim) throws SQLException
463474
boolean inheritNothing = claim.getSubclaimRestrictions();
464475
long parentId = claim.parent == null ? -1 : claim.parent.id;
465476
long expirationDate = claim.getExpirationDate();
477+
boolean explosivesAllowed = claim.areExplosivesAllowed;
466478

467479
try (PreparedStatement insertStmt = this.databaseConnection.prepareStatement(SQL_INSERT_CLAIM))
468480
{
@@ -478,6 +490,7 @@ synchronized private void writeClaimData(Claim claim) throws SQLException
478490
insertStmt.setBoolean(9, inheritNothing);
479491
insertStmt.setLong(10, parentId);
480492
insertStmt.setLong(11, expirationDate);
493+
insertStmt.setBoolean(12, explosivesAllowed);
481494
insertStmt.executeUpdate();
482495
}
483496
catch (SQLException e)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ private boolean handleEntityDamageByBlockExplosion(@NotNull EntityDamageInstance
323323
Claim claim = dataStore.getClaimAt(location, false, null);
324324
if (claim == null)
325325
return false;
326-
// Fall back to claim setting if no GPFlags override
326+
// Check claim setting for explosives
327327
if (claim.areExplosivesAllowed)
328328
return false;
329329

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,14 @@ Claim loadClaim(String input, ArrayList<Long> out_parentID, long lastModifiedDat
553553
// Add is3D flag
554554
boolean is3D = yaml.getBoolean("Is3D", false);
555555

556+
// Load explosives allowed setting (default false = protected)
557+
boolean explosivesAllowed = yaml.getBoolean("Explosives Allowed", false);
558+
556559
//instantiate
557560
claim = new Claim(lesserBoundaryCorner, greaterBoundaryCorner, ownerID, builders, containers, accessors, managers, inheritNothing, claimID, is3D);
558561
claim.modifiedDate = new Date(lastModifiedDate);
559562
claim.id = claimID;
563+
claim.areExplosivesAllowed = explosivesAllowed;
560564

561565
ConfigurationSection childrenSection = yaml.getConfigurationSection("Children");
562566
if (childrenSection != null)
@@ -612,6 +616,7 @@ private Claim deserializeChild(ConfigurationSection section, Claim parent, List<
612616

613617
boolean inheritNothing = section.getBoolean("inheritNothing");
614618
boolean is3D = section.getBoolean("Is3D", false);
619+
boolean explosivesAllowed = section.getBoolean("Explosives Allowed", false);
615620

616621
Long childID = null;
617622
if (section.contains("Claim ID"))
@@ -630,6 +635,7 @@ private Claim deserializeChild(ConfigurationSection section, Claim parent, List<
630635
Claim child = new Claim(lesserBoundaryCorner, greaterBoundaryCorner, ownerID, builders, containers, accessors, managers, inheritNothing, childID, is3D);
631636
child.parent = parent;
632637
child.inDataStore = true;
638+
child.areExplosivesAllowed = explosivesAllowed;
633639

634640
if (!child.getSubclaimRestrictions())
635641
{
@@ -696,6 +702,7 @@ private void populateYamlForClaim(Claim claim, ConfigurationSection section)
696702
section.set("Parent Claim ID", claim.parent == null ? -1L : claim.parent.id);
697703
section.set("inheritNothing", claim.getSubclaimRestrictions());
698704
section.set("Is3D", claim.is3D());
705+
section.set("Explosives Allowed", claim.areExplosivesAllowed);
699706
section.set("Modified Date", claim.modifiedDate != null ? claim.modifiedDate.getTime() : System.currentTimeMillis());
700707

701708
ArrayList<Claim> persistedChildren = new ArrayList<>();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,6 +2005,9 @@ else if (cmd.getName().equalsIgnoreCase("deleteclaim") && player != null) {
20052005
claim.areExplosivesAllowed = true;
20062006
GriefPrevention.sendMessage(player, TextMode.Success, Messages.ExplosivesEnabled);
20072007
}
2008+
2009+
// Save the claim to persist the change
2010+
this.dataStore.saveClaim(claim);
20082011
}
20092012

20102013
return true;
@@ -4160,6 +4163,9 @@ public boolean handleClaimExplosionsCommand(CommandSender sender, String[] args)
41604163
GriefPrevention.sendMessage(player, TextMode.Success, Messages.ExplosivesEnabled);
41614164
}
41624165

4166+
// Save the claim to persist the change
4167+
this.dataStore.saveClaim(claim);
4168+
41634169
return true;
41644170
}
41654171

src/main/resources/plugin.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: GriefPrevention
22
main: me.ryanhamshire.GriefPrevention.GriefPrevention
33
softdepend:
4-
[Multiverse-Core, My_Worlds, MystCraft, Transporter, RoyalCommands, MultiWorld, Denizen, CommandHelper, GPFlags]
4+
[Multiverse-Core, My_Worlds, MystCraft, Transporter, RoyalCommands, MultiWorld, Denizen, CommandHelper]
55
dev-url: https://dev.bukkit.org/projects/grief-prevention
66
version: "${project.version}"
77
api-version: "1.21"
@@ -204,7 +204,6 @@ commands:
204204
description: Sell claim blocks for server currency.
205205
usage: /<command> [amount]
206206
permission: griefprevention.buysellclaimblocks
207-
aliases: sellclaim
208207
restorenature:
209208
description: Switches the shovel tool to restoration mode.
210209
usage: /<command>

0 commit comments

Comments
 (0)