From e4fd341853f10df7bff4adaf5b5d42a8219bffff Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 9 Jul 2023 13:56:57 -0400
Subject: [PATCH 001/151] Fixed an issue where the setting
isAutoFeaturesEnabled was not being applied to the permissions which resulted
in the perms always being enabled when OPd.
---
docs/changelog_v3.3.x.md | 4 +++-
.../prison/spigot/autofeatures/AutoManagerFeatures.java | 9 +++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 837761593..a966e2b37 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,9 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15 2023-07-07
+# 3.3.0-alpha.15 2023-07-09
+* **Fixed an issue where the setting isAutoFeaturesEnabled was not being applied to the permissions which resulted in the perms always being enabled when OPd.**
+
* **2023-07-07 v3.3.0-alpha.15 Released**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
index 841fbae06..5cb7def89 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
@@ -470,12 +470,13 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent ) {
boolean loreSmelt = isLoreEnabled && checkLore( itemInHand, getMessage( AutoFeatures.loreSmeltValue) );
boolean loreBlock = isLoreEnabled && checkLore( itemInHand, getMessage( AutoFeatures.loreBlockValue ) );
- boolean permPickup = player.isPermissionSet( getMessage( AutoFeatures.permissionAutoPickup ));
- boolean permSmelt = player.isPermissionSet( getMessage( AutoFeatures.permissionAutoSmelt ));
- boolean permBlock = player.isPermissionSet( getMessage( AutoFeatures.permissionAutoBlock ));
-
boolean isAutoFeaturesEnabled = isBoolean( AutoFeatures.isAutoFeaturesEnabled );
+ boolean permPickup = isAutoFeaturesEnabled && player.isPermissionSet( getMessage( AutoFeatures.permissionAutoPickup ));
+ boolean permSmelt = isAutoFeaturesEnabled && player.isPermissionSet( getMessage( AutoFeatures.permissionAutoSmelt ));
+ boolean permBlock = isAutoFeaturesEnabled && player.isPermissionSet( getMessage( AutoFeatures.permissionAutoBlock ));
+
+
boolean configPickup = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoPickupEnabled );
boolean configSmelt = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoSmeltEnabled );
boolean configBlock = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoBlockEnabled );
From 903f425e67c1cfd89b018916c4f74e77d0e2341d Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 9 Jul 2023 14:00:07 -0400
Subject: [PATCH 002/151] doc update
---
docs/prison_changelog_v3.3.0-alpha.15.md | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/docs/prison_changelog_v3.3.0-alpha.15.md b/docs/prison_changelog_v3.3.0-alpha.15.md
index 80f7b0ef7..21d8d1fcb 100644
--- a/docs/prison_changelog_v3.3.0-alpha.15.md
+++ b/docs/prison_changelog_v3.3.0-alpha.15.md
@@ -16,7 +16,11 @@ These build logs represent the work that has been going on within prison.
The following is a highlight of changes for the alpha.15 release since the alpha.14 release.
--Full support for 1.20.x including the heights and blocks.
+- Full support for 1.20.x including the heights and blocks.
+
+
+- Added support for Java 20.
+
- MineBombs - Added a new field specifically for use with item names which supports color codes.
@@ -45,7 +49,7 @@ The following is a highlight of changes for the alpha.15 release since the alpha
- Fixed how NBT-api is being shadowed and used to get it to work properly with Spigot 1.20.x.
-- Minor fixes and enchancements: blockEvents, autoFeatures and monitor priorities, GUI Player Mine config options, prevent GUI configs from loading twice, when mining now can control non-prison placed blocks to pass through to be handled by bukkit, fix autosell when disabled, hooked up support for minecraft stats to track block mining, prevent zero drops if calcs are less than 1, fix sellall trying to sell an invalid stack, fix prison utils potion effects when no player is provided, support for ExaltedEconomy, able to bypass adding new players on startup, updated Prison's jar reporter to identify Java versions 19, 20, and 21, clearified help on `/rankup` and `/presetige`, update of how topN is being processed, added topN stats which reports some of the core info.
+- Minor fixes and enhancements: blockEvents, autoFeatures and monitor priorities, GUI Player Mine config options, prevent GUI configs from loading twice, when mining now can control non-prison placed blocks to pass through to be handled by bukkit, fix autosell when disabled, hooked up support for minecraft stats to track block mining, prevent zero drops if calcs are less than 1, fix sellall trying to sell an invalid stack, fix prison utils potion effects when no player is provided, support for ExaltedEconomy, able to bypass adding new players on startup, updated Prison's jar reporter to identify Java versions 19, 20, and 21, clarified help on `/rankup` and `/presetige`, update of how topN is being processed, added topN stats which reports some of the core info.
From 65589703223f6dd355af24431de45093ae61a738 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 9 Jul 2023 14:04:32 -0400
Subject: [PATCH 003/151] Fixed an issue with prison commands being remapped,
but other commands within prison were not using them. This tries to find the
remapped command for all commands by updating the
SpigotCommandSender.dispatchCommand().
---
docs/changelog_v3.3.x.md | 4 ++++
.../commands/PrisonSpigotBackpackCommands.java | 5 +++--
.../commands/PrisonSpigotSellAllCommands.java | 15 +++++++++------
.../prison/spigot/game/SpigotCommandSender.java | 10 +++++++++-
4 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index a966e2b37..e0dac0d3c 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,10 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-09
+* **Fixed an issue with prison commands being remapped, but other commands within prison were not using them.**
+This tries to find the remapped command for all commands by updating the SpigotCommandSender.dispatchCommand().
+
+
* **Fixed an issue where the setting isAutoFeaturesEnabled was not being applied to the permissions which resulted in the perms always being enabled when OPd.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotBackpackCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotBackpackCommands.java
index 4d07b0d54..403baa225 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotBackpackCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotBackpackCommands.java
@@ -29,8 +29,9 @@ private void backpackMainCommand(CommandSender sender,
description = "Leave empty if you want to open your main backpack, add an ID if you've more than one.") String id){
if (sender.hasPermission("prison.admin") || sender.isOp()){
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand("backpack help");
- sender.dispatchCommand(registeredCmd);
+ sender.dispatchCommand("backpack help");
+// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand("backpack help");
+// sender.dispatchCommand(registeredCmd);
return;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
index 9bb582477..4345aeb55 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
@@ -91,11 +91,13 @@ private void sellAllCommands(CommandSender sender) {
if (!isEnabled()) return;
if (sender.hasPermission("prison.admin")) {
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall help" );
- sender.dispatchCommand(registeredCmd);
+ sender.dispatchCommand("sellall help");
+// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall help" );
+// sender.dispatchCommand(registeredCmd);
} else {
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall sell" );
- sender.dispatchCommand(registeredCmd);
+ sender.dispatchCommand("sellall sell");
+// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall sell" );
+// sender.dispatchCommand(registeredCmd);
}
}
@@ -834,8 +836,9 @@ private void sellAllToolsTriggerToggle(CommandSender sender,
if (!isEnabled()) return;
if (enable.equalsIgnoreCase("null")){
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall toolsTrigger help" );
- sender.dispatchCommand(registeredCmd);
+ sender.dispatchCommand("sellall toolsTrigger help");
+// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall toolsTrigger help" );
+// sender.dispatchCommand(registeredCmd);
return;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotCommandSender.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotCommandSender.java
index 26bbb66d4..f3f1ca8d6 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotCommandSender.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotCommandSender.java
@@ -61,8 +61,16 @@ public String getName() {
return bukkitSender.getName();
}
+ /**
+ *
This function will dispatch a command and run it as command sender.
+ * But before it is ran, this function looks up within the Prison command handler
+ * to see if it's commands have been remapped to another command, and if it has,
+ * it then uses the mapped command.
+ *
+ */
@Override public void dispatchCommand(String command) {
- Bukkit.getServer().dispatchCommand(bukkitSender, command);
+ String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( command );
+ Bukkit.getServer().dispatchCommand(bukkitSender, registeredCmd);
}
@Override public boolean doesSupportColors() {
From db7351259b09ecaac8d78d193ce3ad1ea4ad8be3 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Mon, 10 Jul 2023 19:24:24 -0400
Subject: [PATCH 004/151] Setup a way to pull a config's hash keys. These would
be used to dynamically get all settings within a hash.
---
docs/changelog_v3.3.x.md | 6 +++++-
.../tech/mcprison/prison/file/JsonFileIO.java | 7 +++++++
.../prison/internal/platform/Platform.java | 9 ++++++++
.../tech/mcprison/prison/TestPlatform.java | 13 ++++++++++++
.../prison/spigot/SpigotPlatform.java | 21 +++++++++++++++++++
5 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index e0dac0d3c..0428085fc 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15 2023-07-09
+# 3.3.0-alpha.15 2023-07-10
+
+
+* **Setup a way to pull a config's hash keys.**
+These would be used to dynamically get all settings within a hash.
* **Fixed an issue with prison commands being remapped, but other commands within prison were not using them.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/file/JsonFileIO.java b/prison-core/src/main/java/tech/mcprison/prison/file/JsonFileIO.java
index 55e23a387..b2deb33dc 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/file/JsonFileIO.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/file/JsonFileIO.java
@@ -89,6 +89,13 @@ private static String getFileNamePrefix( String UUIDString ) {
return UUIDString.substring( 0, 14 );
}
+
+ public String toString( Object obj ) {
+ String json = getGson().toJson( obj );
+
+ return json;
+ }
+
/**
* This function will save a file as a JSON format. It will first save it as a
* temp file to make sure the data can be written to the file system, then once
diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java b/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
index 479f4be6d..e4479d38d 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
@@ -303,6 +303,15 @@ public default Optional getCommand(String label) {
public double getConfigDouble( String key, double defaultValue );
+ /**
+ *
Given the path to a hash, this will return all of the keys within
+ * the hash at the root level. It will not traverse deeper.
+ * The list of keys can then be used to access all of the values.
+ *
+ *
+ */
+ public List getConfigHashKeys(String hashPrefix);
+
public boolean isWorldExcluded( String worldName );
diff --git a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
index 6875c4201..cdef3f149 100644
--- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
+++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
@@ -299,6 +299,19 @@ public List> getConfigStringArray( String key ) {
return new ArrayList();
}
+ /**
+ *
Given the path to a hash, this will return all of the keys within
+ * the hash at the root level. It will not traverse deeper.
+ * The list of keys can then be used to access all of the values.
+ *
Given the path to a hash, this will return all of the keys within
+ * the hash at the root level. It will not traverse deeper.
+ * The list of keys can then be used to access all of the values.
+ *
+ *
+ */
+ @Override
+ public List getConfigHashKeys( String hashPrefix ) {
+ List keys = new ArrayList<>();
+
+ ConfigurationSection configSection =
+ SpigotPrison.getInstance().getConfig().getConfigurationSection( hashPrefix );
+
+ if ( configSection != null ) {
+ keys.addAll( configSection.getKeys(false) );
+ }
+
+ return keys;
+ }
@Override
public boolean isWorldExcluded( String worldName ) {
From 28c37b2e8ba890da9c668de9c3c4abe35fb16fab Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Mon, 10 Jul 2023 19:27:50 -0400
Subject: [PATCH 005/151] Start to setup support for WorldEdit and WorldGuard.
---
build.gradle | 5 +
docs/changelog_v3.3.x.md | 3 +
.../prison/worldguard/PrisonWorldEdit.java | 5 +
.../prison/worldguard/PrisonWorldGuard.java | 5 +
prison-spigot/build.gradle | 24 +++
.../spigot/worldguard/WorldGuardData.java | 155 ++++++++++++++++++
.../spigot/worldguard/WorldGuardSettings.java | 64 ++++++++
prison-worldguard6/build.gradle | 123 ++++++++++++++
.../worldguard/PrisonWorldEdit6.java | 28 ++++
.../worldguard/PrisonWorldGuard6.java | 14 ++
prison-worldguard7/build.gradle | 85 ++++++++++
11 files changed, 511 insertions(+)
create mode 100644 prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldEdit.java
create mode 100644 prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldGuard.java
create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/worldguard/WorldGuardData.java
create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/worldguard/WorldGuardSettings.java
create mode 100644 prison-worldguard6/build.gradle
create mode 100644 prison-worldguard6/src/main/java/tech/mcprison/worldguard6/worldguard/PrisonWorldEdit6.java
create mode 100644 prison-worldguard6/src/main/java/tech/mcprison/worldguard6/worldguard/PrisonWorldGuard6.java
create mode 100644 prison-worldguard7/build.gradle
diff --git a/build.gradle b/build.gradle
index 8e7504ecf..2e940621c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -127,6 +127,11 @@ subprojects {
includeGroup 'org.apache.commons'
}
}
+
+ maven {
+ url "https://mvnrepository.com/artifact"
+
+ }
}
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 0428085fc..fcb92d60f 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-10
+* **Start to setup support for WorldEdit and WorldGuard.**
+
+
* **Setup a way to pull a config's hash keys.**
These would be used to dynamically get all settings within a hash.
diff --git a/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldEdit.java b/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldEdit.java
new file mode 100644
index 000000000..390cb4fa0
--- /dev/null
+++ b/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldEdit.java
@@ -0,0 +1,5 @@
+package tech.mcprison.prison.worldguard;
+
+public abstract class PrisonWorldEdit {
+
+}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldGuard.java b/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldGuard.java
new file mode 100644
index 000000000..8757b7419
--- /dev/null
+++ b/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldGuard.java
@@ -0,0 +1,5 @@
+package tech.mcprison.prison.worldguard;
+
+public abstract class PrisonWorldGuard {
+
+}
diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle
index 3ab4ae5fe..2043b884a 100644
--- a/prison-spigot/build.gradle
+++ b/prison-spigot/build.gradle
@@ -94,6 +94,8 @@ dependencies {
implementation project(':prison-ranks')
implementation project(':prison-sellall')
+ // implementation project(':prison-worldguard6')
+
// https://mvnrepository.com/artifact/org.bstats/bstats-base
// https://mvnrepository.com/artifact/org.bstats/bstats-bukkit
@@ -112,6 +114,28 @@ dependencies {
implementation 'org.apache.commons:commons-lang3:3.12.0'
+
+/*
+ // https://mvnrepository.com/artifact/com.sk89q.worldedit/worldedit-core
+ implementation 'com.sk89q.worldedit:worldedit-core:7.2.15'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldedit/worldedit-bukkit
+ compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.15'
+
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-core
+ compileOnly 'com.sk89q.worldguard:worldguard-core:7.0.8'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-bukkit
+ compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.8'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard.worldguard-libs/core
+ implementation 'com.sk89q.worldguard.worldguard-libs:core:7.0.8'
+*/
+
+
+
+
compileOnly 'me.clip:placeholderapi:2.11.2'
//compileOnly 'me.clip:placeholderapi:2.10.9'
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/worldguard/WorldGuardData.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/worldguard/WorldGuardData.java
new file mode 100644
index 000000000..e90f54679
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/worldguard/WorldGuardData.java
@@ -0,0 +1,155 @@
+package tech.mcprison.prison.spigot.worldguard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import tech.mcprison.prison.Prison;
+import tech.mcprison.prison.internal.platform.Platform;
+
+public class WorldGuardData {
+
+ private String worldGuardPrefix;
+
+ private boolean enabled;
+ private String name;
+
+ private String permissionPrefix;
+ private int priority;
+
+ private boolean denyNonMembers;
+ private String denyMessage;
+
+ private List flags;
+
+ private int increaseX;
+ private int increaseZ;
+ private int increaseY;
+
+ public WorldGuardData( String worldGuardPrefix ) {
+ super();
+
+ this.worldGuardPrefix = worldGuardPrefix;
+
+ this.flags = new ArrayList<>();
+
+ configure();
+ }
+
+ private void configure() {
+
+ String wgPrefix = getWorldGuardPrefix();
+
+ Platform platform = Prison.get().getPlatform();
+
+ this.enabled = platform.getConfigBooleanFalse( wgPrefix + "enable" );
+
+ if ( isEnabled() ) {
+
+ this.name = platform.getConfigString( wgPrefix + "name-prefix" );
+
+ this.permissionPrefix = platform.getConfigString( wgPrefix + "permission-prefix" );
+
+ this.priority = platform.getConfigInt( wgPrefix + "priority", 10 );
+
+ this.denyNonMembers = platform.getConfigBooleanFalse( wgPrefix + "deny-non-members" );
+
+ this.denyMessage = platform.getConfigString( wgPrefix + "deny-message" );
+
+ List flagKeys = platform.getConfigHashKeys( wgPrefix + "flags" );
+
+ for (String key : flagKeys) {
+ boolean includeFlag = platform.getConfigBooleanFalse( wgPrefix + "flags" + "." + key );
+
+ // Only flags that are enabled are stored:
+ if ( includeFlag ) {
+ flags.add( key );
+ }
+ }
+
+
+ this.increaseX = platform.getConfigInt( wgPrefix + "increase-x", 0 );
+ this.increaseZ = platform.getConfigInt( wgPrefix + "increase-z", 0 );
+ this.increaseY = platform.getConfigInt( wgPrefix + "increase-y", 0 );
+
+ }
+
+ }
+
+ public String getWorldGuardPrefix() {
+ return worldGuardPrefix;
+ }
+ public void setWorldGuardPrefix(String worldGuardPrefix) {
+ this.worldGuardPrefix = worldGuardPrefix;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPermissionPrefix() {
+ return permissionPrefix;
+ }
+ public void setPermissionPrefix(String permissionPrefix) {
+ this.permissionPrefix = permissionPrefix;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ public boolean isDenyNonMembers() {
+ return denyNonMembers;
+ }
+ public void setDenyNonMembers(boolean denyNonMembers) {
+ this.denyNonMembers = denyNonMembers;
+ }
+
+ public String getDenyMessage() {
+ return denyMessage;
+ }
+ public void setDenyMessage(String denyMessage) {
+ this.denyMessage = denyMessage;
+ }
+
+ public List getFlags() {
+ return flags;
+ }
+ public void setFlags(List flags) {
+ this.flags = flags;
+ }
+
+ public int getIncreaseX() {
+ return increaseX;
+ }
+ public void setIncreaseX(int increaseX) {
+ this.increaseX = increaseX;
+ }
+
+ public int getIncreaseZ() {
+ return increaseZ;
+ }
+ public void setIncreaseZ(int increaseZ) {
+ this.increaseZ = increaseZ;
+ }
+
+ public int getIncreaseY() {
+ return increaseY;
+ }
+ public void setIncreaseY(int increaseY) {
+ this.increaseY = increaseY;
+ }
+
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/worldguard/WorldGuardSettings.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/worldguard/WorldGuardSettings.java
new file mode 100644
index 000000000..f9e3b9aa1
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/worldguard/WorldGuardSettings.java
@@ -0,0 +1,64 @@
+package tech.mcprison.prison.spigot.worldguard;
+
+import tech.mcprison.prison.file.JsonFileIO;
+import tech.mcprison.prison.output.Output;
+
+public class WorldGuardSettings {
+
+ public static final String WORLD_GUARD_CONFIG_PREFIX = "prison-mines.world-guard.";
+ public static final String WORLD_GUARD_CONFIG_REGION_MINE = "region-mine";
+ public static final String WORLD_GUARD_CONFIG_REGION_MINE_AREA = "region-mine-area";
+
+ private String wgPrefixRegionMine;
+ private String wgPrefixRegionMineArea;
+
+ private WorldGuardData mineRegion;
+ private WorldGuardData mineAreaRegion;
+
+ public WorldGuardSettings() {
+ super();
+
+ wgPrefixRegionMine = WORLD_GUARD_CONFIG_PREFIX + WORLD_GUARD_CONFIG_REGION_MINE + ".";
+ wgPrefixRegionMineArea = WORLD_GUARD_CONFIG_PREFIX + WORLD_GUARD_CONFIG_REGION_MINE_AREA + ".";
+
+ mineRegion = new WorldGuardData( wgPrefixRegionMine );
+ mineAreaRegion = new WorldGuardData( wgPrefixRegionMineArea );
+
+ String json = new JsonFileIO().toString( this );
+
+ Output.get().logInfo( "WorldGuardSettings: \n" + json );
+ }
+
+
+
+
+ public String getWGPrefixRegionMine() {
+ return wgPrefixRegionMine;
+ }
+ public void setWGPrefixRegionMine(String wgPrefixRegionMine) {
+ this.wgPrefixRegionMine = wgPrefixRegionMine;
+ }
+
+ public String getWGPrefixRegionMineArea() {
+ return wgPrefixRegionMineArea;
+ }
+ public void setWGPrefixRegionMineArea(String wgPrefixRegionMineArea) {
+ this.wgPrefixRegionMineArea = wgPrefixRegionMineArea;
+ }
+
+ public WorldGuardData getMineRegion() {
+ return mineRegion;
+ }
+ public void setMineRegion(WorldGuardData mineRegion) {
+ this.mineRegion = mineRegion;
+ }
+
+ public WorldGuardData getMineAreaRegion() {
+ return mineAreaRegion;
+ }
+ public void setMineAreaRegion(WorldGuardData mineAreaRegion) {
+ this.mineAreaRegion = mineAreaRegion;
+ }
+
+
+}
diff --git a/prison-worldguard6/build.gradle b/prison-worldguard6/build.gradle
new file mode 100644
index 000000000..93874db44
--- /dev/null
+++ b/prison-worldguard6/build.gradle
@@ -0,0 +1,123 @@
+/*
+ * Prison is a Minecraft plugin for the prison game mode.
+ * Copyright (C) 2017 The Prison Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+group 'tech.mcprison'
+
+apply plugin: 'java'
+
+compileJava.options.encoding = 'UTF-8'
+compileTestJava.options.encoding = "UTF-8"
+
+//sourceCompatibility = 1.8
+
+
+// https://www.spigotmc.org/wiki/spigot-gradle/
+
+
+repositories {
+ mavenCentral()
+
+
+ maven {
+ url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
+
+ // As of Gradle 5.1, you can limit this to only those
+ // dependencies you expect from it
+ content {
+ includeGroup 'org.bukkit'
+ includeGroup 'org.spigotmc'
+ }
+ }
+ /*
+ As Spigot-API depends on the BungeeCord ChatComponent-API,
+ we need to add the Sonatype OSS repository, as Gradle,
+ in comparison to maven, doesn't want to understand the ~/.m2
+ directory unless added using mavenLocal(). Maven usually just gets
+ it from there, as most people have run the BuildTools at least once.
+ This is therefore not needed if you're using the full Spigot/CraftBukkit,
+ or if you're using the Bukkit API.
+ */
+ maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
+ maven { url = 'https://oss.sonatype.org/content/repositories/central' }
+
+ // mavenLocal() // This is needed for CraftBukkit and Spigot.
+ maven {
+ url "https://mvnrepository.com/artifact"
+ }
+
+ maven { url = "https://hub.spigotmc.org/nexus/content/groups/public" }
+
+ maven { url = "https://maven.enginehub.org/repo/" }
+}
+
+
+
+dependencies {
+ implementation project(':prison-core')
+// implementation project(':prison-mines')
+// implementation project(':prison-ranks')
+// implementation project(':prison-sellall')
+
+
+ // 1.9.4-R0.1-SNAPSHOT has been the version used for a long time:
+// compileOnly 'org.spigotmc:spigot-api:1.9.4-R0.1-SNAPSHOT'
+ // 1.12.2-R0.1-SNAPSHOT works well:
+// compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT'
+ // 1.13.2 fails since deprecated functions have been removed.
+ compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
+
+
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldedit/worldedit-core
+ implementation 'com.sk89q.worldedit:worldedit-core:6.0.1'
+ //implementation 'com.sk89q.worldedit:worldedit-core:7.2.15'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldedit/worldedit-bukkit
+ compileOnly 'com.sk89q.worldedit:worldedit-bukkit:6.1.5'
+ //compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.15'
+
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-legacy
+ // NOTE: although the following does exist, its unable to be pulled in so instead
+ // the jar is included.
+ //compileOnly 'com.sk89q.worldguard:worldguard-legacy:6.1.2'
+
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-core
+ //compileOnly 'com.sk89q.worldguard:worldguard-core:7.0.8'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-bukkit
+ //compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.8'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard.worldguard-libs/core
+ //implementation 'com.sk89q.worldguard.worldguard-libs:core:7.0.8'
+
+
+
+
+ compileOnly fileTree(dir: 'lib', include: ['*.jar'] );
+
+
+
+
+ testImplementation group: 'junit', name: 'junit', version: '4.12'
+
+}
+
+
+
diff --git a/prison-worldguard6/src/main/java/tech/mcprison/worldguard6/worldguard/PrisonWorldEdit6.java b/prison-worldguard6/src/main/java/tech/mcprison/worldguard6/worldguard/PrisonWorldEdit6.java
new file mode 100644
index 000000000..d5f1345d4
--- /dev/null
+++ b/prison-worldguard6/src/main/java/tech/mcprison/worldguard6/worldguard/PrisonWorldEdit6.java
@@ -0,0 +1,28 @@
+package tech.mcprison.worldguard6.worldguard;
+
+import tech.mcprison.prison.worldguard.PrisonWorldEdit;
+
+public class PrisonWorldEdit6
+ extends PrisonWorldEdit
+{
+
+ public PrisonWorldEdit6() {
+ super();
+
+ }
+
+ public void getWorldEditActor( org.bukkit.entity.Player bukkitPlayer ) {
+
+// Player results = BukkitAdapter.;
+
+// Bukkit
+
+
+
+// com.sk89q.worldedit.bukkit.BukkitPlayer;
+// BukkitAdapter.;
+
+// return results;
+ }
+
+}
diff --git a/prison-worldguard6/src/main/java/tech/mcprison/worldguard6/worldguard/PrisonWorldGuard6.java b/prison-worldguard6/src/main/java/tech/mcprison/worldguard6/worldguard/PrisonWorldGuard6.java
new file mode 100644
index 000000000..e747056e3
--- /dev/null
+++ b/prison-worldguard6/src/main/java/tech/mcprison/worldguard6/worldguard/PrisonWorldGuard6.java
@@ -0,0 +1,14 @@
+package tech.mcprison.worldguard6.worldguard;
+
+import tech.mcprison.prison.worldguard.PrisonWorldGuard;
+
+public class PrisonWorldGuard6
+ extends PrisonWorldGuard
+{
+
+ public PrisonWorldGuard6() {
+ super();
+
+ }
+
+}
diff --git a/prison-worldguard7/build.gradle b/prison-worldguard7/build.gradle
new file mode 100644
index 000000000..96a5b5e1d
--- /dev/null
+++ b/prison-worldguard7/build.gradle
@@ -0,0 +1,85 @@
+/*
+ * Prison is a Minecraft plugin for the prison game mode.
+ * Copyright (C) 2017 The Prison Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+group 'tech.mcprison'
+
+apply plugin: 'java'
+
+compileJava.options.encoding = 'UTF-8'
+compileTestJava.options.encoding = "UTF-8"
+
+//sourceCompatibility = 1.8
+
+repositories {
+ mavenCentral()
+
+}
+
+
+
+dependencies {
+ implementation project(':prison-core')
+// implementation project(':prison-mines')
+// implementation project(':prison-ranks')
+// implementation project(':prison-sellall')
+
+
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldedit/worldedit-core
+ implementation 'com.sk89q.worldedit:worldedit-core:6.0.1'
+ //implementation 'com.sk89q.worldedit:worldedit-core:7.2.15'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldedit/worldedit-bukkit
+ compileOnly 'com.sk89q.worldedit:worldedit-bukkit:6.1.4'
+ //compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.15'
+
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-legacy
+ compileOnly 'com.sk89q.worldguard:worldguard-legacy:6.1.2'
+
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-core
+ //compileOnly 'com.sk89q.worldguard:worldguard-core:7.0.8'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-bukkit
+ //compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.8'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard.worldguard-libs/core
+ //implementation 'com.sk89q.worldguard.worldguard-libs:core:7.0.8'
+
+
+
+
+ // 1.9.4-R0.1-SNAPSHOT has been the version used for a long time:
+// compileOnly 'org.spigotmc:spigot-api:1.9.4-R0.1-SNAPSHOT'
+ // 1.12.2-R0.1-SNAPSHOT works well:
+// compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT'
+ // 1.13.2 fails since deprecated functions have been removed.
+ //compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
+
+
+
+
+
+
+ testImplementation group: 'junit', name: 'junit', version: '4.12'
+
+}
+
+
+
From b1f179839a29f3ef66fb58e6059feed19762b75f Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Mon, 10 Jul 2023 20:02:54 -0400
Subject: [PATCH 006/151] Bug fix... this is a continuation of a prior issue of
prison commands not being mapped to their assigned command name by bukkit
when prison's command handler registers them. This was an issue with another
plugin that registered `/gui` before prison was able to, so then all of
prison's gui commands were mapped to `/prison:gui`. So where this was an
issue was with `/prestige` trying to run the gui presetige confirmation which
was trying to kick off a GuiPlus command as a result of this improper
mis-match. Tested to confirm it is now functional. Changed all occurrences
that I could find that also needed to be mapped.
---
docs/changelog_v3.3.x.md | 5 +
.../prison/spigot/SpigotScheduler.java | 8 +-
.../spigot/backpacks/BackpacksListeners.java | 8 +-
.../PrisonSpigotPrestigeCommands.java | 6 +-
.../spigot/gui/ListenersPrisonManager.java | 94 +++++++++++++------
.../prison/spigot/gui/SpigotGUIMenuTools.java | 7 +-
6 files changed, 92 insertions(+), 36 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index fcb92d60f..8ecda1c0c 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,11 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-10
+* **Bug fix... this is a continuation of a prior issue of prison commands not being mapped to their assigned command name by bukkit when prison's command handler registers them.**
+This was an issue with another plugin that registered `/gui` before prison was able to, so then all of prison's gui commands were mapped to `/prison:gui`. So where this was an issue was with `/prestige` trying to run the gui presetige confirmation which was trying to kick off a GuiPlus command as a result of this improper mis-match.
+Tested to confirm it is now functional. Changed all occurrences that I could find that also needed to be mapped.
+
+
* **Start to setup support for WorldEdit and WorldGuard.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotScheduler.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotScheduler.java
index f290b4cc4..eb992ebd6 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotScheduler.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotScheduler.java
@@ -65,7 +65,9 @@ public void dispatchCommand(Player player, String command) {
if ( player != null && player instanceof SpigotPlayer ) {
SpigotPlayer sPlayer = (SpigotPlayer) player;
- Bukkit.dispatchCommand( sPlayer.getWrapper(), command );
+ sPlayer.dispatchCommand( command );
+
+// Bukkit.dispatchCommand( sPlayer.getWrapper(), command );
}
}
@@ -80,7 +82,9 @@ public void performCommand(Player player, String command) {
SpigotPlayer sPlayer = (SpigotPlayer) p;
- sPlayer.getWrapper().performCommand( command );
+ sPlayer.dispatchCommand( command );
+
+// sPlayer.getWrapper().performCommand( command );
}
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksListeners.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksListeners.java
index 880241c65..74c95c85d 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksListeners.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksListeners.java
@@ -11,6 +11,8 @@
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
+
+import tech.mcprison.prison.Prison;
import tech.mcprison.prison.spigot.SpigotPrison;
import tech.mcprison.prison.spigot.SpigotUtil;
import tech.mcprison.prison.spigot.compat.Compatibility;
@@ -130,9 +132,11 @@ private void backpackItemClickAction(PlayerInteractEvent e) {
if (materialConf != null && inHandItem != null && inHandItem.getType() == materialConf.getType() && inHandItem.hasItemMeta() && inHandItem.getItemMeta().hasDisplayName()
&& inHandItem.getItemMeta().getDisplayName().equalsIgnoreCase(SpigotPrison.format(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Item_Title")))) {
if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled"))){
- Bukkit.dispatchCommand(p, "gui backpackslist");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "gui backpackslist" ));
} else {
- Bukkit.dispatchCommand(p, "gui backpack");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "gui backpack" ));
}
e.setCancelled(true);
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotPrestigeCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotPrestigeCommands.java
index da434a465..688191607 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotPrestigeCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotPrestigeCommands.java
@@ -116,7 +116,8 @@ public void prisonManagerPrestige(CommandSender sender,
// }
//
// if ( PrisonRanks.getInstance().getLadderManager().getLadder("prestiges") == null ) {
-// Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ranks ladder create prestiges");
+// Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
+// Prison.get().getCommandHandler().findRegisteredCommand( "ranks ladder create prestiges" ));
// }
//
// PrisonRanks rankPlugin;
@@ -166,7 +167,8 @@ public void prisonManagerPrestige(CommandSender sender,
// }
// else {
// // Bypassing prestige confirmations:
-// Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "rankup prestiges");
+// Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
+// Prison.get().getCommandHandler().findRegisteredCommand( "rankup prestiges" ));
// }
// }
// }
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/ListenersPrisonManager.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/ListenersPrisonManager.java
index ba981046d..cfe91068e 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/ListenersPrisonManager.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/ListenersPrisonManager.java
@@ -700,9 +700,11 @@ else if ( SpigotGUIMenuTools.getInstance().processGUIPage( p, title, e ) ) {
if (parts[0].equalsIgnoreCase("Backpack")){
if (e.isRightClick() && e.isShiftClick()){
if (parts[2].equalsIgnoreCase("default")){
- Bukkit.dispatchCommand(p, "backpack delete " + parts[1]);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "backpack delete " + parts[1] ));
} else {
- Bukkit.dispatchCommand(p, "backpack delete " + parts[1] + " " + parts[2]);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "backpack delete " + parts[1] + " " + parts[2] ));
}
p.closeInventory();
BackpacksAdminListGUI gui = new BackpacksAdminListGUI(p, parts[1]);
@@ -766,7 +768,8 @@ else if ( SpigotGUIMenuTools.getInstance().processGUIPage( p, title, e ) ) {
// }
//
// if ( isPageAction && command != null ) {
-// Bukkit.dispatchCommand(p, command);
+// Bukkit.dispatchCommand(p,
+// Prison.get().getCommandHandler().findRegisteredCommand( command ));
//
// }
// }
@@ -833,7 +836,8 @@ private void backpacksList(Player p, String buttonNameMain, String[] parts) {
}
String finalID = String.valueOf(freeID);
- Bukkit.dispatchCommand(p, "gui backpack " + finalID);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "gui backpack " + finalID ));
}
} else if (buttonNameMain.equalsIgnoreCase("Backpack")){
@@ -1321,7 +1325,8 @@ private boolean guiConditions(InventoryClickEvent e, Player p) {
private void prisonSetupConfirmGUI(InventoryClickEvent e, Player p, String[] parts) {
if (parts[0].equalsIgnoreCase("Confirm:")){
- Bukkit.dispatchCommand(p, "ranks autoConfigure");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks autoConfigure" ));
} else if (parts[0].equalsIgnoreCase("Cancel:")){
Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_event_cancelled));
}
@@ -1406,7 +1411,9 @@ private void mineBlockPercentage(InventoryClickEvent e, Player p, String[] parts
// Execute the command
if (part4 != null) {
- Bukkit.dispatchCommand(p, "mines block set " + part2 + " " + part3 + " " + part4);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines block set " + part2 + " " + part3 + " " + part4 ));
}
// Cancel the event
@@ -1524,7 +1531,9 @@ private void sellAllItemValue(InventoryClickEvent e, Player p, String[] parts) {
if (e.isLeftClick()){
// Execute the command
- Bukkit.dispatchCommand(p,"sellall edit " + part2 + " " + part3);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "sellall edit " + part2 + " " + part3 ));
// Close the inventory
p.closeInventory();
@@ -1731,7 +1740,8 @@ private void laddersGUI(InventoryClickEvent e, Player p, String buttonNameMain,
else {
// Execute the command
- Bukkit.dispatchCommand(p, "ranks ladder delete " + buttonNameMain);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks ladder delete " + buttonNameMain ));
e.setCancelled(true);
p.closeInventory();
SpigotLaddersGUI gui = new SpigotLaddersGUI(p, 1, "gui ladders", "gui" );
@@ -1776,7 +1786,8 @@ private void ranksGUI(InventoryClickEvent e, Player p, String buttonNameMain, St
RankLadder rLadder = rank.getLadder();
// Execute the command.
- Bukkit.dispatchCommand(p, "ranks delete " + buttonNameMain);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks delete " + buttonNameMain ));
e.setCancelled(true);
p.closeInventory();
SpigotRanksGUI gui = new SpigotRanksGUI( p, rLadder, 1, "gui admin ranks", "gui" );
@@ -1802,7 +1813,8 @@ private void playerPrestigesGUI(InventoryClickEvent e, Player p, String buttonNa
// Close the inventory.
p.closeInventory();
// Execute the command.
- Bukkit.dispatchCommand(p, "prestige");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "prestige" ));
}
// Cancel the event.
@@ -1931,7 +1943,9 @@ private void playerRanksGUI(InventoryClickEvent e, Player p, String buttonNameMa
// Check the buttonName and do the actions.
String message = Text.stripColor( messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup) );
if (buttonNameMain.equals(SpigotPrison.format( message ))){
- Bukkit.dispatchCommand(p, "rankup " + guiConfig.getString("Options.Ranks.Ladder"));
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "rankup " + guiConfig.getString("Options.Ranks.Ladder" )));
p.closeInventory();
}
@@ -1945,7 +1959,8 @@ private void rankUPCommandsGUI(InventoryClickEvent e, Player p, String buttonNam
if (e.isShiftClick() && e.isRightClick()) {
// Execute the command.
- Bukkit.dispatchCommand(p, "ranks command remove " + buttonNameMain);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks command remove " + buttonNameMain ));
// Cancel the event.
e.setCancelled(true);
// Close the inventory.
@@ -1980,7 +1995,8 @@ private void rankPriceGUI(InventoryClickEvent e, Player p, String[] parts) {
if (e.isLeftClick()){
// Execute the command.
- Bukkit.dispatchCommand(p,"ranks set cost " + part2 + " " + part3);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks set cost " + part2 + " " + part3 ));
// Close the inventory.
p.closeInventory();
@@ -2080,7 +2096,8 @@ private void minesGUI(InventoryClickEvent e, Player p, String buttonNameMain, St
// Check the clicks.
if (e.isShiftClick() && e.isRightClick()) {
// Execute the command.
- Bukkit.dispatchCommand(p, "mines delete " + buttonNameMain);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines delete " + buttonNameMain ));
// Cancel the event.
e.setCancelled(true);
// Close the inventory.
@@ -2125,10 +2142,14 @@ private void playerMinesGUI(Player p, InventoryClickEvent e) {
if (errorHasMiningPermission && (p.hasPermission(permission + mineName) ||
p.hasPermission(permission.substring(0, permission.length() - 1)))){
- Bukkit.dispatchCommand(p, SpigotPrison.format(guiConfig.getString("Options.Mines.CommandWarpPlugin") + " " + mineName));
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ SpigotPrison.format(guiConfig.getString("Options.Mines.CommandWarpPlugin") + " " + mineName )));
} else if (hasMiningPermission || p.hasPermission(permission + mineName) ||
p.hasPermission(permission.substring(0, permission.length() - 1))){
- Bukkit.dispatchCommand(p, SpigotPrison.format(guiConfig.getString("Options.Mines.CommandWarpPlugin") + " " + mineName));
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ SpigotPrison.format(guiConfig.getString("Options.Mines.CommandWarpPlugin") + " " + mineName )));
}
}
}
@@ -2155,13 +2176,16 @@ private void mineInfoGUI(InventoryClickEvent e, Player p, String[] parts) {
// Check the clickType and do the actions.
if (e.isLeftClick()) {
// Execute the command.
- Bukkit.dispatchCommand(p, "mines reset " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines reset " + mineName ));
} else if (e.isRightClick()){
// Execute the command.
- Bukkit.dispatchCommand(p, "mines set skipReset " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines set skipReset " + mineName ));
} else if (e.isRightClick() && e.isShiftClick()){
// Execute the command.
- Bukkit.dispatchCommand(p, "mines set zeroBlockResetDelay " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines set zeroBlockResetDelay " + mineName ));
}
// Cancel the event.
@@ -2173,7 +2197,8 @@ private void mineInfoGUI(InventoryClickEvent e, Player p, String[] parts) {
case "Mine_Spawn:":
// Execute the command.
- Bukkit.dispatchCommand(p, "mines set spawn " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines set spawn " + mineName ));
// Cancel the event.
e.setCancelled(true);
@@ -2195,7 +2220,8 @@ private void mineInfoGUI(InventoryClickEvent e, Player p, String[] parts) {
p.closeInventory();
// Execute the Command.
- Bukkit.dispatchCommand(p, "mines tp " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines tp " + mineName ));
break;
@@ -2245,7 +2271,8 @@ private void minesDeleteGUI(Player p, String[] parts) {
if (buttonname.equals("Confirm:")) {
// Confirm
- Bukkit.dispatchCommand(p, "mines delete " + mineName + " confirm");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines delete " + mineName + " confirm" ));
// Close the Inventory
p.closeInventory();
@@ -2254,7 +2281,8 @@ private void minesDeleteGUI(Player p, String[] parts) {
} else if (buttonname.equals("Cancel:")) {
// Cancel
- Bukkit.dispatchCommand(p, "mines delete " + mineName + " cancel");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines delete " + mineName + " cancel" ));
// Close the inventory
p.closeInventory();
@@ -2281,7 +2309,9 @@ private void blocksGUI(InventoryClickEvent e, Player p, String[] parts) {
if (e.isShiftClick() && e.isRightClick()) {
// Execute the command
- Bukkit.dispatchCommand(p, "mines block remove " + mineName + " " + buttonname);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines block remove " + mineName + " " + buttonname ));
// Cancel the event
e.setCancelled(true);
@@ -2330,7 +2360,9 @@ private void resetTimeGUI(InventoryClickEvent e, Player p, String[] parts) {
if (e.isLeftClick()){
// Execute the command
- Bukkit.dispatchCommand(p,"mines set resettime " + part2 + " " + part3);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines set resettime " + part2 + " " + part3 ));
// Cancel the event
e.setCancelled(true);
@@ -2445,7 +2477,9 @@ private void mineNotificationsGUI(InventoryClickEvent e, Player p, String[] part
typeNotification = "within";
// Execute command
- Bukkit.dispatchCommand(p, "mines set notification " + mineName + " " + typeNotification + " 0");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines set notification " + mineName + " " + typeNotification + " 0" ));
// Cancel the event and close the inventory
e.setCancelled(true);
@@ -2471,7 +2505,9 @@ private void mineNotificationsGUI(InventoryClickEvent e, Player p, String[] part
typeNotification = "disabled";
// Execute the command
- Bukkit.dispatchCommand(p, "mines set notification " + mineName + " " + typeNotification + " 0");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines set notification " + mineName + " " + typeNotification + " 0" ));
// Cancel the event and close the inventory
e.setCancelled(true);
@@ -2512,7 +2548,9 @@ private void radiusGUI(InventoryClickEvent e, Player p, String[] parts) {
if (e.isLeftClick()){
// Execute the command
- Bukkit.dispatchCommand(p,"mines set notification " + part2 + " " + typeNotification + " " + part3);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines set notification " + part2 + " " + typeNotification + " " + part3 ));
// Cancel the event
e.setCancelled(true);
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotGUIMenuTools.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotGUIMenuTools.java
index 195fb4b9b..c47c52a46 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotGUIMenuTools.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotGUIMenuTools.java
@@ -11,6 +11,7 @@
import com.cryptomorin.xseries.XMaterial;
+import tech.mcprison.prison.Prison;
import tech.mcprison.prison.spigot.gui.guiutility.Button;
import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore;
import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI;
@@ -356,7 +357,8 @@ public boolean processGUIPage( Player p, String title, InventoryClickEvent e ) {
if ( command != null ) {
isPageAction = true;
- Bukkit.dispatchCommand(p, command);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( command ));
}
}
@@ -390,7 +392,8 @@ else if ( currentItem != null && currentItem.hasItemMeta() ) {
if ( isMenuToolsPage && command != null ) {
isPageAction = true;
- Bukkit.dispatchCommand(p, command);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( command ));
}
}
From 9d5afc7f75a2ca572355813dec50d1f4c0425d03 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Tue, 11 Jul 2023 22:33:56 -0400
Subject: [PATCH 007/151] Sellall : remove the disabled worlds setting in the
configs since it is obsolete and never used. The correct way to disable
prison in specific worlds is by using the config.yml settings for
prisonCommandHandler.exclude-worlds.
---
docs/changelog_v3.3.x.md | 6 ++-
.../prison/spigot/sellall/SellAllUtil.java | 50 ++++++++++---------
2 files changed, 32 insertions(+), 24 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 8ecda1c0c..bad776e52 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15 2023-07-10
+# 3.3.0-alpha.15 2023-07-11
+
+
+* **Sellall : remove the disabled worlds setting in the configs since it is obsolete and never used.**
+The correct way to disable prison in specific worlds is by using the config.yml settings for prisonCommandHandler.exclude-worlds.
* **Bug fix... this is a continuation of a prior issue of prison commands not being mapped to their assigned command name by bukkit when prison's command handler registers them.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index ec41604a3..edc4b85d4 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -69,7 +69,7 @@ public class SellAllUtil
private ArrayList sellAllItemTriggers;
private ArrayList activePlayerDelay = new ArrayList<>();
- private List sellAllDisabledWorlds;
+// private List sellAllDisabledWorlds;
// private MessagesConfig messages;
private double defaultMultiplier;
private int defaultSellAllDelay;
@@ -674,16 +674,20 @@ public boolean checkIfPlayerAutosellIsActive(Player p) {
return results;
}
- /**
- * Check if Player is in a disabled world, where he can't use sellall sell.
- *
- * Return True if he's in a disabled world, False if not.
- *
- * @return boolean.
- * */
- public boolean isPlayerInDisabledWorld(Player p){
- return sellAllDisabledWorlds.contains(p.getWorld().getName());
- }
+// /**
+// * WARNING: Obsolete because disabled worlds are set in config.yml and
+// * the command handler shuts down in those worlds. So it will
+// * never run any sellall commands in a diabled world.
+// *
+// * Check if Player is in a disabled world, where he can't use sellall sell.
+// *
+// * Return True if he's in a disabled world, False if not.
+// *
+// * @return boolean.
+// * */
+// public boolean isPlayerInDisabledWorld(Player p){
+// return sellAllDisabledWorlds.contains(p.getWorld().getName());
+// }
/**
* Check if Player is waiting for the end of SellAll Sell Delay.
@@ -753,7 +757,7 @@ private void initCachedData() {
sellAllBlocks = initSellAllBlocks();
sellAllPrestigeMultipliers = initPrestigeMultipliers();
sellAllItemTriggers = initSellAllItemTrigger();
- sellAllDisabledWorlds = initSellAllDisabledWorlds();
+// sellAllDisabledWorlds = initSellAllDisabledWorlds();
defaultMultiplier = Double.parseDouble(sellAllConfig.getString("Options.Multiplier_Default"));
defaultSellAllDelay = Integer.parseInt(sellAllConfig.getString("Options.Sell_Delay_Seconds"));
defaultAutoSellEarningNotificationDelay = Integer.parseInt(sellAllConfig.getString("Options.Full_Inv_AutoSell_EarnedMoneyNotificationDelay_Delay_Seconds"));
@@ -898,13 +902,13 @@ public ArrayList initSellAllItemTrigger(){
return xMaterials;
}
- /**
- * Get List of names of disabled worlds.
- * If a Player is in one of these worlds, he won't be able to use SellAll.
- * */
- public List initSellAllDisabledWorlds(){
- return sellAllConfig.getStringList("Options.DisabledWorlds");
- }
+// /**
+// * Get List of names of disabled worlds.
+// * If a Player is in one of these worlds, he won't be able to use SellAll.
+// * */
+// public List initSellAllDisabledWorlds(){
+// return sellAllConfig.getStringList("Options.DisabledWorlds");
+// }
/**
* Add a block to SellAll config.
@@ -1161,7 +1165,7 @@ private HashMap addInventoryToHashMap(HashMap
Date: Wed, 12 Jul 2023 12:06:07 -0400
Subject: [PATCH 008/151] Sellall : remove the disabled worlds setting in the
configs since it is obsolete and never used. The correct way to disable
prison in specific worlds is by using the config.yml settings for
prisonCommandHandler.exclude-worlds.
---
.../spigot/commands/PrisonSpigotSellAllCommands.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
index 4345aeb55..45ac395d3 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
@@ -297,7 +297,7 @@ else if (p == null){
return;
}
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (sellAllUtil.isSellAllSellPermissionEnabled){
String permission = sellAllUtil.permissionSellAllSell;
@@ -339,7 +339,7 @@ public void sellAllSellHandCommand(CommandSender sender){
return;
}
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (sellAllUtil.isSellAllSellPermissionEnabled){
String permission = sellAllUtil.permissionSellAllSell;
@@ -373,7 +373,7 @@ public void sellAllSell(Player p){
return;
}
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (sellAllUtil.isSellAllSellPermissionEnabled){
String permission = sellAllUtil.permissionSellAllSell;
@@ -413,7 +413,7 @@ public void sellAllSellWithDelayCommand(CommandSender sender){
return;
}
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (sellAllUtil.isSellAllSellPermissionEnabled){
String permission = sellAllUtil.permissionSellAllSell;
@@ -454,7 +454,7 @@ private void sellAllAutoEnableUser(CommandSender sender){
return;
}
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (!sellAllUtil.isAutoSellPerUserToggleable){
return;
From a5caccd8e2ecf295fb6e895de63ef1e28dad519a Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Wed, 12 Jul 2023 12:10:38 -0400
Subject: [PATCH 009/151] Add new salePrice and purchasePrice to the prison
Block.
---
docs/changelog_v3.3.x.md | 5 +-
.../mcprison/prison/internal/block/Block.java | 37 ++++++++++++++
.../prison/internal/block/PrisonBlock.java | 50 +++++++++++++++++++
3 files changed, 91 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index bad776e52..a7cdb968b 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,10 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15 2023-07-11
+# 3.3.0-alpha.15 2023-07-12
+
+
+* **Add new salePrice and purchasePrice to the prison Block.**
* **Sellall : remove the disabled worlds setting in the configs since it is obsolete and never used.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/Block.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/Block.java
index 5e166a0cf..df65f516f 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/Block.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/Block.java
@@ -121,4 +121,41 @@ default boolean isEmpty() {
public void setBlockName( String blockName );
+ /**
+ *
The sale price is the amount that is paid to the player when they
+ * sell their items. A null indicates that no price was set.
+ *
The purchase price is what player pays to purchase the items.,
+ * A null indicates that no price was set.
+ *
+ *
+ * @param price
+ */
+ public void setPurchasePrice( Double price ) {
+ this.purchasePrice = price;
+ }
+
+
public PrisonBlock clone() {
return new PrisonBlock( this );
}
From 29190d25334c6e88589c214372ce9c09d2262079 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Wed, 12 Jul 2023 12:12:37 -0400
Subject: [PATCH 010/151] Allow additional parameters to be passed on the
gradlew.bat command; needed for additional debugging and etc...
---
docs/changelog_v3.3.x.md | 3 +++
gradlew8.bat | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index a7cdb968b..981f5cfa9 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-12
+* **Allow additional parameters to be passed on the gradlew.bat command; needed for additional debugging and etc...**
+
+
* **Add new salePrice and purchasePrice to the prison Block.**
diff --git a/gradlew8.bat b/gradlew8.bat
index 009240f46..7230d4d90 100644
--- a/gradlew8.bat
+++ b/gradlew8.bat
@@ -1 +1 @@
-./gradlew build -Dorg.gradle.java.home="C:\Program Files\Java\jdk1.8.0_321" --stacktrace
\ No newline at end of file
+./gradlew build -Dorg.gradle.java.home="C:\Program Files\Java\jdk1.8.0_321" --stacktrace %*
\ No newline at end of file
From 91e573ddb3febf6b7873503dc4e666ccbc5ea1dc Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Thu, 13 Jul 2023 00:04:32 -0400
Subject: [PATCH 011/151] Updated Prison's PlayerInventory to include
'contents' and 'extraContents' to match the bukkit PlayerInventory object.
Within the SpigotPlayerInventory class, overrode the behavior of removeItem
to ensure that obscure inventory locations are being removed, since there was
a bug where you can get all inventory items, then remove them, and they would
not remove all occurrences of the items stacks that were initially returned,
such as when someone is wearing an item as a hat, or holding something in one
of their hands.
---
docs/changelog_v3.3.x.md | 6 +-
.../internal/inventory/PlayerInventory.java | 8 +
.../prison/spigot/game/SpigotPlayer.java | 5 +-
.../inventory/SpigotPlayerInventory.java | 156 +++++++++++++++++-
4 files changed, 167 insertions(+), 8 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 981f5cfa9..cb0f718bf 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15 2023-07-12
+# 3.3.0-alpha.15 2023-07-13
+
+
+* **Updated Prison's PlayerInventory to include 'contents' and 'extraContents' to match the bukkit PlayerInventory object.**
+Within the SpigotPlayerInventory class, overrode the behavior of removeItem to ensure that obscure inventory locations are being removed, since there was a bug where you can get all inventory items, then remove them, and they would not remove all occurrences of the items stacks that were initially returned, such as when someone is wearing an item as a hat, or holding something in one of their hands.
* **Allow additional parameters to be passed on the gradlew.bat command; needed for additional debugging and etc...**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/PlayerInventory.java b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/PlayerInventory.java
index 723b4b11d..b8d4ab439 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/PlayerInventory.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/PlayerInventory.java
@@ -28,6 +28,14 @@
*/
public interface PlayerInventory extends Inventory {
+
+ public ItemStack[] getContents();
+ public void setContents( ItemStack[] items );
+
+ public ItemStack[] getExtraContents();
+ public void setExtraContents( ItemStack[] items );
+
+
/**
* Gets the armor this player is wearing
*
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java
index d1dd9ed9d..47157a008 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java
@@ -230,7 +230,10 @@ public org.bukkit.entity.Player getWrapper() {
@Override
public Inventory getInventory() {
- return new SpigotPlayerInventory(getWrapper().getInventory());
+ return getSpigotPlayerInventory();
+ }
+ public SpigotPlayerInventory getSpigotPlayerInventory() {
+ return new SpigotPlayerInventory(getWrapper().getInventory());
}
@Override public void updateInventory() {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotPlayerInventory.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotPlayerInventory.java
index 840eab86b..14649eeb5 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotPlayerInventory.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotPlayerInventory.java
@@ -23,6 +23,7 @@
import java.util.List;
import tech.mcprison.prison.internal.ItemStack;
+import tech.mcprison.prison.internal.block.PrisonBlock;
import tech.mcprison.prison.internal.inventory.PlayerInventory;
import tech.mcprison.prison.spigot.SpigotUtil;
import tech.mcprison.prison.spigot.block.SpigotItemStack;
@@ -31,20 +32,161 @@
/**
* Created by DMP9 on 04/02/2017.
*/
-public class SpigotPlayerInventory extends SpigotInventory implements PlayerInventory {
+public class SpigotPlayerInventory
+ extends SpigotInventory
+ implements PlayerInventory {
public SpigotPlayerInventory(org.bukkit.inventory.PlayerInventory wrapper) {
super(wrapper);
}
- @Override public ItemStack[] getArmorContents() {
+ /**
+ *
This function gets all of the player's contents from the getContents(),
+ * getExtraContents(), and getArmorContents().
+ *
+ *
+ * @return
+ */
+ public List getAllContents() {
+ List results = new ArrayList<>();
+
+ for ( ItemStack iStack : getContents() ) {
+ if ( iStack != null ) {
+ results.add(iStack);
+ }
+ }
+
+ try {
+ for ( ItemStack iStack : getExtraContents() ) {
+ if ( iStack != null ) {
+ results.add(iStack);
+ }
+ }
+ } catch (NoSuchMethodError e) {
+ // Ignore on older versions of spigot... Spigot 1.8.8 does not have this function.
+ }
+
+ // then remove the armor ItemStacks:
+ for ( ItemStack iStack : getArmorContents() ) {
+ if ( iStack != null ) {
+ results.remove(iStack);
+ }
+ }
+
+ return results;
+ }
+
+ @Override
+ public void removeItem( ItemStack... iStack ) {
+ if ( iStack != null ) {
+
+ // Remove all items...
+ super.removeItem(iStack);
+
+ // But since this is a player's inventory, try to remove them from the players slots
+ for (ItemStack itemStack : iStack) {
+ PrisonBlock pBlock = itemStack.getMaterial();
+
+ if ( isPrisonBlockEqual( pBlock, getBoots() ) ) {
+ setBoots( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ if ( isPrisonBlockEqual( pBlock, getChestplate() ) ) {
+ setChestplate( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ if ( isPrisonBlockEqual( pBlock, getHelmet() ) ) {
+ setHelmet( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ if ( isPrisonBlockEqual( pBlock, getLeggings() ) ) {
+ setLeggings( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+
+ try {
+
+ if ( isPrisonBlockEqual( pBlock, getItemInLeftHand() ) ) {
+ setItemInLeftHand( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ }
+ catch ( Exception e ) {
+ // java 1.8 may not be able to handle this
+ }
+ try {
+
+ if ( isPrisonBlockEqual( pBlock, getItemInRightHand() ) ) {
+ setItemInRightHand( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ }
+ catch ( Exception e ) {
+ // java 1.8 may not be able to handle this
+ }
+
+ }
+ }
+ }
+
+
+ private boolean isPrisonBlockEqual( PrisonBlock pBlock, ItemStack iStack ) {
+ boolean results = false;
+
+ if ( pBlock != null && iStack != null ) {
+ results = pBlock.equals( iStack.getMaterial() );
+ }
+
+ return results;
+ }
+
+ @Override
+ public ItemStack[] getContents() {
+ List items = new ArrayList<>();
+ Arrays.asList(((org.bukkit.inventory.PlayerInventory) getWrapper()).getContents())
+ .forEach(x -> items.add(SpigotUtil.bukkitItemStackToPrison(x)));
+ return (ItemStack[]) items.toArray();
+ }
+
+ @Override
+ public void setContents( ItemStack[] items ) {
+ List stacks = new ArrayList<>();
+ Arrays.asList(items).forEach(x -> stacks.add(SpigotUtil.prisonItemStackToBukkit(x)));
+ ((org.bukkit.inventory.PlayerInventory) getWrapper())
+ .setContents((org.bukkit.inventory.ItemStack[]) stacks.toArray());
+ }
+
+ @Override
+ public ItemStack[] getExtraContents() {
+ try {
+ List items = new ArrayList<>();
+ Arrays.asList(((org.bukkit.inventory.PlayerInventory) getWrapper()).getExtraContents())
+ .forEach(x -> items.add(SpigotUtil.bukkitItemStackToPrison(x)));
+ return (ItemStack[]) items.toArray();
+ }
+ catch ( Exception e ) {
+ return null;
+ }
+ }
+ @Override
+ public void setExtraContents( ItemStack[] items ) {
+ try {
+ List stacks = new ArrayList<>();
+ Arrays.asList(items).forEach(x -> stacks.add(SpigotUtil.prisonItemStackToBukkit(x)));
+ ((org.bukkit.inventory.PlayerInventory) getWrapper())
+ .setExtraContents((org.bukkit.inventory.ItemStack[]) stacks.toArray());
+ }
+ catch ( Exception e ) {
+ // extraContents does not exist in spigot 1.8
+ }
+ }
+
+
+
+ @Override
+ public ItemStack[] getArmorContents() {
List items = new ArrayList<>();
Arrays.asList(((org.bukkit.inventory.PlayerInventory) getWrapper()).getArmorContents())
.forEach(x -> items.add(SpigotUtil.bukkitItemStackToPrison(x)));
return (ItemStack[]) items.toArray();
}
- @Override public void setArmorContents(ItemStack[] items) {
+ @Override
+ public void setArmorContents(ItemStack[] items) {
List stacks = new ArrayList<>();
Arrays.asList(items).forEach(x -> stacks.add(SpigotUtil.prisonItemStackToBukkit(x)));
((org.bukkit.inventory.PlayerInventory) getWrapper())
@@ -119,7 +261,8 @@ public SpigotPlayerInventory(org.bukkit.inventory.PlayerInventory wrapper) {
}
}
- @Override public ItemStack getItemInRightHand() {
+ @Override
+ public ItemStack getItemInRightHand() {
return SpigotUtil.bukkitItemStackToPrison(
@@ -127,7 +270,8 @@ public SpigotPlayerInventory(org.bukkit.inventory.PlayerInventory wrapper) {
((org.bukkit.inventory.PlayerInventory) getWrapper()) ));
}
- @Override public void setItemInRightHand(ItemStack stack) {
+ @Override
+ public void setItemInRightHand(ItemStack stack) {
if ( stack instanceof SpigotItemStack ) {
@@ -135,5 +279,5 @@ public SpigotPlayerInventory(org.bukkit.inventory.PlayerInventory wrapper) {
.setItemStackInMainHand( this, ((SpigotItemStack) stack) );
}
}
-
+
}
From a2a39ba793201b6b94dbc92519540fbf3ed9609d Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Thu, 13 Jul 2023 00:29:50 -0400
Subject: [PATCH 012/151] Major rewrites to sellall to utilize more of Prison's
internal classes and to get away from XMaterial since it cannot handle custom
blocks. A lot of sellall code has been eliminated, but no loss in
functionality. Actually new functions and enhancements have been added.
Eliminated the two step process of selling... where it first calculated the
values, then after the fact, would try to remove the items with no
"validation" that the items removed were the items that calculated the sales
amount. Sellall commands: moved the '/sellall trigger add' and '/sellall
trigger remove' to under the '/sell set' section since they were hidden
because '/sellall trigger' was a command and many did not realize they have
to use the 'help' keyword to show the others.
---
.../prison/spigot/api/PrisonSpigotAPI.java | 3 +-
.../autofeatures/AutoManagerFeatures.java | 2 +-
.../commands/PrisonSpigotSellAllCommands.java | 40 +-
.../prison/spigot/sellall/SellAllData.java | 114 +
.../prison/spigot/sellall/SellAllUtil.java | 1825 ++++++++++-------
5 files changed, 1247 insertions(+), 737 deletions(-)
create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
index f6a11d90a..dc86a4839 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
@@ -468,7 +468,8 @@ public Double getSellAllMoneyWithMultiplier(Player player){
}
if (sellAll != null){
- return sellAll.getSellMoney(player);
+ return sellAll.getPlayerInventoryValue( (SpigotPlayer)player );
+// return sellAll.getSellMoney(player);
}
return null;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
index 5cb7def89..0e86d2647 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
@@ -891,7 +891,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
if ( Output.get().isDebug() && isSellallEnabled ) {
// Just get the calculated value for the drops... do not sell:
- double amount = SellAllUtil.get().getSellMoney( player, itemStack );
+ double amount = SellAllUtil.get().getItemStackValue( (SpigotPlayer)player, itemStack );
autosellTotal += amount;
debugInfo.append( "(Debug-unsold-value-check: " + itemStack.getName() +
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
index 45ac395d3..b8b5dd928 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
@@ -17,14 +17,15 @@
import tech.mcprison.prison.commands.Wildcard;
import tech.mcprison.prison.integration.EconomyCurrencyIntegration;
import tech.mcprison.prison.internal.CommandSender;
+import tech.mcprison.prison.internal.block.PrisonBlock;
import tech.mcprison.prison.output.ChatDisplay;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages;
import tech.mcprison.prison.spigot.SpigotPlatform;
import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.spigot.compat.Compatibility;
import tech.mcprison.prison.spigot.configs.MessagesConfig;
-import tech.mcprison.prison.spigot.game.SpigotOfflinePlayer;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
import tech.mcprison.prison.spigot.gui.sellall.SellAllAdminBlocksGUI;
import tech.mcprison.prison.spigot.sellall.SellAllBlockData;
@@ -391,7 +392,8 @@ public void sellAllSell(Player p){
}
- @Command(identifier = "sellall delaysell", description = "Like SellAll Sell command but this will be delayed for some " +
+ @Command(identifier = "sellall delaysell",
+ description = "Like SellAll Sell command but this will be delayed for some " +
"seconds and if sellall sell commands are triggered during this delay, " +
"they will sum up to the total value that will be visible in a notification at the end of the delay. " +
"Running more of these commands before a delay have been completed won't reset it and will do the same of /sellall sell " +
@@ -573,7 +575,7 @@ private void sellAllAddCommand(CommandSender sender,
}
if (sellAllUtil.addSellAllBlock(blockAdd, value)){
- Output.get().sendInfo(sender, "&3 ITEM [" + itemID + ", " + value + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_add_success));
+ Output.get().sendInfo(sender, "&3 ITEM [" + itemID + ", " + value + "] " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_add_success));
}
} catch (IllegalArgumentException ex){
@@ -676,7 +678,7 @@ private void sellAllEditCommand(CommandSender sender,
}
if (sellAllUtil.editPrice(blockAdd, value)){
- Output.get().sendInfo(sender, "&3ITEM [" + itemID + ", " + value + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_edit_success));
+ Output.get().sendInfo(sender, "&3ITEM [" + itemID + ", " + value + "] " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_edit_success));
}
} catch (IllegalArgumentException ex){
@@ -826,7 +828,7 @@ private void sellAllDeleteMultiplierCommand(CommandSender sender,
}
}
- @Command(identifier = "sellall Trigger",
+ @Command(identifier = "sellall trigger",
description = "Toggle SellAll Shift+Right Click on a tool to trigger the /sellall sell command, "
+ "true -> Enabled or False -> Disabled.",
permissions = "prison.admin", onlyPlayers = false)
@@ -871,7 +873,7 @@ private void sellAllToolsTriggerToggle(CommandSender sender,
}
}
- @Command(identifier = "sellall Trigger add",
+ @Command(identifier = "sellall set trigger add",
description = "Add an Item to trigger the Shift+Right Click -> /sellall sell command.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllTriggerAdd(CommandSender sender,
@@ -912,7 +914,7 @@ private void sellAllTriggerAdd(CommandSender sender,
}
}
- @Command(identifier = "sellall Trigger delete",
+ @Command(identifier = "sellall set trigger delete",
description = "Delete an Item from the Shift+Right Click trigger -> /sellall sell command.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllTriggerDelete(CommandSender sender,
@@ -981,22 +983,22 @@ private void sellAllListItems( CommandSender sender ) {
return;
}
- TreeMap items = new TreeMap<>( sellAllUtil.getSellAllBlocks() );
+ TreeMap items = new TreeMap<>( sellAllUtil.getSellAllItems() );
DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
- Set keys = items.keySet();
+ Set keys = items.keySet();
int maxLenKey = 0;
int maxLenVal = 0;
int maxLenCode = 0;
- for ( XMaterial key : keys ) {
- if ( key.toString().length() > maxLenKey ) {
- maxLenKey = key.toString().length();
- }
- if ( key.name().length() > maxLenCode ) {
- maxLenCode = key.name().length();
+ for ( String key : keys ) {
+// if ( key.toString().length() > maxLenKey ) {
+// maxLenKey = key.toString().length();
+// }
+ if ( key.length() > maxLenCode ) {
+ maxLenCode = key.length();
}
- String val = fFmt.format( items.get( key ) );
+ String val = fFmt.format( items.get( key ).getSalePrice() );
if ( val.length() > maxLenVal ) {
maxLenVal = val.length();
}
@@ -1007,17 +1009,17 @@ private void sellAllListItems( CommandSender sender ) {
int lines = 0;
StringBuilder sb = new StringBuilder();
- for ( XMaterial key : keys ) {
+ for ( String key : keys ) {
boolean first = sb.length() == 0;
- Double cost = items.get( key );
+ Double cost = items.get( key ).getSalePrice();
if ( !first ) {
sb.append( " " );
}
sb.append( String.format( "%-" + maxLenCode + "s %" + maxLenVal + "s",
- key.name(), fFmt.format( cost ) ) );
+ key, fFmt.format( cost ) ) );
// sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s %-" + maxLenCode + "s",
// key.toString(), fFmt.format( cost ), key.name() ) );
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
new file mode 100644
index 000000000..4c639edc4
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
@@ -0,0 +1,114 @@
+package tech.mcprison.prison.spigot.sellall;
+
+import java.text.DecimalFormat;
+import java.util.List;
+
+import tech.mcprison.prison.internal.block.PrisonBlock;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.game.SpigotPlayer;
+
+/**
+ *
This is a simple class that contains the times that have been sold
+ * and the amount that they were sold for.
+ *
+ *
+ * @author Blue
+ *
+ */
+public class SellAllData {
+
+ private PrisonBlock prisonBlock;
+ private int quantity;
+ private double transactionAmount;
+
+ public SellAllData( PrisonBlock pBlock, int quantity, double transactionAmount ) {
+ super();
+
+ this.prisonBlock = pBlock;
+ this.quantity = quantity;
+ this.transactionAmount = transactionAmount;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.00" );
+ sb.append( getPrisonBlock().getBlockName() )
+ .append( ":" )
+ .append( getQuantity() )
+ .append( ":" )
+ .append( dFmt.format(getTransactionAmount()) );
+
+ return sb.toString();
+ }
+
+
+ public static void debugItemsSold( List soldItems, SpigotPlayer sPlayer, double multiplier ) {
+ if ( Output.get().isDebug() ) {
+ String report = SellAllData.itemsSoldReport( soldItems, sPlayer, multiplier );
+ Output.get().logInfo( report );
+ }
+ }
+
+ public static String itemsSoldReport( List soldItems, SpigotPlayer sPlayer, double multiplier ) {
+ StringBuilder sb = new StringBuilder();
+ StringBuilder sbItems = new StringBuilder();
+
+ double totalAmount = 0;
+ int itemCount = 0;
+ for (SellAllData soldItem : soldItems) {
+ if ( soldItem != null ) {
+
+ totalAmount += soldItem.getTransactionAmount();
+ itemCount += soldItem.getQuantity();
+
+ if ( sbItems.length() > 0 ) {
+
+ sbItems.append( ", " );
+ }
+ sbItems.append( soldItem.toString() );
+ }
+ }
+
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.00" );
+ DecimalFormat iFmt = new DecimalFormat( "#,##0" );
+
+ sb.append( "Transaction log: " )
+ .append( sPlayer.getName() )
+ .append( " multiplier: " )
+ .append( dFmt.format(multiplier) )
+ .append( " ItemStacks: " )
+ .append( soldItems.size() )
+ .append( " ItemCount: " )
+ .append( iFmt.format(itemCount) )
+ .append( " TotalAmount: " )
+ .append( dFmt.format( totalAmount ))
+ .append( " [" )
+ .append( sbItems )
+ .append("]");
+
+ return sb.toString();
+ }
+
+ public PrisonBlock getPrisonBlock() {
+ return prisonBlock;
+ }
+ public void setPrisonBlock(PrisonBlock prisonBlock) {
+ this.prisonBlock = prisonBlock;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+ public double getTransactionAmount() {
+ return transactionAmount;
+ }
+ public void setTransactionAmount(double transactionAmount) {
+ this.transactionAmount = transactionAmount;
+ }
+
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index edc4b85d4..5dd5c09b2 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -9,27 +9,22 @@
import java.util.Optional;
import org.bukkit.Bukkit;
-import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.PlayerInventory;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
-import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
import tech.mcprison.prison.Prison;
import tech.mcprison.prison.PrisonAPI;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.integration.EconomyCurrencyIntegration;
import tech.mcprison.prison.internal.block.PrisonBlock;
-import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.ranks.PrisonRanks;
import tech.mcprison.prison.ranks.data.PlayerRank;
@@ -37,16 +32,12 @@
import tech.mcprison.prison.ranks.data.RankPlayer;
import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages;
import tech.mcprison.prison.spigot.SpigotPrison;
-import tech.mcprison.prison.spigot.backpacks.BackpacksUtil;
import tech.mcprison.prison.spigot.block.SpigotItemStack;
-import tech.mcprison.prison.spigot.compat.Compatibility;
-import tech.mcprison.prison.spigot.compat.SpigotCompatibility;
//import tech.mcprison.prison.spigot.configs.MessagesConfig;
import tech.mcprison.prison.spigot.game.SpigotCommandSender;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
import tech.mcprison.prison.spigot.gui.sellall.SellAllAdminGUI;
import tech.mcprison.prison.spigot.gui.sellall.SellAllPlayerGUI;
-import tech.mcprison.prison.spigot.integrations.IntegrationMinepacksPlugin;
import tech.mcprison.prison.spigot.inventory.SpigotPlayerInventory;
import tech.mcprison.prison.util.Text;
@@ -58,12 +49,14 @@ public class SellAllUtil
private static SellAllUtil instance;
- private final Compatibility compat = SpigotPrison.getInstance().getCompatibility();
+// private final Compatibility compat = SpigotPrison.getInstance().getCompatibility();
- private final ItemStack lapisLazuli = compat.getLapisItemStack();
+// private final ItemStack lapisLazuli = compat.getLapisItemStack();
public Configuration sellAllConfig;
- private HashMap sellAllBlocks;
+ private HashMap sellAllItems;
+// private HashMap sellAllBlocks;
+
private HashMap sellAllPrestigeMultipliers;
private HashMap autoSellEarningsNotificationWaiting = new HashMap<>();
private ArrayList sellAllItemTriggers;
@@ -129,15 +122,103 @@ public static SellAllUtil get() {
}
return instance;
}
-
+
/**
- * Return boolean value from String.
- *
- * @return boolean.
+ * Init options that will be cached.
* */
- private static boolean getBoolean(String string) {
- return string != null && string.equalsIgnoreCase("true");
+ private void initCachedData() {
+ sellAllConfig = SpigotPrison.getInstance().updateSellAllConfig();
+// messages = SpigotPrison.getInstance().getMessagesConfig();
+ permissionSellAllSell = sellAllConfig.getString("Options.Sell_Permission");
+ permissionBypassSign = sellAllConfig.getString("Options.SellAll_By_Sign_Bypass_Permission");
+ permissionUseSign = sellAllConfig.getString("Options.SellAll_Sign_Use_Permission");
+ permissionGUI = sellAllConfig.getString("Options.GUI_Permission");
+ permissionPlayerGUI = sellAllConfig.getString("Options.Player_GUI_Permission");
+ permissionPrefixBlocks = sellAllConfig.getString("Options.Sell_Per_Block_Permission");
+ permissionAutoSellPerUserToggleable = sellAllConfig.getString("Options.Full_Inv_AutoSell_PerUserToggleable_Permission");
+ permissionItemTrigger = sellAllConfig.getString("Options.ShiftAndRightClickSellAll.Permission");
+ sellAllCurrency = sellAllConfig.getString("Options.SellAll_Currency");
+ sellAllSoundSuccess = XSound.matchXSound("Options.Sell_Sound_Success_Name").orElse(XSound.ENTITY_PLAYER_LEVELUP).parseSound();
+ sellAllSoundFail = XSound.matchXSound("Options.Sell_Sound_Fail_Name").orElse(XSound.BLOCK_ANVIL_PLACE).parseSound();
+ sellAllSignTag = Text.translateAmpColorCodes(sellAllConfig.getString("Options.SellAll_Sign_Visible_Tag") );
+// sellAllBlocks = initSellAllBlocks();
+ sellAllItems = initSellAllItems();
+
+ sellAllPrestigeMultipliers = initPrestigeMultipliers();
+ sellAllItemTriggers = initSellAllItemTrigger();
+// sellAllDisabledWorlds = initSellAllDisabledWorlds();
+ defaultMultiplier = Double.parseDouble(sellAllConfig.getString("Options.Multiplier_Default"));
+ defaultSellAllDelay = Integer.parseInt(sellAllConfig.getString("Options.Sell_Delay_Seconds"));
+ defaultAutoSellEarningNotificationDelay = Integer.parseInt(sellAllConfig.getString("Options.Full_Inv_AutoSell_EarnedMoneyNotificationDelay_Delay_Seconds"));
+ isPerBlockPermissionEnabled = getBooleanValue("Options.Sell_Per_Block_Permission_Enabled");
+ isAutoSellEnabled = getBooleanValue("Options.Full_Inv_AutoSell");
+ isAutoSellNotificationEnabled = getBooleanValue("Options.Full_Inv_AutoSell_Notification");
+ isAutoSellEarningNotificationDelayEnabled = getBooleanValue("Options.Full_Inv_AutoSell_EarnedMoneyNotificationDelay_Enabled");
+ isAutoSellPerUserToggleable = getBooleanValue("Options.Full_Inv_AutoSell_perUserToggleable");
+ isAutoSellPerUserToggleablePermEnabled = getBooleanValue("Options.Full_Inv_AutoSell_perUserToggleable_Need_Perm");
+ isSellAllNotificationEnabled = getBooleanValue("Options.Sell_Notify_Enabled");
+ isSellAllSoundEnabled = getBooleanValue("Options.Sell_Sound_Enabled");
+ isSellAllBackpackItemsEnabled = getBooleanValue("Options.Sell_Prison_BackPack_Items");
+ isSellAllMinesBackpacksPluginEnabled = getBooleanValue("Options.Sell_MinesBackPacks_Plugin_Backpack");
+ isSellAllDelayEnabled = getBooleanValue("Options.Sell_Delay_Enabled");
+ isSellAllSellPermissionEnabled = getBooleanValue("Options.Sell_Permission_Enabled");
+ isSellAllItemTriggerEnabled = getBooleanValue("Options.ShiftAndRightClickSellAll.Enabled");
+ isSellAllItemTriggerPermissionEnabled = getBooleanValue("Options.ShiftAndRightClickSellAll.PermissionEnabled");
+ isSellAllGUIEnabled = getBooleanValue("Options.GUI_Enabled");
+ isSellAllPlayerGUIEnabled = getBooleanValue("Options.Player_GUI_Enabled");
+ isSellAllGUIPermissionEnabled = getBooleanValue("Options.GUI_Permission_Enabled");
+ isSellAllPlayerGUIPermissionEnabled = getBooleanValue("Options.Player_GUI_Permission_Enabled");
+ isSellAllMultiplierEnabled = getBooleanValue("Options.Multiplier_Enabled");
+ isSellAllPermissionMultiplierOnlyHigherEnabled = getBooleanValue("Options.Multiplier_Permission_Only_Higher");
+ isSellAllSignEnabled = getBooleanValue("Options.SellAll_Sign_Enabled");
+ isSellAllSignNotifyEnabled = getBooleanValue("Options.SellAll_Sign_Notify");
+ isSellAllSignPermissionToUseEnabled = getBooleanValue("Options.SellAll_Sign_Use_Permission_Enabled");
+ isSellAllBySignOnlyEnabled = getBooleanValue("Options.SellAll_By_Sign_Only");
+ isSellAllHandEnabled = getBooleanValue("Options.SellAll_Hand_Enabled");
+
+ isSellAllIgnoreCustomNames = getBooleanValue("Options.SellAll_ignoreCustomNames", false);
}
+
+ private boolean getBooleanValue( String configName ) {
+ return getBooleanValue(configName, false);
+ }
+ private boolean getBooleanValue( String configName, Boolean defaultValue ) {
+ boolean results = (defaultValue == null ? false : defaultValue.booleanValue() );
+
+ if ( configName != null ) {
+ if ( sellAllConfig.isString(configName) ) {
+ String boolVal = sellAllConfig.getString(configName);
+ if ( boolVal != null ) {
+ // Boolean.parseBoolean() also supports yes and no so don't pretest for true/false.
+ try {
+ results = Boolean.parseBoolean(boolVal);
+ } catch (Exception e) {
+ // Not a boolean value, so ignore and let the "defaut" value stand
+ }
+ }
+ else {
+ // ignore since it's not a boolean value and let the "default" value stand
+ }
+ }
+ else if ( sellAllConfig.isBoolean(configName) ) {
+ results = sellAllConfig.getBoolean(configName, results);
+ }
+ else {
+ // Ignore since the config is not boolean or a String that "could" be a boolean
+ }
+ }
+
+ return results;
+ }
+
+// /**
+// * Return boolean value from String.
+// *
+// * @return boolean.
+// * */
+// private static boolean getBoolean(String string) {
+// return string != null && string.equalsIgnoreCase("true");
+// }
/**
* Get an ArrayList of SellAllItemTriggers as XMaterials.
@@ -172,60 +253,68 @@ public ArrayList getItemTriggerXMaterials(){
// return materials;
// }
- /**
- * Get SellAll XMaterial or Lapis (As Lapis is weird) from an ItemStack.
- *
- * @param itemStack - ItemStack.
- *
- * @return XMaterial.
- * */
- private XMaterial getXMaterialOrLapis(ItemStack itemStack) {
- XMaterial results = null;
-
- String altName = null;
-
- if ( itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() ) {
- altName = itemStack.getItemMeta().getDisplayName();
- }
-
- if ( altName == null || isSellAllIgnoreCustomNames ) {
- XMaterial xMat = null;
-
- if (itemStack.isSimilar(lapisLazuli)) {
- xMat = XMaterial.LAPIS_LAZULI;
- }
- else {
-
- try
- {
- xMat = XMaterial.matchXMaterial(itemStack);
- }
- catch ( Exception e )
- {
- // ignore... it is not normal matertial so it cannot be sold
- }
- }
- if ( xMat != null ) {
-
- // When converted over to be based upon a String name, instead of XMaterial,
- // the altName will take priority over the XMaterial name.
- results = xMat;
- }
- }
-
- return results;
- }
+// /**
+// * Get SellAll XMaterial or Lapis (As Lapis is weird) from an ItemStack.
+// *
+// * @param itemStack - ItemStack.
+// *
+// * @return XMaterial.
+// * */
+// private XMaterial getXMaterialOrLapis(ItemStack itemStack) {
+// XMaterial results = null;
+//
+// String altName = null;
+//
+// if ( itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() ) {
+// altName = itemStack.getItemMeta().getDisplayName();
+// }
+//
+// if ( altName == null || isSellAllIgnoreCustomNames ) {
+// XMaterial xMat = null;
+//
+// if (itemStack.isSimilar(lapisLazuli)) {
+// xMat = XMaterial.LAPIS_LAZULI;
+// }
+// else {
+//
+// try
+// {
+// xMat = XMaterial.matchXMaterial(itemStack);
+// }
+// catch ( Exception e )
+// {
+// // ignore... it is not normal matertial so it cannot be sold
+// }
+// }
+// if ( xMat != null ) {
+//
+// // When converted over to be based upon a String name, instead of XMaterial,
+// // the altName will take priority over the XMaterial name.
+// results = xMat;
+// }
+// }
+//
+// return results;
+// }
- /**
- * Return SellAll Blocks HashMap cached values.
- *
- * @return HashMap of XMaterial-Double.
- * */
- public HashMap getSellAllBlocks() {
- return sellAllBlocks;
- }
+// /**
+// * Return SellAll Blocks HashMap cached values.
+// *
+// * @return HashMap of XMaterial-Double.
+// * */
+// public HashMap getSellAllBlocks() {
+// return sellAllBlocks;
+// }
/**
+ *
+ * @return HashMap
+ */
+ public HashMap getSellAllItems() {
+ return sellAllItems;
+ }
+
+ /**
* Return SellAll Prestige Multiplier HashMap read before from config on init.
*
* HashMap details:
@@ -238,64 +327,64 @@ public HashMap getPrestigeMultipliers() {
return sellAllPrestigeMultipliers;
}
- /**
- * Get HashMap of XMaterials and amounts from an Inventory.
- *
- * @param inv - Inventory.
- *
- * @return HashMap of XMaterials and Integers.
- * */
- public HashMap getXMaterialsHashMapFromInventory(Inventory inv){
-
- HashMap xMaterialIntegerHashMap = new HashMap<>();
- for (ItemStack itemStack : inv.getContents()){
- if (itemStack != null){
- XMaterial xMaterial = getXMaterialOrLapis(itemStack);
- if ( xMaterial != null ) {
-
- if (xMaterialIntegerHashMap.containsKey(xMaterial) && xMaterialIntegerHashMap.get(xMaterial) != 0){
- xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
- }
- else {
- xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
- }
- }
- }
- }
-
- return xMaterialIntegerHashMap;
- }
-
+// /**
+// * Get HashMap of XMaterials and amounts from an Inventory.
+// *
+// * @param inv - Inventory.
+// *
+// * @return HashMap of XMaterials and Integers.
+// * */
+// private HashMap getXMaterialsHashMapFromInventory(Inventory inv){
+//
+// HashMap xMaterialIntegerHashMap = new HashMap<>();
+// for (ItemStack itemStack : inv.getContents()){
+// if (itemStack != null){
+// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+// if ( xMaterial != null ) {
+//
+// if (xMaterialIntegerHashMap.containsKey(xMaterial) && xMaterialIntegerHashMap.get(xMaterial) != 0){
+// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
+// }
+// else {
+// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
+// }
+// }
+// }
+// }
+//
+// return xMaterialIntegerHashMap;
+// }
- /**
- * get HashMap of XMaterials and Amounts from an ArrayList of ItemStacks.
- *
- * @param itemStacks - ArrayList of ItemStacks.
- *
- * @return HashMap of XMaterials and Integers.
- * */
- public HashMap getXMaterialsHashMapFromArrayList(ArrayList itemStacks){
-
- HashMap xMaterialIntegerHashMap = new HashMap<>();
- for (ItemStack itemStack : itemStacks){
- if (itemStack != null){
- try {
- XMaterial xMaterial = getXMaterialOrLapis(itemStack);
- if ( xMaterial != null ) {
-
- if (xMaterialIntegerHashMap.containsKey(xMaterial) && xMaterialIntegerHashMap.get(xMaterial) != 0) {
- xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
- }
- else {
- xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
- }
- }
- } catch (IllegalArgumentException ignored){}
- }
- }
- return xMaterialIntegerHashMap;
- }
+// /**
+// * get HashMap of XMaterials and Amounts from an ArrayList of ItemStacks.
+// *
+// * @param itemStacks - ArrayList of ItemStacks.
+// *
+// * @return HashMap of XMaterials and Integers.
+// * */
+// private HashMap getXMaterialsHashMapFromArrayList(ArrayList itemStacks){
+//
+// HashMap xMaterialIntegerHashMap = new HashMap<>();
+// for (ItemStack itemStack : itemStacks){
+// if (itemStack != null){
+// try {
+// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+// if ( xMaterial != null ) {
+//
+// if (xMaterialIntegerHashMap.containsKey(xMaterial) && xMaterialIntegerHashMap.get(xMaterial) != 0) {
+// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
+// }
+// else {
+// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
+// }
+// }
+// } catch (IllegalArgumentException ignored){}
+// }
+// }
+//
+// return xMaterialIntegerHashMap;
+// }
/**
* Get SellAll Player Multiplier.
@@ -389,257 +478,410 @@ public double getPlayerMultiplier(Player p){
return multiplier;
}
- /**
- * Get SellAll Money to give, it requires Player because of SellAll perBlockPermission as an option.
- * NOTE: This WON'T remove blocks from the HashMap when sold, and won't edit Inventories of Players,
- * but only return the amount of money that the Player would get if he sells now everything from the
- * specified HashMap of XMaterials and Integers.
- *
- * Will also calculate the Multiplier of the Player.
- *
- * Get SellAll Sell value of HashMap values.
- * NOTE: If there aren't blocks in the SellAll shop this will return 0.
- * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
- *
- * @param p - Player.
- * @param xMaterialIntegerHashMap - HashMap of XMaterial-Integer (Blocks of origin).
- *
- * @return double.
- * */
- public double getSellMoney(Player p, HashMap xMaterialIntegerHashMap){
- StringBuilder sb = new StringBuilder();
- boolean debug = Output.get().isDebug();
+// /**
+// * Get SellAll Money to give, it requires Player because of SellAll perBlockPermission as an option.
+// * NOTE: This WON'T remove blocks from the HashMap when sold, and won't edit Inventories of Players,
+// * but only return the amount of money that the Player would get if he sells now everything from the
+// * specified HashMap of XMaterials and Integers.
+// *
+// * Will also calculate the Multiplier of the Player.
+// *
+// * Get SellAll Sell value of HashMap values.
+// * NOTE: If there aren't blocks in the SellAll shop this will return 0.
+// * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
+// *
+// * @param p - Player.
+// * @param xMaterialIntegerHashMap - HashMap of XMaterial-Integer (Blocks of origin).
+// *
+// * @return double.
+// * */
+// private double getSellMoney(Player p, HashMap xMaterialIntegerHashMap){
+// StringBuilder sb = new StringBuilder();
+// boolean debug = Output.get().isDebug();
+//
+// if (sellAllItems.isEmpty()){
+// return 0;
+// }
+//
+// double multiplier = getPlayerMultiplier(p);
+//
+//
+// double earned = 0;
+// for (HashMap.Entry xMatEntry : xMaterialIntegerHashMap.entrySet()){
+//
+// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMatEntry.getKey().name() );
+//
+// String key = pBlockKey.getBlockName();
+//
+// if (sellAllItems.containsKey( key )){
+// // This is stupid but right now I'm too confused, sorry.
+// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + key )){
+// // Nothing will change.
+// }
+// else {
+// PrisonBlock pBlock = sellAllItems.get(key);
+//
+//// XMaterial xMat = xMatEntry.getKey();
+// int qty = xMatEntry.getValue();
+// double value = pBlock.getSalePrice();
+//
+// if ( debug ) {
+//
+// if ( sb.length() > 0 ) {
+// sb.append(", ");
+// }
+// sb.append( key.toLowerCase() ).append(":")
+// .append( qty ).append("@").append(value);
+// }
+//
+// earned += qty * value;
+// }
+// }
+// }
+//
+// double total = earned * multiplier;
+//
+// if ( debug ) {
+// DecimalFormat dFmt = Prison.get().getDecimalFormat( "#,##0.00" );
+// sb.append( " earned: " ).append( dFmt.format(earned) )
+// .append( " mult: " ).append( dFmt.format(multiplier) )
+// .append( " total: " ).append( dFmt.format(total) );
+// String message = String.format(
+// "Sellall.getSellMoney: %s %s",
+// p.getName(), sb.toString() );
+// Output.get().logInfo(message);
+// }
+//
+// return total;
+// }
- if (sellAllBlocks.isEmpty()){
- return 0;
- }
+// /**
+// * Get SellAll Money to give, it requires Player because of SellAll perBlockPermission as an option.
+// * NOTE: This WON'T remove blocks from the ArrayList when sold, and won't edit Inventories of Players,
+// * but only return the amount of money that the Player would get if he sells now everything from the
+// * specified ArrayList of ItemStacks.
+// *
+// * Will also calculate the Multiplier of the Player.
+// *
+// * Get SellAll Sell value of ArrayList of itemstack.
+// * NOTE: If there aren't blocks in the SellAll shop this will return 0.
+// * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
+// *
+// * @param p - Player.
+// * @param itemStacks - ArrayList of ItemStacks (Blocks of origin).
+// *
+// * @return double.
+// * */
+// private double getSellMoney(Player p, ArrayList itemStacks){
+// HashMap xMaterialIntegerHashMap = getXMaterialsHashMapFromArrayList(itemStacks);
+// return getSellMoney(p, xMaterialIntegerHashMap);
+// }
+
+
+ public double getPlayerInventoryValue( SpigotPlayer sPlayer ) {
+ double value = 0;
+
+ double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
- double multiplier = getPlayerMultiplier(p);
-
-
- double earned = 0;
- for (HashMap.Entry xMatEntry : xMaterialIntegerHashMap.entrySet()){
- if (sellAllBlocks.containsKey(xMatEntry.getKey())){
- // This is stupid but right now I'm too confused, sorry.
- if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMatEntry.getKey().name())){
- // Nothing will change.
- }
- else {
- XMaterial xMat = xMatEntry.getKey();
- int qty = xMatEntry.getValue();
- double value = sellAllBlocks.get(xMat);
-
- if ( debug ) {
-
- if ( sb.length() > 0 ) {
- sb.append(", ");
- }
- sb.append( xMat.name().toLowerCase() ).append(":")
- .append( qty ).append("@").append(value);
- }
-
- earned += qty * value;
- }
- }
- }
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
- double total = earned * multiplier;
-
- if ( debug ) {
- DecimalFormat dFmt = Prison.get().getDecimalFormat( "#,##0.00" );
- sb.append( " earned: " ).append( dFmt.format(earned) )
- .append( " mult: " ).append( dFmt.format(multiplier) )
- .append( " total: " ).append( dFmt.format(total) );
- String message = String.format(
- "Sellall.getSellMoney: %s %s",
- p.getName(), sb.toString() );
- Output.get().logInfo(message);
- }
-
- return total;
+ List soldItems = valueOfInventoryItems( spInventory, multiplier );
+ for (SellAllData soldItem : soldItems) {
+ value += soldItem.getTransactionAmount();
+ }
+
+ return value;
}
-
- /**
- * Get SellAll Money to give, it requires Player because of SellAll perBlockPermission as an option.
- * NOTE: This WON'T remove blocks from the ArrayList when sold, and won't edit Inventories of Players,
- * but only return the amount of money that the Player would get if he sells now everything from the
- * specified ArrayList of ItemStacks.
- *
- * Will also calculate the Multiplier of the Player.
- *
- * Get SellAll Sell value of ArrayList of itemstack.
- * NOTE: If there aren't blocks in the SellAll shop this will return 0.
- * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
- *
- * @param p - Player.
- * @param itemStacks - ArrayList of ItemStacks (Blocks of origin).
- *
- * @return double.
- * */
- public double getSellMoney(Player p, ArrayList itemStacks){
- HashMap xMaterialIntegerHashMap = getXMaterialsHashMapFromArrayList(itemStacks);
- return getSellMoney(p, xMaterialIntegerHashMap);
+
+ public String getPlayerInventoryValueReport( SpigotPlayer sPlayer ) {
+
+ double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+ List soldItems = valueOfInventoryItems( spInventory, multiplier );
+
+ String report = SellAllData.itemsSoldReport(soldItems, sPlayer, multiplier);
+
+ return report;
}
-
- /**
- * Get SellAll Sell Money, calculated from all the enabled backpacks (from sellAll config and integrations) and
- * main inventory.
- * NOTE: This WON'T remove blocks from Inventories/Backpacks, but only return their value.
- *
- * Will also calculate the Multiplier of the Player.
- *
- * NOTE: If there aren't blocks in the SellAll shop this will return 0.
- * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
- *
- * @param p - Player.
- *
- * @return double.
- * */
- public double getSellMoney(Player p){
-
- if (sellAllBlocks.isEmpty()){
- return 0;
- }
-
- return getSellMoney(p, getHashMapOfPlayerInventories(p));
+
+ public double getItemStackValue( SpigotPlayer player, SpigotItemStack itemStack ) {
+
+ double multiplier = getPlayerMultiplier(player.getWrapper());
+
+ SellAllData sad = sellItemStack( itemStack, multiplier );
+
+ return sad.getTransactionAmount();
}
- /**
- *
This sells a specific item stack. Actually it returns the value of an item stack,
- * its up to the calling function to dispose of the contents if the result is non-zero.
- *
- * @param p
- * @param itemStack
- * @return
- */
- public double getSellMoney( Player p, SpigotItemStack itemStack )
- {
- double results = 0d;
+ public String getItemStackValueReport( SpigotPlayer sPlayer, SpigotItemStack itemStack ) {
- // Either ignore custom names, or if isSellAllIgnoreCustomNames is set, then allow them
- // to be processed as they used to be processed.
+ double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
- // For now, do not sell custom blocks since this sellall is based upon
- // XMaterial and custom blocks cannot be represented by XMaterial so
- // it will sell it as the wrong material
- if ( isSellAllIgnoreCustomNames ||
- itemStack.getMaterial().getBlockType() == null ||
- itemStack.getMaterial().getBlockType() == PrisonBlockType.minecraft ) {
-
- HashMap xMaterialIntegerHashMap = new HashMap<>();
+ List soldItems = new ArrayList<>();
+
+ SellAllData sad = sellItemStack( itemStack, multiplier );
+ if ( sad != null ) {
- PrisonBlock pBlock = itemStack.getMaterial();
+ soldItems.add( sad );
+ }
+
+ String report = SellAllData.itemsSoldReport(soldItems, sPlayer, multiplier);
+
+ return report;
+ }
+
+ private List sellPlayerItems(Player p) {
+
+ double multiplier = getPlayerMultiplier(p);
+
+ SpigotPlayer sPlayer = new SpigotPlayer( p );
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+ return sellInventoryItems( spInventory, multiplier );
+ }
+
+ private List sellInventoryItems( tech.mcprison.prison.internal.inventory.Inventory inventory, double multiplier ) {
+ List soldItems = new ArrayList<>();
+
+ if ( inventory != null ) {
- XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( pBlock );
+ List removable = new ArrayList<>();
- if ( xMat != null ) {
- xMaterialIntegerHashMap.put( xMat, itemStack.getAmount() );
+ // Go through all of the player's inventory and identify what can be sold.
+ // 1. if it can be sold, then create a SellAllData "receipt"
+ // 2. Add sad to the soldItems List
+ // 3. Add the ItemStack to the removable List to be removed later
+ for ( tech.mcprison.prison.internal.ItemStack inv : inventory.getItems() ) {
- results = getSellMoney( p, xMaterialIntegerHashMap );
+ SellAllData sad = sellItemStack( (SpigotItemStack)inv, multiplier );
+
+ if ( sad != null ) {
+ soldItems.add(sad);
+
+ removable.add(inv);
+ }
+ }
+
+ // We've identified all that could be sold, now remove them from the player's inventory
+ for (tech.mcprison.prison.internal.ItemStack itemStack : removable) {
+ inventory.removeItem( itemStack );
}
}
+ return soldItems;
+ }
+
+ private List valueOfInventoryItems(
+ tech.mcprison.prison.internal.inventory.Inventory inventory, double multiplier ) {
+ List soldItems = new ArrayList<>();
- return results;
- }
-
+ if ( inventory != null ) {
+
+ for ( tech.mcprison.prison.internal.ItemStack inv : inventory.getItems() ) {
+
+ SellAllData sad = sellItemStack( (SpigotItemStack)inv, multiplier );
+
+ if ( sad != null ) {
+ soldItems.add(sad);
+ }
+ }
+ }
+
+ return soldItems;
+ }
/**
- *
This gets the player's inventory, ignoring the armor slots.
+ *
This takes an SpigotItemStack and generates a SellAllData items with
+ * the transaction amount based upon how many items are in the itemStack,
+ * times the salePrice, times the player's multiplier.
+ * This function DOES NOT remove anything from any ItemStack, any Inventory,
+ * or any player's inventory. This just generates the transaction.
+ *
*
- * @param p
+ * @param iStack
+ * @param multiplier
* @return
*/
- private List getPlayerInventory( Player p ) {
+ private SellAllData sellItemStack( SpigotItemStack iStack, double multiplier ) {
+ SellAllData soldItem = null;
- return getPlayerInventory( p.getInventory() );
+ if ( iStack != null ) {
+
+ PrisonBlock pBlockInv = iStack.getMaterial();
+ PrisonBlock pBlockSellAll = sellAllItems.get( pBlockInv.getBlockName().toLowerCase() );
+
+ if ( pBlockSellAll != null ) {
+ double amount = iStack.getAmount() * pBlockSellAll.getSalePrice() * multiplier;
+ soldItem = new SellAllData( pBlockSellAll, iStack.getAmount(), amount );
+
+ }
+ }
-// List results = new ArrayList<>();
+ return soldItem;
+ }
+
+// /**
+// * Get SellAll Sell Money, calculated from all the enabled backpacks (from sellAll config and integrations) and
+// * main inventory.
+// * NOTE: This WON'T remove blocks from Inventories/Backpacks, but only return their value.
+// *
+// * Will also calculate the Multiplier of the Player.
+// *
+// * NOTE: If there aren't blocks in the SellAll shop this will return 0.
+// * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
+// *
+// * @param p - Player.
+// *
+// * @return double.
+// * */
+// public double getSellMoney(Player p){
+//
+// if (sellAllItems.isEmpty()){
+// return 0;
+// }
+//
+// return getSellMoney(p, getHashMapOfPlayerInventories(p));
+// }
+
+// /**
+// *
This sells a specific item stack. Actually it returns the value of an item stack,
+// * its up to the calling function to dispose of the contents if the result is non-zero.
+// *
+// * @param p
+// * @param itemStack
+// * @return
+// */
+// private double getSellMoney( Player p, SpigotItemStack itemStack )
+// {
+// double results = 0d;
//
-// PlayerInventory inv = p.getInventory();
+// // Either ignore custom names, or if isSellAllIgnoreCustomNames is set, then allow them
+// // to be processed as they used to be processed.
+//
+// // For now, do not sell custom blocks since this sellall is based upon
+// // XMaterial and custom blocks cannot be represented by XMaterial so
+// // it will sell it as the wrong material
+// if ( isSellAllIgnoreCustomNames ||
+// itemStack.getMaterial().getBlockType() == null ||
+// itemStack.getMaterial().getBlockType() == PrisonBlockType.minecraft ) {
+//
+// HashMap xMaterialIntegerHashMap = new HashMap<>();
+//
+// PrisonBlock pBlock = itemStack.getMaterial();
+//
+// XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( pBlock );
+//
+// if ( xMat != null ) {
+// xMaterialIntegerHashMap.put( xMat, itemStack.getAmount() );
+//
+// results = getSellMoney( p, xMaterialIntegerHashMap );
+// }
+// }
//
-// for ( ItemStack iStack : inv.getStorageContents() ) {
+//
+// return results;
+// }
+
+
+// /**
+// *
This gets the player's inventory, ignoring the armor slots.
+// *
+// * @param p
+// * @return
+// */
+// private List getPlayerInventory( Player p ) {
+//
+// return getPlayerInventory( p.getInventory() );
+//
+//// List results = new ArrayList<>();
+////
+//// PlayerInventory inv = p.getInventory();
+////
+//// for ( ItemStack iStack : inv.getStorageContents() ) {
+//// if ( iStack != null ) {
+//// results.add(iStack);
+//// }
+//// }
+//// for ( ItemStack iStack : inv.getExtraContents() ) {
+//// if ( iStack != null ) {
+//// results.add(iStack);
+//// }
+//// }
+////
+//// return results;
+// }
+// private List getPlayerInventory( PlayerInventory inv ) {
+// List results = new ArrayList<>();
+//
+// for ( ItemStack iStack : inv.getContents() ) {
// if ( iStack != null ) {
// results.add(iStack);
// }
// }
-// for ( ItemStack iStack : inv.getExtraContents() ) {
+//
+// try {
+// for ( ItemStack iStack : inv.getExtraContents() ) {
+// if ( iStack != null ) {
+// results.add(iStack);
+// }
+// }
+// } catch (NoSuchMethodError e) {
+// // Ignore on older versions of spigot... Spigot 1.8.8 does not have this function.
+// }
+//
+// // then remove the armor ItemStacks:
+// for ( ItemStack iStack : inv.getArmorContents() ) {
// if ( iStack != null ) {
-// results.add(iStack);
+// results.remove(iStack);
// }
// }
//
// return results;
- }
- private List getPlayerInventory( PlayerInventory inv ) {
- List results = new ArrayList<>();
-
- for ( ItemStack iStack : inv.getContents() ) {
- if ( iStack != null ) {
- results.add(iStack);
- }
- }
-
- try {
- for ( ItemStack iStack : inv.getExtraContents() ) {
- if ( iStack != null ) {
- results.add(iStack);
- }
- }
- } catch (NoSuchMethodError e) {
- // Ignore on older versions of spigot... Spigot 1.8.8 does not have this function.
- }
-
- // then remove the armor ItemStacks:
- for ( ItemStack iStack : inv.getArmorContents() ) {
- if ( iStack != null ) {
- results.remove(iStack);
- }
- }
-
- return results;
- }
+// }
- /**
- * Get HashMap with all the items of a Player.
- *
- * Return HashMap of XMaterial-Integer.
- *
- * @param p - Player.
- *
- * @return HashMap - XMaterial-Integer.
- * */
- private HashMap getHashMapOfPlayerInventories(Player p) {
-
- HashMap xMaterialIntegerHashMap = new HashMap<>();
-
- if (isSellAllBackpackItemsEnabled && getBoolean(SpigotPrison.getInstance().getConfig().getString("backpacks"))){
-
- BackpacksUtil backpacksUtil = BackpacksUtil.get();
- if (backpacksUtil.isMultipleBackpacksEnabled()){
- for (String id : backpacksUtil.getBackpacksIDs(p)){
- xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, backpacksUtil.getBackpack(p, id));
- }
- } else {
- String id = null;
- xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap,
- backpacksUtil.getBackpack(p, id));
- }
- }
-
- if (isSellAllMinesBackpacksPluginEnabled && IntegrationMinepacksPlugin.getInstance().isEnabled()){
- Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p);
- if (backpack != null) {
- xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, backpack.getInventory());
- backpack.setChanged();
- backpack.save();
- }
- }
-
- xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, getPlayerInventory( p ));
-// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, p.getInventory());
- return xMaterialIntegerHashMap;
- }
+// /**
+// * Get HashMap with all the items of a Player.
+// *
+// * Return HashMap of XMaterial-Integer.
+// *
+// * @param p - Player.
+// *
+// * @return HashMap - XMaterial-Integer.
+// * */
+// private HashMap getHashMapOfPlayerInventories(Player p) {
+//
+// HashMap xMaterialIntegerHashMap = new HashMap<>();
+//
+// if (isSellAllBackpackItemsEnabled && getBoolean(SpigotPrison.getInstance().getConfig().getString("backpacks"))){
+//
+// BackpacksUtil backpacksUtil = BackpacksUtil.get();
+// if (backpacksUtil.isMultipleBackpacksEnabled()){
+// for (String id : backpacksUtil.getBackpacksIDs(p)){
+// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, backpacksUtil.getBackpack(p, id));
+// }
+// } else {
+// String id = null;
+// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap,
+// backpacksUtil.getBackpack(p, id));
+// }
+// }
+//
+// if (isSellAllMinesBackpacksPluginEnabled && IntegrationMinepacksPlugin.getInstance().isEnabled()){
+// Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p);
+// if (backpack != null) {
+// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, backpack.getInventory());
+// backpack.setChanged();
+// backpack.save();
+// }
+// }
+//
+// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, getPlayerInventory( p ));
+//// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, p.getInventory());
+// return xMaterialIntegerHashMap;
+// }
/**
* Get AutoSell Player toggle if available.
@@ -736,125 +978,70 @@ public void updateConfig(){
// sellAllConfig = SpigotPrison.getInstance().updateSellAllConfig();
}
- /**
- * Init options that will be cached.
- * */
- private void initCachedData() {
- sellAllConfig = SpigotPrison.getInstance().updateSellAllConfig();
-// messages = SpigotPrison.getInstance().getMessagesConfig();
- permissionSellAllSell = sellAllConfig.getString("Options.Sell_Permission");
- permissionBypassSign = sellAllConfig.getString("Options.SellAll_By_Sign_Bypass_Permission");
- permissionUseSign = sellAllConfig.getString("Options.SellAll_Sign_Use_Permission");
- permissionGUI = sellAllConfig.getString("Options.GUI_Permission");
- permissionPlayerGUI = sellAllConfig.getString("Options.Player_GUI_Permission");
- permissionPrefixBlocks = sellAllConfig.getString("Options.Sell_Per_Block_Permission");
- permissionAutoSellPerUserToggleable = sellAllConfig.getString("Options.Full_Inv_AutoSell_PerUserToggleable_Permission");
- permissionItemTrigger = sellAllConfig.getString("Options.ShiftAndRightClickSellAll.Permission");
- sellAllCurrency = sellAllConfig.getString("Options.SellAll_Currency");
- sellAllSoundSuccess = XSound.matchXSound("Options.Sell_Sound_Success_Name").orElse(XSound.ENTITY_PLAYER_LEVELUP).parseSound();
- sellAllSoundFail = XSound.matchXSound("Options.Sell_Sound_Fail_Name").orElse(XSound.BLOCK_ANVIL_PLACE).parseSound();
- sellAllSignTag = Text.translateAmpColorCodes(sellAllConfig.getString("Options.SellAll_Sign_Visible_Tag") );
- sellAllBlocks = initSellAllBlocks();
- sellAllPrestigeMultipliers = initPrestigeMultipliers();
- sellAllItemTriggers = initSellAllItemTrigger();
-// sellAllDisabledWorlds = initSellAllDisabledWorlds();
- defaultMultiplier = Double.parseDouble(sellAllConfig.getString("Options.Multiplier_Default"));
- defaultSellAllDelay = Integer.parseInt(sellAllConfig.getString("Options.Sell_Delay_Seconds"));
- defaultAutoSellEarningNotificationDelay = Integer.parseInt(sellAllConfig.getString("Options.Full_Inv_AutoSell_EarnedMoneyNotificationDelay_Delay_Seconds"));
- isPerBlockPermissionEnabled = getBooleanValue("Options.Sell_Per_Block_Permission_Enabled");
- isAutoSellEnabled = getBooleanValue("Options.Full_Inv_AutoSell");
- isAutoSellNotificationEnabled = getBooleanValue("Options.Full_Inv_AutoSell_Notification");
- isAutoSellEarningNotificationDelayEnabled = getBooleanValue("Options.Full_Inv_AutoSell_EarnedMoneyNotificationDelay_Enabled");
- isAutoSellPerUserToggleable = getBooleanValue("Options.Full_Inv_AutoSell_perUserToggleable");
- isAutoSellPerUserToggleablePermEnabled = getBooleanValue("Options.Full_Inv_AutoSell_perUserToggleable_Need_Perm");
- isSellAllNotificationEnabled = getBooleanValue("Options.Sell_Notify_Enabled");
- isSellAllSoundEnabled = getBooleanValue("Options.Sell_Sound_Enabled");
- isSellAllBackpackItemsEnabled = getBooleanValue("Options.Sell_Prison_BackPack_Items");
- isSellAllMinesBackpacksPluginEnabled = getBooleanValue("Options.Sell_MinesBackPacks_Plugin_Backpack");
- isSellAllDelayEnabled = getBooleanValue("Options.Sell_Delay_Enabled");
- isSellAllSellPermissionEnabled = getBooleanValue("Options.Sell_Permission_Enabled");
- isSellAllItemTriggerEnabled = getBooleanValue("Options.ShiftAndRightClickSellAll.Enabled");
- isSellAllItemTriggerPermissionEnabled = getBooleanValue("Options.ShiftAndRightClickSellAll.PermissionEnabled");
- isSellAllGUIEnabled = getBooleanValue("Options.GUI_Enabled");
- isSellAllPlayerGUIEnabled = getBooleanValue("Options.Player_GUI_Enabled");
- isSellAllGUIPermissionEnabled = getBooleanValue("Options.GUI_Permission_Enabled");
- isSellAllPlayerGUIPermissionEnabled = getBooleanValue("Options.Player_GUI_Permission_Enabled");
- isSellAllMultiplierEnabled = getBooleanValue("Options.Multiplier_Enabled");
- isSellAllPermissionMultiplierOnlyHigherEnabled = getBooleanValue("Options.Multiplier_Permission_Only_Higher");
- isSellAllSignEnabled = getBooleanValue("Options.SellAll_Sign_Enabled");
- isSellAllSignNotifyEnabled = getBooleanValue("Options.SellAll_Sign_Notify");
- isSellAllSignPermissionToUseEnabled = getBooleanValue("Options.SellAll_Sign_Use_Permission_Enabled");
- isSellAllBySignOnlyEnabled = getBooleanValue("Options.SellAll_By_Sign_Only");
- isSellAllHandEnabled = getBooleanValue("Options.SellAll_Hand_Enabled");
-
- isSellAllIgnoreCustomNames = getBooleanValue("Options.SellAll_ignoreCustomNames", false);
- }
-
- private boolean getBooleanValue( String configName ) {
- return getBooleanValue(configName, false);
- }
- private boolean getBooleanValue( String configName, Boolean defaultValue ) {
- boolean results = (defaultValue == null ? false : defaultValue.booleanValue() );
-
- if ( configName != null ) {
- if ( sellAllConfig.isString(configName) ) {
- String boolVal = sellAllConfig.getString(configName);
- if ( boolVal != null ) {
- // Boolean.parseBoolean() also supports yes and no so don't pretest for true/false.
- try {
- results = Boolean.parseBoolean(boolVal);
- } catch (Exception e) {
- // Not a boolean value, so ignore and let the "defaut" value stand
- }
- }
- else {
- // ignore since it's not a boolean value and let the "default" value stand
- }
- }
- else if ( sellAllConfig.isBoolean(configName) ) {
- results = sellAllConfig.getBoolean(configName, results);
- }
- else {
- // Ignore since the config is not boolean or a String that "could" be a boolean
- }
- }
-
- return results;
- }
+
/**
* Loads sellAll blocks from SellAllConfig.yml
* With XMaterials and double values (money).
*
- * @return HashMap XMaterial-Double.
+ * @return HashMap
* */
- public HashMap initSellAllBlocks(){
+ public HashMap initSellAllItems(){
- HashMap sellAllXMaterials = new HashMap<>();
+ HashMap sellAllItems = new HashMap<>();
+
+// HashMap sellAllXMaterials = new HashMap<>();
if (sellAllConfig.getConfigurationSection("Items") == null){
- return sellAllXMaterials;
+ return sellAllItems;
}
for (String key : sellAllConfig.getConfigurationSection("Items").getKeys(false)) {
- String itemID = sellAllConfig.getString("Items." + key + ".ITEM_ID");
-
- Optional iMatOptional = XMaterial.matchXMaterial(itemID);
- XMaterial itemMaterial = iMatOptional.orElse(null);
-
- if (itemMaterial != null) {
- String valueString = sellAllConfig.getString("Items." + key + ".ITEM_VALUE");
- if (valueString != null) {
- try {
- double value = Double.parseDouble(valueString);
- sellAllXMaterials.put(itemMaterial, value);
- } catch (NumberFormatException ignored) {
- }
- }
+ String itemName = key.trim().toUpperCase();
+
+ String itemID = sellAllConfig.getString("Items." + itemName + ".ITEM_ID");
+
+ PrisonBlock pBlock = Prison.get().getPlatform().getPrisonBlock(itemID);
+
+ if ( pBlock != null ) {
+ String saleValueString = sellAllConfig.getString("Items." + itemName + ".ITEM_VALUE");
+ if ( saleValueString != null ) {
+
+ try {
+ double value = Double.parseDouble(saleValueString);
+ pBlock.setSalePrice( value );
+ } catch (NumberFormatException ignored) {
+ }
+ }
+
+ String purchaseValueString = sellAllConfig.getString("Items." + itemName + ".PURCHASE_PRICE");
+ if ( purchaseValueString != null ) {
+
+ try {
+ double value = Double.parseDouble(purchaseValueString);
+ pBlock.setPurchasePrice( value );
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ sellAllItems.put( pBlock.getBlockName().toLowerCase(), pBlock );
}
+
+// Optional iMatOptional = XMaterial.matchXMaterial(itemID);
+// XMaterial itemMaterial = iMatOptional.orElse(null);
+
+// if (itemMaterial != null) {
+// String valueString = sellAllConfig.getString("Items." + key.trim().toUpperCase() + ".ITEM_VALUE");
+// if (valueString != null) {
+// try {
+// double value = Double.parseDouble(valueString);
+// sellAllXMaterials.put(itemMaterial, value);
+// } catch (NumberFormatException ignored) {
+// }
+// }
+// }
}
- return sellAllXMaterials;
+ return sellAllItems;
}
/**
@@ -921,21 +1108,47 @@ public ArrayList initSellAllItemTrigger(){
* @return boolean.
* */
public boolean addSellAllBlock(XMaterial xMaterial, double value){
+
+ PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMaterial.name() );
+ if ( pBlockKey == null ) {
+ Output.get().logDebug( "sellall add: invalid block name (%s)", xMaterial.name());
+ return false;
+ }
+ String key = pBlockKey.getBlockName().toLowerCase();
+
+ PrisonBlock pBlock = sellAllItems.get( key );
+
+ // If that is an invalid PrisonBlock, then exit
+ if ( pBlock != null ) {
+ Output.get().logDebug( "sellall add: block already exists (%s)", xMaterial.name());
+ return false;
+ }
+
try {
+
+ String itemName = pBlockKey.getBlockName().toUpperCase();
+
File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
- conf.set("Items." + xMaterial.name() + ".ITEM_ID", xMaterial.name());
- conf.set("Items." + xMaterial.name() + ".ITEM_VALUE", value);
+ conf.set("Items." + itemName + ".ITEM_ID", xMaterial.name());
+ conf.set("Items." + itemName + ".ITEM_VALUE", value);
if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) {
- conf.set("Items." + xMaterial.name() + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + xMaterial.name());
+ String itemPerm = "Items." + itemName + ".ITEM_PERMISSION";
+ conf.set( itemPerm, sellAllConfig.getString("Options.Sell_Per_Block_Permission") + xMaterial.name());
}
conf.save(sellAllFile);
+ updateConfig();
+
+ pBlockKey.setSalePrice( value );
+ sellAllItems.put( pBlockKey.getBlockName().toLowerCase(), pBlockKey );
+
} catch (IOException e) {
e.printStackTrace();
return false;
}
- updateConfig();
- sellAllBlocks.put(xMaterial, value);
+
+
+// sellAllBlocks.put(xMaterial, value);
return true;
}
@@ -1047,7 +1260,7 @@ public boolean addItemTrigger(XMaterial xMaterial){
// /**
// * BUG: With Spigot versions less than 1.13 bukkit's Material will not work on all Materials since
-// * varient data is stored in the ItemStack. SO must use the XMaterial version of this function.
+// * variant data is stored in the ItemStack. SO must use the XMaterial version of this function.
// *
// * Add SellAll Item Trigger.
// *
@@ -1111,54 +1324,54 @@ public void addDelayedEarningAutoSellNotification(Player p, double value){
}
}
- private HashMap addInventoryToHashMap(HashMap xMaterialIntegerHashMap, Inventory inv) {
-
- List inventory = new ArrayList<>();
-
- for (ItemStack itemStack : inv.getContents()){
- if (itemStack != null){
- inventory.add(itemStack);
- }
- }
-
- return addInventoryToHashMap( xMaterialIntegerHashMap, inventory );
-
-// for (ItemStack itemStack : inv.getContents()){
+// private HashMap addInventoryToHashMap(HashMap xMaterialIntegerHashMap, Inventory inv) {
+//
+// List inventory = new ArrayList<>();
+//
+// for (ItemStack itemStack : inv.getContents()){
// if (itemStack != null){
-// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-//
-// if ( xMaterial != null ) {
-//
-// if (xMaterialIntegerHashMap.containsKey(xMaterial)){
-// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
-// }
-// else {
-// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
-// }
-// }
+// inventory.add(itemStack);
// }
-// }
-// return xMaterialIntegerHashMap;
- }
+// }
+//
+// return addInventoryToHashMap( xMaterialIntegerHashMap, inventory );
+//
+//// for (ItemStack itemStack : inv.getContents()){
+//// if (itemStack != null){
+//// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+////
+//// if ( xMaterial != null ) {
+////
+//// if (xMaterialIntegerHashMap.containsKey(xMaterial)){
+//// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
+//// }
+//// else {
+//// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
+//// }
+//// }
+//// }
+//// }
+//// return xMaterialIntegerHashMap;
+// }
- private HashMap addInventoryToHashMap(HashMap xMaterialIntegerHashMap, List inv) {
- for (ItemStack itemStack : inv){
- if (itemStack != null){
- XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-
- if ( xMaterial != null ) {
-
- if (xMaterialIntegerHashMap.containsKey(xMaterial)){
- xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
- }
- else {
- xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
- }
- }
- }
- }
- return xMaterialIntegerHashMap;
- }
+// private HashMap addInventoryToHashMap(HashMap xMaterialIntegerHashMap, List inv) {
+// for (ItemStack itemStack : inv){
+// if (itemStack != null){
+// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+//
+// if ( xMaterial != null ) {
+//
+// if (xMaterialIntegerHashMap.containsKey(xMaterial)){
+// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
+// }
+// else {
+// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
+// }
+// }
+// }
+// }
+// return xMaterialIntegerHashMap;
+// }
/**
* Check if Player meets requirements to use SellAll.
@@ -1211,26 +1424,54 @@ public boolean canPlayerSell(Player p, boolean isUsingSign){
* */
public boolean editPrice(XMaterial xMaterial, double value){
+ PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMaterial.name() );
+ String key = pBlockKey.getBlockName().toLowerCase();
+
+ PrisonBlock pBlock = sellAllItems.get( key );
+
// Do not allow an edit price if the material does not exist, or if the value has not changed:
- if (!sellAllBlocks.containsKey(xMaterial) && sellAllBlocks.get(xMaterial) != value ){
+ if ( pBlock == null ){
+
+ Output.get().logDebug( "sellall edit: item does not exist in shop so it cannot be edited (%s)", pBlockKey.getBlockName());
return false;
}
+ if ( pBlock.getSalePrice() == value ){
+ DecimalFormat dFmt = new DecimalFormat("#,##0.00");
+ Output.get().logDebug( "sellall edit: No change in price (%s:%s)",
+ pBlockKey.getBlockName(), dFmt.format(value) );
+ return false;
+ }
+
+ pBlock.setSalePrice( value );
try {
File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
- conf.set("Items." + xMaterial.name() + ".ITEM_ID", xMaterial.name());
- conf.set("Items." + xMaterial.name() + ".ITEM_VALUE", value);
+
+ String itemName = key.toUpperCase();
+ conf.set("Items." + itemName + ".ITEM_ID", key );
+ conf.set("Items." + itemName + ".ITEM_VALUE", value);
+
+ if ( pBlock.getPurchasePrice() != null ) {
+
+ conf.set("Items." + itemName + ".PURCHASE_PRICE", pBlock.getPurchasePrice().doubleValue() );
+ }
+
if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) {
- conf.set("Items." + xMaterial + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + xMaterial.name());
+ conf.set("Items." + itemName + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + itemName );
}
conf.save(sellAllFile);
+
+ // Update only if successful
+ updateConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
}
- updateConfig();
- sellAllBlocks.put(xMaterial, value);
+
+ // pBlock is still in the sellAllItems collection so no need to readd it
+// sellAllBlocks.put(xMaterial, value);
+
return true;
}
@@ -1279,21 +1520,29 @@ public boolean editPrestigeMultiplier(String prestigeName, double multiplier) {
* */
public boolean removeSellAllBlock(XMaterial xMaterial){
- if (!sellAllBlocks.containsKey(xMaterial)){
+ PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMaterial.name() );
+ String key = pBlockKey.getBlockName().toLowerCase();
+
+ PrisonBlock pBlock = sellAllItems.get( key );
+
+ if ( pBlock == null ){
return false;
}
try {
File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
- conf.set("Items." + xMaterial.name(), null);
+ conf.set("Items." + pBlock.getBlockName().toUpperCase(), null);
conf.save(sellAllFile);
+
+ updateConfig();
} catch (IOException e) {
e.printStackTrace();
return false;
}
- updateConfig();
- sellAllBlocks.remove(xMaterial);
+
+ sellAllItems.remove( key );
+// sellAllBlocks.remove(xMaterial);
return true;
}
@@ -1387,197 +1636,254 @@ public boolean removeItemTrigger(XMaterial xMaterial){
// return removeItemTrigger(XMaterial.matchXMaterial(material));
// }
- /**
- * Remove Sellable Blocks from HashMap of XMaterial-Integer given as a parameter.
- * NOTE: If there aren't blocks in the SellAll shop, nothing will change.
- * NOTE: This method will remove blocks from the HashMap, but it WON'T return the value of money, for that please use
- * the getSellAllSellMoney method.
- *
- * @param p - Player.
- * @param xMaterialIntegerHashMap - HashMap of XMaterial-Integer (Blocks of origin).
- *
- *
- * @return HashMap - XMaterial-Integer.
- * */
- public HashMap removeSellableItems(Player p, HashMap xMaterialIntegerHashMap){
-
- if (sellAllBlocks.isEmpty()){
- return xMaterialIntegerHashMap;
- }
-
- /* Not necessary now, as this only removes what's sellable, this should be checked in another place before.
- if (isPlayerInDisabledWorld(p)){
- return xMaterialIntegerHashMap;
- }
- */
-
- for (HashMap.Entry xMaterialIntegerEntry : xMaterialIntegerHashMap.entrySet()){
- if (sellAllBlocks.containsKey(xMaterialIntegerEntry.getKey())){
- // This is stupid but right now I'm too confused, sorry.
- if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMaterialIntegerEntry.getKey().name())){
- // Nothing will happen.
- } else {
- xMaterialIntegerHashMap.remove(xMaterialIntegerEntry.getKey());
- }
- }
- }
-
- return xMaterialIntegerHashMap;
- }
-
- /**
- * Remove Sellable Blocks from ArrayList of ItemStacks given as a parameter.
- * NOTE: If there aren't blocks in the SellAll shop, nothing will change.
- * NOTE: This method will remove blocks from the HashMap, but it WON'T return the value of money, for that please use
- * the getSellAllSellMoney method.
- *
- * @param p - Player.
- * @param itemStacks - ItemStacks.
- *
- * @return ArrayList - ItemStacks.
- * */
- public ArrayList removeSellableItems(Player p, ArrayList itemStacks){
-
- if (sellAllBlocks.isEmpty()){
- return itemStacks;
- }
-
- HashMap xMaterialIntegerHashMap = getXMaterialsHashMapFromArrayList(itemStacks);
-
- xMaterialIntegerHashMap = removeSellableItems(p, xMaterialIntegerHashMap);
-
- ArrayList newItemStacks = new ArrayList<>();
- for (HashMap.Entry xMaterialIntegerEntry : xMaterialIntegerHashMap.entrySet()){
-
- // WARNING: Cannot convert XMaterial to a Material then ItemStack or it will fail on variants
- // for spigot versions less than 1.13:
-
- ItemStack iStack = xMaterialIntegerEntry.getKey().parseItem();
- if ( iStack != null ) {
- iStack.setAmount( xMaterialIntegerEntry.getValue() );
- newItemStacks.add( iStack );
- }
-
-// Material material = xMaterialIntegerEntry.getKey().parseMaterial();
-// if (material != null) {
-// newItemStacks.add(new ItemStack(material, xMaterialIntegerEntry.getValue()));
+// /**
+// * Remove Sellable Blocks from HashMap of XMaterial-Integer given as a parameter.
+// * NOTE: If there aren't blocks in the SellAll shop, nothing will change.
+// * NOTE: This method will remove blocks from the HashMap, but it WON'T return the value of money, for that please use
+// * the getSellAllSellMoney method.
+// *
+// * @param p - Player.
+// * @param xMaterialIntegerHashMap - HashMap of XMaterial-Integer (Blocks of origin).
+// *
+// *
+// * @return HashMap - XMaterial-Integer.
+// * */
+// public HashMap removeSellableItems(Player p, HashMap xMaterialIntegerHashMap){
+//
+// if (sellAllItems.isEmpty()){
+// return xMaterialIntegerHashMap;
+// }
+//
+// /* Not necessary now, as this only removes what's sellable, this should be checked in another place before.
+// if (isPlayerInDisabledWorld(p)){
+// return xMaterialIntegerHashMap;
+// }
+// */
+//
+// for (HashMap.Entry xMaterialIntegerEntry : xMaterialIntegerHashMap.entrySet()){
+//
+// XMaterial xMaterial = xMaterialIntegerEntry.getKey();
+// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMaterial.name() );
+// String key = pBlockKey.getBlockName();
+//
+// PrisonBlock pBlock = sellAllItems.get( key );
+//
+// if ( pBlock != null ){
+// // This is stupid but right now I'm too confused, sorry.
+// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + pBlock.getBlockName().toUpperCase() )){
+// // Nothing will happen.
+// } else {
+// xMaterialIntegerHashMap.remove( xMaterial );
+// }
// }
- }
+// }
+//
+// return xMaterialIntegerHashMap;
+// }
- return newItemStacks;
- }
-
- /**
- * Remove Sellable blocks from an Inventory of a Player.
- *
- * Return an Inventory with the unsold items.
- *
- * @param p - Player.
- * @param inv - Inventory.
- *
- * @return inv - Inventory.
- * */
- public Inventory removeSellableItems(Player p, Inventory inv){
- if (sellAllBlocks.isEmpty()){
- return inv;
- }
-
- SpigotCompatibility.getInstance().getItemInOffHand( p );
-
- List removeable = new ArrayList<>();
-
- for (ItemStack itemStack : inv.getContents()){
- if (itemStack != null){
- try {
- XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-
- if ( xMaterial != null && sellAllBlocks.containsKey(xMaterial)) {
- if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMaterial.name())) {
- // Nothing will change.
- } else {
- removeable.add( itemStack );
-// inv.remove(itemStack);
- }
- }
- } catch (IllegalArgumentException ignored){}
- }
- }
-
- for ( ItemStack remove : removeable )
- {
- inv.remove(remove);
- }
-
- return inv;
- }
+// /**
+// * Remove Sellable Blocks from ArrayList of ItemStacks given as a parameter.
+// * NOTE: If there aren't blocks in the SellAll shop, nothing will change.
+// * NOTE: This method will remove blocks from the HashMap, but it WON'T return the value of money, for that please use
+// * the getSellAllSellMoney method.
+// *
+// * @param p - Player.
+// * @param itemStacks - ItemStacks.
+// *
+// * @return ArrayList - ItemStacks.
+// * */
+// private ArrayList removeSellableItems(Player p, ArrayList itemStacks){
+//
+// if (sellAllItems.isEmpty()){
+// return itemStacks;
+// }
+//
+// HashMap xMaterialIntegerHashMap = getXMaterialsHashMapFromArrayList(itemStacks);
+//
+// xMaterialIntegerHashMap = removeSellableItems(p, xMaterialIntegerHashMap);
+//
+// ArrayList newItemStacks = new ArrayList<>();
+// for (HashMap.Entry xMaterialIntegerEntry : xMaterialIntegerHashMap.entrySet()){
+//
+// // WARNING: Cannot convert XMaterial to a Material then ItemStack or it will fail on variants
+// // for spigot versions less than 1.13:
+//
+// ItemStack iStack = xMaterialIntegerEntry.getKey().parseItem();
+// if ( iStack != null ) {
+// iStack.setAmount( xMaterialIntegerEntry.getValue() );
+// newItemStacks.add( iStack );
+// }
+//
+//// Material material = xMaterialIntegerEntry.getKey().parseMaterial();
+//// if (material != null) {
+//// newItemStacks.add(new ItemStack(material, xMaterialIntegerEntry.getValue()));
+//// }
+// }
+//
+// return newItemStacks;
+// }
- public void removeSellableItemsInOffHand(Player p){
-
-
- ItemStack itemStack = SpigotCompatibility.getInstance().getItemInOffHand( p );
-
- if ( itemStack != null ) {
-
- if (itemStack != null){
- try {
- XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-
- if ( xMaterial != null && sellAllBlocks.containsKey(xMaterial)) {
- if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMaterial.name())) {
- // Nothing will change.
- }
- else {
-
- SpigotPlayerInventory spInventory = new SpigotPlayerInventory( p.getInventory() ) ;
- SpigotItemStack sItemStack = new SpigotItemStack( new ItemStack( Material.AIR ) );
-
- SpigotCompatibility.getInstance().setItemStackInOffHand( spInventory, sItemStack );
-
- }
- }
- } catch (IllegalArgumentException ignored){}
- }
- }
-
+// /**
+// * Remove Sellable blocks from an Inventory of a Player.
+// *
+// * Return an Inventory with the unsold items.
+// *
+// * @param p - Player.
+// * @param inv - Inventory.
+// *
+// * @return inv - Inventory.
+// * */
+// private Inventory removeSellableItems(Player p, Inventory inv){
+// if (sellAllItems.isEmpty()){
+// return inv;
+// }
+//
+// // ?? why?
+//// SpigotCompatibility.getInstance().getItemInOffHand( p );
+//
+// List removeable = new ArrayList<>();
+//
+// SpigotInventory sInv = new SpigotInventory( inv );
+//
+// for (tech.mcprison.prison.internal.ItemStack itemStack : sInv.getItems()) {
+// if (itemStack != null){
+// try {
+// PrisonBlock pBlock = itemStack.getMaterial();
+//
+//
+//// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+//
+// if ( pBlock != null && sellAllItems.containsKey( pBlock.getBlockName() )) {
+// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + pBlock.getBlockName().toUpperCase() )) {
+// // Nothing will change.
+// } else {
+// removeable.add( ((SpigotItemStack) itemStack).getBukkitStack() );
+//// inv.remove(itemStack);
+// }
+// }
+// } catch (IllegalArgumentException ignored){}
+// }
+// }
+//
+//// for (ItemStack itemStack : inv.getContents()){
+//// if (itemStack != null){
+//// try {
+//// PrisonBlock
+////
+////
+//// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+////
+//// if ( xMaterial != null && sellAllBlocks.containsKey(xMaterial)) {
+//// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMaterial.name())) {
+//// // Nothing will change.
+//// } else {
+//// removeable.add( itemStack );
+////// inv.remove(itemStack);
+//// }
+//// }
+//// } catch (IllegalArgumentException ignored){}
+//// }
+//// }
+//
+// for ( ItemStack remove : removeable )
+// {
+// inv.remove(remove);
+// }
+//
+// return inv;
+// }
- }
+// private void removeSellableItemsInOffHand(Player p){
+//
+//
+//
+// SpigotItemStack sItemStack = SpigotCompatibility.getInstance().getPrisonItemInOffHand( p );
+//
+// if ( sItemStack != null ) {
+//
+// PrisonBlock pBlock = sItemStack.getMaterial();
+//
+// if ( pBlock != null && sellAllItems.containsKey( pBlock.getBlockName() )) {
+// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + pBlock.getBlockName().toUpperCase() )) {
+// // Nothing will change.
+// } else {
+//
+// SpigotPlayer sPlayer = new SpigotPlayer( p );
+// SpigotPlayerInventory spInventory = (SpigotPlayerInventory) sPlayer.getInventory();
+//
+// SpigotItemStack sItemStackAir = (SpigotItemStack) PrisonBlock.AIR.getItemStack( 1 );
+//
+// SpigotCompatibility.getInstance().setItemStackInOffHand( spInventory, sItemStackAir );
+// }
+// }
+// }
+//
+//
+//
+//// ItemStack itemStack = SpigotCompatibility.getInstance().getItemInOffHand( p );
+////
+//// if ( itemStack != null ) {
+////
+//// if (itemStack != null){
+//// try {
+//// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+////
+//// if ( xMaterial != null && sellAllBlocks.containsKey(xMaterial)) {
+//// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMaterial.name())) {
+//// // Nothing will change.
+//// }
+//// else {
+////
+//// SpigotPlayerInventory spInventory = new SpigotPlayerInventory( p.getInventory() ) ;
+//// SpigotItemStack sItemStack = new SpigotItemStack( new ItemStack( Material.AIR ) );
+////
+//// SpigotCompatibility.getInstance().setItemStackInOffHand( spInventory, sItemStack );
+////
+//// }
+//// }
+//// } catch (IllegalArgumentException ignored){}
+//// }
+//// }
+//
+//
+// }
- /**
- * Remove Sellable blocks from all Player inventories directly hooked.
- *
- * @param p - Player.
- * */
- public void removeSellableItems(Player p){
-
- if (sellAllBlocks.isEmpty()){
- return;
- }
-
- if (isSellAllBackpackItemsEnabled && getBoolean(SpigotPrison.getInstance().getConfig().getString("backpacks"))){
- BackpacksUtil backpacksUtil = BackpacksUtil.get();
- if (backpacksUtil.isMultipleBackpacksEnabled()){
- for (String id : backpacksUtil.getBackpacksIDs(p)){
- backpacksUtil.setInventory(p, removeSellableItems(p, backpacksUtil.getBackpack(p, id)), id);
- }
- } else {
- String id = null;
- backpacksUtil.setInventory(p, removeSellableItems(p, backpacksUtil.getBackpack(p, id)), id);
- }
- }
-
- if (isSellAllMinesBackpacksPluginEnabled && IntegrationMinepacksPlugin.getInstance().isEnabled()){
- Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p);
- if (backpack != null) {
- removeSellableItems(p, backpack.getInventory());
- backpack.setChanged();
- backpack.save();
- }
- }
-
- removeSellableItems(p, p.getInventory());
-
- removeSellableItemsInOffHand( p );
- }
+// /**
+// * Remove Sellable blocks from all Player inventories directly hooked.
+// *
+// * @param p - Player.
+// * */
+// private void removeSellableItems(Player p){
+//
+// if (sellAllItems.isEmpty()){
+// return;
+// }
+//
+// if (isSellAllBackpackItemsEnabled && getBoolean(SpigotPrison.getInstance().getConfig().getString("backpacks"))){
+// BackpacksUtil backpacksUtil = BackpacksUtil.get();
+// if (backpacksUtil.isMultipleBackpacksEnabled()){
+// for (String id : backpacksUtil.getBackpacksIDs(p)){
+// backpacksUtil.setInventory(p, removeSellableItems(p, backpacksUtil.getBackpack(p, id)), id);
+// }
+// } else {
+// String id = null;
+// backpacksUtil.setInventory(p, removeSellableItems(p, backpacksUtil.getBackpack(p, id)), id);
+// }
+// }
+//
+// if (isSellAllMinesBackpacksPluginEnabled && IntegrationMinepacksPlugin.getInstance().isEnabled()){
+// Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p);
+// if (backpack != null) {
+// removeSellableItems(p, backpack.getInventory());
+// backpack.setChanged();
+// backpack.save();
+// }
+// }
+//
+// removeSellableItems(p, p.getInventory());
+//
+// removeSellableItemsInOffHand( p );
+// }
/**
* Remove Player from delay.
@@ -1833,13 +2139,20 @@ public boolean setDelay(int delay){
*
* @return boolean If successful
* */
- public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySilent, boolean notifyPlayerEarned,
- boolean notifyPlayerDelay, boolean notifyPlayerEarningDelay, boolean playSoundOnSellAll){
+ public boolean sellAllSell(Player p,
+ boolean isUsingSign, boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay, boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll) {
return sellAllSell( p, isUsingSign, completelySilent, notifyPlayerEarned, notifyPlayerDelay,
notifyPlayerEarningDelay, playSoundOnSellAll, null );
}
- public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySilent, boolean notifyPlayerEarned,
- boolean notifyPlayerDelay, boolean notifyPlayerEarningDelay, boolean playSoundOnSellAll, List amounts ){
+
+ public boolean sellAllSell(Player p,
+ boolean isUsingSign, boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay, boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll, List amounts ){
if (!isUsingSign && isSellAllSignEnabled && isSellAllBySignOnlyEnabled && !p.hasPermission(permissionBypassSign)){
if (!completelySilent) {
@@ -1859,7 +2172,7 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile
return false;
}
- if (sellAllBlocks.isEmpty()){
+ if (sellAllItems.isEmpty()){
if (!completelySilent){
sellallShopIsEmptyMsg( new SpigotCommandSender(p) );
@@ -1867,9 +2180,24 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile
}
return false;
}
+
+
+
+ double money = 0;
+ double multiplier = getPlayerMultiplier(p);
+
+ List soldItems = sellPlayerItems(p);
+
+ for (SellAllData soldItem : soldItems) {
+ money += soldItem.getTransactionAmount();
+ }
+
+ SellAllData.debugItemsSold( soldItems, new SpigotPlayer( p ), multiplier );
+
+
//TODO inventory access: getHashMapOfPlayerInventories() && removeSellableItems(p, p.getInventory());
- double money = getSellMoney(p);
+// double money = getSellMoney(p);
if (money != 0){
if ( amounts != null ) {
@@ -1883,7 +2211,7 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile
//TODO inventory access: getHashMapOfPlayerInventories() && removeSellableItems(p, p.getInventory());
- removeSellableItems(p);
+ //removeSellableItems(p);
SpigotPlayer sPlayer = new SpigotPlayer(p);
@@ -1941,8 +2269,9 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile
}
}
-
- /**
+
+
+ /**
*
This function enables the selling of just one ItemStack and can be used outside of
* the player's inventory, such as processing the drops of tens of thousands of blocks
* worth of drops. This would be much faster than processing the player's inventory.
@@ -1967,7 +2296,24 @@ public double sellAllSell(Player p, SpigotItemStack itemStack,
// long tPoint4 = tPoint1;
// long tPoint5 = tPoint1;
- double money = getSellMoney(p, itemStack);
+
+ double money = 0;
+ double multiplier = getPlayerMultiplier(p);
+
+ List soldItems = new ArrayList<>();
+
+ SellAllData sad = sellItemStack( itemStack, multiplier );
+ if ( sad != null ) {
+ soldItems.add(sad);
+ }
+
+ for (SellAllData soldItem : soldItems) {
+ money += soldItem.getTransactionAmount();
+ }
+
+ SellAllData.debugItemsSold(soldItems, new SpigotPlayer(p), multiplier);
+
+// double money = getSellMoney(p, itemStack);
// tPoint2 = System.nanoTime();
@@ -2062,7 +2408,11 @@ else if (notifyPlayerEarned){
*
* @return boolean.
* */
- public ArrayList sellAllSell(Player p, ArrayList itemStacks, boolean isUsingSign, boolean completelySilent, boolean notifyPlayerEarned, boolean notifyPlayerDelay, boolean notifyPlayerEarningDelay, boolean playSoundOnSellAll, boolean sellInputArrayListOnly){
+ public ArrayList sellAllSell(Player p, ArrayList itemStacks,
+ boolean isUsingSign, boolean completelySilent,
+ boolean notifyPlayerEarned, boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay, boolean playSoundOnSellAll,
+ boolean sellInputArrayListOnly){
if (!isUsingSign && isSellAllSignEnabled && isSellAllBySignOnlyEnabled && !p.hasPermission(permissionBypassSign)){
if (!completelySilent) {
@@ -2081,7 +2431,7 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
return itemStacks;
}
- if (sellAllBlocks.isEmpty()){
+ if (sellAllItems.isEmpty()){
if (!completelySilent){
sellallShopIsEmptyMsg( new SpigotCommandSender(p) );
@@ -2090,17 +2440,58 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
return itemStacks;
}
- double arrayListMoney = getSellMoney(p, itemStacks);
- if (arrayListMoney != 0.00){
- itemStacks = removeSellableItems(p, itemStacks);
+
+ double money = 0;
+ double multiplier = getPlayerMultiplier(p);
+
+ List soldItems = new ArrayList<>();
+
+ ArrayList itemsNotSold = new ArrayList<>();
+
+ for (ItemStack itemStack : itemStacks ) {
+
+ SellAllData sad = sellItemStack( new SpigotItemStack( itemStack ), multiplier );
+ if ( sad != null ) {
+ soldItems.add(sad);
+ }
+ else {
+ itemsNotSold.add( itemStack );
+ }
+ }
+
+ // "return" all items not sold:
+ itemStacks.clear();
+ itemStacks.addAll( itemsNotSold );
+
+
+ // Sell the player's inventory if requested
+ if ( !sellInputArrayListOnly ) {
+ soldItems.addAll( sellPlayerItems(p) );
}
+
+ for (SellAllData soldItem : soldItems) {
+ money += soldItem.getTransactionAmount();
+ }
- double money;
- if (sellInputArrayListOnly){
- money = arrayListMoney;
- } else {
- money = getSellMoney(p) + arrayListMoney;
- }
+
+ SellAllData.debugItemsSold( soldItems, new SpigotPlayer( p ), multiplier );
+
+
+ // Sell only the itemStacks and then remove the ones that were sold:
+// double arrayListMoney = getSellMoney(p, itemStacks);
+// if (arrayListMoney != 0.00){
+// itemStacks = removeSellableItems(p, itemStacks);
+// }
+
+// double money;
+//
+// // If to include the player's inventory, then add that too:
+// if (sellInputArrayListOnly){
+// money = arrayListMoney;
+// } else {
+// // Add the players inventory
+// money = getSellMoney(p) + arrayListMoney;
+// }
if (money != 0){
@@ -2108,9 +2499,9 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName());
if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) sellAllCurrency = null;
- if (!sellInputArrayListOnly) {
- removeSellableItems(p);
- }
+// if (!sellInputArrayListOnly) {
+// removeSellableItems(p);
+// }
rankPlayer.addBalance(sellAllCurrency, money);
if (isSellAllDelayEnabled){
@@ -2153,7 +2544,9 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
return itemStacks;
}
- /**
+
+
+ /**
* Open SellAll GUI to the specified Player.
* NOTE: SellAll GUI must be enabled from the config or nothing will happen.
* NOTE #2: A Player if admin will open another GUI if meets requirements, if not it will try to check
From 28aff3a625cd83cc787d6ac5692c95657da4a3e4 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Thu, 13 Jul 2023 00:31:57 -0400
Subject: [PATCH 013/151] New sellall features: 'sellall valueof' calculates
the value of everything in the player's inventory that can be sold.
'/sellall valueofHand' calculates what is held in the player's hand.
---
docs/changelog_v3.3.x.md | 9 ++
.../commands/PrisonSpigotSellAllCommands.java | 122 ++++++++++++++++++
2 files changed, 131 insertions(+)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index cb0f718bf..e237c9747 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,15 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-13
+* **New sellall features: 'sellall valueof' calculates the value of everything in the player's inventory that can be sold. '/sellall valueofHand' calculates what is held in the player's hand.**
+
+
+* **Major rewrites to sellall to utilize more of Prison's internal classes and to get away from XMaterial since it cannot handle custom blocks.**
+A lot of sellall code has been eliminated, but no loss in functionality. Actually new functions and enhancements have been added.
+Eliminated the two step process of selling... where it first calculated the values, then after the fact, would try to remove the items with no "validation" that the items removed were the items that calculated the sales amount.
+Sellall commands: moved the '/sellall trigger add' and '/sellall trigger remove' to under the '/sell set' section since they were hidden because '/sellall trigger' was a command and many did not realize they have to use the 'help' keyword to show the others.
+
+
* **Updated Prison's PlayerInventory to include 'contents' and 'extraContents' to match the bukkit PlayerInventory object.**
Within the SpigotPlayerInventory class, overrode the behavior of removeItem to ensure that obscure inventory locations are being removed, since there was a bug where you can get all inventory items, then remove them, and they would not remove all occurrences of the items stacks that were initially returned, such as when someone is wearing an item as a hat, or holding something in one of their hands.
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
index b8b5dd928..c8a3b9b66 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
@@ -392,6 +392,128 @@ public void sellAllSell(Player p){
}
+
+
+ @Command(identifier = "sellall valueof",
+ description = "SellAll valueof command will report the total value of the player's inventory "
+ + "without selling anything.", onlyPlayers = false)
+ public void sellAllValueOfCommand(CommandSender sender,
+ @Arg(name = "player", def = "", description = "An online player name to get the value of their inventory - " +
+ "Only console or prison commands can include this parameter") String playerName
+ ){
+
+ if (!isEnabled()) return;
+
+ Player p = getSpigotPlayer(sender);
+
+
+ boolean isOp = sender.isOp();
+
+ tech.mcprison.prison.internal.Player sPlayerAlt = getOnlinePlayer( sender, playerName );
+// if ( sPlayerAlt == null ){
+// // If sPlayerAlt is null then the value in playerName is really intended for notification:
+// notification = playerName;
+// }
+
+ if ( isOp && !sender.isPlayer() && sPlayerAlt != null ) {
+ // Only if OP and a valid player name was provided, then OP is trying to run this
+ // for another player
+
+ if ( !sPlayerAlt.isOnline() ) {
+ sender.sendMessage( "Player is not online." );
+ return;
+ }
+
+ // Set the active player to who OP specified:
+ p = ((SpigotPlayer) sPlayerAlt).getWrapper();
+ }
+
+
+ else if (p == null){
+
+ if ( getPlayer( sender, playerName ) != null ) {
+
+ Output.get().sendInfo(sender, "&cSorry but the specified player must be online "
+ + "[/sellall valueof %s]", playerName );
+ }
+ else {
+
+ Output.get().sendInfo(sender, "&cSorry but you can't use that from the console!");
+ }
+
+
+ return;
+ }
+
+
+ SellAllUtil sellAllUtil = SellAllUtil.get();
+ if (sellAllUtil == null){
+ return;
+ }
+
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+
+ if (sellAllUtil.isSellAllSellPermissionEnabled){
+ String permission = sellAllUtil.permissionSellAllSell;
+ if (permission == null || !p.hasPermission(permission)){
+ Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + permission + "]");
+ return;
+ }
+ }
+
+ SpigotPlayer sPlayer = new SpigotPlayer( p );
+
+ String report = sellAllUtil.getPlayerInventoryValueReport( sPlayer );
+
+
+ sender.sendMessage(report);
+
+ PlayerAutoRankupTask.autoSubmitPlayerRankupTask( sPlayer, null );
+ }
+
+ @Command(identifier = "sellall valueofHand",
+ description = "Get the value of what is in your hand if sellable.",
+ onlyPlayers = true)
+ public void sellAllValueOfHandCommand(CommandSender sender){
+
+ if (!isEnabled()) return;
+
+ SellAllUtil sellAllUtil = SellAllUtil.get();
+
+ if (sellAllUtil == null){
+ return;
+ }
+
+ if (!sellAllUtil.isSellAllHandEnabled){
+ Output.get().sendWarn(sender, "The command /sellall valueofHand is disabled from the config! (SellAllHandEnabled)");
+ return;
+ }
+
+ Player p = getSpigotPlayer(sender);
+
+ if (p == null){
+ Output.get().sendInfo(sender, "&cSorry but you can't use that from the console!");
+ return;
+ }
+
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+
+ if (sellAllUtil.isSellAllSellPermissionEnabled){
+ String permission = sellAllUtil.permissionSellAllSell;
+ if (permission == null || !p.hasPermission(permission)){
+ Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + permission + "]");
+ return;
+ }
+ }
+
+
+ String report = sellAllUtil.getItemStackValueReport(
+ new SpigotPlayer(p), new SpigotItemStack( compat.getItemInMainHand(p)) );
+
+ sender.sendMessage(report);
+ }
+
+
@Command(identifier = "sellall delaysell",
description = "Like SellAll Sell command but this will be delayed for some " +
"seconds and if sellall sell commands are triggered during this delay, " +
From 6f18d2fb191516f1c72ddabdddbdde48cd8909a0 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Thu, 13 Jul 2023 04:40:35 -0400
Subject: [PATCH 014/151] Sellall: Expanded the functionality of the
SellAllData obejcts to indicate if the items were sold.
---
docs/changelog_v3.3.x.md | 3 ++
.../prison/spigot/sellall/SellAllData.java | 38 +++++++++++++------
.../prison/spigot/sellall/SellAllUtil.java | 3 ++
3 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index e237c9747..352a96cf8 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-13
+* **Sellall: Expanded the functionality of the SellAllData obejcts to indicate if the items were sold.**
+
+
* **New sellall features: 'sellall valueof' calculates the value of everything in the player's inventory that can be sold. '/sellall valueofHand' calculates what is held in the player's hand.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
index 4c639edc4..cca21122a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
@@ -20,10 +20,13 @@ public class SellAllData {
private PrisonBlock prisonBlock;
private int quantity;
private double transactionAmount;
+ private boolean itemsSold;
public SellAllData( PrisonBlock pBlock, int quantity, double transactionAmount ) {
super();
+ this.itemsSold = false;
+
this.prisonBlock = pBlock;
this.quantity = quantity;
this.transactionAmount = transactionAmount;
@@ -39,6 +42,10 @@ public String toString() {
.append( ":" )
.append( dFmt.format(getTransactionAmount()) );
+ if ( isItemsSold() ) {
+ sb.append( ":SOLD" );
+ }
+
return sb.toString();
}
@@ -74,18 +81,18 @@ public static String itemsSoldReport( List soldItems, SpigotPlayer
DecimalFormat iFmt = new DecimalFormat( "#,##0" );
sb.append( "Transaction log: " )
- .append( sPlayer.getName() )
- .append( " multiplier: " )
- .append( dFmt.format(multiplier) )
- .append( " ItemStacks: " )
- .append( soldItems.size() )
- .append( " ItemCount: " )
- .append( iFmt.format(itemCount) )
- .append( " TotalAmount: " )
- .append( dFmt.format( totalAmount ))
- .append( " [" )
- .append( sbItems )
- .append("]");
+ .append( sPlayer.getName() )
+ .append( " multiplier: " )
+ .append( dFmt.format(multiplier) )
+ .append( " ItemStacks: " )
+ .append( soldItems.size() )
+ .append( " ItemCount: " )
+ .append( iFmt.format(itemCount) )
+ .append( " TotalAmount: " )
+ .append( dFmt.format( totalAmount ))
+ .append( " [" )
+ .append( sbItems )
+ .append("]");
return sb.toString();
}
@@ -110,5 +117,12 @@ public double getTransactionAmount() {
public void setTransactionAmount(double transactionAmount) {
this.transactionAmount = transactionAmount;
}
+
+ public boolean isItemsSold() {
+ return itemsSold;
+ }
+ public void setItemsSold(boolean itemsSold) {
+ this.itemsSold = itemsSold;
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index 5dd5c09b2..69c1188bc 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -659,6 +659,9 @@ private List sellInventoryItems( tech.mcprison.prison.internal.inve
SellAllData sad = sellItemStack( (SpigotItemStack)inv, multiplier );
if ( sad != null ) {
+
+ sad.setItemsSold( true );
+
soldItems.add(sad);
removable.add(inv);
From bb004e1c966a9230c83a788d7bcb425aa8ab1b2c Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Thu, 13 Jul 2023 04:43:17 -0400
Subject: [PATCH 015/151] Update the PrisonSpigotAPI to include a lot of new
api endpoints for accessing sellall related functions.
---
docs/changelog_v3.3.x.md | 3 +
.../prison/spigot/api/PrisonSpigotAPI.java | 478 +++++++++++++++++-
.../prison/spigot/sellall/SellAllUtil.java | 94 +++-
3 files changed, 564 insertions(+), 11 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 352a96cf8..c368ecabe 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-13
+* **Update the PrisonSpigotAPI to include a lot of new api endpoints for accessing sellall related functions.**
+
+
* **Sellall: Expanded the functionality of the SellAllData obejcts to indicate if the items were sold.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
index dc86a4839..c6d4a9d5b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
@@ -11,6 +11,7 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.inventory.ItemStack;
import tech.mcprison.prison.Prison;
import tech.mcprison.prison.internal.block.PrisonBlock;
@@ -30,8 +31,10 @@
import tech.mcprison.prison.spigot.SpigotPrison;
import tech.mcprison.prison.spigot.backpacks.BackpacksUtil;
import tech.mcprison.prison.spigot.block.SpigotBlock;
+import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
import tech.mcprison.prison.spigot.game.SpigotWorld;
+import tech.mcprison.prison.spigot.sellall.SellAllData;
import tech.mcprison.prison.spigot.sellall.SellAllUtil;
import tech.mcprison.prison.util.ChatColor;
import tech.mcprison.prison.util.Location;
@@ -43,6 +46,10 @@
*
Use of these are at your own risk. Misuse can result in corruption of Prison's
* internal data.
*
+ *
+ *
If you need something special, then please ask on our discord server and we
+ * can probably provide it for you.
+ *
*
*/
public class PrisonSpigotAPI {
@@ -438,8 +445,28 @@ public BackpacksUtil getPrisonBackpacks(){
}
/**
- * Get the whole SellAllUtil of Prison Sellall to manage what you
+ *
Get the whole SellAllUtil of Prison Sellall to manage what you
* want of Prison SellAll.
+ *
+ *
+ *
WARNING: usage of this object is at your own risk! Functions will change,
+ * and will be eliminated. The majority of the functions that were in, and are
+ * in this object that are `public` were never intended to be used outside
+ * of prison. Many of the functions really should have been marked as private.
+ *
+ *
+ *
WARNING: The sellall functions will be undergoing major revisions and
+ * improvements in the near future. As such, do not rely on internal functions
+ * unless otherwise indicated. Some of the features that will be changing, is the
+ * support for all of prison's items and blocks, including custom blocks and items.
+ * Also Prison will be adding a very dynamic shop that will allow customization
+ * for each player rank, if desired. Hence why you should be careful when not using
+ * this API class.
+ *
+ *
+ *
It is highly suggested to use the exposed functions within this API class.
+ * As such, more have been added to get a variety of different data out of prison.
+ *
*
* @return SellAllUtil - Null if Prison Sellall's disabled.
* */
@@ -460,21 +487,454 @@ public SellAllUtil getPrisonSellAll(){
*
* @param player
* @return
- * */
+ */
+ @Deprecated
public Double getSellAllMoneyWithMultiplier(Player player){
+ Double results = null;
+
- if (sellAll == null){
- sellAll = SpigotPrison.getInstance().getSellAllUtil();
- }
-
- if (sellAll != null){
- return sellAll.getPlayerInventoryValue( (SpigotPlayer)player );
+ if (getPrisonSellAll() != null) {
+
+ double value = 0;
+
+ List soldItems = getPrisonSellAll().sellPlayerItems( player );
+ for (SellAllData soldItem : soldItems) {
+ if ( soldItem != null ) {
+ value += soldItem.getTransactionAmount();
+ }
+ }
+
// return sellAll.getSellMoney(player);
+ results = value;
}
- return null;
+ return results;
+ }
+
+ /**
+ *
This function will calculate the value of all sellable items within the player's inventory
+ * and provide a total amount that they earned for the sales.
+ * This includes the calculated player's multipliers.
+ *
This function will calculate the value of the player's inventory that
+ * are sellable and then will generate
+ * a simple report listing everything that can be sold with their values.
+ *
+ *
+ *
Nothing is sold. No notifications are sent to the player.
+ *
+ *
+ *
See the function
getPlayerInventoryValueTransactions()
to
+ * gain access to the transaction logs for more information.
+ *
This function calculates the value of the player's inventory items that are salable,
+ * and returns the transaction log within the collection of SellAllData.
+ *
+ *
+ *
Nothing is sold. No notifications are sent to the player.
+ *
+ *
+ *
To get the total transaction value, add all elements together.
+ * To generate a transaction report use the static function:
+ *
+ *
List itemsSold = prisonApi.getPlayerInventoryValueTransactions(Player player);
+ *SellAllData.itemSoldReport( itemsSold );
+ *
+ * @param player
+ * @return transactionLogs
+ */
+ public List getPlayerInventoryValueTransactions(Player player) {
+ List results = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getPlayerInventoryValueTransactions( new SpigotPlayer(player) );
+ }
+
+ return results;
+ }
+
+
+ /**
+ *
This function will calculate the value of ItemStack
+ * and provide a total amount that would earn for the sales.
+ * This includes the calculated player's multipliers.
+ *
This function will calculate the value of the ItemStack that
+ * are sellable and then will generate
+ * a simple report listing everything that can be sold with their values.
+ *
+ *
+ *
Nothing is sold. No notifications are sent to the player.
+ *
+ *
+ *
See the function
getPlayerInventoryValueTransactions()
to
+ * gain access to the transaction logs for more information.
+ *
+ *
+ * @param player
+ * @param itemStack
+ * @return
+ */
+ public String getItemStackValueReport(Player player, ItemStack itemStack ) {
+ String results = null;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getItemStackValueReport(
+ new SpigotPlayer(player), new SpigotItemStack(itemStack) );
+
+ }
+
+ return results;
}
+ /**
+ *
This function calculates the value of the ItemStack that are salable,
+ * and returns the transaction log within the collection of SellAllData.
+ *
+ *
+ *
Nothing is sold. No notifications are sent to the player.
+ *
+ *
+ *
To get the total transaction value, add all elements together.
+ * To generate a transaction report use the static function:
+ *
+ *
List itemsSold = prisonApi.getPlayerInventoryValueTransactions(Player player);
+ *SellAllData.itemSoldReport( itemsSold );
+ *
+ * @param player
+ * @param itemStack
+ * @return
+ */
+ public List getItemStackValueTransactions(Player player, ItemStack itemStack ) {
+ List results = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getItemStackValueTransactions(
+ new SpigotPlayer(player), new SpigotItemStack(itemStack) );
+
+ }
+
+ return results;
+ }
+
+ /**
+ *
This function sells anything within the player's inventory that is
+ * sellable. This function returns a transaction log of soldItems that can
+ * be summarized to get the total sales amount.
+ *
+ *
WARNING: This function REMOVES items from the player's inventory, but does
+ * NOT pay them any money!! If you are using this function, then
+ * you must sum all of the transactions and pay the player.
+ *
+ *
+ *
This is an exposed internal function that provides sellall capabilities without
+ * all of the complexities of the formal `sellAllSell()` functions.
+ * Use at your own risk.
+ *
+ *
+ *
This function does not notify the players, does not pay the players,
+ * does not provide all of the bells-and-whistles of customization within the
+ * sellall config files, and is basically a bare-bones sell it if it can be sold
+ * type of function.
+ *
+ *
+ * @param player
+ * @param itemStack
+ * @return
+ */
+ public List sellPlayerItems(Player player ) {
+ List soldItems = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ soldItems = getPrisonSellAll().sellPlayerItems( player );
+ }
+
+ return soldItems;
+ }
+
+ /**
+ *
This function sells anything within the ItemStack List that is
+ * sellable. This function returns a transaction log of soldItems that can
+ * be summarized to get the total sales amount.
+ *
+ *
WARNING: This function REMOVES items from the ItemStack that have been
+ * sold, but does NOT pay the player any money!! If you are
+ * using this function, then you must sum all of the
+ * transactions and pay the player.
+ *
+ *
+ *
This is an exposed internal function that provides sellall capabilities without
+ * all of the complexities of the formal `sellAllSell()` functions.
+ * Use at your own risk.
+ *
+ *
+ *
This function does not notify the players, does not pay the players,
+ * does not provide all of the bells-and-whistles of customization within the
+ * sellall config files, and is basically a bare-bones sell it if it can be sold
+ * type of function.
+ *
+ *
+ * @param player
+ * @param itemStacks
+ * @return
+ */
+ public List sellPlayerItemStacks(Player player, List itemStacks ) {
+ List soldItems = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ List iStacks = new ArrayList<>();
+ for (ItemStack itemStack : itemStacks) {
+ if ( itemStack != null ) {
+ iStacks.add( new SpigotItemStack( itemStack ));
+ }
+ }
+
+ soldItems = getPrisonSellAll().sellPlayerItemStacks( player, iStacks );
+ }
+
+ return soldItems;
+ }
+
+
+ /**
+ *
This function will remove all sellable items from the player's Inventories. It will first ensure that a
+ * Player can sell the items. Some of the conditions that are checked are, along with some of the behaviors:
+ *
+ *
+ *
+ *
If player has access to use SellAll signs.
+ *
Provide the amount the player earned if this is not disabled.
+ *
If this actions is silenced, then text and audio notifications are suppressed.
+ *
If configured, the reported earnings amount may be delayed and added to other earnings,
+ * which will reduce flooding the player with notifications.
+ *
If sound notifications are enabled, then they will be played.
This function performs the sellall functions over an ItemStack.
+ *
+ *
+ * @param p
+ * @param itemStack
+ * @param completelySilent
+ * @param notifyPlayerEarned
+ * @param notifyPlayerEarningDelay
+ * @return
+ */
+ public double sellAllSell(Player p,
+ SpigotItemStack itemStack,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerEarningDelay)
+ {
+ double results = 0;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().sellAllSell( p,
+ itemStack,
+ completelySilent,
+ notifyPlayerEarned,
+ notifyPlayerEarningDelay );
+ }
+
+ return results;
+ }
+
+
+
+ /**
+ * Sell removing items from Inventories and checking all the possible conditions that a Player must meet to sell
+ * items, this includes method parameters like:
+ * - Is using SellAll Sign.
+ * - If tell the Player how much did he earn (if this's disabled by config, the parameter will be ignored).
+ * - If do this action without making the player notice it, disabling sounds and all messages.
+ * - If tell the Player to wait the end of SellAll Delay if not ended (if this's disabled by config, the parameter will be ignored).
+ * - If tell the Player how much did he earn only after a delay (AutoSell Delay Earnings will use this option for example).
+ * - If play sound on SellAll Sell (If sounds are disabled from the config, this parameter will be ignored.
+ * - If Sell only stuff from the input arrayList and not sell what is in the many Player inventories and supported backpacks.
+ *
+ * NOTE: With this method you can add an ArrayList of ItemStacks to sell, remove sold items (this will return the ArrayList without
+ * sold items), and give money to the player, also note that this will also trigger the usual sellall sell and sell everything sellable
+ * from all inventories and enabled backpacks of the Player.
+ *
+ * Return True if success, False if error or nothing changed or Player not meeting requirements.
+ *
+ * Default usage of this method: sellAllSell(p, itemStacks, false, false, true, false, false, true, false);
+ *
+ * @param p - Player.
+ * @param itemStacks - ArrayList of ItemStacks.
+ * @param isUsingSign - boolean.
+ * @param completelySilent - boolean.
+ * @param notifyPlayerEarned - boolean.
+ * @param notifyPlayerDelay - boolean.
+ * @param notifyPlayerEarningDelay - boolean.
+ * @param playSoundOnSellAll - boolean.
+ * @param sellInputArrayListOnly - boolean.
+ *
+ * @return Array of ItemStacks
+ * */
+ public ArrayList sellAllSell(Player p,
+ ArrayList itemStacks,
+ boolean isUsingSign,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll,
+ boolean sellInputArrayListOnly){
+
+ ArrayList results = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().sellAllSell( p,
+ itemStacks,
+ isUsingSign,
+ completelySilent,
+ notifyPlayerEarned,
+ notifyPlayerDelay,
+ notifyPlayerEarningDelay,
+ playSoundOnSellAll,
+ sellInputArrayListOnly);
+ }
+
+ return results;
+ }
+
+
+
/**
*
Gets a player's current token balance.
*
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index 69c1188bc..23b128c8b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -606,6 +606,19 @@ public String getPlayerInventoryValueReport( SpigotPlayer sPlayer ) {
return report;
}
+ public List getPlayerInventoryValueTransactions( SpigotPlayer sPlayer ) {
+
+ double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+ List soldItems = valueOfInventoryItems( spInventory, multiplier );
+
+ return soldItems;
+ }
+
+
+
public double getItemStackValue( SpigotPlayer player, SpigotItemStack itemStack ) {
double multiplier = getPlayerMultiplier(player.getWrapper());
@@ -632,7 +645,30 @@ public String getItemStackValueReport( SpigotPlayer sPlayer, SpigotItemStack ite
return report;
}
- private List sellPlayerItems(Player p) {
+ public List getItemStackValueTransactions( SpigotPlayer sPlayer, SpigotItemStack itemStack ) {
+
+ double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
+
+ List soldItems = new ArrayList<>();
+
+ SellAllData sad = sellItemStack( itemStack, multiplier );
+ if ( sad != null ) {
+
+ soldItems.add( sad );
+ }
+
+ return soldItems;
+ }
+
+ /**
+ *
This sells the players inventory, and removes what is sold.
+ * This returns the transaction logs within the SellAllData obects.
+ *
This function sells the Item Stacks and returns a transaction log of items sold.
+ * This is an internal function. No messages are sent, most sellall options are bypassed,
+ * etc... Use at your own risk.
+ *
+ *
+ *
The parameter itemStacks will have the items sold removed. The sold items will
+ * be reflected in the returned transaction logs.
+ *
This function will use Prison internals to pay a player a given sum of money as specified
+ * by the amount. If the currency is non-standard, then you can also specify it's name as a
+ * String value; otherwise pass a null or an empty String. Example of non-standard currencies
+ * would be alternative currencies setup on ranks.
+ *
+ *
+ *
This function will notify the player each time they are paid of the payment amount
+ * (notifyPlayerEarned). It will also play a payment sound (playSoundOnSellAll), the sound can
+ * be changed within the SellAll config file.
+ *
+ *
+ *
If you need to delay player notifications, please use the other `payPlayer()` functions.
+ *
+ *
+ *
Prison's internals keep track of the player's balance in the Prison's player cache. It
+ * allows for rapid payments to a player, without overwhelming Vault or the Economy plugins.
+ * Some economy plugins will update their database with each hit, which can result in a
+ * serious performance drain on the system, since such I/O is blocking, and if they run those
+ * updates in bukkit's main thread. Since prison is caching the payments, as soon as it
+ * receives a payment, prison starts a count down to make the payment. Any additional payment
+ * made to a player before that count down reaches zero, will be included in the transaction.
+ * Rapid mining can create TONS of transactions per second, so Prison's payment cache is
+ * an important component to help weaker economy plugins from killing the server's TPS.
+ *
+ *
+ * @param player
+ * @param amount
+ * @param currency - If standard, pass null or an empty String
+ */
+ public void payPlayer( Player player, double amount, String currency ) {
+ payPlayer( player, amount, currency, true, false, false, true );
+ }
+
+ /**
+ *
This function will use Prison internals to pay a player a given sum of money as specified
+ * by the amount. This function is the same as the other one that is similar, except that it
+ * provides more options such as delayed notifications. Please see the help on the other
+ * `payPlayer()` functions to better understand what they are doing.
+ *
+ *
+ *
The payment amount must be greater than zero. If the amount is zero, or less,
+ * then this function will end silently without any notification.
+ *
+ *
+ *
This function has additional parameters for controlling player notifications. If they
+ * are all set to false, then no notifications will be sent to the player (completelySilent).
+ *
+ *
+ *
'notifyPlayerEarned': This function will notify the player each time they are paid
+ * of the payment amount (notifyPlayerEarned). It will also play a payment
+ * sound (playSoundOnSellAll), the sound can be changed within the SellAll config file.
+ *
+ *
+ *
'notifyPlayerDelay' & SellAll Delay (cooldown): If the SellAll configuration
+ * `isSellAllDelayEnabled` is set to `true`, then
+ * the player will be subjected to a cooldown for using the sellall command/feature.
+ * If the have tried to sell within the allocated amount of time, then they will get a
+ * message indicating that there is a rate limit in effect for them. They will get
+ * this notification if the parameter 'notifyPlayerDelay' is set to `true`.
+ *
+ *
+ *
Please NOTE: This function, `payPlayer()` only activates the cooldown timer and
+ * the player will be paid. What is impacted is the ability to use the functions
+ * `sellAllSell()`... it is then when the rate limit will kick in. If you use the
+ * other function `sellPlayerItems()` or `sellPlayerItemStacks()` then the
+ * cooldown rate limit will be bypassed and will not inhibit any selling.
+ *
+ *
+ *
'notifyPlayerEarningDelay': If in the SellAll config, the option
+ * `isAutoSellEarningNotificationDelayEnabled` is enabled, then this parameter
+ * `notifyPlayerEarningDelay` will then add the amount the player was paid to
+ * a delayed queue which will gather other payments the player receives during the
+ * delayed period. At the end of this delayed period of time, then the player
+ * will get a message indicating the total amount of money that they earned.
+ * This helps to reduce the amount of spam the player will get on line for their
+ * sales. Please NOTE: This does not delay the player from getting paid. If the
+ * delay is set to 15 seconds and they mine 100 times, they will get only one
+ * message with the total amount that they earned; otherwise they would have been
+ * sent 100 messages each time something was sold.
+ *
+ *
+ *
`playSoundOnSellAll`: If enabled, then a sound will be played upon a payment
+ * to the player. Please see the SellAll configuration file for changing
+ * the settings for the sound.
+ *
+ *
+ *
`completelySilent`: This is a virtual setting that is generated when all four
+ * of these settings are set to false: `notifyPlayerEarned`, `notifyPlayerDelay`,
+ * `notifyPlayerEarningDelay`, and `playSoundOnSellAll`. When enabled, this
+ * basically shuts off all notifications and the player is paid silently in the
+ * background.
+ *
+ * @param player
+ * @param amount
+ * @param currency
+ * @param notifyPlayerEarned
+ * @param notifyPlayerDelay
+ * @param notifyPlayerEarningDelay
+ * @param playSoundOnSellAll
+ */
+ public void payPlayer( Player player, double amount, String currency,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll ) {
+
+ if ( amount > 0 ) {
+
+ boolean completelySilent = notifyPlayerEarned || notifyPlayerDelay || notifyPlayerEarningDelay || playSoundOnSellAll;
+
+ SpigotPlayer sPlayer = new SpigotPlayer( player );
+ RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName());
+
+ currency = currency != null && currency.equalsIgnoreCase("default") ? null : currency;
+
+// if (!sellInputArrayListOnly) {
+// removeSellableItems(p);
+// }
+ rankPlayer.addBalance(currency, amount);
+
+ if ( getPrisonSellAll().isSellAllDelayEnabled ){
+ getPrisonSellAll().addToDelay(player);
+ }
+
+ if (!completelySilent) {
+ if ( getPrisonSellAll().isSellAllSoundEnabled && playSoundOnSellAll) {
+ player.playSound( player.getLocation(), getPrisonSellAll().sellAllSoundSuccess, 3, 1);
+ }
+
+ if (notifyPlayerEarningDelay && getPrisonSellAll().isAutoSellEarningNotificationDelayEnabled){
+ if (!getPrisonSellAll().isPlayerWaitingAutoSellNotification( player )){
+ getPrisonSellAll().addToAutoSellNotificationDelay( player);
+ } else {
+ getPrisonSellAll().addDelayedEarningAutoSellNotification( player, amount );
+ }
+ }
+ else if (notifyPlayerEarned){
+ DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
+ String amt = fFmt.format( amount );
+
+ String message = getPrisonSellAll().sellallAmountEarnedMsg( amt );
+
+// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt;
+// new SpigotPlayer(p).setActionBar( message );
+ Output.get().send( sPlayer, message );
+
+ }
+ }
+ }
+ }
+
+
+ /**
+ *
This function will use Prison internals to pay a player a given sum of money as specified
+ * by the amount. This function is the same as the other ones with the same name and similar
+ * parameters. This one differs in that you can pass it a List of `SellAllData` transactions
+ * and it will summarize them all, and pass the total amount to the other
+ * `payPlayer()` function. Please see the help on the other
+ * `payPlayer()` functions to better understand what they are doing.
+ *
This function will calculate the value of all sellable items within the player's inventory
* and provide a total amount that they earned for the sales.
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index 23b128c8b..cc2929063 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -67,7 +67,7 @@ public class SellAllUtil
private double defaultMultiplier;
private int defaultSellAllDelay;
private int defaultAutoSellEarningNotificationDelay;
- private Sound sellAllSoundSuccess;
+ public Sound sellAllSoundSuccess;
private Sound sellAllSoundFail;
public String sellAllSignTag;
public String sellAllCurrency;
From eb6d427a39401de81ebd431dde7ea99b83ad50e2 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sat, 15 Jul 2023 00:56:43 -0400
Subject: [PATCH 020/151] Fixed a bug with using the wrong player object within
auto feature's autosell.
---
docs/changelog_v3.3.x.md | 3 +++
.../prison/spigot/autofeatures/AutoManagerFeatures.java | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 79a442408..ddf14b798 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-14
+* **Fixed a bug with using the wrong player object within auto feature's autosell.**
+
+
* **Update the prison API to add direct support for payPlayer function (various options).**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
index 0e86d2647..37af7dd9f 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
@@ -891,7 +891,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
if ( Output.get().isDebug() && isSellallEnabled ) {
// Just get the calculated value for the drops... do not sell:
- double amount = SellAllUtil.get().getItemStackValue( (SpigotPlayer)player, itemStack );
+ double amount = SellAllUtil.get().getItemStackValue( pmEvent.getSpigotPlayer(), itemStack );
autosellTotal += amount;
debugInfo.append( "(Debug-unsold-value-check: " + itemStack.getName() +
From 299c05aeac4866723a7de209d3536f207f1ac3ff Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sat, 15 Jul 2023 01:42:47 -0400
Subject: [PATCH 021/151] Prison Tokens: bug fix: Ran in to NPE when an invalid
player name is used. The message text needs to be stored in the lang files.
---
docs/changelog_v3.3.x.md | 6 +++++-
.../java/tech/mcprison/prison/PrisonCommand.java | 12 ++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index ddf14b798..8029a71f9 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15 2023-07-14
+# 3.3.0-alpha.15 2023-07-15
+
+
+* **Prison Tokens: bug fix: Ran in to NPE when an invalid player name is used.**
+The message text needs to be stored in the lang files.
* **Fixed a bug with using the wrong player object within auto feature's autosell.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
index 6598e41b4..c18fc525d 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
@@ -2010,6 +2010,18 @@ public void tokensAdd( CommandSender sender,
}
Player player = getPlayer( playerName );
+
+ if ( player == null ) {
+ if ( !silent ) {
+ sender.sendMessage(
+ String.format(
+ "Prison Tokens: Player name not found. [%s] (hardCodedMessag)",
+ playerName ));
+ }
+ return;
+ }
+
+
PlayerCachePlayerData pCache = player.getPlayerCachePlayerData();
long tokenBal = pCache.getTokens();
From 780bf47072429ad00a89556582b0c82a1512e724 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sat, 15 Jul 2023 01:52:43 -0400
Subject: [PATCH 022/151] Prison tokens: expanded the error messages for
playing not being found to the set and remove functions for the admin token
commands.
---
docs/changelog_v3.3.x.md | 3 +++
.../tech/mcprison/prison/PrisonCommand.java | 25 ++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 8029a71f9..dab21a97b 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-15
+* **Prison tokens: expanded the error messages for playing not being found to the set and remove functions for the admin token commands.**
+
+
* **Prison Tokens: bug fix: Ran in to NPE when an invalid player name is used.**
The message text needs to be stored in the lang files.
diff --git a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
index c18fc525d..455c3115d 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
@@ -2015,7 +2015,7 @@ public void tokensAdd( CommandSender sender,
if ( !silent ) {
sender.sendMessage(
String.format(
- "Prison Tokens: Player name not found. [%s] (hardCodedMessag)",
+ "Prison Tokens add: Player name not found. [%s] (hardCodedMessag)",
playerName ));
}
return;
@@ -2121,6 +2121,18 @@ public void tokensRemove( CommandSender sender,
Player player = getPlayer( playerName );
+
+ if ( player == null ) {
+ if ( !silent ) {
+ sender.sendMessage(
+ String.format(
+ "Prison Tokens remove: Player name not found. [%s] (hardCodedMessag)",
+ playerName ));
+ }
+ return;
+ }
+
+
if ( forcePlayer ) {
player.getPlayerCachePlayerData().removeTokens( amount );
@@ -2194,6 +2206,17 @@ public void tokensSet( CommandSender sender,
// DecimalFormat dFmt = Prison.get().getDecimalFormatInt();
Player player = getPlayer( playerName );
+
+
+ if ( player == null ) {
+ if ( !silent ) {
+ sender.sendMessage(
+ String.format(
+ "Prison Tokens set: Player name not found. [%s] (hardCodedMessag)",
+ playerName ));
+ }
+ return;
+ }
// // Set to zero:
// long totalTokens = player.getPlayerCachePlayerData().getTokens();
From 839ca3a8500591c05b1e86aee1db765a876538b3 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sat, 15 Jul 2023 03:49:08 -0400
Subject: [PATCH 023/151] Auto Features AutoSell fix: There were situations
where mine bombs that are set with the setting autosell was not being sold.
Found a conflict with the logic of enabling autosell within the auto pickup
code. There are four ways autsell could be enabled, and a couple were
incorrectly mixed with their logic. Debug mode is now showing drop counts
before and after adjustments from the fortune calculations.
---
.../autofeatures/AutoManagerFeatures.java | 41 ++++++++++++++-----
...nagerPrisonsExplosiveBlockBreakEvents.java | 3 ++
2 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
index 37af7dd9f..4257391c5 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
@@ -756,7 +756,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
.append( amt );
if ( amt != amtBukkit ) {
sItemStack.setAmount( amt );
- sb.append( "(").append( amtBukkit ).append( ")" );
+ sb.append( "(bukkitAmt:").append( amtBukkit ).append( ")" );
}
}
if ( bukkitDropsMultiplier != 1.0d ) {
@@ -765,7 +765,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
sb.insert( 0, "bukkitDropMult=" );
}
- debugInfo.append( "[autoPickupDrops:: " ).append( sb ).append( "] ");
+ debugInfo.append( "[autoPickupDrops:beforeFortune:: " ).append( sb ).append( "] ");
@@ -780,15 +780,24 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
// Add fortune to the items in the inventory
if ( isBoolean( AutoFeatures.isCalculateFortuneEnabled ) ) {
+ sb.setLength(0);
short fortuneLevel = getFortune(itemInHand, debugInfo );
// debugInfo.append( "(calculateFortune: fort " + fortuneLevel + ")" );
for ( SpigotItemStack itemStack : drops ) {
+ if ( sb.length() > 0 ) {
+ sb.append( "," );
+ }
// calculateFortune directly modifies the quantity on the blocks ItemStack:
calculateFortune( itemStack, fortuneLevel, pmEvent.getDebugInfo() );
+
+ sb.append( itemStack.getName() )
+ .append( ":" )
+ .append( itemStack.getAmount() );
}
+ debugInfo.append( "[totalDrops:afterFortune:: " ).append( sb ).append( "] ");
}
@@ -840,21 +849,31 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
pmEvent.getSpigotPlayer().getWrapper() )
;
+ boolean forceAutoSell = isSellallEnabled && pmEvent.isForceAutoSell();
+
+ boolean autoSellBySettings = isSellallEnabled && isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled);
+ boolean autoSellByPerm = isSellallEnabled &&
+ !player.isOp() &&
+ !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
+ player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) );
for ( SpigotItemStack itemStack : drops ) {
count += itemStack.getAmount();
- // Try to autosell if enabled:
- if ( isSellallEnabled &&
-
- (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) &&
- isPlayerAutosellEnabled ||
- pmEvent.isForceAutoSell() ||
- !player.isOp() && !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
- player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) &&
- isPlayerAutosellEnabled ) {
+ // Try to autosell if enabled in any of the following ways:
+ if ( isPlayerAutosellEnabled || forceAutoSell || autoSellBySettings || autoSellByPerm ) {
+
+// // Try to autosell if enabled:
+// if ( isSellallEnabled &&
+//
+// (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) &&
+// isPlayerAutosellEnabled ||
+// pmEvent.isForceAutoSell() ||
+// !player.isOp() && !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
+// player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) &&
+// isPlayerAutosellEnabled ) {
final long nanoStart = System.nanoTime();
double amount = SellAllUtil.get().sellAllSell( player, itemStack, false, false, true );
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
index 64d5c0995..fdc7309fd 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
@@ -321,6 +321,9 @@ protected void handleExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e,
// than one.
if ( e.getMineBomb() != null ) {
pmEvent.setCalculateDurability( false );
+
+ // Set if forced autoSell:
+ pmEvent.setForceAutoSell( e.getMineBomb().isAutosell() );
}
if ( !validateEvent( pmEvent ) ) {
From 973d7efad7f21c81bc568e206fd35bc4d405598e Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sat, 15 Jul 2023 04:00:59 -0400
Subject: [PATCH 024/151] SellAllData: The transaction log: Enhanced the
itemsSoldReport by combining (compressing) entries for the same PrisonBlock
type. This will make it easier to review since there will be only one entry
per PrisonBlockType.
---
docs/changelog_v3.3.x.md | 9 +++++
.../prison/spigot/sellall/SellAllData.java | 33 ++++++++++++++++++-
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index dab21a97b..10824af21 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,15 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15 2023-07-15
+* **SellAllData: The transaction log: Enhanced the itemsSoldReport by combining (compressing) entries for the same PrisonBlock type.**
+This will make it easier to review since there will be only one entry per PrisonBlockType.
+
+
+* **Auto Features AutoSell fix: There were situations where mine bombs that are set with the setting autosell was not being sold.**
+Found a conflict with the logic of enabling autosell within the auto pickup code. There are four ways autsell could be enabled, and a couple were incorrectly mixed with their logic.
+Debug mode is now showing drop counts before and after adjustments from the fortune calculations.
+
+
* **Prison tokens: expanded the error messages for playing not being found to the set and remove functions for the admin token commands.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
index cca21122a..85fe93f33 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
@@ -1,6 +1,7 @@
package tech.mcprison.prison.spigot.sellall;
import java.text.DecimalFormat;
+import java.util.ArrayList;
import java.util.List;
import tech.mcprison.prison.internal.block.PrisonBlock;
@@ -63,6 +64,11 @@ public static String itemsSoldReport( List soldItems, SpigotPlayer
double totalAmount = 0;
int itemCount = 0;
+ int stacks = soldItems.size();
+
+ // Add same blocks together:
+ soldItems = compressSoldItems( soldItems );
+
for (SellAllData soldItem : soldItems) {
if ( soldItem != null ) {
@@ -85,7 +91,7 @@ public static String itemsSoldReport( List soldItems, SpigotPlayer
.append( " multiplier: " )
.append( dFmt.format(multiplier) )
.append( " ItemStacks: " )
- .append( soldItems.size() )
+ .append( stacks )
.append( " ItemCount: " )
.append( iFmt.format(itemCount) )
.append( " TotalAmount: " )
@@ -97,6 +103,31 @@ public static String itemsSoldReport( List soldItems, SpigotPlayer
return sb.toString();
}
+ private static List compressSoldItems(List soldItems) {
+ List results = new ArrayList<>();
+
+ for (SellAllData sItem : soldItems) {
+ boolean found = false;
+
+ for (SellAllData result : results) {
+ if ( sItem.getPrisonBlock().equals(result.getPrisonBlock() ) ) {
+ found = true;
+
+ // found a match... add to the result item:
+ result.setQuantity( result.getQuantity() + sItem.getQuantity() );
+ result.setTransactionAmount( result.getTransactionAmount() + sItem.getTransactionAmount() );
+ break;
+ }
+ }
+
+ if ( !found ) {
+ results.add(sItem);
+ }
+ }
+
+ return results;
+ }
+
public PrisonBlock getPrisonBlock() {
return prisonBlock;
}
From 8571c87e1fe0a4d01045941cae4e95b12d8da4f3 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sat, 15 Jul 2023 13:59:48 -0400
Subject: [PATCH 025/151] v3.3.0-alpha.15a released on 2023-07-15
---
docs/changelog_v3.3.x.md | 5 ++++-
gradle.properties | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 10824af21..be4f9b797 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,10 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15 2023-07-15
+# 3.3.0-alpha.15a 2023-07-15
+
+
+* ** v3.3.0-alpha.15a 2023-07-15**
* **SellAllData: The transaction log: Enhanced the itemsSoldReport by combining (compressing) entries for the same PrisonBlock type.**
diff --git a/gradle.properties b/gradle.properties
index 1e461305f..9daf50886 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,7 +3,7 @@
## # This is actually the "correct" place to define the version for the project.
## # Used within build.gradle with ${project.version}.
## # Can be overridden on the command line: gradle -Pversion=3.2.1-alpha.3
-version=3.3.0-alpha.15
+version=3.3.0-alpha.15a
From 18c6201fd1a8dbdddde85e3e7c1666e625798487 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sat, 15 Jul 2023 14:22:27 -0400
Subject: [PATCH 026/151] Auto features not being fully disabled when turned
off. There was an issue with `/prison reload autoFeatures` enabling itself
when it should have been off.
---
docs/changelog_v3.3.x.md | 4 ++
.../mcprison/prison/spigot/SpigotPrison.java | 1 +
.../events/AutoManagerBlockBreakEvents.java | 5 ++-
.../events/AutoManagerCrazyEnchants.java | 7 +++-
.../events/AutoManagerPrisonEnchants.java | 7 +++-
...nagerPrisonsExplosiveBlockBreakEvents.java | 6 ++-
.../AutoManagerRevEnchantsExplosiveEvent.java | 7 +++-
...AutoManagerRevEnchantsJackHammerEvent.java | 7 +++-
.../events/AutoManagerTokenEnchant.java | 6 ++-
.../events/AutoManagerZenchantments.java | 6 ++-
.../block/OnBlockBreakEventListener.java | 37 +++++++++++++------
11 files changed, 68 insertions(+), 25 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index be4f9b797..7298f60e5 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,10 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-15
+* **Auto features not being fully disabled when turned off.**
+There was an issue with `/prison reload autoFeatures` enabling itself when it should have been off.
+
+
* ** v3.3.0-alpha.15a 2023-07-15**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPrison.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPrison.java
index 4008430ef..189db7af7 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPrison.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPrison.java
@@ -346,6 +346,7 @@ public void onEnableStartup() {
// The BlockBreakEvents must be registered after the mines and ranks modules have been enabled:
+ // Auto features will prevent this if it's disabled.
getBlockBreakEventListeners().registerAllBlockBreakEvents( this );
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerBlockBreakEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerBlockBreakEvents.java
index 55dd38947..05f0474c9 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerBlockBreakEvents.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerBlockBreakEvents.java
@@ -49,7 +49,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java
index 7d5b598e9..0337dfa4c 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java
@@ -13,6 +13,7 @@
import org.bukkit.plugin.PluginManager;
import me.badbones69.crazyenchantments.api.events.BlastUseEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
@@ -56,8 +57,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonEnchants.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonEnchants.java
index 799113caa..6fae4927b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonEnchants.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonEnchants.java
@@ -13,6 +13,7 @@
import org.bukkit.plugin.PluginManager;
import me.pulsi_.prisonenchants.events.PEExplosionEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
@@ -48,8 +49,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
/**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
index fdc7309fd..28788f1dc 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
@@ -51,8 +51,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
index 982094061..32b49b5d0 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
@@ -13,6 +13,7 @@
import org.bukkit.plugin.PluginManager;
import me.revils.revenchants.events.ExplosiveEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
@@ -49,8 +50,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
index e5c1bc2ee..8f29c41d1 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
@@ -15,6 +15,7 @@
import org.bukkit.plugin.PluginManager;
import me.revils.revenchants.events.JackHammerEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.bombs.MineBombs;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
@@ -54,8 +55,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java
index 88240da24..782ca8d81 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java
@@ -14,6 +14,7 @@
import com.vk2gpz.tokenenchant.event.TEBlockExplodeEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
@@ -53,7 +54,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerZenchantments.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerZenchantments.java
index 15745d535..ed0f54a57 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerZenchantments.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerZenchantments.java
@@ -50,8 +50,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
index d7ad293f5..095ec0d91 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
@@ -208,29 +208,44 @@ public void reloadEventListeners() {
private void registerEvents() {
bbEvents = new AutoManagerBlockBreakEvents();
- bbEvents.registerEvents();
-
+
// Prison's own internal event and listener:
pebbEvents = new AutoManagerPrisonsExplosiveBlockBreakEvents();
- pebbEvents.registerEvents();
-
+
+ ceEvents = new AutoManagerCrazyEnchants();
+
ceEvents = new AutoManagerCrazyEnchants();
- ceEvents.registerEvents();
peEvents = new AutoManagerPrisonEnchants();
- peEvents.registerEvents();
-
+
teEvents = new AutoManagerTokenEnchant();
- teEvents.registerEvents();
zcEvents = new AutoManagerZenchantments();
- zcEvents.registerEvents();
reEEvents = new AutoManagerRevEnchantsExplosiveEvent();
- reEEvents.registerEvents();
reJHEvents = new AutoManagerRevEnchantsJackHammerEvent();
- reJHEvents.registerEvents();
+
+
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ bbEvents.registerEvents();
+
+ // Prison's own internal event and listener:
+ pebbEvents.registerEvents();
+
+ ceEvents.registerEvents();
+
+ peEvents.registerEvents();
+
+ teEvents.registerEvents();
+
+ zcEvents.registerEvents();
+
+ reEEvents.registerEvents();
+
+ reJHEvents.registerEvents();
+ }
pdBlockInspector = new PrisonDebugBlockInspector();
pdBlockInspector.init();
From eec5c89d8bae2996ab01895adab7deda11c5aaca Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 16 Jul 2023 00:33:58 -0400
Subject: [PATCH 027/151] Enhance Prison's debug block inspector to fix an
issue with running it multiple times for one test. Reformatted the layout so
each plugin is now using only one line instead of two, and added the duration
of runtime in ms.
---
docs/changelog_v3.3.x.md | 9 +-
.../events/PrisonDebugBlockInspector.java | 159 +++++++++++++-----
.../block/OnBlockBreakEventListener.java | 4 +-
3 files changed, 130 insertions(+), 42 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 7298f60e5..87777dd97 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -21,7 +21,14 @@ These change logs represent the work that has been going on within prison.
There was an issue with `/prison reload autoFeatures` enabling itself when it should have been off.
-* ** v3.3.0-alpha.15a 2023-07-15**
+
+** v3.3.0-alpha.15a 2023-07-16**
+
+
+
+
+* **Enhance Prison's debug block inspector to fix an issue with running it multiple times for one test.**
+Reformatted the layout so each plugin is now using only one line instead of two, and added the duration of runtime in ms.
* **SellAllData: The transaction log: Enhanced the itemsSoldReport by combining (compressing) entries for the same PrisonBlock type.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
index 27981860d..850efb532 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
@@ -1,5 +1,6 @@
package tech.mcprison.prison.spigot.autofeatures.events;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
@@ -27,21 +28,41 @@
public class PrisonDebugBlockInspector
// extends OnBlockBreakMines
{
+ private static PrisonDebugBlockInspector instance;
+
private OnBlockBreakMines obbMines;
+ private long lastAccess = 0;
+// private boolean active = false;
+
public enum EventDropsStatus {
normal,
canceled,
notSupported;
}
- public PrisonDebugBlockInspector() {
+ private PrisonDebugBlockInspector() {
super();
obbMines = new OnBlockBreakMines();
+
+ init();
+ }
+
+ public static PrisonDebugBlockInspector getInstance() {
+ if ( instance == null ) {
+ synchronized ( PrisonDebugBlockInspector.class ) {
+ if ( instance == null ) {
+
+ instance = new PrisonDebugBlockInspector();
+
+ }
+ }
+ }
+ return instance;
}
- public void init() {
+ private void init() {
Prison.get().getEventBus().register(this);
@@ -81,6 +102,12 @@ public void init() {
@Subscribe
public void onPlayerInteract( PrisonPlayerInteractEvent e ) {
+ // Cool down: run no sooner than every 2 seconds... prevents duplicate runs:
+ if ( lastAccess != 0 && (System.currentTimeMillis() - lastAccess) < 2000 ) {
+ return;
+ }
+
+ this.lastAccess = System.currentTimeMillis();
ItemStack ourItem = e.getItemInHand();
ItemStack toolItem = SelectionManager.SELECTION_TOOL;
@@ -146,20 +173,22 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) {
}
else {
+
String message = String.format( " &3TargetBlock: &7%s " +
- "&3Mined: %s%b &3Broke: &7%b",
+ "&3Mined: %s%b &3Broke: &7%b &3Counted: &7%b",
targetBlock.getPrisonBlock().getBlockName(),
(targetBlock.isMined() ? "&d" : "&2"),
targetBlock.isMined(),
- targetBlock.isAirBroke()
+ targetBlock.isAirBroke(),
+ targetBlock.isCounted()
);
player.sendMessage( message );
Output.get().logInfo( message );
- String message2 = String.format( " &3Counted: &7%b &3Edge: &7%b " +
- "&3Exploded: %s%b &3IgnoreAllEvents: &7%b",
- targetBlock.isCounted(),
+ String message2 = String.format( " &3isEdge: &7%b " +
+ "&3Exploded: %s%b &3IgnoreAllEvents: &7%b",
+
targetBlock.isEdge(),
(targetBlock.isExploded() ? "&d" : "&2"),
targetBlock.isExploded(),
@@ -215,6 +244,10 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) {
//
// checkForEvent(e.getPlayer(), sel);
// }
+
+ // disable active prior to exiting function:
+ //this.active = false;
+
}
public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTargetPrisonBlock targetBlock ) {
@@ -291,19 +324,28 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTa
tool.getName()
) );
+ output.add( " &3Legend: &7EP&3: Event Priority &7EC&3: Event Canceled "
+ + "&7DC&3: Drops Canceled &7EB&3: Event Block &7Ds&3: Drops "
+ + "&7ms&3: duration in ms");
+
- printEventStatus( bbe, "-initial-", "", checkBlock, targetBlock, tool, output, player );
+ printEventStatus( bbe, "-initial-", "", checkBlock, targetBlock, tool, output, player, -1 );
for ( RegisteredListener listener : bbe.getHandlers().getRegisteredListeners() ) {
+ long start = 0;
+ long stop = 0;
+
try {
// boolean isPrison = listener.getPlugin().getName().equalsIgnoreCase( "Prison" );
// boolean isSpigotListener = isPrison && listener.getListener() instanceof SpigotListener;
// if ( !isSpigotListener ) {
+ start = System.nanoTime();
listener.callEvent( bbe );
+ stop = System.nanoTime();
// }
}
@@ -316,9 +358,15 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTa
}
+ double durationNano = (stop - start);
+
+ if ( durationNano > 0 ) {
+ durationNano = durationNano / 1_000_000;
+ }
+
printEventStatus( bbe,
listener.getPlugin().getName(), listener.getPriority().name(), checkBlock, targetBlock,
- tool, output, player );
+ tool, output, player, durationNano );
}
@@ -363,9 +411,11 @@ private void printEventStatus( BlockBreakEvent bbe,
MineTargetPrisonBlock targetBlock,
SpigotItemStack tool,
List output,
- SpigotPlayer player ) {
+ SpigotPlayer player,
+ double durationNano ) {
StringBuilder sb = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
sb.append( " " );
boolean isCanceled = bbe.isCancelled();
@@ -386,30 +436,13 @@ else if ( isDropCanceled == EventDropsStatus.notSupported ) {
bukkitDrops = obbMines.mergeDrops( bukkitDrops );
- String msg = String.format( " &3Plugin: &7%-15s &2EventPriority: &7%-9s "
- + "&2EventCanceled: &7%5s &2DropsCanceled: &7%s",
- plugin,
- ( priority == null ? "$dnone" : priority ),
- ( isCanceled ? "&4true " : "false" ),
- dropStats
- );
- sb.append( msg );
-
-
-
-
- output.add( sb.toString() );
- sb.setLength( 0 );
-
SpigotBlock eventBlock = SpigotBlock.getSpigotBlock( bbe.getBlock() );
-
- String msg2 = String.format( " &aEventBlock: &b%s ",
- eventBlock == null ?
- "&4none" :
- eventBlock.getBlockNameFormal() );
- sb.append( msg2 );
+ String eventBlockName = eventBlock == null ?
+ "&4none" :
+ eventBlock.getBlockNameFormal();
+
- sb.append( " &aDrops:" );
+ // Build the drops listing:
if ( bukkitDrops.size() > 0 ) {
// List drops = sBlk.getDrops( tool );
@@ -417,20 +450,68 @@ else if ( isDropCanceled == EventDropsStatus.notSupported ) {
{
// SpigotItemStack sis = (SpigotItemStack) itemStack;
- sb.append( " &b" ).append( itemStack.getName() );
+ sb2.append( " &b" ).append( itemStack.getName() );
if ( itemStack.getAmount() > 0 ) {
- sb.append( "&a(&b" ).append( itemStack.getAmount() ).append( "&a)" );
+ sb2.append( "&a(&b" ).append( itemStack.getAmount() ).append( "&a)" );
}
}
}
else {
- sb.append( "&4none" );
+ sb2.append( "&4none" );
}
- if ( sb.length() > 0 ) {
- output.add( sb.toString() );
- sb.setLength( 0 );
- }
+
+ DecimalFormat dFmt = new DecimalFormat("#,##0.000000");
+ String durationNanoStr = durationNano == -1 ? "---" : dFmt.format( durationNano );
+
+
+ String msg = String.format( " &3Plugin: &7%-15s &2EP: &7%-9s "
+ + "&2EC: &7%5s &2DC: &7%s &aEB: &b%s &aDs: %s &ams: &7%s",
+ plugin,
+ ( priority == null ? "$dnone" : priority ),
+ ( isCanceled ? "&4true " : "false" ),
+ dropStats,
+ eventBlockName,
+ sb2,
+ durationNanoStr
+ );
+ sb.append( msg );
+
+
+ output.add( sb.toString() );
+
+
+// sb.setLength( 0 );
+
+
+// String msg2 = String.format( " &aEventBlock: &b%s ",
+// eventBlock == null ?
+// "&4none" :
+// eventBlock.getBlockNameFormal() );
+// sb.append( msg2 );
+
+// sb.append( " &aDrops:" );
+// if ( bukkitDrops.size() > 0 ) {
+//
+//// List drops = sBlk.getDrops( tool );
+// for ( ItemStack itemStack : bukkitDrops )
+// {
+//// SpigotItemStack sis = (SpigotItemStack) itemStack;
+//
+// sb.append( " &b" ).append( itemStack.getName() );
+// if ( itemStack.getAmount() > 0 ) {
+// sb.append( "&a(&b" ).append( itemStack.getAmount() ).append( "&a)" );
+// }
+// }
+// }
+// else {
+// sb.append( "&4none" );
+// }
+
+// if ( sb.length() > 0 ) {
+// output.add( sb.toString() );
+// sb.setLength( 0 );
+// }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
index 095ec0d91..a604f1b8a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
@@ -247,8 +247,8 @@ private void registerEvents() {
reJHEvents.registerEvents();
}
- pdBlockInspector = new PrisonDebugBlockInspector();
- pdBlockInspector.init();
+ pdBlockInspector = PrisonDebugBlockInspector.getInstance();
+// pdBlockInspector.init();
}
From 55e9f17ed39d972ac456ec2ac6a84f940e9766b6 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 16 Jul 2023 01:24:17 -0400
Subject: [PATCH 028/151] More adjustments to the PrisonDebugBlockInspector for
readability.
---
docs/changelog_v3.3.x.md | 5 ++++-
.../events/PrisonDebugBlockInspector.java | 14 ++++++++++----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 87777dd97..9817531e0 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,10 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15a 2023-07-15
+# 3.3.0-alpha.15a 2023-07-16
+
+
+* **More adjustments to the PrisonDebugBlockInspector for readability.**
* **Auto features not being fully disabled when turned off.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
index 850efb532..a0db0925a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
@@ -324,9 +324,15 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTa
tool.getName()
) );
- output.add( " &3Legend: &7EP&3: Event Priority &7EC&3: Event Canceled "
- + "&7DC&3: Drops Canceled &7EB&3: Event Block &7Ds&3: Drops "
- + "&7ms&3: duration in ms");
+
+ EventDropsStatus isNs = isDropCanceled( bbe );
+
+
+ output.add( " &3Legend: &7EP&3: EventPriority &7EC&3: EventCanceled "
+ + "&7DC&3: DropsCanceled &7EB&3: EventBlock &7Ds&3: Drops "
+ + "&7ms&3: dur ms"
+ + ( isNs == EventDropsStatus.notSupported ? " &7NS&3: NotSupported" : "" )
+ );
printEventStatus( bbe, "-initial-", "", checkBlock, targetBlock, tool, output, player, -1 );
@@ -425,7 +431,7 @@ private void printEventStatus( BlockBreakEvent bbe,
dropStats = "&4" + isDropCanceled.name();
}
else if ( isDropCanceled == EventDropsStatus.notSupported ) {
- dropStats = "&d" + isDropCanceled.name();
+ dropStats = "&dNS"; // + isDropCanceled.name();
}
// Get a fresh copy of the block to ensure we pickup the latest status:
From 368255784b56d831d369e56a75e17087b035c532 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 16 Jul 2023 13:12:49 -0400
Subject: [PATCH 029/151] Bug fix: If a sellall transaction is null, then it
now returns a zero since nothing was sold.
---
docs/changelog_v3.3.x.md | 3 +++
.../java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 9817531e0..c3801ead4 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-16
+* **Bug fix: If a sellall transaction is null, then it now returns a zero since nothing was sold.**
+
+
* **More adjustments to the PrisonDebugBlockInspector for readability.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index cc2929063..92c957eab 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -625,7 +625,7 @@ public double getItemStackValue( SpigotPlayer player, SpigotItemStack itemStack
SellAllData sad = sellItemStack( itemStack, multiplier );
- return sad.getTransactionAmount();
+ return sad == null ? 0 : sad.getTransactionAmount();
}
public String getItemStackValueReport( SpigotPlayer sPlayer, SpigotItemStack itemStack ) {
From 2a71900ab8ef59d758f16ec16b01e2d592699859 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 16 Jul 2023 13:15:21 -0400
Subject: [PATCH 030/151] The Platform function getConfigStringArray should be
a List of Strings for the return value, so updated the result type to reflect
the correct setting.
---
docs/changelog_v3.3.x.md | 3 +++
.../tech/mcprison/prison/internal/platform/Platform.java | 2 +-
.../src/test/java/tech/mcprison/prison/TestPlatform.java | 2 +-
.../java/tech/mcprison/prison/spigot/SpigotPlatform.java | 6 ++++--
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index c3801ead4..d6fa0be98 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-16
+* **The Platform function getConfigStringArray should be a List of Strings for the return value, so updated the result type to reflect the correct setting.**
+
+
* **Bug fix: If a sellall transaction is null, then it now returns a zero since nothing was sold.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java b/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
index e4479d38d..1c954dc6b 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
@@ -444,7 +444,7 @@ public void autoCreateMineLinerAssignment( List rankMineNames,
public TreeSet getExcludedWorlds();
- public List> getConfigStringArray( String key );
+ public List getConfigStringArray( String key );
public int compareServerVerisonTo( String comparisonVersion );
diff --git a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
index cdef3f149..a17832b6d 100644
--- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
+++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
@@ -295,7 +295,7 @@ public double getConfigDouble( String key, double defaultValue ) {
}
@Override
- public List> getConfigStringArray( String key ) {
+ public List getConfigStringArray( String key ) {
return new ArrayList();
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
index f5b7758f5..a7c549417 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
@@ -928,9 +928,11 @@ public String getConfigString( String key, String defaultValue ) {
}
+ @SuppressWarnings("unchecked")
@Override
- public List> getConfigStringArray( String key ) {
- return SpigotPrison.getInstance().getConfig().getList( key, new ArrayList() );
+ public List getConfigStringArray( String key ) {
+ return (List) SpigotPrison.getInstance().getConfig()
+ .getList( key, new ArrayList() );
}
From 4fa8166e8431929c1d19b0eb5d65db6316035012 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 16 Jul 2023 13:21:09 -0400
Subject: [PATCH 031/151] Added new feature to prevent mine bombs from being
used in mines. A specific mine bomb can have a list of included mines, which
overrides any exclusions. The mine bombs can be excluded from specific mines
too. There is also a global disallowed mine list that will apply to all mine
bombs, its in the config.yml file with the setting name of:
prison-mines.mine-bombs.prevent-usage-in-mines
---
docs/changelog_v3.3.x.md | 6 ++
.../mcprison/prison/bombs/MineBombData.java | 37 +++++++++++
.../tech/mcprison/prison/bombs/MineBombs.java | 62 +++++++++++++++++++
.../spigot/utils/PrisonBombListener.java | 22 +++++++
prison-spigot/src/main/resources/config.yml | 4 ++
5 files changed, 131 insertions(+)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index d6fa0be98..45707be0b 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,12 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-16
+* **Added new feature to prevent mine bombs from being used in mines.**
+A specific mine bomb can have a list of included mines, which overrides any exclusions. The mine bombs can be excluded from specific mines too.
+There is also a global disallowed mine list that will apply to all mine bombs, its in the config.yml file with the setting name of:
+ prison-mines.mine-bombs.prevent-usage-in-mines
+
+
* **The Platform function getConfigStringArray should be a List of Strings for the return value, so updated the result type to reflect the correct setting.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombData.java b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombData.java
index f7a41d20d..fee24d4e1 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombData.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombData.java
@@ -179,6 +179,26 @@ public class MineBombData {
private boolean autosell = false;
+ /**
+ *
This is a list of mine names where a mine bomb is allowed to be used.
+ * This setting overrides any global setting to disallow a specific mine, which
+ * allows a specific mine bomb to be used within a mine where all other
+ * mine bombs are excluded.
+ *
+ */
+ private List allowedMines;
+
+ /**
+ *
This is a list of mine names where this mine bomb cannot be used.
+ * This mine bomb specific list is combined with the global setting of
+ * excluded mines. The global settings is in `config.yml` and is named
+ * `prison-mines.mine-bombs.prevent-usage-in-mines`.
+ *
+ */
+ private List preventedMines;
+
+
+
/**
*
Internal just to indicated if a mine bomb is activated or not.
* This has not purpose if used in a save file.
@@ -201,6 +221,9 @@ public MineBombData() {
this.soundEffects = new TreeSet<>( new MineBombEffectsData() );
this.visualEffects = new TreeSet<>( new MineBombEffectsData() );
+
+ this.allowedMines = new ArrayList<>();
+ this.preventedMines = new ArrayList<>();
}
@@ -473,6 +496,20 @@ public void setAutosell( boolean autosell ) {
this.autosell = autosell;
}
+ public List getAllowedMines() {
+ return allowedMines;
+ }
+ public void setAllowedMines(List allowedMines) {
+ this.allowedMines = allowedMines;
+ }
+
+ public List getPreventedMines() {
+ return preventedMines;
+ }
+ public void setPreventedMines(List preventedMines) {
+ this.preventedMines = preventedMines;
+ }
+
public boolean isActivated() {
return activated;
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombs.java b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombs.java
index 2f65a6392..ce3df4b73 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombs.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombs.java
@@ -5,8 +5,10 @@
import java.util.List;
import java.util.Set;
+import tech.mcprison.prison.Prison;
import tech.mcprison.prison.file.JsonFileIO;
import tech.mcprison.prison.internal.block.PrisonBlock;
+import tech.mcprison.prison.output.LogLevel;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.util.Location;
import tech.mcprison.prison.util.Text;
@@ -355,6 +357,66 @@ public void validateMineBombs()
isDirty = true;
}
+ // map all names to lower case
+ if ( bomb.getAllowedMines().size() > 0 ) {
+ List mines = new ArrayList<>();
+ boolean cleaned = false;
+
+ for (String mineName : bomb.getAllowedMines() ) {
+ String cleanedMineName = mineName.toLowerCase();
+
+ if ( !cleanedMineName.equals( mineName ) ) {
+ cleaned = true;
+ }
+
+ if ( !Prison.get().getPlatform().getMinesListString().contains(cleanName) ) {
+ Output.get().log( "MineBomb %s: invalid mine name for allowedMines: %s Removed.",
+ LogLevel.WARNING,
+ bomb.getName(), cleanedMineName );
+ cleaned = true;
+ }
+ else {
+
+ mines.add(cleanedMineName);
+ }
+
+ }
+ if ( cleaned ) {
+ bomb.setAllowedMines(mines);
+ isDirty = true;
+ }
+ }
+
+ // map all names to lower case
+ if ( bomb.getPreventedMines().size() > 0 ) {
+ List mines = new ArrayList<>();
+ boolean cleaned = false;
+
+ for (String mineName : bomb.getPreventedMines() ) {
+ String cleanedMineName = mineName.toLowerCase();
+
+ if ( !cleanedMineName.equals( mineName ) ) {
+ cleaned = true;
+ }
+
+ if ( !Prison.get().getPlatform().getMinesListString().contains(cleanName) ) {
+ Output.get().log( "MineBomb %s: invalid mine name for prevented-Mines: %s Removed.",
+ LogLevel.WARNING,
+ bomb.getName(), cleanedMineName );
+ cleaned = true;
+ }
+ else {
+
+ mines.add(cleanedMineName);
+ }
+
+ }
+ if ( cleaned ) {
+ bomb.setPreventedMines(mines);
+ isDirty = true;
+ }
+ }
+
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonBombListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonBombListener.java
index b1c4c6ee4..966b638fc 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonBombListener.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonBombListener.java
@@ -1,5 +1,8 @@
package tech.mcprison.prison.spigot.utils;
+import java.util.HashSet;
+import java.util.List;
+
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -9,6 +12,7 @@
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
+import tech.mcprison.prison.Prison;
import tech.mcprison.prison.bombs.MineBombData;
import tech.mcprison.prison.bombs.MineBombs;
import tech.mcprison.prison.mines.data.Mine;
@@ -159,6 +163,24 @@ else if ( !mine.hasMiningAccess( sPlayer ) ) {
return;
}
+ HashSet allowedMines = new HashSet<>( bomb.getAllowedMines() );
+ HashSet preventedMines = new HashSet<>( bomb.getPreventedMines() );
+ List globalPreventedMines = (List) Prison.get().getPlatform()
+ .getConfigStringArray("prison-mines.mine-bombs.prevent-usage-in-mines");
+ preventedMines.addAll( globalPreventedMines );
+
+ // Skip prevent-in-mines check if mine is within the allowedMines list:
+ if ( !allowedMines.contains( mine.getName().toLowerCase() ) ) {
+
+ if ( preventedMines.contains( mine.getName().toLowerCase() ) ) {
+
+ // Mine bombs are not allowed to be used in this mine so cancel:
+ event.setCancelled( true );
+ return;
+ }
+ }
+
+
// getHand() is not available with bukkit 1.8.8 so use the compatibility functions:
EquipmentSlot hand = SpigotCompatibility.getInstance().getHand(event);
// EquipmentSlot hand = event.getHand();
diff --git a/prison-spigot/src/main/resources/config.yml b/prison-spigot/src/main/resources/config.yml
index 5b8f4265d..c9d9ede8a 100644
--- a/prison-spigot/src/main/resources/config.yml
+++ b/prison-spigot/src/main/resources/config.yml
@@ -271,6 +271,10 @@ prison-mines:
access-to-prior-mines: true
tp-to-spawn-on-mine-resets: true
enable-suffocation-in-mines: false
+ mine-bombs:
+ prevent-usage-in-mines:
+ - GoldMine
+ - SampleMineName
world-guard:
region-mine:
enable: true
From 1652f79103db02f0bfcf45ba5144c544b7d484d6 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 16 Jul 2023 13:23:52 -0400
Subject: [PATCH 032/151] Added a few more items to the default list of items
in sellall.
---
docs/changelog_v3.3.x.md | 3 +++
.../mcprison/prison/spigot/SpigotPlatform.java | 14 ++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 45707be0b..93ea0a199 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-16
+* **Added a few more items to the default list of items in sellall.**
+
+
* **Added new feature to prevent mine bombs from being used in mines.**
A specific mine bomb can have a list of included mines, which overrides any exclusions. The mine bombs can be excluded from specific mines too.
There is also a global disallowed mine list that will apply to all mine bombs, its in the config.yml file with the setting name of:
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
index a7c549417..a5e37c73a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
@@ -2013,6 +2013,20 @@ public List buildBlockListXMaterial() {
blockList.add( new SellAllBlockData( XMaterial.SUGAR, 13 ) );
blockList.add( new SellAllBlockData( XMaterial.PAPER, 13 ) );
+
+ blockList.add( new SellAllBlockData( XMaterial.SOUL_SAND, 25 ) );
+ blockList.add( new SellAllBlockData( XMaterial.BROWN_MUSHROOM, 5 ) );
+ blockList.add( new SellAllBlockData( XMaterial.BROWN_MUSHROOM_BLOCK, 5 ) );
+ blockList.add( new SellAllBlockData( XMaterial.RED_MUSHROOM, 5 ) );
+ blockList.add( new SellAllBlockData( XMaterial.RED_MUSHROOM_BLOCK, 5 ) );
+ blockList.add( new SellAllBlockData( XMaterial.SLIME_BALL, 7 ) );
+ blockList.add( new SellAllBlockData( XMaterial.SLIME_BLOCK, 63 ) );
+ blockList.add( new SellAllBlockData( XMaterial.PACKED_ICE, 7 ) );
+
+ blockList.add( new SellAllBlockData( XMaterial.BRICK, 4 ) );
+ blockList.add( new SellAllBlockData( XMaterial.BRICKS, 16 ) ); // 1 bricks = 4 brick
+
+
return blockList;
}
From ed12d1a996ef3af6c85b268a09367a7de381be70 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 16 Jul 2023 16:52:08 -0400
Subject: [PATCH 033/151] If at last rank, show a message to tell the player
that.
---
docs/changelog_v3.3.x.md | 3 +++
.../mcprison/prison/ranks/commands/RankUpCommand.java | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 93ea0a199..e25c67ae2 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-16
+* **If at last rank, show a message to tell the player that.**
+
+
* **Added a few more items to the default list of items in sellall.**
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
index 71abf642c..d7bb62685 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
@@ -455,7 +455,16 @@ private boolean rankUpPrivate(CommandSender sender, String playerName, String la
RankPlayer rankPlayer = getRankPlayer( sender, player.getUUID(), player.getName() );
+
+
+ PlayerRank rankCurrent = rankPlayer.getPlayerRank(ladder);
+ if ( rankCurrent.getRank().getRankNext() == null ) {
+ rankupAtLastRankMsg(sender);
+ return false;
+ }
+ // If at last rank on ladder, then cannot /rankup
+// if ( rankPlayer.getran)
// Get the player's next rank on default ladder, or if at end then it will return the next
From aa737548b718677de3883934db5a3097a488fde7 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 16 Jul 2023 16:54:18 -0400
Subject: [PATCH 034/151] PrisonPasteChat: change the exception to just
Exception so it can capture all errors. The server has been down for the last
two days and so other errors need to be caught.
---
docs/changelog_v3.3.x.md | 4 ++++
.../java/tech/mcprison/prison/discord/PrisonPasteChat.java | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index e25c67ae2..0c2bcea3e 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,10 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-16
+* **PrisonPasteChat: change the exception to just Exception so it can capture all errors.**
+The server has been down for the last two days and so other errors need to be caught.
+
+
* **If at last rank, show a message to tell the player that.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonPasteChat.java b/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonPasteChat.java
index a88baaed2..7d4f53db8 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonPasteChat.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonPasteChat.java
@@ -249,8 +249,8 @@ private String postPaste( String text, boolean raw )
rawJson = reader.readLine();
}
}
- catch (IOException e) {
- Output.get().logError(
+ catch (Exception e) {
+ Output.get().logWarn(
String.format( "Failure in sending paste. %s ", e.getMessage()) , e );
}
From fbe93d4e33547e7253b12c649a48fbc574532909 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Wed, 19 Jul 2023 11:23:45 -0400
Subject: [PATCH 035/151] Prison Support: Start to setup an alternative
support file target, of an html file. This file will also convert minecraft
color codes to html colors.
---
docs/changelog_v3.3.x.md | 6 +-
.../prison/discord/PrisonSupportFiles.java | 398 ++++++++++++++++++
.../output/SupportHyperLinkComponent.java | 23 +
.../discord/PrisonSupportFilesTest.java | 49 +++
4 files changed, 475 insertions(+), 1 deletion(-)
create mode 100644 prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
create mode 100644 prison-core/src/main/java/tech/mcprison/prison/output/SupportHyperLinkComponent.java
create mode 100644 prison-core/src/test/java/tech/mcprison/prison/discord/PrisonSupportFilesTest.java
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 0c2bcea3e..73b5c87b8 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15a 2023-07-16
+# 3.3.0-alpha.15a 2023-07-19
+
+
+* **Prison Support: Start to setup an alternative support file target, of an html file.**
+This file will also convert minecraft color codes to html colors.
* **PrisonPasteChat: change the exception to just Exception so it can capture all errors.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java b/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
new file mode 100644
index 000000000..22ca6f54d
--- /dev/null
+++ b/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
@@ -0,0 +1,398 @@
+package tech.mcprison.prison.discord;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.DecimalFormat;
+
+import tech.mcprison.prison.Prison;
+
+public class PrisonSupportFiles {
+
+ public static final String PSFN_KEY__NAME = "{$name}";
+ public static final String PSFN_KEY__NUMBER = "{$number}";
+ public static final String PRISON_SUPPORT_FILE_NAME__PATTERN = "prison_support_" +
+ PSFN_KEY__NAME + "_" + PSFN_KEY__NUMBER + ".htm";
+
+ public static final String SECTION_CODE = "§";
+
+ private File supportFile;
+
+ private boolean colorMapping = true;
+
+ public enum ColorMaps {
+ black( "&0", "", "", ".cc0 { color: black; }"),
+ DarkBlue( "&1", "", "", ".cc1 { color: darkblue; }"),
+ DarkGreen( "&2", "", "", ".cc2 { color: darkgreen; }"),
+ DarkCyan( "&3", "", "", ".cc3 { color: darkCyan; }"),
+ DarkRed( "&4", "", "", ".cc4 { color: darkred; }"),
+ DarkMagenta( "&5", "", "", ".cc5 { color: darkmagenta; }"),
+ Orange( "&6", "", "", ".cc6 { color: orange; }"),
+ LightGray( "&7", "", "", ".cc7 { color: lightgray; }"),
+ DarkGray( "&8", "", "", ".cc8 { color: darkgray; }"),
+
+ Blue( "&9", "", "", ".cc9 { color: blue; }"),
+ Green( "&a", "", "", ".cca { color: green; }"),
+ Cyan( "&b", "", "", ".ccb { color: cyan; }"),
+ Red( "&c", "", "", ".ccc { color: red[; }"),
+ Magenta( "&d", "", "", ".ccd { color: magenta; }"),
+ Yellow( "&e", "", "", ".cce { color: yellow; }"),
+ White( "&f", "", "", ".ccf { color: white; }"),
+
+
+ bold( "&l", "", "", null ),
+ strike( "&m", "", "", null ),
+ underline( "&n", "", "", null ),
+ italic( "&o", "", "", null ),
+
+ reset( "&r", "", "", null ),
+
+ // Internal codes:
+ colorMappingOff( "&-", "", "", null ),
+ colorMappingOn( "&+", "", "", null )
+ ;
+
+ private final String colorCode;
+ private final String start;
+ private final String end;
+ private final String css;
+ private ColorMaps( String colorCode, String start, String end, String css ) {
+ this.colorCode = colorCode;
+ this.start = start;
+ this.end = end;
+ this.css = css;
+ }
+ public String getColorCode() {
+ return colorCode;
+ }
+ public String getStart() {
+ return start;
+ }
+ public String getEnd() {
+ return end;
+ }
+ public String getCss() {
+ return css;
+ }
+
+ public static ColorMaps match( String line ) {
+ ColorMaps results = null;
+
+ for (ColorMaps cm : values() ) {
+
+ String cc1 = cm.getColorCode();
+ String cc2 = cc1.replace("&", SECTION_CODE);
+
+// char test = line.charAt(0);
+// char test2 = '\u0167';
+//
+// String t = "Test: " + test + test2;
+//
+// String cc2 = cc1.replace("&", "§");
+// String cc3 = cc1.replace("&", "\u0167"); // Section code: §, § § §
+// String cc4 = cc1.replace("&", Character.toString(test2) );
+//
+// char test3 = cc2.charAt(0);
+
+// Character.getType( cc2.charAt(0));
+// Character. ( cc2.charAt(0));
+
+ if ( line.toLowerCase().startsWith( cc1 ) || line.startsWith( cc2 ) ) {
+ results = cm;
+ break;
+ }
+ }
+
+ return results;
+ }
+ }
+
+
+ public File setupSupportFile( String name ) {
+
+ String nameId = name.replaceAll("\\s", "_");
+ File file = createSupportFile( nameId );
+
+ setSupportFile( file );
+
+ return getSupportFile();
+ }
+
+ public void saveToSupportFile( StringBuilder text ) {
+
+ File file = getSupportFile();
+
+ // If an empty file, then delete it:
+ if ( file.exists() && file.length() == 0 ) {
+ file.delete();
+ }
+
+ if ( !file.exists() ) {
+ saveSupportDataToFile( text );
+ }
+ else {
+ appendSaveSupportDataToFile( text );
+ }
+
+ }
+
+// private void saveSupportDataToFile( StringBuilder text ) {
+// File file = getSupportFile();
+//
+// try {
+// Files.write( text.toString().getBytes(), file);
+// }
+// catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+
+
+ private void saveSupportDataToFile( StringBuilder text ) {
+ File file = getSupportFile();
+
+ try (
+ BufferedWriter bw = new BufferedWriter( new FileWriter( file, false )); // create file
+ ) {
+
+
+ bw.write( getGlobalCss() );
+
+ writeBufferedWriter( bw, text );
+
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void appendSaveSupportDataToFile( StringBuilder text ) {
+ File file = getSupportFile();
+
+ try (
+ BufferedWriter bw = new BufferedWriter( new FileWriter( file, true )); // append
+ ) {
+
+ bw.write( "\n\n- = - = - = - = - = - = - = - = - = - = -\n\n");
+
+ writeBufferedWriter( bw, text );
+// bw.write( text.toString() );
+
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ private void writeBufferedWriter( BufferedWriter bw, StringBuilder text ) {
+
+ try (
+ BufferedReader br = new BufferedReader( new StringReader( text.toString() ));
+ ) {
+
+ String line = br.readLine();
+
+ while ( line != null ) {
+
+ String converted = convertColorCodes( line );
+
+ bw.write(converted);
+
+ line = br.readLine();
+ }
+
+ }
+ catch ( Exception e ) {
+
+ }
+ }
+
+
+ protected String convertColorCodes(String line) {
+ StringBuilder sb = new StringBuilder();
+
+ if ( isColorMapping() ) {
+
+ StringBuilder sbEnd = new StringBuilder();
+
+ for ( int i = 0; i < line.length(); i++ ) {
+
+ int idx1 = line.indexOf(SECTION_CODE, i);
+ int idx2 = line.indexOf("&", i);
+
+ int idx = smallestButValid( idx1, idx2 );
+
+ if ( idx == -1 ) {
+ sb.append( line.substring(i) );
+ break;
+ }
+
+ String left = line.substring(i, idx);
+ sb.append( left );
+
+ String right = line.substring(idx);
+ ColorMaps cm = ColorMaps.match( right );
+
+ if ( cm == null ) {
+ sb.append( line.substring(idx,idx+1));
+ i = idx;
+ }
+ else if ( cm == ColorMaps.colorMappingOff ) {
+
+ setColorMapping( false );
+ sb.append( right.replace( cm.getColorCode(), "" ) );
+ break;
+ }
+ else if ( cm == ColorMaps.colorMappingOn ) {
+
+ setColorMapping( true );
+ sb.append( right.replace( cm.getColorCode(), "" ) );
+ break;
+ }
+ else if ( cm == ColorMaps.reset ) {
+ sb.append( sbEnd );
+ sbEnd.setLength(0);
+ i = idx + 1;
+ }
+ else {
+ sb.append( cm.getStart() );
+ sbEnd.insert(0, cm.getEnd() );
+ i = idx + 1;
+ }
+ }
+
+ sb.append( sbEnd )
+ .append( " ");
+ }
+ else {
+ ColorMaps cm = ColorMaps.match( line );
+
+ // ignore all other maps... since color mapping is off, we can only search for ON:
+ if ( cm == ColorMaps.colorMappingOn ) {
+ setColorMapping( true );
+
+ // Return the line without the color code:
+ sb.append( line.replace( cm.getColorCode(), "" ) )
+ .append( " ");
+ }
+ else {
+ sb.append( line )
+ .append( " ");
+
+ }
+ }
+
+ return sb.toString();
+ }
+
+ private int smallestButValid(int idx1, int idx2) {
+
+ int results = idx1 != -1 ? idx1 : -1;
+
+ if ( results == -1 || idx2 != -1 && idx2 < results ) {
+ results = idx2;
+ }
+
+ return results;
+ }
+
+ public String getFileStats( long addedContentSize ) {
+ StringBuilder sb = new StringBuilder();
+
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.000" );
+
+ double fileSize = getSupportFile().length() / 1024d;
+
+ double newDataSize = addedContentSize / 1024d;
+
+ sb.append( " * " )
+ .append( getSupportFile().getAbsolutePath() )
+ .append( " " )
+ .append( dFmt.format(fileSize) )
+ .append( " KB Added: " )
+ .append( dFmt.format(newDataSize) )
+ .append( " KB");
+
+ return sb.toString();
+ }
+
+
+ private File createSupportFile( File dir, String name ) {
+ File file = null;
+
+ DecimalFormat iFmt = new DecimalFormat( "0000" );
+
+ for ( int i = 0; i < 1000; i++ ) {
+ String fileName = PRISON_SUPPORT_FILE_NAME__PATTERN
+ .replace( PSFN_KEY__NAME, name )
+ .replace( PSFN_KEY__NUMBER, iFmt.format( i ) );
+
+ file = new File( dir, fileName );
+ if ( !file.exists() ) {
+ break;
+ }
+ }
+ return file;
+ }
+
+ private File createSupportFile( String name ) {
+ File dir = new File( Prison.get().getDataFolder(), "backups" );
+
+ File file = createSupportFile( dir, name );
+
+// File[] files = dir.listFiles( new FilenameFilter() {
+// public boolean accept( File dir, String fileName ) {
+// return fileName.startsWith("prison_support_") &&
+// fileName.endsWith(".md");
+// }
+// });
+
+ return file;
+ }
+
+ private String getGlobalCss() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "" );
+
+ return sb.toString();
+ }
+
+ public File getSupportFile() {
+ return supportFile;
+ }
+ public void setSupportFile(File supportFile) {
+ this.supportFile = supportFile;
+ }
+
+ public boolean isColorMapping() {
+ return colorMapping;
+ }
+ public void setColorMapping(boolean colorMapping) {
+ this.colorMapping = colorMapping;
+ }
+
+
+}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/output/SupportHyperLinkComponent.java b/prison-core/src/main/java/tech/mcprison/prison/output/SupportHyperLinkComponent.java
new file mode 100644
index 000000000..0bd33f354
--- /dev/null
+++ b/prison-core/src/main/java/tech/mcprison/prison/output/SupportHyperLinkComponent.java
@@ -0,0 +1,23 @@
+package tech.mcprison.prison.output;
+
+import tech.mcprison.prison.internal.CommandSender;
+
+public class SupportHyperLinkComponent
+ extends DisplayComponent {
+
+ protected String text;
+
+ public SupportHyperLinkComponent(String text, Object... args) {
+ this.text = Output.stringFormat(text, args);
+ }
+
+ @Override public String text() {
+ return text;
+ }
+
+ @Override public void send(CommandSender sender) {
+
+ // Do not send this message to the player... it is only for support documents:
+ //sender.sendMessage(text());
+ }
+}
diff --git a/prison-core/src/test/java/tech/mcprison/prison/discord/PrisonSupportFilesTest.java b/prison-core/src/test/java/tech/mcprison/prison/discord/PrisonSupportFilesTest.java
new file mode 100644
index 000000000..e058f19e1
--- /dev/null
+++ b/prison-core/src/test/java/tech/mcprison/prison/discord/PrisonSupportFilesTest.java
@@ -0,0 +1,49 @@
+package tech.mcprison.prison.discord;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class PrisonSupportFilesTest
+ extends PrisonSupportFiles
+{
+
+ @Test
+ public void test() {
+
+ String t1 = "This is a test";
+ String r1 = "This is a test ";
+
+ assertEquals(r1, convertColorCodes(t1) );
+
+
+ String t2 = "&3This is a test";
+ String r2 = "This is a test ";
+
+ assertEquals(r2, convertColorCodes(t2) );
+
+
+ String t3 = "&3This is a &1test";
+ String r3 = "This is a "
+ + "test ";
+
+ assertEquals(r3, convertColorCodes(t3) );
+
+
+ String t4 = "&3This is a &1test & sample";
+ String r4 = "This is a "
+ + "test & sample ";
+
+ assertEquals(r4, convertColorCodes(t4) );
+
+
+ String t5 = "&3This is a &1test & a&r fun &1sample";
+ String r5 = "This is a "
+ + "test & a"
+ + " fun sample ";
+
+ assertEquals(r5, convertColorCodes(t5) );
+
+ }
+
+}
From fc935b1e28a5d58b0553a41de9d275940ebf300f Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Wed, 19 Jul 2023 11:27:42 -0400
Subject: [PATCH 036/151] Prison Support: Setup the Platform with the function
to get the related Rank name or Ladder name, based upon the save file's name.
This is used to reverse engineer which rank or ladder is tied to a give file,
without having to read the file.
---
docs/changelog_v3.3.x.md | 4 +++
.../prison/internal/platform/Platform.java | 6 +++++
.../tech/mcprison/prison/TestPlatform.java | 9 +++++++
.../prison/ranks/managers/LadderManager.java | 18 ++++++++++++-
.../prison/ranks/managers/RankManager.java | 13 +++++++++
.../prison/spigot/SpigotPlatform.java | 27 ++++++++++++++++++-
6 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 73b5c87b8..1579ecf3f 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,10 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-19
+* **Prison Support: Setup the Platform with the function to get the related Rank name or Ladder name, based upon the save file's name.**
+This is used to reverse engineer which rank or ladder is tied to a give file, without having to read the file.
+
+
* **Prison Support: Start to setup an alternative support file target, of an html file.**
This file will also convert minecraft color codes to html colors.
diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java b/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
index 1c954dc6b..3249ca241 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
@@ -469,4 +469,10 @@ public void autoCreateMineLinerAssignment( List rankMineNames,
public int getMaxY();
+
+ public String getLadderByFileName(String name);
+
+
+ public String getRankByFileName(String name);
+
}
diff --git a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
index a17832b6d..5d7b08063 100644
--- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
+++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
@@ -546,4 +546,13 @@ public int getMinY() {
public int getMaxY() {
return 255;
}
+
+ public String getLadderByFileName(String name) {
+ return "default";
+ }
+
+
+ public String getRankByFileName(String name) {
+ return "a";
+ }
}
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/LadderManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/LadderManager.java
index b2613746c..f9bd31eac 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/LadderManager.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/LadderManager.java
@@ -134,9 +134,13 @@ public void saveLadder(RankLadder ladder, String fileKey) throws IOException {
* @throws IOException If the ladder could not be serialized, or if the ladder could not be saved to the file.
*/
private void saveLadder(RankLadder ladder) throws IOException {
- this.saveLadder(ladder, "ladder_" + ladder.getId());
+ this.saveLadder(ladder, getLadderName(ladder));
}
+ private String getLadderName( RankLadder ladder ) {
+ return "ladder_" + ladder.getId();
+ }
+
/**
*
This is the save function that should be used from outside of the LadderManager, such as
* within the LadderCommands functions because this will be able to handle the possible
@@ -369,5 +373,17 @@ public String printRankLadderInfoDetail( RankLadder ladder ) {
return ladderInfo;
}
+
+ public String getLadderByFileName(String fileName) {
+ String results = "";
+
+ for (RankLadder rankLadder : loadedLadders) {
+ String ladderFileName = getLadderName(rankLadder) + ".json";
+ if ( ladderFileName.equalsIgnoreCase(fileName) ) {
+ results = rankLadder.getName();
+ }
+ }
+ return results;
+ }
}
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankManager.java
index f56f41209..38766cc23 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankManager.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankManager.java
@@ -1570,6 +1570,19 @@ public void reloadPlaceholders() {
getTranslatedPlaceHolderKeys();
}
+
+
+ public String getRankByFileName(String fileName) {
+ String results = "";
+
+ for (Rank rank : loadedRanks) {
+ String rankFileName = rank.filename() + ".json";
+ if ( rankFileName.equalsIgnoreCase(fileName) ) {
+ results = rank.getName();
+ }
+ }
+ return results;
+ }
private List getLoadedRanks() {
return loadedRanks;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
index a5e37c73a..a1d599490 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
@@ -2586,7 +2586,9 @@ else if ( !isBasic ) {
}
-
+ // REMOVE! The following will "load" the WorldGuard settings and then dump them as json to console
+ // to confirm they were loaded properly. Remove when done with this test1
+// new WorldGuardSettings();
}
@@ -3152,4 +3154,27 @@ public int getMinY() {
public int getMaxY() {
return SpigotCompatibility.getInstance().getMaxY();
}
+
+ @Override
+ public String getLadderByFileName(String name) {
+ String results = "";
+
+ if ( PrisonRanks.getInstance().isEnabled() ) {
+ results = PrisonRanks.getInstance().getLadderManager().getLadderByFileName( name );
+ }
+
+ return results;
+ }
+
+ @Override
+ public String getRankByFileName(String name) {
+ String results = "";
+
+ if ( PrisonRanks.getInstance().isEnabled() ) {
+
+ results = PrisonRanks.getInstance().getRankManager().getRankByFileName( name );
+ }
+
+ return results;
+ }
}
From d75233d6b8fa37b6fb4bbe944e2365a669af2fbf Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Wed, 19 Jul 2023 11:33:10 -0400
Subject: [PATCH 037/151] Prison Support: More setup of the new
SupportHyperLinkComponent, but mostly the java docs which explains it pretty
well.
---
docs/changelog_v3.3.x.md | 2 +
.../mcprison/prison/output/ChatDisplay.java | 55 ++++++++++++++++++
.../output/SupportHyperLinkComponent.java | 56 +++++++++++++++++++
3 files changed, 113 insertions(+)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 1579ecf3f..3f00ec2da 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -16,6 +16,8 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-19
+* **Prison Support: More setup of the new SupportHyperLinkComponent, but mostly the java docs which explains it pretty well.**
+
* **Prison Support: Setup the Platform with the function to get the related Rank name or Ladder name, based upon the save file's name.**
This is used to reverse engineer which rank or ladder is tied to a give file, without having to read the file.
diff --git a/prison-core/src/main/java/tech/mcprison/prison/output/ChatDisplay.java b/prison-core/src/main/java/tech/mcprison/prison/output/ChatDisplay.java
index 05e938e08..306300843 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/output/ChatDisplay.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/output/ChatDisplay.java
@@ -152,5 +152,60 @@ public boolean isShowTitle() {
public void setShowTitle(boolean showTitle) {
this.showTitle = showTitle;
}
+
+ /**
+ *
This adds a hyperLink data element to the ChatDisplay.
+ * A hyperLink data element consist of 2 or 3 words, and no actual linkage. The hyperlinks
+ * will be auto generated when the support document is generated.
+ *
+ *
+ *
The proper format is for the first word to identify the major grouping, such as
+ * `Mine`, `Rank`, `Ladder`, or `Commands`.
+ *
+ *
+ *
The second word must be the name of the mine, rank, or ladder. For mines, ranks, and
+ * ladders, the second word can also be a type of groupings of such mines, rnaks, and ladders,
+ * such as `TOC`, `List`, etc...
+ * For commands, the second word must be the name of the command's config file.
+ *
+ *
+ *
The third word is used to qualify the type of item, for example for config files, the
+ * third world would always be `File` since it carries a special format where the contents
+ * do not have the color mappings rendered. Also, for some major groupings, like `Ladder List`,
+ * it also needs a qualifying ladder name as the third word since there are multiple
+ * ladders, each is a group of ranks, but there is also just a list of
+ * all ladders, as found in `Ladder List`. For example, `Ladder List default`, or
+ * `Ladder List donors`, with also `Ladder List`.
+ *
+ *
+ *
This structure is used to auto generate html tag IDs and also their related links
+ * to other content.
+ *
+ *
+ *
For example, let's assume we have one entry for `Rank B`. This will crate an ID for that
+ * section of something like `` Then it will also create hyperlinks
+ * to `(TOC)` `(Rank List)` `(Rank B File)`. These hyperlinks will then generat it's own ID, with
+ * hyperlinks to the other related content. This will allow fast and simple way to
+ * jump to the various components of data that is related to this concerpt of Rank B.
+ *
+ *
+ *
The data that is passed to this function should just be plain names. But the actual
+ * content is wrapped with double pipes. So if the data `Rank B` is passed to this function,
+ * it would be stored as `||Rank B||`. This notation is used to identify that it is a
+ * support hyperlink, so all supporting hyperlinks can be generated from this data.
+ *
+ *
+ *
This data will never be shown to players in game, or shown within the console.
+ * This is only included in the Prison Support documents to better utilize the
+ * support teams time and talents.
+ *
This adds a hyperLink data element to the ChatDisplay.
+ * A hyperLink data element consist of 2 or 3 words, and no actual linkage. The hyperlinks
+ * will be auto generated when the support document is generated.
+ *
+ *
+ *
This information applies to this data type, which is also part of the constructor
+ * with parameters.
+ *
+ *
+ *
The proper format is for the first word to identify the major grouping, such as
+ * `Mine`, `Rank`, `Ladder`, or `Commands`.
+ *
+ *
+ *
The second word must be the name of the mine, rank, or ladder. For mines, ranks, and
+ * ladders, the second word can also be a type of groupings of such mines, rnaks, and ladders,
+ * such as `TOC`, `List`, etc...
+ * For commands, the second word must be the name of the command's config file.
+ *
+ *
+ *
The third word is used to qualify the type of item, for example for config files, the
+ * third world would always be `File` since it carries a special format where the contents
+ * do not have the color mappings rendered. Also, for some major groupings, like `Ladder List`,
+ * it also needs a qualifying ladder name as the third word since there are multiple
+ * ladders, each is a group of ranks, but there is also just a list of
+ * all ladders, as found in `Ladder List`. For example, `Ladder List default`, or
+ * `Ladder List donors`, with also `Ladder List`.
+ *
+ *
+ *
This structure is used to auto generate html tag IDs and also their related links
+ * to other content.
+ *
+ *
+ *
For example, let's assume we have one entry for `Rank B`. This will crate an ID for that
+ * section of something like `` Then it will also create hyperlinks
+ * to `(TOC)` `(Rank List)` `(Rank B File)`. These hyperlinks will then generat it's own ID, with
+ * hyperlinks to the other related content. This will allow fast and simple way to
+ * jump to the various components of data that is related to this concerpt of Rank B.
+ *
+ *
+ *
The data that is passed to this function should just be plain names. But the actual
+ * content is wrapped with double pipes. So if the data `Rank B` is passed to this function,
+ * it would be stored as `||Rank B||`. This notation is used to identify that it is a
+ * support hyperlink, so all supporting hyperlinks can be generated from this data.
+ *
+ *
+ *
This data will never be shown to players in game, or shown within the console.
+ * This is only included in the Prison Support documents to better utilize the
+ * support teams time and talents.
+ *
+ *
+ *
+ *
+ * @author Blue
+ *
+ */
public class SupportHyperLinkComponent
extends DisplayComponent {
From 6d75b218f742b5047d96dc5294af6957b596b785 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Wed, 19 Jul 2023 12:03:51 -0400
Subject: [PATCH 038/151] Prison Support: Enabling the initial save file to an
HTML file. Color codes are working great, but needs some tweaking. The
framework for hyperlinks are inserted in most locations... they are just
double pipes surrounding 2 or 3 words. I will generate a series of classes
that will auto generate hyperlinks and table of contents based upon these
encodings.
---
docs/changelog_v3.3.x.md | 5 +
.../tech/mcprison/prison/PrisonCommand.java | 207 +++++++++++++-----
.../mcprison/prison/util/PrisonStatsUtil.java | 47 +++-
.../prison/ranks/commands/LadderCommands.java | 4 +
.../prison/ranks/commands/RanksCommands.java | 7 +
5 files changed, 217 insertions(+), 53 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 3f00ec2da..e64e41667 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -16,6 +16,11 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-19
+* **Prison Support: Enabling the initial save file to an HTML file.**
+Color codes are working great, but needs some tweaking.
+The framework for hyperlinks are inserted in most locations... they are just double pipes surrounding 2 or 3 words. I will generate a series of classes that will auto generate hyperlinks and table of contents based upon these encodings.
+
+
* **Prison Support: More setup of the new SupportHyperLinkComponent, but mostly the java docs which explains it pretty well.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
index 455c3115d..4244f4135 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
@@ -43,6 +43,7 @@
import tech.mcprison.prison.commands.RegisteredCommand;
import tech.mcprison.prison.commands.Wildcard;
import tech.mcprison.prison.discord.PrisonPasteChat;
+import tech.mcprison.prison.discord.PrisonSupportFiles;
import tech.mcprison.prison.internal.CommandSender;
import tech.mcprison.prison.internal.Player;
import tech.mcprison.prison.localization.LocaleManager;
@@ -73,6 +74,7 @@ public class PrisonCommand
private List prisonStartupDetails;
private String supportName = null;
+ private PrisonSupportFiles supportFile = null;
private TreeMap supportURLs;
@@ -1301,6 +1303,62 @@ public void supportSetName(CommandSender sender,
+ @Command(identifier = "prison support saveToFile",
+ description = "This sets the target of the support data to a local file.",
+ onlyPlayers = false, permissions = "prison.debug" )
+ public void supportSaveToFile(CommandSender sender,
+ @Wildcard(join=true)
+ @Arg(name = "options",
+ description = "Enables, or disables the support file. 'basic' will enable the support file " +
+ "and add 'version', 'ranks', 'mines, and 'configs to the file automatically. " +
+ "Defaults to 'enable'. [enable, basic, disable]" )
+ String options
+ ) {
+
+
+ if ( getSupportName() == null || getSupportName().trim().isEmpty() ) {
+ sender.sendMessage( "The support name needs to be set prior to using this command." );
+ sender.sendMessage( "Use &7/prison support setSupportName help" );
+
+ return;
+ }
+
+
+ if ( options != null && options.toLowerCase().startsWith( "disable" ) ) {
+
+ setSupportFile( null );
+ }
+ else {
+
+ setSupportFile( new PrisonSupportFiles() );
+ getSupportFile().setupSupportFile( getSupportName() );
+ }
+
+
+
+ sender.sendMessage( String.format( "Save the support data to file: %b",
+ getSupportFile() != null ) );
+
+ if ( getSupportFile() != null ) {
+ sender.sendMessage( "You can now use the support submit options and they will be save to files." );
+
+ sender.sendMessage( " Your support save file location: " +
+ getSupportFile().getSupportFile().getAbsolutePath() );
+
+ if ( options.toLowerCase().equals( "basic" ) ) {
+ supportSubmitVersion(sender);
+ supportSubmitRanks(sender);
+ supportSubmitMines(sender);
+ supportSubmitConfigs(sender);
+ }
+ }
+ else {
+ sender.sendMessage( "Support save file has been disabled. Support files have not been removed." );
+ }
+ }
+
+
+
@Command(identifier = "prison support submit version",
description = "For Prison support: This will copy the contents of '/prison version all' " +
"to paste.helpch.at so it can be easily shared with Prison's support staff .",
@@ -1352,23 +1410,33 @@ public void supportSubmitVersion(CommandSender sender
text.append( Output.decodePercentEncoding(log) ).append( "\n" );
}
+ if ( getSupportFile() != null ) {
+
+ getSupportFile().saveToSupportFile( text );
+
+ sender.sendMessage(" - Support 'version' data was just added to the support output file." );
+ sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
+ }
+ else {
+
+ PrisonPasteChat pasteChat = new PrisonPasteChat( getSupportName(), getSupportURLs() );
+
+ String helpURL = pasteChat.post( text.toString() );
+
+ getSupportURLs().put( "Submit version:", helpURL );
+
+ if ( helpURL != null ) {
+
+ sender.sendMessage( "Prison's support information has been pasted. Copy and " +
+ "paste this URL in to Prison's Discord server." );
+ sender.sendMessage( String.format( "Paste this URL: %s", helpURL ));
+ }
+ else {
+ sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." );
+ }
+
+ }
- PrisonPasteChat pasteChat = new PrisonPasteChat( getSupportName(), getSupportURLs() );
-
- String helpURL = pasteChat.post( text.toString() );
-
- getSupportURLs().put( "Submit version:", helpURL );
-
- if ( helpURL != null ) {
-
- sender.sendMessage( "Prison's support information has been pasted. Copy and " +
- "paste this URL in to Prison's Discord server." );
- sender.sendMessage( String.format( "Paste this URL: %s", helpURL ));
- }
- else {
- sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." );
- }
-
}
@@ -1394,24 +1462,34 @@ public void supportSubmitConfigs(CommandSender sender
StringBuilder text = Prison.get().getPrisonStatsUtil().getSupportSubmitConfigsData();
-
- PrisonPasteChat pasteChat = new PrisonPasteChat( getSupportName(), getSupportURLs() );
- String helpURL = pasteChat.postKeepColorCodes( text.toString() );
- getSupportURLs().put( "Submit configs:", helpURL );
-
- if ( helpURL != null ) {
+ if ( getSupportFile() != null ) {
- sender.sendMessage( "Prison's support information has been pasted. Copy and " +
- "paste this URL in to Prison's Discord server." );
- sender.sendMessage( String.format( "Paste this URL: %s", helpURL ));
+ getSupportFile().saveToSupportFile( text );
+
+ sender.sendMessage(" - Support 'configs' data was just added to the support output file." );
+ sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
}
else {
- sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." );
+
+ PrisonPasteChat pasteChat = new PrisonPasteChat( getSupportName(), getSupportURLs() );
+
+ String helpURL = pasteChat.postKeepColorCodes( text.toString() );
+
+ getSupportURLs().put( "Submit configs:", helpURL );
+
+ if ( helpURL != null ) {
+
+ sender.sendMessage( "Prison's support information has been pasted. Copy and " +
+ "paste this URL in to Prison's Discord server." );
+ sender.sendMessage( String.format( "Paste this URL: %s", helpURL ));
+ }
+ else {
+ sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." );
+ }
+
}
-
-
}
@@ -1435,23 +1513,32 @@ public void supportSubmitRanks(CommandSender sender
StringBuilder text = Prison.get().getPrisonStatsUtil().getSupportSubmitRanksData();
- PrisonPasteChat pasteChat = new PrisonPasteChat( getSupportName(), getSupportURLs() );
-
- String helpURL = pasteChat.post( text.toString() );
-
- getSupportURLs().put( "Submit ranks:", helpURL );
-
- if ( helpURL != null ) {
+ if ( getSupportFile() != null ) {
- sender.sendMessage( "Prison's support information has been pasted. Copy and " +
- "paste this URL in to Prison's Discord server." );
- sender.sendMessage( String.format( "Paste this URL: %s", helpURL ));
+ getSupportFile().saveToSupportFile( text );
+
+ sender.sendMessage(" - Support 'ranks' data was just added to the support output file." );
+ sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
}
else {
- sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." );
+
+ PrisonPasteChat pasteChat = new PrisonPasteChat( getSupportName(), getSupportURLs() );
+
+ String helpURL = pasteChat.post( text.toString() );
+
+ getSupportURLs().put( "Submit ranks:", helpURL );
+
+ if ( helpURL != null ) {
+
+ sender.sendMessage( "Prison's support information has been pasted. Copy and " +
+ "paste this URL in to Prison's Discord server." );
+ sender.sendMessage( String.format( "Paste this URL: %s", helpURL ));
+ }
+ else {
+ sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." );
+ }
}
-
}
@@ -1476,23 +1563,32 @@ public void supportSubmitMines(CommandSender sender
StringBuilder text = Prison.get().getPrisonStatsUtil().getSupportSubmitMinesData();
- PrisonPasteChat pasteChat = new PrisonPasteChat( getSupportName(), getSupportURLs() );
-
- String helpURL = pasteChat.post( text.toString() );
-
- getSupportURLs().put( "Submit mines:", helpURL );
-
- if ( helpURL != null ) {
+ if ( getSupportFile() != null ) {
- sender.sendMessage( "Prison's support information has been pasted. Copy and " +
- "paste this URL in to Prison's Discord server." );
- sender.sendMessage( String.format( "Paste this URL: %s", helpURL ));
+ getSupportFile().saveToSupportFile( text );
+
+ sender.sendMessage(" - Support 'mines' data was just added to the support output file." );
+ sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
}
else {
- sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." );
+
+ PrisonPasteChat pasteChat = new PrisonPasteChat( getSupportName(), getSupportURLs() );
+
+ String helpURL = pasteChat.post( text.toString() );
+
+ getSupportURLs().put( "Submit mines:", helpURL );
+
+ if ( helpURL != null ) {
+
+ sender.sendMessage( "Prison's support information has been pasted. Copy and " +
+ "paste this URL in to Prison's Discord server." );
+ sender.sendMessage( String.format( "Paste this URL: %s", helpURL ));
+ }
+ else {
+ sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." );
+ }
}
-
}
@@ -2333,6 +2429,13 @@ public void setSupportName( String supportName ) {
this.supportName = supportName;
}
+ public PrisonSupportFiles getSupportFile() {
+ return supportFile;
+ }
+ public void setSupportFile(PrisonSupportFiles supportFile) {
+ this.supportFile = supportFile;
+ }
+
public TreeMap getSupportURLs() {
return supportURLs;
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java b/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
index 56857746c..6267c2f0a 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
@@ -223,11 +223,54 @@ private void addFileToText(File file, StringBuilder sb) {
DecimalFormat dFmt = Prison.get().getDecimalFormatInt();
SimpleDateFormat sdFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ String parentDirName = file.getParentFile().getName();
+
+ String header = "";
+ String name = "";
+
+ if ( "ranks".equalsIgnoreCase(parentDirName) ) {
+ // Rank file names have a prefix of "ranks_" and then the rankId, followed by the suffix.
+ // Need to use the rankId to find the rank's name:
+
+ header = "Rank";
+ name = Prison.get().getPlatform().getRankByFileName( file.getName() );
+ }
+ else if ( "ladders".equalsIgnoreCase(parentDirName) ) {
+ // Ladder file names have a prefix of "ladders_" and then the ladderId, followed by the suffix.
+ // Need to use the ladderId to find the ladder's name:
+
+ header = "Ladder";
+ name = Prison.get().getPlatform().getLadderByFileName( file.getName() );
+ }
+ else if ( "mines".equalsIgnoreCase(parentDirName) ) {
+ // The file name of the mine, minus the suffix, is the name's name.
+
+ header = "Mine";
+ name = file.getName().replace(".json", "");
+ }
+ else {
+ header = "Config";
+ name = file.getName();
+ }
+
+
sb.append("\n");
JumboTextFont.makeJumboFontText(file.getName(), sb);
sb.append("\n");
+
+
+ // Hyper Link codes:
+ sb.append( "||" )
+ .append( header )
+ .append( " " )
+ .append( name )
+ .append( " " )
+ .append( "File" )
+ .append( "||\n" );
+
sb.append("File Name: ").append(file.getName()).append("\n");
sb.append("File Path: ").append(file.getAbsolutePath()).append("\n");
@@ -241,7 +284,9 @@ private void addFileToText(File file, StringBuilder sb) {
sb.append("\n");
if (file.exists() && file.canRead()) {
+ sb.append("&-");
readFileToStringBulider(file, sb);
+ sb.append("\n&+");
} else {
sb.append("Warning: The file is not readable so it cannot be included.\n");
}
@@ -251,7 +296,7 @@ private void addFileToText(File file, StringBuilder sb) {
public void printFooter(StringBuilder sb) {
- sb.append("\n\n\n");
+ sb.append("\n\n");
sb.append("=== --- === --- === --- === --- === --- ===\n");
sb.append("=== # # ### # # # ### # # # ### # # # ### # # # ### # # ===\n");
sb.append("=== --- === --- === --- === --- === --- ===\n");
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
index 4e166ba48..f1f42181c 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
@@ -96,6 +96,10 @@ public void ladderRemove(CommandSender sender, @Arg(name = "ladderName") String
public void ladderList(CommandSender sender) {
ChatDisplay display = new ChatDisplay("Ladders");
+
+ display.addSupportHyperLinkData( "Ladder List" );
+
+
BulletedListComponent.BulletedListBuilder list =
new BulletedListComponent.BulletedListBuilder();
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
index 47b28ea24..651155a9e 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
@@ -676,6 +676,8 @@ public void listRanks(CommandSender sender,
else {
display = new ChatDisplay( "List ALL Ranks" );
+ display.addSupportHyperLinkData( "Rank List" );
+
listAllRanksByLadders( display, hasPerm, rPlayer );
}
@@ -836,6 +838,8 @@ private ChatDisplay listRanksOnLadder( RankLadder ladder, boolean hasPerm, RankP
String rankHeader = ranksListHeaderMsg( ladder.getName() );
ChatDisplay display = new ChatDisplay( rankHeader );
+ display.addSupportHyperLinkData( "Ladder List %s", ladder.getName() );
+
display.addText( " " + PrisonRanks.getInstance().getLadderManager().printRankLadderInfoHeader() );
display.addText( " " + PrisonRanks.getInstance().getLadderManager().printRankLadderInfoDetail(ladder) );
@@ -1161,6 +1165,9 @@ private ChatDisplay rankInfoDetails( CommandSender sender, Rank rank, String opt
ChatDisplay display = new ChatDisplay( ranksInfoHeaderMsg( title ));
+ display.addSupportHyperLinkData( "Rank %s", rank.getName() );
+
+
boolean isOp = sender != null && sender.isOp();
boolean isConsole = sender == null || !sender.isPlayer();
From 65b9ae2c30419eb009a095d117a47c820c0c9894 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Wed, 19 Jul 2023 21:39:44 -0400
Subject: [PATCH 039/151] Prison Support: More enhancements to the html save
file. Instead of calling the four `/prison support submit` commands, they are
all now generated from within the same function. This will allow the
collection of all hyperlinks to generate a tabl of contents. Improvements to
the layout of some of the items in report.
---
docs/changelog_v3.3.x.md | 6 +
.../tech/mcprison/prison/PrisonCommand.java | 61 ++--
.../prison/discord/PrisonSupportFiles.java | 2 +-
.../mcprison/prison/util/PrisonStatsUtil.java | 267 ++++++++++++++++--
.../prison/mines/commands/MinesCommands.java | 2 +
.../prison/ranks/commands/LadderCommands.java | 56 +++-
.../prison/spigot/SpigotPlatform.java | 27 +-
7 files changed, 369 insertions(+), 52 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index e64e41667..4e158ea17 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -16,6 +16,12 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15a 2023-07-19
+
+* **Prison Support: More enhancements to the html save file.**
+Instead of calling the four `/prison support submit` commands, they are all now generated from within the same function. This will allow the collection of all hyperlinks to generate a tabl of contents.
+Improvements to the layout of some of the items in report.
+
+
* **Prison Support: Enabling the initial save file to an HTML file.**
Color codes are working great, but needs some tweaking.
The framework for hyperlinks are inserted in most locations... they are just double pipes surrounding 2 or 3 words. I will generate a series of classes that will auto generate hyperlinks and table of contents based upon these encodings.
diff --git a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
index 4244f4135..aa1e49c5c 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
@@ -1346,10 +1346,19 @@ public void supportSaveToFile(CommandSender sender,
getSupportFile().getSupportFile().getAbsolutePath() );
if ( options.toLowerCase().equals( "basic" ) ) {
- supportSubmitVersion(sender);
- supportSubmitRanks(sender);
- supportSubmitMines(sender);
- supportSubmitConfigs(sender);
+
+ StringBuilder text = Prison.get().getPrisonStatsUtil().getSupportSubmitBasic();
+
+ getSupportFile().saveToSupportFile( text );
+
+ sender.sendMessage(" - Support 'basic' data was just added to the support output file." );
+ sender.sendMessage(" - Includes: version, listeners, command stats, ladders, Ranks, Mines, and all Config files." );
+ sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
+
+// supportSubmitVersion(sender);
+// supportSubmitRanks(sender);
+// supportSubmitMines(sender);
+// supportSubmitConfigs(sender);
}
}
else {
@@ -1393,22 +1402,27 @@ public void supportSubmitVersion(CommandSender sender
);
// Include the command stats:
- text.append( "\n\n" );
- List cmdStats = getCommandStats();
- for (String cmd : cmdStats) {
- text.append( cmd ).append( "\n" );
- }
+ text.append( Prison.get().getPrisonStatsUtil().getCommandStatsDetailData() );
+// text.append( "\n\n" );
+// List cmdStats = getCommandStats();
+// for (String cmd : cmdStats) {
+// text.append( cmd ).append( "\n" );
+// }
// Include Prison backup logs:
- text.append( "\n\n" );
- text.append( "Prison Backup Logs:" ).append( "\n" );
- List backupLogs = getPrisonBackupLogs();
+ text.append( Prison.get().getPrisonStatsUtil().getPrisonBackupLogsData() );
+// text.append( "\n\n" );
+// text.append( "Prison Backup Logs:" ).append( "\n" );
+// List backupLogs = getPrisonBackupLogs();
+//
+// for (String log : backupLogs) {
+// text.append( Output.decodePercentEncoding(log) ).append( "\n" );
+// }
+
+
- for (String log : backupLogs) {
- text.append( Output.decodePercentEncoding(log) ).append( "\n" );
- }
if ( getSupportFile() != null ) {
@@ -1510,8 +1524,12 @@ public void supportSubmitRanks(CommandSender sender
}
+ // List Ladder and rank lists:
StringBuilder text = Prison.get().getPrisonStatsUtil().getSupportSubmitRanksData();
+ // List rank files:
+ text.append( Prison.get().getPrisonStatsUtil().getSupportSubmitRanksFileData() );
+
if ( getSupportFile() != null ) {
@@ -1978,7 +1996,8 @@ public void supportBackupList( CommandSender sender ) {
ChatDisplay display = new ChatDisplay("Prison Backup Logs:");
- List backupLogs = getPrisonBackupLogs();
+ List backupLogs = Prison.get().getPrisonStatsUtil().getPrisonBackupLogs();
+// List backupLogs = getPrisonBackupLogs();
for (String log : backupLogs) {
display.addText(log);
@@ -1988,11 +2007,11 @@ public void supportBackupList( CommandSender sender ) {
}
- private List getPrisonBackupLogs() {
- PrisonBackups prisonBackup = new PrisonBackups();
- List backupLogs = prisonBackup.backupReport02BackupLog();
- return backupLogs;
- }
+// private List getPrisonBackupLogs() {
+// PrisonBackups prisonBackup = new PrisonBackups();
+// List backupLogs = prisonBackup.backupReport02BackupLog();
+// return backupLogs;
+// }
@Command(identifier = "prison tokens balance",
diff --git a/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java b/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
index 22ca6f54d..7783a469d 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
@@ -313,7 +313,7 @@ public String getFileStats( long addedContentSize ) {
.append( getSupportFile().getAbsolutePath() )
.append( " " )
.append( dFmt.format(fileSize) )
- .append( " KB Added: " )
+ .append( " KB Before HTML conversion: " )
.append( dFmt.format(newDataSize) )
.append( " KB");
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java b/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
index 6267c2f0a..d7f0f2599 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
@@ -10,14 +10,100 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.TreeSet;
import tech.mcprison.prison.Prison;
+import tech.mcprison.prison.backups.PrisonBackups;
+import tech.mcprison.prison.commands.RegisteredCommand;
import tech.mcprison.prison.discord.PrisonPasteChat;
import tech.mcprison.prison.file.JsonFileIO;
import tech.mcprison.prison.output.ChatDisplay;
import tech.mcprison.prison.output.Output;
public class PrisonStatsUtil {
+
+
+ /**
+ *
This will return in a StringBuilder all of the information from the following
+ * commands. They will be combined in one large StringBuilder object so a table of
+ * contents can be built from it. This is similar to running the following 4
+ * commands, but are better organized with the order of the details (files last).
+ *
+ *
+ *
/prison support submit version
+ *
/prison support submit ranks
+ *
/prison support submit mines
+ *
/prison support submit commands
+ *
+ *
The difference with this function, is that all of the raw files are
+ * included at the end, instead of being mixed in with the other non-raw file
+ * dumps.
+ *
+ *
+ *
Order of reports:
+ *
+ *
Version ALL
+ *
listeners ALL
+ *
Command Stats
+ *
+ *
Ladder List - Missing?
+ *
Rank List
+ *
Rank details
+ *
+ *
Mine List
+ *
Mine details
+ *
+ *
Prison Backup Files
+
+ *
Ladder Files
+ *
Rank Files
+ *
+ *
Mine Files
+ *
+ *
ConfigSettings Files
+ *
+ *
+ *
+ * @return
+ */
+ public StringBuilder getSupportSubmitBasic() {
+ StringBuilder sb = new StringBuilder();
+
+ // version info:
+ sb.append( getSupportSubmitVersionData() );
+
+ // Listeners:
+ sb.append( getSupportSubmitListenersData( "all" ) );
+
+ // Command Stats:
+ sb.append( getCommandStatsDetailData() );
+
+
+ // Rank Lists and Rank details:
+ sb.append( getSupportSubmitRanksData() );
+
+
+ // Mine lists and Mine details:
+ sb.append( getSupportSubmitMinesData() );
+
+
+ // Backup log files:
+ sb.append( getPrisonBackupLogsData() );
+
+
+ // Rank Files:
+ sb.append( getSupportSubmitRanksFileData() );
+
+
+ // Mine files:
+ sb.append( getSupportSubmitMinesFileData() );
+
+
+ // Config files:
+ sb.append( getSupportSubmitConfigsData() );
+
+ return sb;
+ }
public ChatDisplay displayVersion(String options) {
@@ -102,14 +188,30 @@ public void copyConfigsFiles() {
}
-
+
public StringBuilder getSupportSubmitRanksData() {
+
+ StringBuilder text = new StringBuilder();
+
+ text.append(Prison.get().getPlatform().getRanksListString());
+ printFooter(text);
+
+// List files = listFiles("data_storage/ranksDb/ladders/", ".json");
+// files.addAll(listFiles("data_storage/ranksDb/ranks/", ".json"));
+// for (File file : files) {
+//
+// addFileToText(file, text);
+// }
+
+ return text;
+ }
+
+ public StringBuilder getSupportSubmitRanksFileData() {
List files = listFiles("data_storage/ranksDb/ladders/", ".json");
files.addAll(listFiles("data_storage/ranksDb/ranks/", ".json"));
StringBuilder text = new StringBuilder();
- text.append(Prison.get().getPlatform().getRanksListString());
printFooter(text);
for (File file : files) {
@@ -121,28 +223,46 @@ public StringBuilder getSupportSubmitRanksData() {
}
public StringBuilder getSupportSubmitMinesData() {
- List files = listFiles("data_storage/mines/mines/", ".json");
- Collections.sort(files);
+// List files = listFiles("data_storage/mines/mines/", ".json");
+// Collections.sort(files);
StringBuilder text = new StringBuilder();
- text.append("\n");
- text.append("Table of contents:\n");
- text.append(" 1. Mine list - All mines including virtual mines: /mines list all\n");
- text.append(" 2. Mine info - All mines: /mines info all\n");
- text.append(" 3. Mine files - Raw JSON dump of all mine configuration files.\n");
- text.append("\n");
+// text.append("\n");
+// text.append("Table of contents:\n");
+// text.append(" 1. Mine list - All mines including virtual mines: /mines list all\n");
+// text.append(" 2. Mine info - All mines: /mines info all\n");
+// text.append(" 3. Mine files - Raw JSON dump of all mine configuration files.\n");
+// text.append("\n");
// Display a list of all mines, then display the /mines info all for
// each:
text.append(Prison.get().getPlatform().getMinesListString());
- printFooter(text);
+// printFooter(text);
+// // get all the file details for each mine:
+// for (File file : files) {
+//
+// addFileToText(file, text);
+// }
+
+ return text;
+ }
+
+ public StringBuilder getSupportSubmitMinesFileData() {
+ List files = listFiles("data_storage/mines/mines/", ".json");
+ Collections.sort(files);
+
+ StringBuilder text = new StringBuilder();
+
+ printFooter(text);
+
+ // get all the file details for each mine:
for (File file : files) {
-
+
addFileToText(file, text);
-
}
+
return text;
}
@@ -156,11 +276,13 @@ public StringBuilder getSupportSubmitListenersData( String listenerType ) {
if ( "blockBreak".equalsIgnoreCase( listenerType ) || "all".equalsIgnoreCase( listenerType ) ) {
+ sb.append( "||Listeners blockBreak||" );
sb.append( Prison.get().getPlatform().dumpEventListenersBlockBreakEvents() );
}
if ( "chat".equalsIgnoreCase( listenerType ) || "all".equalsIgnoreCase( listenerType ) ) {
+ sb.append( "||Listeners chat||" );
sb.append( Prison.get().getPlatform().dumpEventListenersPlayerChatEvents() );
}
@@ -172,12 +294,109 @@ public StringBuilder getSupportSubmitListenersData( String listenerType ) {
if ( "playerInteract".equalsIgnoreCase( listenerType ) || "all".equalsIgnoreCase( listenerType ) ) {
+ sb.append( "||Listeners playerInteract||" );
sb.append( Prison.get().getPlatform().dumpEventListenersPlayerInteractEvents() );
}
return sb;
}
+
+ public StringBuilder getCommandStatsDetailData() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "\n\n" );
+
+ List cmds = getCommandStats();
+ cmds.add( 1, "||CommandStats List||" );
+
+ for (String cmd : cmds) {
+
+ sb.append( cmd ).append( "\n" );
+ }
+
+ return sb;
+ }
+
+ public void getCommandStatsData() {
+
+ List cmds = getCommandStats();
+ for (String cmd : cmds) {
+
+ Output.get().logInfo( cmd );
+ }
+ }
+
+ private List getCommandStats() {
+ List results = new ArrayList<>();
+
+ DecimalFormat iFmt = Prison.get().getDecimalFormatInt();
+ DecimalFormat dFmt = Prison.get().getDecimalFormatDouble();
+
+ TreeSet allCmds = Prison.get().getCommandHandler().getAllRegisteredCommands();
+
+ results.add( "Prison Command Stats:" );
+ results.add(
+ Output.stringFormat( " &a&n%-40s&r &a&n%7s&r &a&n%-11s&r",
+ " Commands ", " Usage ", " Avg ms ") );
+
+ int count = 0;
+ int totals = 0;
+ double totalDuration = 0d;
+ for (RegisteredCommand cmd : allCmds) {
+
+ if ( cmd.getUsageCount() > 0 ) {
+
+ double duration = cmd.getUsageRunTimeNanos() / (double) cmd.getUsageCount() / 1000000.0d;
+
+ results.add( Output.stringFormat( " &2%-40s &2%7s &2%11s",
+ cmd.getCompleteLabel(),
+ iFmt.format( cmd.getUsageCount() ),
+ dFmt.format( duration )
+ ) );
+ count++;
+ totals += cmd.getUsageCount();
+ totalDuration += cmd.getUsageRunTimeNanos();
+ }
+ }
+
+ results.add( Output.stringFormat(" &3Total Registered Prison Commands: &7%9s", iFmt.format( allCmds.size() )) );
+ results.add( Output.stringFormat(" &3Total Prison Commands Listed: &7%9s", iFmt.format( count )) );
+ results.add( Output.stringFormat(" &3Total Prison Command Usage: &7%9s", iFmt.format( totals )) );
+
+ double avgDuration = totalDuration / (double) count / 1000000.0d;
+ results.add( Output.stringFormat(" &3Average Command Duration ms: &7%9s", dFmt.format( avgDuration )) );
+
+ results.add( " &d&oNOTE: Async Commands like '/mines reset' will not show actual runtime values. " );
+
+
+ return results;
+ }
+
+
+ public StringBuilder getPrisonBackupLogsData() {
+ StringBuilder sb = new StringBuilder();
+
+ // Include Prison backup logs:
+ sb.append( "\n\n" );
+ sb.append( "Prison Backup Logs:" ).append( "\n" );
+ List backupLogs = getPrisonBackupLogs();
+
+ for (String log : backupLogs) {
+ sb.append( Output.decodePercentEncoding(log) ).append( "\n" );
+ }
+
+ return sb;
+ }
+
+
+ public List getPrisonBackupLogs() {
+ PrisonBackups prisonBackup = new PrisonBackups();
+ List backupLogs = prisonBackup.backupReport02BackupLog();
+ return backupLogs;
+ }
+
+
public void readFileToStringBulider(File textFile, StringBuilder text) {
try (BufferedReader br = Files.newBufferedReader(textFile.toPath());) {
String line = br.readLine();
@@ -220,7 +439,8 @@ private List listFiles(String path, String fileSuffix) {
}
private void addFileToText(File file, StringBuilder sb) {
- DecimalFormat dFmt = Prison.get().getDecimalFormatInt();
+ DecimalFormat iFmt = Prison.get().getDecimalFormatInt();
+ DecimalFormat dFmt = Prison.get().getDecimalFormatDouble();
SimpleDateFormat sdFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -271,12 +491,19 @@ else if ( "mines".equalsIgnoreCase(parentDirName) ) {
.append( "File" )
.append( "||\n" );
-
- sb.append("File Name: ").append(file.getName()).append("\n");
- sb.append("File Path: ").append(file.getAbsolutePath()).append("\n");
- sb.append("File Size: ").append(dFmt.format(file.length())).append(" bytes\n");
- sb.append("File Date: ").append(sdFmt.format(new Date(file.lastModified()))).append(" bytes\n");
- sb.append("File Stats: ").append(file.exists() ? "EXISTS " : "").append(file.canRead() ? "READABLE " : "")
+ String prisonPath = Prison.get().getDataFolder().getAbsolutePath();
+ String filePath = file.getAbsolutePath().replace( prisonPath, "" );
+
+ long fileSize = file.length();
+ double fileSizeKB = fileSize / 1024.0;
+
+ sb.append("File Name: ").append( file.getName() ).append("\n");
+ sb.append("Prison Path: ").append( prisonPath ).append("\n");
+ sb.append("File Path: ").append( filePath ).append("\n");
+ sb.append("File Size: ").append( iFmt.format( fileSize ) ).append(" bytes\n");
+ sb.append("File Size: ").append( dFmt.format( fileSizeKB ) ).append(" KB\n");
+ sb.append("File Date: ").append( sdFmt.format(new Date(file.lastModified())) ).append(" \n");
+ sb.append("File Stats: ").append( file.exists() ? "EXISTS " : "" ).append(file.canRead() ? "READABLE " : "")
.append(file.canWrite() ? "WRITEABLE " : "").append("\n");
sb.append("\n");
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesCommands.java
index 505fbcae0..f50b595e6 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesCommands.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesCommands.java
@@ -897,6 +897,8 @@ private ChatDisplay mineInfoDetails( CommandSender sender, boolean isMineStats,
DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
ChatDisplay chatDisplay = new ChatDisplay("&bMine: &3" + m.getName());
+
+ chatDisplay.addSupportHyperLinkData( "Mine %s", m.getName() );
{
RowComponent row = new RowComponent();
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
index f1f42181c..f8d9ab32a 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
@@ -94,11 +94,57 @@ public void ladderRemove(CommandSender sender, @Arg(name = "ladderName") String
@Command(identifier = "ranks ladder list", description = "Lists all rank ladders.",
onlyPlayers = false, permissions = "ranks.ladder")
public void ladderList(CommandSender sender) {
- ChatDisplay display = new ChatDisplay("Ladders");
-
- display.addSupportHyperLinkData( "Ladder List" );
+ ChatDisplay display = getLadderList();
+
+// ChatDisplay display = new ChatDisplay("Ladders");
+//
+// display.addSupportHyperLinkData( "Ladder List" );
+//
+// BulletedListComponent.BulletedListBuilder list =
+// new BulletedListComponent.BulletedListBuilder();
+//
+//// DecimalFormat dFmt = Prison.get().getDecimalFormat( "#,##0.0000" );
+//
+//// String header = String.format(
+//// "&d%-12s %16s %5s %12s %12s",
+//// "Ladder",
+//// "Rank Cost Mult",
+//// "Ranks",
+//// "First Rank",
+//// "Last Rank"
+//// );
+//
+// list.add( PrisonRanks.getInstance().getLadderManager().printRankLadderInfoHeader() );
+//
+// for (RankLadder ladder : PrisonRanks.getInstance().getLadderManager().getLadders()) {
+//
+//// int rankCount = ladder.getRanks() == null ? 0 : ladder.getRanks().size();
+////
+//// Rank firstRank = rankCount == 0 ? null : ladder.getRanks().get(0);
+//// Rank lastRank = rankCount == 0 ? null : ladder.getRanks().get( rankCount - 1 );
+////
+//// String ladderInfo = String.format(
+//// "&7%-12s %16s %4d %-12s %-12s",
+//// ladder.getName(),
+//// dFmt.format( ladder.getRankCostMultiplierPerRank() ),
+//// rankCount,
+//// firstRank.getName(),
+//// lastRank.getName()
+//// );
+//
+// list.add( PrisonRanks.getInstance().getLadderManager().printRankLadderInfoDetail( ladder ) );
+// }
+//
+// display.addComponent(list.build());
+ display.send(sender);
+ }
+
+ public ChatDisplay getLadderList() {
+ ChatDisplay display = new ChatDisplay("Ladders");
+
+ display.addSupportHyperLinkData( "Ladder List" );
BulletedListComponent.BulletedListBuilder list =
new BulletedListComponent.BulletedListBuilder();
@@ -136,8 +182,8 @@ public void ladderList(CommandSender sender) {
}
display.addComponent(list.build());
-
- display.send(sender);
+
+ return display;
}
// @Command(identifier = "ranks ladder listranks", description = "Lists the ranks within a ladder.",
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
index a1d599490..5920c43a5 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
@@ -98,6 +98,7 @@
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.output.RowComponent;
import tech.mcprison.prison.ranks.PrisonRanks;
+import tech.mcprison.prison.ranks.commands.LadderCommands;
import tech.mcprison.prison.ranks.commands.RanksCommands;
import tech.mcprison.prison.ranks.data.PlayerRank;
import tech.mcprison.prison.ranks.data.Rank;
@@ -2880,12 +2881,17 @@ public String getMinesListString() {
ChatDisplay display = new ChatDisplay("Mines");
+
+ display.addSupportHyperLinkData( "Mines List" );
+
+ // get the mine list:
mc.getMinesList( display, MineManager.MineSortOrder.sortOrder, "all", null );
StringBuilder sb = display.toStringBuilder();
sb.append( "\n" );
+ // get the mine details for all mines:
mc.allMinesInfoDetails( sb );
return sb.toString();
@@ -2894,20 +2900,31 @@ public String getMinesListString() {
@Override
public String getRanksListString() {
+ StringBuilder sb = new StringBuilder();
+
+ LadderCommands lc =
+ PrisonRanks.getInstance().getRankManager().getLadderCommands();
RanksCommands rc =
PrisonRanks.getInstance().getRankManager().getRanksCommands();
+ sb.append( "\n\n" );
+
+ ChatDisplay displayLadders = lc.getLadderList();
+
+ sb.append( displayLadders.toStringBuilder() );
+ sb.append( "\n" );
- ChatDisplay display = new ChatDisplay("Ranks");
RankPlayer rPlayer = null;
- rc.listAllRanksByLadders( display, true, rPlayer );
- StringBuilder sb = display.toStringBuilder();
+ ChatDisplay displayRanks = new ChatDisplay("Ranks");
+ rc.listAllRanksByLadders( displayRanks, true, rPlayer );
- sb.append( "\n" );
-
+ sb.append( displayRanks.toStringBuilder() );
+ sb.append( "\n" );
+
+
rc.listAllRanksByInfo( sb );
// rc.allRanksInfoDetails( sb );
From b8d00509f66e95ece76176fc5e6478a0e30bab26 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Thu, 20 Jul 2023 10:38:15 -0400
Subject: [PATCH 040/151] Prison Support: Support HTML file: Added a color test
to prison, color matched on the console's colors to provide an accurate
reproduction and match with the console. Added the ability to support
themes: console is the primary, with Madog being an alternative. Can have
others themes too. Fixed a few layout issues. Added the ladder listing,
which did not exist before. Setup the placeholders for the hyperlinks...
they will be added next along with the auto generation of a table of
contents.
---
docs/changelog_v3.3.x.md | 7 +-
.../tech/mcprison/prison/PrisonCommand.java | 24 ++-
.../prison/discord/PrisonSupportFiles.java | 191 +++++++++++++-----
.../mcprison/prison/util/PrisonStatsUtil.java | 41 ++++
.../discord/PrisonSupportFilesTest.java | 10 +-
5 files changed, 210 insertions(+), 63 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 4e158ea17..3284f2804 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,12 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15a 2023-07-19
+# 3.3.0-alpha.15a 2023-07-20
+
+
+* **Prison Support: Support HTML file: Added a color test to prison, color matched on the console's colors to provide an accurate reproduction and match with the console.**
+Added the ability to support themes: console is the primary, with Madog being an alternative. Can have others themes too.
+Fixed a few layout issues. Added the ladder listing, which did not exist before. Setup the placeholders for the hyperlinks... they will be added next along with the auto generation of a table of contents.
* **Prison Support: More enhancements to the html save file.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
index aa1e49c5c..69891a374 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
@@ -1349,7 +1349,7 @@ public void supportSaveToFile(CommandSender sender,
StringBuilder text = Prison.get().getPrisonStatsUtil().getSupportSubmitBasic();
- getSupportFile().saveToSupportFile( text );
+ getSupportFile().saveToSupportFile( text, getSupportName() );
sender.sendMessage(" - Support 'basic' data was just added to the support output file." );
sender.sendMessage(" - Includes: version, listeners, command stats, ladders, Ranks, Mines, and all Config files." );
@@ -1366,7 +1366,19 @@ public void supportSaveToFile(CommandSender sender,
}
}
-
+
+ @Command(identifier = "prison support colorTest",
+ description = "Displays a test swatch of minecraft colors .",
+ onlyPlayers = false, permissions = "prison.debug" )
+ public void supportColorTest(CommandSender sender
+ ) {
+
+ StringBuilder sb = Prison.get().getPrisonStatsUtil().getColorTest();
+
+ for (String line : sb.toString().split("\n")) {
+ Output.get().logInfo(line);
+ }
+ }
@Command(identifier = "prison support submit version",
description = "For Prison support: This will copy the contents of '/prison version all' " +
@@ -1426,7 +1438,7 @@ public void supportSubmitVersion(CommandSender sender
if ( getSupportFile() != null ) {
- getSupportFile().saveToSupportFile( text );
+ getSupportFile().saveToSupportFile( text, getSupportName() );
sender.sendMessage(" - Support 'version' data was just added to the support output file." );
sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
@@ -1480,7 +1492,7 @@ public void supportSubmitConfigs(CommandSender sender
if ( getSupportFile() != null ) {
- getSupportFile().saveToSupportFile( text );
+ getSupportFile().saveToSupportFile( text, getSupportName() );
sender.sendMessage(" - Support 'configs' data was just added to the support output file." );
sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
@@ -1533,7 +1545,7 @@ public void supportSubmitRanks(CommandSender sender
if ( getSupportFile() != null ) {
- getSupportFile().saveToSupportFile( text );
+ getSupportFile().saveToSupportFile( text, getSupportName() );
sender.sendMessage(" - Support 'ranks' data was just added to the support output file." );
sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
@@ -1583,7 +1595,7 @@ public void supportSubmitMines(CommandSender sender
if ( getSupportFile() != null ) {
- getSupportFile().saveToSupportFile( text );
+ getSupportFile().saveToSupportFile( text, getSupportName() );
sender.sendMessage(" - Support 'mines' data was just added to the support output file." );
sender.sendMessage( getSupportFile().getFileStats( text.length() ) );
diff --git a/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java b/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
index 7783a469d..940692dfb 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/discord/PrisonSupportFiles.java
@@ -15,7 +15,7 @@ public class PrisonSupportFiles {
public static final String PSFN_KEY__NAME = "{$name}";
public static final String PSFN_KEY__NUMBER = "{$number}";
public static final String PRISON_SUPPORT_FILE_NAME__PATTERN = "prison_support_" +
- PSFN_KEY__NAME + "_" + PSFN_KEY__NUMBER + ".htm";
+ PSFN_KEY__NAME + "_" + PSFN_KEY__NUMBER + ".html";
public static final String SECTION_CODE = "§";
@@ -24,46 +24,44 @@ public class PrisonSupportFiles {
private boolean colorMapping = true;
public enum ColorMaps {
- black( "&0", "", "", ".cc0 { color: black; }"),
- DarkBlue( "&1", "", "", ".cc1 { color: darkblue; }"),
- DarkGreen( "&2", "", "", ".cc2 { color: darkgreen; }"),
- DarkCyan( "&3", "", "", ".cc3 { color: darkCyan; }"),
- DarkRed( "&4", "", "", ".cc4 { color: darkred; }"),
- DarkMagenta( "&5", "", "", ".cc5 { color: darkmagenta; }"),
- Orange( "&6", "", "", ".cc6 { color: orange; }"),
- LightGray( "&7", "", "", ".cc7 { color: lightgray; }"),
- DarkGray( "&8", "", "", ".cc8 { color: darkgray; }"),
+ black( "&0", "", "" ),
+ DarkBlue( "&1", "", "" ),
+ DarkGreen( "&2", "", "" ),
+ DarkCyan( "&3", "", "" ),
+ DarkRed( "&4", "", "" ),
+ DarkMagenta( "&5", "", "" ),
+ Orange( "&6", "", "" ),
+ LightGray( "&7", "", "" ),
+ DarkGray( "&8", "", "" ),
- Blue( "&9", "", "", ".cc9 { color: blue; }"),
- Green( "&a", "", "", ".cca { color: green; }"),
- Cyan( "&b", "", "", ".ccb { color: cyan; }"),
- Red( "&c", "", "", ".ccc { color: red[; }"),
- Magenta( "&d", "", "", ".ccd { color: magenta; }"),
- Yellow( "&e", "", "", ".cce { color: yellow; }"),
- White( "&f", "", "", ".ccf { color: white; }"),
+ Blue( "&9", "", "" ),
+ Green( "&a", "", "" ),
+ Cyan( "&b", "", "" ),
+ Red( "&c", "", "" ),
+ Magenta( "&d", "", "" ),
+ Yellow( "&e", "", "" ),
+ White( "&f", "", "" ),
- bold( "&l", "", "", null ),
- strike( "&m", "", "", null ),
- underline( "&n", "", "", null ),
- italic( "&o", "", "", null ),
+ bold( "&l", "", "" ),
+ strike( "&m", "", "" ),
+ underline( "&n", "", "" ),
+ italic( "&o", "", "" ),
- reset( "&r", "", "", null ),
+ reset( "&r", "", "" ),
// Internal codes:
- colorMappingOff( "&-", "", "", null ),
- colorMappingOn( "&+", "", "", null )
+ colorMappingOff( "&-", "", "" ),
+ colorMappingOn( "&+", "", "" )
;
private final String colorCode;
private final String start;
private final String end;
- private final String css;
- private ColorMaps( String colorCode, String start, String end, String css ) {
+ private ColorMaps( String colorCode, String start, String end ) {
this.colorCode = colorCode;
this.start = start;
this.end = end;
- this.css = css;
}
public String getColorCode() {
return colorCode;
@@ -74,9 +72,6 @@ public String getStart() {
public String getEnd() {
return end;
}
- public String getCss() {
- return css;
- }
public static ColorMaps match( String line ) {
ColorMaps results = null;
@@ -121,7 +116,7 @@ public File setupSupportFile( String name ) {
return getSupportFile();
}
- public void saveToSupportFile( StringBuilder text ) {
+ public void saveToSupportFile( StringBuilder text, String supportName ) {
File file = getSupportFile();
@@ -131,7 +126,7 @@ public void saveToSupportFile( StringBuilder text ) {
}
if ( !file.exists() ) {
- saveSupportDataToFile( text );
+ saveSupportDataToFile( text, supportName );
}
else {
appendSaveSupportDataToFile( text );
@@ -151,7 +146,7 @@ public void saveToSupportFile( StringBuilder text ) {
// }
- private void saveSupportDataToFile( StringBuilder text ) {
+ private void saveSupportDataToFile( StringBuilder text, String supportName ) {
File file = getSupportFile();
try (
@@ -159,10 +154,13 @@ private void saveSupportDataToFile( StringBuilder text ) {
) {
- bw.write( getGlobalCss() );
+ bw.write( getHtmlHead( supportName ) );
+ bw.write( getHtmlBodyStart() );
writeBufferedWriter( bw, text );
+// bw.write( getHtmlBodyEnd() );
+
}
catch (IOException e) {
e.printStackTrace();
@@ -241,18 +239,21 @@ protected String convertColorCodes(String line) {
sb.append( line.substring(idx,idx+1));
i = idx;
}
+// else if ( cm == ColorMaps.colorMappingOn ) {
+//
+// setColorMapping( true );
+// sb.append( right.replace( cm.getColorCode(), "" ) );
+// break;
+// }
+// else if ( !isColorMapping() ) {
+// i = idx + 1;
+// }
else if ( cm == ColorMaps.colorMappingOff ) {
setColorMapping( false );
sb.append( right.replace( cm.getColorCode(), "" ) );
break;
}
- else if ( cm == ColorMaps.colorMappingOn ) {
-
- setColorMapping( true );
- sb.append( right.replace( cm.getColorCode(), "" ) );
- break;
- }
else if ( cm == ColorMaps.reset ) {
sb.append( sbEnd );
sbEnd.setLength(0);
@@ -263,10 +264,11 @@ else if ( cm == ColorMaps.reset ) {
sbEnd.insert(0, cm.getEnd() );
i = idx + 1;
}
+
}
sb.append( sbEnd )
- .append( " ");
+ .append( "\n");
}
else {
ColorMaps cm = ColorMaps.match( line );
@@ -277,11 +279,11 @@ else if ( cm == ColorMaps.reset ) {
// Return the line without the color code:
sb.append( line.replace( cm.getColorCode(), "" ) )
- .append( " ");
+ .append( "\n");
}
else {
sb.append( line )
- .append( " ");
+ .append( "\n");
}
}
@@ -354,6 +356,44 @@ private File createSupportFile( String name ) {
return file;
}
+ private String getHtmlHead( String supportName ) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "\n" )
+ .append( "\n" )
+ .append( "\n" )
+ .append( "Prison Support: " )
+ .append( supportName )
+ .append( "\n" )
+ .append( " \n" )
+ .append( getGlobalCss() )
+ .append( "\n" );
+
+ return sb.toString();
+ }
+
+ private String getHtmlBodyStart() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "\n");
+ sb.append( "
\n");
return sb.toString();
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java b/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
index 30f6121db..a597c11ae 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
@@ -173,6 +173,23 @@ public StringBuilder getColorTest() {
sb.append( "&f### f ### &r\n" );
sb.append( "&f######### &r\n" );
+
+ sb.append( "&3&l#####################&r\n" );
+ sb.append( "&3&l### Bold & 3 ###&r\n" );
+ sb.append( "&3&l#####################&r\n" );
+
+ sb.append( "&3&m#####################&r\n" );
+ sb.append( "&3&m### Strike & 3 ###&r\n" );
+ sb.append( "&3&m#####################&r\n" );
+
+ sb.append( "&3&n#####################&r\n" );
+ sb.append( "&3&n### Underline & 3 ###&r\n" );
+ sb.append( "&3&n#####################&r\n" );
+
+ sb.append( "&3&o#####################&r\n" );
+ sb.append( "&3&o### Italic & 3 ###&r\n" );
+ sb.append( "&3&o#####################&r\n" );
+
sb.append( "\n\n" );
return sb;
From b1d501e421e25785b5d3b3e45b87820262e96415 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Mon, 24 Jul 2023 22:49:55 -0400
Subject: [PATCH 045/151] Updated a number of prison docs.
---
...son_docs_010_setting_up_a_spigot_server.md | 11 +--
...rison_docs_012_setting_up_prison_basics.md | 30 +++++---
docs/prison_docs_013_Prison_Help.md | 75 +++++++++++++++++++
docs/prison_docs_101_setting_up_mines.md | 13 +++-
docs/prison_docs_111_mine_commands.md | 2 +-
5 files changed, 113 insertions(+), 18 deletions(-)
diff --git a/docs/prison_docs_010_setting_up_a_spigot_server.md b/docs/prison_docs_010_setting_up_a_spigot_server.md
index 44751af85..700636b22 100644
--- a/docs/prison_docs_010_setting_up_a_spigot_server.md
+++ b/docs/prison_docs_010_setting_up_a_spigot_server.md
@@ -13,7 +13,7 @@ Buildtools also allows easy setup of many test environments since all you
would need to do is to just change the version.
-*Documented updated: 2023-01-14*
+*Documented updated: 2023-07-24*
@@ -24,11 +24,11 @@ If you need more assistance, please search for online documentation since
there are many good resources out there.
* First install a copy of Java that is accessible from the command line.
- - The current version of Java is version 17. Even if you are using jars and other plugins that were compiled with Java 1.8.x, it is recommended to use Java 17.
- - If you feel like you must use Java 1.8, it's strongly suggested to use only the latest version 1.8.0_x.
+ - The current recommended version of Java is version 17. Even if you are using jars and other plugins that were compiled with Java 1.8.x, or older, it is recommended to use Java 17.
+ - If you feel like you must use Java 1.8, it's strongly suggested to use only the latest version 1.8.0_x since there are still current security releases.
-* You can download it from [Sun SE Development Kit 8]https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html) for product that you need.
+* You can download it from [Sun SE Development Kit 8]https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html) for a product that you need.
* You can also use Open JDK if Sun's license does not fit your needs. [OpenJDK Install](https://openjdk.java.net/install/)
@@ -61,6 +61,7 @@ there are many good resources out there.
java -jar BuildTools.jar --rev 1.17.1
java -jar BuildTools.jar --rev 1.18.2
java -jar BuildTools.jar --rev 1.19.3
+ java -jar BuildTools.jar --rev 1.20.1
```
* For example, with BuildTools.jar being in a root directory, create a subdirectory and then start a build within that directory. The benefit is that you can use the same BuildTools.jar to build multiple different versions of spigot. This example starts off with building a v1.17.1 instance and then builds a 1.8.8 instance. Normally you wouldn't build multiple versions of spigot, but this shows how easy and flexible it is to build any version of spigot that has been released.
@@ -79,7 +80,7 @@ there are many good resources out there.
* **Updating BuildTools:** Once in a while you will be prompted to update the BuildTools.jar file. To do update it, all you need to do is to just download it, and replace the older one you were using.
-* **Updating the built servers:** Every once in a while, when you are starting a server, there may be a notification that the server software needs to be update. Just rerun the BuildTools for the same version within the original build directory. The build tools will update all of the changed resources and then generate the new server jars that you copy to the actual server (see the next step).
+* **Updating the built servers:** Every once in a while, when you are starting a server, there may be a notification that the server software needs to be update and the server startup will be paused for about 20 seconds. Just rerun the BuildTools for the same version within the original build directory. The build tools will update all of the changed resources and then generate the new server jars that you copy to the actual server (see the next step).
diff --git a/docs/prison_docs_012_setting_up_prison_basics.md b/docs/prison_docs_012_setting_up_prison_basics.md
index 0dee13510..71d18ace3 100644
--- a/docs/prison_docs_012_setting_up_prison_basics.md
+++ b/docs/prison_docs_012_setting_up_prison_basics.md
@@ -7,7 +7,7 @@
This document provides a quick overview on how to install Prison and get it running.
-*Documented updated: 2023-01-28*
+*Documented updated: 2023-07-24*
@@ -18,9 +18,10 @@ This document provides a quick overview on how to install Prison and get it runn
Download Prison from one of the following sites:
* [spigotmc.org's Prison History Page](https://www.spigotmc.org/resources/prison.1223/history).
-* [Polymart.org](https://polymart.org/resource/prison-1-8-x-1-17.678)
+* [Polymart.org](https://polymart.org/resource/prison-1-8-x-1-20-x.678)
* [bukkit.org](https://www.curseforge.com/minecraft/bukkit-plugins/mc-prison-v3)
+These sites will have stable alpha releases published to them from time to time.
Setting up Prison is simple:
@@ -34,7 +35,7 @@ Setting up Prison is simple:
- You can always find the latest alpha build on the Discord Server in the #alpha-versions channel:
- [Prison Discord Server](https://discord.gg/DCJ3j6r)
-* Copy the prison jar file to your server's plugin directory.
+* Copy the prison jar file to your server's `/plugin` directory.
* Remove any older prison jar file
@@ -43,7 +44,7 @@ Setting up Prison is simple:
* Prison's startup information contains a lot of information. If you ever have issues, check that information first since it probably will identify what the issues are.
-* It is strongly suggested that `/ranks autoConfigure` is ran to initially setup your Prison environment. A great deal of configurations are setup that can save a lot of effort. Even if you are wanting to start from scratch, it may be worth giving it a try to see how some of the more complex settings are configured. You can always start over by deleting the `plugins/Prison/` directory.
+* It is strongly suggested that `/ranks autoConfigure` is ran to initially setup your Prison environment. A great deal of configurations are setup that can save a lot of effort. Even if you are wanting to start from scratch, it may be worth giving it a try to see how some of the more complex settings are configured. You can always start over by deleting the `/plugins/Prison/` directory then restarting the server.
* Follow Prison's documentation on customization; at this point it's ready for use.
@@ -60,7 +61,7 @@ Setting up Prison is simple:
There may be no hard dependencies that will prevent Prison from running, but there are some core plugins that will make it easier to use, and are even required for activation of some features within Prison. This short list is just a suggestion, but alternatives do exist and may be outside of our ability to comment or assist in their usage.
-* **Vault** - Optional, but STRONGLY Suggested - This is perhaps the most important plugin. This plugin provides a common way to access other plugins running on your server, but without having to write any code within Prison to support them. Vault provides the mapping of a plugin's unique APIs to a common Vault API. Vault helps support Economy, Permissions, and Placeholders. Because of Vault, Prison can work flawlessly with dozens of other plugins. Please refer to Vault's documentation for what it supports.
+* **Vault** - Optional, but **STRONGLY Suggested** - This is perhaps the most important plugin. This plugin provides a common way to access other plugins running on your server, but without having to write any code within Prison to support them. Vault provides the mapping of a plugin's unique APIs to a common Vault API. Vault helps support Economy, Permissions, and Placeholders. Because of Vault, Prison can work flawlessly with dozens of other plugins. Please refer to Vault's documentation for what it supports. Valut does have it's limitations, such as it can only support one currency at a time.
* **EssentialsX** - **STRONGLY SUGGESTED**, but still Optional - Provides many of the basic commands and behaviors that you would expect from a Spigot server such as chat, warps, and even some moderation commands and commands that can be given to premium players. EssentialsX is not Essentials, since Essentials is an older abandoned project, and EssentialsX is a forked project that is still maintained. Unfortunately, internally it is identified as simply Essentials, but you can tell it's EssentialsX if the version is greater than 2.15.x.
@@ -72,6 +73,8 @@ There may be no hard dependencies that will prevent Prison from running, but the
Prison requires an active economy in order to active the Ranks plugin. When Prison starts up, it performs many validations on the mines and ranks as they are being loaded. With Ranks, if Prison cannot find an active economy, then it will refuse to load the Ranks module due to possible server corruption (ie... what failed that there is no economy).
+We say an economy is required, but it's still optional. Without an economy, you cannot use the ranks module, but we fully understand that some servers choose to use a different ranks plugin.
+
* **EssentialsX Economy** - SUGGESTED - Optional - This is a simple economy plugin that just works well. If you don't have a specific need to use another economy plugin, then it may be best to use this one since it works so well. The reason why we recommend this economy is because it always works. That said, we acknowledge the reason it works well, is because it is so simple, so if there are features in other economy plugins that you want to use on your sever, then please explore using them. But overall, if you just want an economy that is rock solid, then EssentialsX's Economy is a great choice.
@@ -163,13 +166,15 @@ All of Prison's placeholders have an alias. An alias is a shortened name for a
**NOTE: Prison no longer supports MVdWPlaceholder** because it could not support all of the advanced features with placeholders that prison uses. Also, since prison generates so many possible placeholders, MVdW pollutes the console log with thousands of lines of useless information stating each variant of a placeholder has been registered. We also dropped support for this plugin because there is no way to contact the developer because they hide behind a pay-wall, and I'm not about to buy one of their other plugins to just tell them their so-called-free plugin is not working properly.
-But perhaps the biggest reason why I dropped support for MVdW is because it's 100% pointless. **PlaceholderAPI** works flawlessly with MVdW so there is absolutely no reason why prison needs to support MVdW anymore. If you need to use MVdW, then please keep using it, it works great with their other plugins. But you can use PlaceholderAPI along with it too. So there are zero reasons why you cannot use PlaceholderAPI, and everyone is happy.
+But perhaps the biggest reason why I dropped support for MVdW is because it's 100% pointless from Prison's perspective. **PlaceholderAPI** works flawlessly with MVdW installed too, so there is absolutely no reason why prison needs to support MVdW anymore since everything works perfectly through PlaceholderAPI. If you need to use MVdW, then please keep using it, it works great with their other plugins. But you can use PlaceholderAPI along with it too. So there are zero reasons why you cannot use PlaceholderAPI, and everyone is happy.
~~Suggested to Avoid - Prison does support this plugin, but since it is used mostly with premium plugins, we have no way to fully test this plugin to ensure it actually works correctly. We've heard very few people have used this plugin, but we've heard it does work well. Use at your own risk.~~
~~With this plugin, all placeholders are registered with it automatically when prison starts up, and all placeholders should be used as all lower case. Because prison has so many placeholders, with many that are expanded based upon ladders, ranks, and mine names, a modest prison server could generate and register well over 1000 placeholders. MVdWPlaceholder appears to be very verbose so you will see a lot of logging in the console when it starts up.~~
-~~It should also be noted that because of some of the limitations of MVdW, not all features of Prison's placeholder support will be supported. For example, you may not be able to reload placeholders, or use placeholder attributes to customize how placeholders are used.~~
+~~It should also be noted that because of some of the limitations of MVdW, not all features of Prison's placeholder support will be supported. For example, you may not be able to reload placeholders, or use placeholder attributes to customize how placeholders are used. Also the numerical sequence placeholders may not work either.~~
+
+~~Like it was said earlier, there is no way to contact the developers. If we could make just one suggestion, and that would be to allow setting up placeholders by specifying a prefix that's used. This is how PlaceholderAPI works, so with just registering once, a value of "prison_" that ensures all of prison's placeholders are routed to us. Also, make sure the allowable placeholders are not limited by length. Prison use placeholder attributes that can customize how the results are modified which gives an almost limitless opportunity to customize placeholders as desired to match the server's design standards. The third suggestion for changes is to allow the reloading of placeholders with a simple command, such as reregistering them. As admins add ranks, ladders, or mines, or even change their names, then all of the placeholders must be reregistered so the new entries are included.~~
@@ -243,7 +248,9 @@ Warning: People have paid for this plugin only to find out after the fact that i
If you purchase this plugin to use on your server, do so with great caution since it is not supported and it may not integrate with prison.
[ * Not supported * Tokens * Not supported * ](https://www.spigotmc.org/resources/%E2%9A%A1%EF%B8%8F-tokens-%E2%9A%A1%EF%B8%8F-40-enchantments-%E2%AD%95-free-expansions-%E2%AD%95-25-off.79668/)
-**Please Note:** There is another plugin by the same name "Tokens" that strictly deals with tokens and not enchantments, which works just fine with prison.
+
+**Please Note:** There is another plugin by the same name "Tokens" that strictly deals with tokens and not enchantments, which works just fine with prison. I have even personally contributed to that plugin to provide caching of the player's data to resolve an issue with ultra fast mining in prison. Basically it used to be that if you give players tokens too quickly, it would lockup the server trying to update the save files. Now it easily supports 100's, if not 1000's of transactions per second without any impact to the TPS.
+
### Enchantment Plugin Features Supported
@@ -461,15 +468,16 @@ Once entered, it will enable the following submit tools:
`/prison support submit` - Show the available tools.
```
+/prison support submit version
/prison support submit configs
/prison support submit latestLogs
/prison support submit mines
/prison support submit ranks
-/prison support submit version
```
-Here is an example that I generated from one of my test servers on 2021-12-03. I have no idea how long the content remains available, but for support purposes, we only need this information for a few hours.
- [https://paste.helpch.at/itejovejeh](https://paste.helpch.at/itejovejeh)
+Here is an example that I generated from one of my test servers on 2021-12-03. I have no idea how long the content remains available, but for support purposes, we only need this information for a few hours. It appears like this information is never deleted? As such, here are two different versions which shows you how much more information has been addeed.
+ [https://paste.helpch.at/silihuxaja](https://paste.helpch.at/silihuxaja) From Prison v3.3.0-alpha.15a
+ [https://paste.helpch.at/itejovejeh](https://paste.helpch.at/itejovejeh) From Prison v3.2.11-alpha.9
# Prison Commands
diff --git a/docs/prison_docs_013_Prison_Help.md b/docs/prison_docs_013_Prison_Help.md
index f6d6bd04e..353dfa148 100644
--- a/docs/prison_docs_013_Prison_Help.md
+++ b/docs/prison_docs_013_Prison_Help.md
@@ -13,6 +13,10 @@ This document provides some important information on how to find help in setting
# Overview
+We take support seriously. We realize that being a Prison plugin, we are working with a lot of different aspects of minecraft, and that there are many other plugins that may cross paths with Prison. We cannot support every single plugin out there, but we will try to resolve and identify all problems that are brought to our attention..
+
+Because we are so very concerned with your server's functionality, we have put a lot of effort in trying to create support tools to better understand what is happening. We cannot control other plugins, but prison is capable of tracking and reporting many fine-grained details about how it works and what is happening step-by-step. This can allow us to figure out difficult problems.
+
If you are having problem, please take a quick look at the following documents as found in the Table of Contents:
* Setting up prison and various plugins - If special conditions for their configurations become apparent in order for prison to work, notes will be added there. If you notice there is a special configuration consideration that we did not document, please share with us so we can update the documents.
@@ -129,6 +133,77 @@ You can also submit a help ticket on the Prison github Issues tab, but the respo
+
+# Prison Support Submit Information
+
+Prison now has a built in way to share your configurations and settings with support personnel.
+
+More information will be documented in the future, but for now, here are the basics on how to use it.
+
+When requested by the Prison support team, you would first enter the following command to set your name that will be included on all reports to help identify who the are related to. It doesn't have to be your full discord name, but enough characters to allow us to identify who you are.
+
+
+These commands will collect all of the related information from your Prison setup, and send it to the website `https://paste.helpch.at`. It will provide you with an URL. All you need to do is to copy and paste that URL in to the discord chat so the Prison support team can help with your issue.
+
+
+`/prison support setSupportName `
+
+Once entered, it will enable the following submit tools:
+
+`/prison support submit` - Show the available tools.
+
+```
+/prison support submit version
+/prison support submit ranks
+/prison support submit mines
+/prison support submit configs
+/prison support submit listeners
+/prison support submit latestLogs
+```
+
+**Version** This is generally the most requested information needed for support. Provides general overall information on Prison and it's environment on the server. This is similar to the command `/prison version all` plus a few other features such as listeners, and the command cache.
+
+**Ranks** This is everything related to ranks. Includes ladders, ranks lists, and rank details. It also includes all of the raw save file for these items too.
+
+**Mines** This is everything related to mines. Includes the mine list, mine info, and the related files for each mine.
+
+**Configs** These are all of the other config files that are within prison. These do not include any of the files included in ranks or mines.
+
+**Listeners** These are dumps of the event listeners for BlockBreak, chat, and playerinteract. See the command `/prison support listeners help` for more detailed information.
+
+**LatestLogs** This will send the latest log file, up to a max allowed amount.
+
+
+Here are two examples that I generated from one of my test servers on 2021-12-03 and 2023-07-24. I have no idea how long the content remains available, but for support purposes, we only need this information for a few hours. It appears like this information is never deleted? As such, here are two different versions which shows you how much more information has been added.
+ [https://paste.helpch.at/silihuxaja](https://paste.helpch.at/silihuxaja) From Prison v3.3.0-alpha.15a
+ [https://paste.helpch.at/itejovejeh](https://paste.helpch.at/itejovejeh) From Prison v3.2.11-alpha.9
+
+
+# Prison Support HTML Output Files
+
+As a brand new feature, Prison now is able to generate HTML files that are stored within the `plugins/Prison/backups/` directory. It includes information from version, ranks, mines, listeners, and configs. See above. The nice thing about this support format is that it reproduces all of the colors as found in the console version of these commands.
+
+This file format is also good for server owners who do not want to post their server information on another website.
+
+To generate the file, use the command:
+`/prison support saveToFile help`
+
+To generate with the defaults settings:
+`/prison support saveToFile basic`
+
+If an existing file exists, it will generate the next one in the series. When ran, it will identify what the current file is. Please send this file to support.
+
+
+
+If you want to use this format instead of the above file that are sent to paste.helpch.at, then generate the file and you can DM it to either Blue or Madog. It's best to ask before sending to confirm we are available to respond to your needs.
+
+
+NOTE: Hyperlinks and table of contents will be added to this HTML support document.
+
+
+
+
+
# Prison Debugger
diff --git a/docs/prison_docs_101_setting_up_mines.md b/docs/prison_docs_101_setting_up_mines.md
index e116ed6db..15594f294 100644
--- a/docs/prison_docs_101_setting_up_mines.md
+++ b/docs/prison_docs_101_setting_up_mines.md
@@ -15,6 +15,9 @@ This document provides some highlights to how to setup mines. It is a work in p
This document should be able to provide the basic information to get your mines configured. There are many options available within Prison, and also through the use of other plugins, so advanced topics that blend multiple plugins, and their various settings, are beyond the scope of this document.
+As a side note, if you installed prison, and it appears like it may not be working in a specific world, please see the `config.yml` file to see if prison's command handler is disabled within that world. If it is, then all prison commands will be turned off in that world, and there will be no way to bypass it unless the config.yml file is changed.
+
+
Prison has a list of suggested plugins that works well with Prison, and a few that do not work at all with Prison. Please see the following document for a list of suggested plugins. If you have a favorite plugin that works well with Prison and it's not in that list, then please reach out to us in our discord server and make a suggestion for it to be added.
[Setting up Prison - The Basics](prison_docs_012_setting_up_prison_basics.md)
@@ -249,7 +252,11 @@ Some of the highlights of these commands are as follows:
* `/mines set liner` : A quick way to wrap your mine with a 2D Pattern in 3D space. This command also will `repair` the area around a mine, and will effectively erase a liner. There are six directions that can be specified for change: `north`, `south`, `east`, `west`, `top`, and `bottom`. `walls` also is a shortcut for `north`, `south`, `east`, and `west`. The patterns available are listed by the command. There is even a `force` setting that will allow the mine to be wrapped when in air, since the wrappings normally needs blocks in contact with the mine so it is able to conform to the terrain.
+
+
* `/mines set mineSweeper` : If all else fails to get Prison to monitor and track blocks that are broken within a mine, mostly due to conflicts with other plugins, then this option can provide a last chance effort to monitor the progress within a mine. It is very rare that you would have to use this setting and the chances are that there are better ways to get the mines working correctly. The larger the mine, the more costly this setting is to enable.
+
+
* **Removed:** `/mines set move` is a new command that is not yet enabled. It is still in development, but will be active soon. This command will move a whole mine as a single unit, be it a few blocks or many (not recommended). The same effect of moving a mine can be done through the command: `/mine set size` but note it will possibly damage or destory the surrounding builds if not careful.
* **Removed:** `/mines set norank` : Disconnect the mine from a rank. **Note:** This command has been changed to `/mines set rank *none*` to delete the rank from the mine.
@@ -266,7 +273,11 @@ Some of the highlights of these commands are as follows:
* `/mines set sortOrder` : Mines can be sorted for view within `/mines list` or the GUI. Setting the sortOrder allows you manually set the order in which the mines are listed. There is even the option to suppress (hide) mines from that list too by setting the sort order to a -1.
* `/mines set spawn` : Sets the mines spawn point. Whatever you are looking at is what the players will be looking at when they tp to that spot.
* `/mines set tag` : Set a mine tag value that can be used with placeholders.
-* `/mines set tracer` : Removes all blocks in a mine and replaces them with air, with the exception of the corners, of which are replace with pink_stained_glass. This function allows for easy viewing of the full mine without the blocks getting in the way. It also helps when setting the liner of the mine. Using `/mines reset` returns the mine to normal functionality, or it will reset on its own.
+
+
+* `/mines set tracer help` : Removes all blocks in a mine and replaces them with air. This is good to allow you to access and work on the liners or ladders. There are three options with this command: `outline`, `corners` and `clear`. The option `outline` is the default and will use this option unless the others are specified. `outline` will apply pink glass blocks along the outline of the mine. `corners` will only place pink stained glass blocks in the 8 corners of the mine. And `clear` will add no tracers and will result in a fully cleared mine. This function allows for easy viewing of the full mine without the blocks getting in the way. It also helps when setting the liner of the mine. Using `/mines reset` returns the mine to normal functionality, or it will reset on its own.
+
+.
* `/mines set zeroBlockResetDelay` : If the mine runs out of blocks, when enabled, it will force a manual reset after the specified delay. The delay can be zero for instant reset.
diff --git a/docs/prison_docs_111_mine_commands.md b/docs/prison_docs_111_mine_commands.md
index 6f11fbc15..346b73749 100644
--- a/docs/prison_docs_111_mine_commands.md
+++ b/docs/prison_docs_111_mine_commands.md
@@ -29,7 +29,7 @@ My personal goals to use this new feature was to dynamically build a large fores
The family of mine commands are as follows:
```
-/mines command
+/mines
```
From d66d47c37cf1cb7c5afd1a6bdfccb093b3ccc8fe Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Thu, 27 Jul 2023 18:57:57 -0400
Subject: [PATCH 046/151] TopN: TopN was not being disabled correctly for when
ranks were disabled. This now properly checks the PrisonRanks to see if the
ranks module is active or not. The prior code was not being as detailed.
---
docs/changelog_v3.3.x.md | 6 +++-
.../prison/ranks/data/TopNPlayers.java | 28 ++++++++++++++-----
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 45c9836c5..0524cef95 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15a 2023-07-24
+# 3.3.0-alpha.15a 2023-07-27
+
+
+* **TopN: TopN was not being disabled correctly for when ranks were disabled.**
+This now properly checks the PrisonRanks to see if the ranks module is active or not. The prior code was not being as detailed.
* **Prison support: Added more color related test. Changed the color schema name from 'madog' to 'prison'.**
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java
index be8763fd6..b11021aae 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java
@@ -130,7 +130,9 @@ public File getSaveFile() {
*/
private void launchTopNPlayerUpdateAsyncTask() {
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
Long delayTicks = Prison.get().getPlatform().getConfigLong(
"topNPlayers.refresh.delay-ticks", DELAY_THIRTY_SECONDS_TICKS );
@@ -169,7 +171,9 @@ private void launchTopNPlayerUpdateAsyncTask() {
public void loadSaveFile() {
// If Ranks module is not loaded, then do not try to load any save file:
- if ( PrisonRanks.getInstance().getPlayerManager() == null ) {
+ if ( PrisonRanks.getInstance() == null ||
+ !PrisonRanks.getInstance().isEnabled() ||
+ PrisonRanks.getInstance().getPlayerManager() == null ) {
// Ranks is not loaded, so reset to empties:
setTopNList( new ArrayList<>() );
@@ -242,7 +246,9 @@ public void loadSaveFile() {
*/
public void forceReloadAllPlayers() {
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
long start = System.nanoTime();
@@ -380,7 +386,9 @@ private void addPlayerData( TopNPlayersData topN, PlayerState activePlayerState
public void refreshAndSort() {
- if ( PrisonRanks.getInstance().getPlayerManager() == null ) {
+ if ( PrisonRanks.getInstance() == null ||
+ !PrisonRanks.getInstance().isEnabled() ||
+ PrisonRanks.getInstance().getPlayerManager() == null ) {
return;
}
@@ -491,7 +499,9 @@ public void refreshAndSort() {
private void calculateAllRankScores( ArrayList topNList ) {
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
for ( TopNPlayersData topN : topNList ) {
@@ -590,7 +600,9 @@ else if ( getArchivedMap().containsKey( key ) ) {
*/
public void updatePlayerData( RankPlayer rPlayer ) {
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
addPlayerData( rPlayer);
@@ -662,7 +674,9 @@ public RankPlayer getTopNRankArchivedPlayer( int rankPosition ) {
private RankPlayer getTopNRankPlayer( int rankPosition, boolean archived ) {
RankPlayer rPlayer = null;
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
ArrayList tList =
archived ?
From 3db2cf4117333539655585005d34ce4cee44a9d1 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 28 Jul 2023 09:39:43 -0400
Subject: [PATCH 047/151] Fixed an issue with BRICKS being mismatched to BRICK.
This is an XSeries bug.
---
docs/changelog_v3.3.x.md | 5 ++++-
.../tech/mcprison/prison/spigot/compat/Spigot18Blocks.java | 5 +++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 0524cef95..87f8fd4c7 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,10 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15a 2023-07-27
+# 3.3.0-alpha.15a 2023-07-28
+
+
+* **Fixed an issue with BRICKS being mismatched to BRICK. This is an XSeries bug.**
* **TopN: TopN was not being disabled correctly for when ranks were disabled.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Blocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Blocks.java
index 8594d6924..96892420a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Blocks.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Blocks.java
@@ -275,10 +275,15 @@ public XMaterial getXMaterial( PrisonBlock prisonBlock ) {
results = XMaterial.matchXMaterial( blockName ).orElse( null );
+ // Convert items to their block representation:
if ( results == XMaterial.MELON_SLICE &&
prisonBlock.getBlockName().equalsIgnoreCase( "melon" ) ) {
results = XMaterial.MELON;
}
+ else if ( results == XMaterial.BRICK &&
+ prisonBlock.getBlockName().equalsIgnoreCase( "bricks" ) ) {
+ results = XMaterial.BRICKS;
+ }
putCachedXMaterial( prisonBlock, results );
}
From 2891ac831493e955acd7744ed6e84e598c539671 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 28 Jul 2023 09:41:17 -0400
Subject: [PATCH 048/151] v3.3.0-alpha.15b 2023-07-28
---
docs/changelog_v3.3.x.md | 6 +++++-
gradle.properties | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 87f8fd4c7..0f7061b95 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15a 2023-07-28
+# 3.3.0-alpha.15b 2023-07-28
+
+
+
+**v3.3.0-alpha.15b 2023-07-28**
* **Fixed an issue with BRICKS being mismatched to BRICK. This is an XSeries bug.**
diff --git a/gradle.properties b/gradle.properties
index 9daf50886..9aa660bdb 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,7 +3,7 @@
## # This is actually the "correct" place to define the version for the project.
## # Used within build.gradle with ${project.version}.
## # Can be overridden on the command line: gradle -Pversion=3.2.1-alpha.3
-version=3.3.0-alpha.15a
+version=3.3.0-alpha.15b
From 795a851e5323189ac8cd7acc2494dcba7767f40d Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 28 Jul 2023 11:44:50 -0400
Subject: [PATCH 049/151] Mine Bombs: Found an issue with the bomb settings for
allowedMines and preventMines, and fixed it. There is a global setting in
config.yml under the settings:
`prison-mines.mine-bombs.prevent-usage-in-mines` to disable all mine bombs
from working in those mines. The bombs can then be individually added by
setting adding mine names to the bomb configs settings for `allowedMines` and
`preventedMines`. If a mine is included on a bomb's allowedMines setting, it
will override any global setting.
---
docs/changelog_v3.3.x.md | 4 ++
.../mcprison/prison/bombs/MineBombData.java | 8 +++
.../bombs/MineBombDefaultConfigSettings.java | 7 +++
.../tech/mcprison/prison/bombs/MineBombs.java | 26 +++++++--
.../prison/bombs/MineBombsConfigData.java | 2 +-
.../prison/internal/platform/Platform.java | 2 +
.../tech/mcprison/prison/TestPlatform.java | 7 +++
.../prison/spigot/SpigotPlatform.java | 54 ++++++++++++-------
8 files changed, 88 insertions(+), 22 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 0f7061b95..2e63b4e31 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -21,6 +21,10 @@ These change logs represent the work that has been going on within prison.
**v3.3.0-alpha.15b 2023-07-28**
+* **Mine Bombs: Found an issue with the bomb settings for allowedMines and preventMines, and fixed it.**
+There is a global setting in config.yml under the settings: `prison-mines.mine-bombs.prevent-usage-in-mines` to disable all mine bombs from working in those mines. The bombs can then be individually added by setting adding mine names to the bomb configs settings for `allowedMines` and `preventedMines`. If a mine is included on a bomb's allowedMines setting, it will override any global setting.
+
+
* **Fixed an issue with BRICKS being mismatched to BRICK. This is an XSeries bug.**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombData.java b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombData.java
index fee24d4e1..d341e3b8c 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombData.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombData.java
@@ -309,6 +309,14 @@ public MineBombData clone() {
cloned.getLore().add( l );
}
+ for ( String mine : getAllowedMines() ) {
+ cloned.getAllowedMines().add( mine );
+ }
+
+ for ( String mine : getPreventedMines() ) {
+ cloned.getPreventedMines().add( mine );
+ }
+
for ( MineBombEffectsData soundEffect : getSoundEffects() )
{
diff --git a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombDefaultConfigSettings.java b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombDefaultConfigSettings.java
index 89494b456..ef03e2c9b 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombDefaultConfigSettings.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombDefaultConfigSettings.java
@@ -219,6 +219,13 @@ public void setupDefaultMineBombData(MineBombs mineBombs)
mbd.setToolInHandFortuneLevel( 0 );
mbd.setRemovalChance( 40.0d );
+ mbd.getAllowedMines().add( "a" );
+ mbd.getAllowedMines().add( "b" );
+ mbd.getAllowedMines().add( "c" );
+
+ mbd.getPreventedMines().add( "d" );
+ mbd.getPreventedMines().add( "e" );
+
mbd.getSoundEffects().add( mbeSound01.clone() );
mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) );
mbd.getSoundEffects().add( mbeSound03.clone() );
diff --git a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombs.java b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombs.java
index ce3df4b73..eb22b99c9 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombs.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombs.java
@@ -147,9 +147,12 @@ public void loadConfigJson() {
File configFile = getConfigFile( fio );
- if ( !configFile.exists() ) {
+ boolean configExists = configFile.exists();
+
+ if ( !configExists ) {
MineBombDefaultConfigSettings defaultConfigs = new MineBombDefaultConfigSettings();
defaultConfigs.setupDefaultMineBombData( this );
+
}
else {
@@ -192,8 +195,25 @@ public void loadConfigJson() {
}
}
+ }
+
+
+ StringBuilder sbMsg = new StringBuilder();
+ int cnt = getConfigData().getBombs().size();
+ sbMsg.append( "Prison Mine Bombs: " )
+ .append( cnt )
+ .append( "[" );
+
+ for ( String key : getConfigData().getBombs().keySet() ) {
+ MineBombData bomb = getConfigData().getBombs().get( key );
+ sbMsg.append( " " )
+ .append( bomb.getName() );
}
+
+ sbMsg.append( " ]" );
+
+ Output.get().logInfo( sbMsg.toString() );
}
@@ -369,7 +389,7 @@ public void validateMineBombs()
cleaned = true;
}
- if ( !Prison.get().getPlatform().getMinesListString().contains(cleanName) ) {
+ if ( !Prison.get().getPlatform().isMineNameValid(cleanedMineName) ) {
Output.get().log( "MineBomb %s: invalid mine name for allowedMines: %s Removed.",
LogLevel.WARNING,
bomb.getName(), cleanedMineName );
@@ -399,7 +419,7 @@ public void validateMineBombs()
cleaned = true;
}
- if ( !Prison.get().getPlatform().getMinesListString().contains(cleanName) ) {
+ if ( !Prison.get().getPlatform().isMineNameValid(cleanedMineName) ) {
Output.get().log( "MineBomb %s: invalid mine name for prevented-Mines: %s Removed.",
LogLevel.WARNING,
bomb.getName(), cleanedMineName );
diff --git a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombsConfigData.java b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombsConfigData.java
index fd45845b1..4c34d0b99 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombsConfigData.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombsConfigData.java
@@ -16,7 +16,7 @@ public class MineBombsConfigData
* data.
*
*/
- public static final int MINE_BOMB_DATA_FORMAT_VERSION = 1;
+ public static final int MINE_BOMB_DATA_FORMAT_VERSION = 2;
private int dataFormatVersion = 1;
diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java b/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
index 3249ca241..d0ac90ea1 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/internal/platform/Platform.java
@@ -388,6 +388,8 @@ public void autoCreateMineLinerAssignment( List rankMineNames,
public void saveResource( String string, boolean replace );
+
+ public boolean isMineNameValid(String mineName);
public String getMinesListString();
diff --git a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
index 5d7b08063..a1d5ca6d6 100644
--- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
+++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
@@ -434,6 +434,13 @@ public void saveResource( String string, boolean replace ) {
}
+
+ @Override
+ public boolean isMineNameValid(String mineName) {
+ return false;
+ }
+
+
@Override
public String getMinesListString() {
return "";
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
index 5920c43a5..13603d703 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
@@ -2872,29 +2872,47 @@ public void saveResource( String fileName, boolean replace ) {
SpigotPrison.getInstance().saveResource( fileName, replace );
}
-
@Override
- public String getMinesListString() {
+ public boolean isMineNameValid( String mineName ) {
+ boolean results = false;
+ if ( PrisonMines.getInstance().isEnabled() ) {
+
+ Mine mine = PrisonMines.getInstance().getMine(mineName);
+
+ results = mine != null;
+ }
- MinesCommands mc = PrisonMines.getInstance().getMinesCommands();
+ return results;
+ }
+
+ @Override
+ public String getMinesListString() {
+ String results = "";
-
- ChatDisplay display = new ChatDisplay("Mines");
-
- display.addSupportHyperLinkData( "Mines List" );
-
- // get the mine list:
- mc.getMinesList( display, MineManager.MineSortOrder.sortOrder, "all", null );
-
- StringBuilder sb = display.toStringBuilder();
-
- sb.append( "\n" );
-
- // get the mine details for all mines:
- mc.allMinesInfoDetails( sb );
+ if ( PrisonMines.getInstance().isEnabled() ) {
+
+ MinesCommands mc = PrisonMines.getInstance().getMinesCommands();
+
+
+ ChatDisplay display = new ChatDisplay("Mines");
+
+ display.addSupportHyperLinkData( "Mines List" );
+
+ // get the mine list:
+ mc.getMinesList( display, MineManager.MineSortOrder.sortOrder, "all", null );
+
+ StringBuilder sb = display.toStringBuilder();
+
+ sb.append( "\n" );
+
+ // get the mine details for all mines:
+ mc.allMinesInfoDetails( sb );
+
+ results = sb.toString();
+ }
- return sb.toString();
+ return results;
// return Text.stripColor( sb.toString() );
}
From ff7b39f80f03192687b8c4eac4f2692505d21005 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 28 Jul 2023 12:07:38 -0400
Subject: [PATCH 050/151] Prevent a NPE if the target block is not found within
the mine's settings.
---
docs/changelog_v3.3.x.md | 3 +++
.../mcprison/prison/spigot/block/OnBlockBreakEventCore.java | 1 +
2 files changed, 4 insertions(+)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 2e63b4e31..d4dee79a0 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -21,6 +21,9 @@ These change logs represent the work that has been going on within prison.
**v3.3.0-alpha.15b 2023-07-28**
+* **Prevent a NPE if the target block is not found within the mine's settings.**
+
+
* **Mine Bombs: Found an issue with the bomb settings for allowedMines and preventMines, and fixed it.**
There is a global setting in config.yml under the settings: `prison-mines.mine-bombs.prevent-usage-in-mines` to disable all mine bombs from working in those mines. The bombs can then be individually added by setting adding mine names to the bomb configs settings for `allowedMines` and `preventedMines`. If a mine is included on a bomb's allowedMines setting, it will override any global setting.
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
index 760da3281..9468458af 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
@@ -407,6 +407,7 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent )
// and the block has not been mined before, then allow the breakage by
// setting bypassMatchedBlocks to true to allow normal processing:
if ( !matchedBlocks &&
+ targetBlock != null &&
!targetBlock.isMined() &&
sBlockHit.isAir() &&
pmEvent.getBbPriority().isMonitor() ) {
From b2c8c76bc8332ed901654c46f86cfdcbf6a0112f Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 28 Jul 2023 21:31:05 -0400
Subject: [PATCH 051/151] Sellall: clean up some of the help for a few sellall
features and expand on the details.
---
docs/changelog_v3.3.x.md | 3 +
.../commands/PrisonSpigotSellAllCommands.java | 57 ++++++++++++-------
2 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index d4dee79a0..1304ba1ef 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,8 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15b 2023-07-28
+* **Sellall: clean up some of the help for a few sellall features and expand on the details. **
+
**v3.3.0-alpha.15b 2023-07-28**
@@ -90,6 +92,7 @@ The server has been down for the last two days and so other errors need to be ca
A specific mine bomb can have a list of included mines, which overrides any exclusions. The mine bombs can be excluded from specific mines too.
There is also a global disallowed mine list that will apply to all mine bombs, its in the config.yml file with the setting name of:
prison-mines.mine-bombs.prevent-usage-in-mines
+There is a global setting in config.yml under the settings: `prison-mines.mine-bombs.prevent-usage-in-mines` to disable all mine bombs from working in those mines. The bombs can then be individually added by setting adding mine names to the bomb configs settings for `allowedMines` and `preventedMines`. If a mine is included on a bomb's allowedMines setting, it will override any global setting.
* **The Platform function getConfigStringArray should be a List of Strings for the return value, so updated the result type to reflect the correct setting.**
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
index 292d23814..84a79c46b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
@@ -84,7 +84,8 @@ private void sellAllCurrency(CommandSender sender,
}
}
- @Command(identifier = "sellall", description = "SellAll main command",
+ @Command(identifier = "sellall",
+ description = "SellAll main command",
altPermissions = {"-none-", "prison.admin"},
onlyPlayers = false)
private void sellAllCommands(CommandSender sender) {
@@ -164,28 +165,34 @@ private void sellAllDelaySet(CommandSender sender,
}
}
- @Command(identifier = "sellall autosell", description = "Enable SellAll AutoSell.",
+ @Command(identifier = "sellall autosell",
+ description = "Enable SellAll AutoSell. "
+ + "For AutoFeatures based sellall, please see the AutoFeatures configs.",
onlyPlayers = false, permissions = "prison.autosell.edit")
private void sellAllAutoSell(CommandSender sender,
- @Arg(name = "boolean", description = "True to enable or false to disable.", def = "null") String enable){
+ @Arg(name = "boolean",
+ description = "'True' to enable or 'false' to disable. Use 'perUserToggleable' to "
+ + "enable with users being able to turn on/off. Default value is 'true'. "
+ + "[true false perUserToggleable]",
+ def = "true") String enable){
if (!isEnabled()) return;
+
+ SellAllUtil sellAllUtil = SellAllUtil.get();
+ if (sellAllUtil == null){
+ return;
+ }
if (enable.equalsIgnoreCase("perusertoggleable")){
sellAllAutoSellPerUserToggleable(sender, enable);
return;
}
- if (!(enable.equalsIgnoreCase("true") || enable.equalsIgnoreCase("false"))){
+ if (!enable.equalsIgnoreCase("true") && !enable.equalsIgnoreCase("false") ){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_boolean_input_invalid));
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
-
boolean enableBoolean = getBoolean(enable);
if (sellAllUtil.isAutoSellEnabled == enableBoolean){
if (enableBoolean){
@@ -205,20 +212,27 @@ private void sellAllAutoSell(CommandSender sender,
}
}
- @Command(identifier = "sellall autosell perUserToggleable", description = "Enable AutoSell perUserToggleable.",
+ @Command(identifier = "sellall autosell perUserToggleable",
+ description = "Enable AutoSell perUserToggleable. This will "
+ + "enable autosell if it's not already enabled, plus it will allow players to "
+ + "turn autosell on/off when they need to using the command `/sellall auto toggle`. "
+ + "If user toggleable is disabled through this command, it will also disable "
+ + "autosell, so you may need to turn it back on with `/sellall autosell true`.",
onlyPlayers = false, permissions = "prison.autosell.edit")
private void sellAllAutoSellPerUserToggleable(CommandSender sender,
- @Arg(name = "boolean", description = "True to enable or false to disable", def = "null") String enable){
+ @Arg(name = "boolean",
+ description = "'True' to enable or 'false' to disable. [true false]",
+ def = "") String enable){
if (!isEnabled()) return;
-
- if (!(enable.equalsIgnoreCase("true") || enable.equalsIgnoreCase("false"))){
- Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_boolean_input_invalid));
- return;
- }
-
+
SellAllUtil sellAllUtil = SellAllUtil.get();
if (sellAllUtil == null){
+ return;
+ }
+
+ if ( !enable.equalsIgnoreCase("true") && !enable.equalsIgnoreCase("false") ) {
+ Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_boolean_input_invalid));
return;
}
@@ -246,8 +260,8 @@ public void sellAllSellCommand(CommandSender sender,
@Arg(name = "player", def = "", description = "An online player name to sell their inventory - " +
"Only console or prison commands can include this parameter") String playerName,
@Arg(name = "notification", def="",
- description = "Notification about the sellall transaction. Defaults to normal. " +
- "'silent' suppresses results. [silent]") String notification ){
+ description = "Notification behavior for the sellall transaction. Defaults to normal. " +
+ "'silent' suppresses all notifications. [silent]") String notification ){
if (!isEnabled()) return;
@@ -559,7 +573,10 @@ public void sellAllSellWithDelayCommand(CommandSender sender){
}
- @Command(identifier = "sellall auto toggle", description = "Let the user enable or disable sellall auto",
+ @Command(identifier = "sellall auto toggle",
+ description = "When `perUserToggleable` is enabled with autosell, this "
+ + "command allow the players to enable or disable their own use of autosell. "
+ + "When using this command, autosell will be toggled on/off for the player.",
altPermissions = "prison.sellall.toggle", onlyPlayers = true)
private void sellAllAutoEnableUser(CommandSender sender){
From 1d6fb325bae5fd805a4c57676b1a962e97d8737e Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sat, 29 Jul 2023 19:01:55 -0400
Subject: [PATCH 052/151] sellall & autosell: auto sell was not working
correctly within auto manager. Also fixed the user toggle on auto sell so
players can turn off autosell when they need to.
---
docs/changelog_v3.3.x.md | 6 +-
.../autofeatures/AutoManagerFeatures.java | 54 +++++++++----
.../spigot/block/OnBlockBreakEventCore.java | 19 +++--
.../commands/PrisonSpigotSellAllCommands.java | 5 +-
.../prison/spigot/sellall/SellAllUtil.java | 80 +++++++++++++++----
5 files changed, 126 insertions(+), 38 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 1304ba1ef..9c60f0c5b 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,11 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15b 2023-07-28
+# 3.3.0-alpha.15b 2023-07-29
+
+
+* **sellall & autosell: auto sell was not working correctly within auto manager.**
+Also fixed the user toggle on auto sell so players can turn off autosell when they need to.
* **Sellall: clean up some of the help for a few sellall features and expand on the details. **
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
index 4257391c5..122576d55 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
@@ -839,23 +839,34 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
long nanoTime = 0L;
- boolean isSellallEnabled = SpigotPrison.getInstance().isSellAllEnabled();
+ boolean isSellallEnabled = SellAllUtil.get() != null &&
+ SpigotPrison.getInstance().isSellAllEnabled();
- // This is true if the player cannot toggle the autosell, and it's
- // true if they can, and the have it enabled:
- boolean isPlayerAutosellEnabled = isSellallEnabled &&
- SellAllUtil.get() != null &&
- SellAllUtil.get().checkIfPlayerAutosellIsActive(
- pmEvent.getSpigotPlayer().getWrapper() )
- ;
+ // This will return true (allow autosell) unless players can toggle autosell and they turned it off:
+ // This is to be used with other auto sell setting, but never on it's own:
+ boolean isPlayerAutosellEnabled =
+ isSellallEnabled &&
+ (!SellAllUtil.get().isAutoSellPerUserToggleable ||
+ SellAllUtil.get().isSellallPlayerUserToggleEnabled(
+ pmEvent.getSpigotPlayer().getWrapper() ));
+
+ // In the event, forceAutoSell is enabled, which means the drops must be sold.
+ // The player's toggle cannot disable this.
boolean forceAutoSell = isSellallEnabled && pmEvent.isForceAutoSell();
- boolean autoSellBySettings = isSellallEnabled && isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled);
- boolean autoSellByPerm = isSellallEnabled &&
- !player.isOp() &&
- !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
- player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) );
+
+ // AutoFeature's autosell per block break - global setting
+ boolean autoSellBySettings =
+ isPlayerAutosellEnabled &&
+ isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled);
+
+ // AutoFeature's autosell per block break - per player perms setting
+ boolean autoSellByPerm =
+ isPlayerAutosellEnabled &&
+ !player.isOp() &&
+ !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
+ player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) );
for ( SpigotItemStack itemStack : drops ) {
@@ -863,7 +874,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
// Try to autosell if enabled in any of the following ways:
- if ( isPlayerAutosellEnabled || forceAutoSell || autoSellBySettings || autoSellByPerm ) {
+ if ( forceAutoSell || autoSellBySettings || autoSellByPerm ) {
// // Try to autosell if enabled:
// if ( isSellallEnabled &&
@@ -1349,6 +1360,19 @@ protected void dropExtra( HashMap extra, Player player
SellAllUtil sellAllUtil = SellAllUtil.get();
+ boolean isSellallEnabled = sellAllUtil != null &&
+ SpigotPrison.getInstance().isSellAllEnabled();
+
+ // This will return true (allow autosell) unless players can toggle autosell and they turned it off:
+ // This is to be used with other auto sell setting, but never on it's own:
+ boolean isPlayerAutosellEnabled =
+ isSellallEnabled &&
+ (!sellAllUtil.isAutoSellPerUserToggleable ||
+ sellAllUtil.isSellallPlayerUserToggleEnabled(
+ player ));
+
+
+
// On inventory is full, will auto sell if auto sell is enabled in either
// the sellall configs, or the auto feature configs.
if (sellAllUtil != null && (
@@ -1356,7 +1380,7 @@ protected void dropExtra( HashMap extra, Player player
isBoolean(AutoFeatures.isAutoSellIfInventoryIsFull) )) {
- if ( sellAllUtil.checkIfPlayerAutosellIsActive(player) ) {
+ if ( isPlayerAutosellEnabled ) {
boolean saNote = sellAllUtil.isAutoSellNotificationEnabled;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
index 9468458af..e5cfc9fcd 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
@@ -868,12 +868,19 @@ else if ( results && pmEvent.getBbPriority().isMonitor() && mine != null ) {
debugInfo.append( "(BLOCKEVENTS processing) " );
- // This is true if the player cannot toggle the autosell, and it's
- // true if they can, and the have it enabled:
- boolean isPlayerAutosellEnabled = SellAllUtil.get() != null &&
- SellAllUtil.get().checkIfPlayerAutosellIsActive(
- pmEvent.getSpigotPlayer().getWrapper() )
- ;
+ SellAllUtil sellAllUtil = SellAllUtil.get();
+ boolean isSellallEnabled = sellAllUtil != null &&
+ SpigotPrison.getInstance().isSellAllEnabled();
+
+ // This will return true (allow autosell) unless players can toggle autosell and they turned it off:
+ // This is to be used with other auto sell setting, but never on it's own:
+ boolean isPlayerAutosellEnabled =
+ isSellallEnabled &&
+ (!sellAllUtil.isAutoSellPerUserToggleable ||
+ sellAllUtil.isSellallPlayerUserToggleEnabled(
+ pmEvent.getPlayer() ));
+
+
// AutoSell on full inventory when using BLOCKEVENTS:
if ( isBoolean( AutoFeatures.isAutoSellIfInventoryIsFullForBLOCKEVENTSPriority ) &&
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
index 84a79c46b..93e432064 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
@@ -607,8 +607,9 @@ private void sellAllAutoEnableUser(CommandSender sender){
return;
}
- if (sellAllUtil.setAutoSellPlayer(p, !sellAllUtil.isPlayerAutoSellEnabled(p))){
- if (sellAllUtil.isPlayerAutoSellEnabled(p)){
+ boolean isplayerAutosellEnabled = sellAllUtil.isPlayerAutoSellEnabled(p);
+ if (sellAllUtil.setAutoSellPlayer(p, !isplayerAutosellEnabled)){
+ if ( !isplayerAutosellEnabled ){ // Note this variable was negated then saved, so we need to check the negative:
Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_auto_enabled));
} else {
Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_auto_disabled));
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index e3108d1a4..82f3e4736 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -977,6 +977,9 @@ private SellAllData sellItemStack( SpigotItemStack iStack, double multiplier ) {
// }
/**
+ * If autosell is enabled, and if user toggleable is enabled, then
+ * it will check to see if the player has the perm or
+ *
* Get AutoSell Player toggle if available.
* If he enabled it, AutoSell will work, otherwise it won't.
* If he never used the toggle command, this will return true, just like if he enabled it in the first place.
@@ -986,28 +989,77 @@ private SellAllData sellItemStack( SpigotItemStack iStack, double multiplier ) {
* @return boolean.
* */
public boolean isPlayerAutoSellEnabled(Player p){
+ boolean results = false;
+
+ // If autosell isn't enabled, then return false
+ if ( isAutoSellEnabled ) {
+
+ results = isSellallPlayerUserToggleEnabled( p );
+// if ( !isAutoSellPerUserToggleablePermEnabled ||
+// isAutoSellPerUserToggleablePermEnabled &&
+// p.hasPermission(permissionAutoSellPerUserToggleable)){
+//
+// String settingName = "Users." + p.getUniqueId() + ".isEnabled";
+//
+// results = sellAllConfig.getString(settingName) == null ||
+// getBooleanValue( settingName );
+// }
+ }
+
+
+// if (isAutoSellPerUserToggleablePermEnabled &&
+// !p.hasPermission(permissionAutoSellPerUserToggleable)){
+// return false;
+// }
+//
+// if (sellAllConfig.getString("Users." + p.getUniqueId() + ".isEnabled") == null){
+// return true;
+// }
- if (isAutoSellPerUserToggleablePermEnabled &&
- !p.hasPermission(permissionAutoSellPerUserToggleable)){
- return false;
- }
-
- if (sellAllConfig.getString("Users." + p.getUniqueId() + ".isEnabled") == null){
- return true;
- }
-
- return getBooleanValue("Users." + p.getUniqueId() + ".isEnabled");
+// return getBooleanValue("Users." + p.getUniqueId() + ".isEnabled");
+ return results;
}
- public boolean checkIfPlayerAutosellIsActive(Player p) {
- boolean results = true;
+ /**
+ *
This function only checks to see if the user can toggle autosell
+ * on or off. If they can, then it checks the state to see if it's on
+ * or off. It does not matter if autosell is enabled within sellall or not,
+ * since this can be used with the auto features autosell too.
+ *
+ *
+ *
+ *
+ * @param p
+ * @return
+ */
+ public boolean isSellallPlayerUserToggleEnabled( Player p ) {
+ boolean results = false;
- if ( isAutoSellPerUserToggleable ) {
- results = isPlayerAutoSellEnabled(p);
+ if ( isAutoSellPerUserToggleable ) {
+
+ if ( !isAutoSellPerUserToggleablePermEnabled ||
+ isAutoSellPerUserToggleablePermEnabled &&
+ p.hasPermission(permissionAutoSellPerUserToggleable)){
+
+ String settingName = "Users." + p.getUniqueId() + ".isEnabled";
+
+ results = sellAllConfig.getString( settingName ) == null ||
+ getBooleanValue( settingName );
+ }
}
return results;
}
+
+// public boolean checkIfPlayerAutosellIsActive(Player p) {
+// boolean results = isAutoSellEnabled;
+//
+// if ( isAutoSellPerUserToggleable ) {
+// results = isPlayerAutoSellEnabled(p);
+// }
+//
+// return results;
+// }
// /**
// * WARNING: Obsolete because disabled worlds are set in config.yml and
From 0ef001100512c78b834ade4f5419b4b703dcfa0d Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 30 Jul 2023 00:22:38 -0400
Subject: [PATCH 053/151] Sellall: Rearrange the sellall commands so they are
better organized and updated the help text so its also meaningful.
---
docs/changelog_v3.3.x.md | 3 +
.../spigot/block/OnBlockBreakEventCore.java | 1 -
.../commands/PrisonSpigotSellAllCommands.java | 80 ++++++++++++-------
3 files changed, 54 insertions(+), 30 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 9c60f0c5b..e7271a607 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15b 2023-07-29
+* **Sellall: Rearrange the sellall commands so they are better organized and updated the help text so its also meaningful.**
+
+
* **sellall & autosell: auto sell was not working correctly within auto manager.**
Also fixed the user toggle on auto sell so players can turn off autosell when they need to.
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
index e5cfc9fcd..3a0e7736c 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
@@ -884,7 +884,6 @@ else if ( results && pmEvent.getBbPriority().isMonitor() && mine != null ) {
// AutoSell on full inventory when using BLOCKEVENTS:
if ( isBoolean( AutoFeatures.isAutoSellIfInventoryIsFullForBLOCKEVENTSPriority ) &&
- SpigotPrison.getInstance().isSellAllEnabled() &&
isPlayerAutosellEnabled &&
pmEvent.getSpigotPlayer().isInventoryFull() ) {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
index 93e432064..b69306ae9 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
@@ -103,10 +103,13 @@ private void sellAllCommands(CommandSender sender) {
}
}
- @Command(identifier = "sellall delay", description = "SellAll delay.",
+ @Command(identifier = "sellall set delay",
+ description = "Enables or disables a SellAll cooldown delay to preventh "
+ + "players from spamming the sellall command. "
+ + "See `/sellall set delayTime`.",
onlyPlayers = false, permissions = "prison.sellall.delay")
private void sellAllDelay(CommandSender sender,
- @Arg(name = "boolean", description = "True to enable or false to disable.", def = "null") String enable){
+ @Arg(name = "boolean", description = "True to enable or false to disable.", def = "false") String enable){
if (!isEnabled()) return;
@@ -140,10 +143,12 @@ private void sellAllDelay(CommandSender sender,
}
}
- @Command(identifier = "sellall set delay", description = "Edit SellAll delay.",
+ @Command(identifier = "sellall set delayTime",
+ description = "This sets the sellall cooldown delay to the specified number of seconds.",
onlyPlayers = false, permissions = "prison.sellall.delay")
private void sellAllDelaySet(CommandSender sender,
- @Arg(name = "delay", description = "Set delay value in seconds.", def = "0") String delay){
+ @Arg(name = "delay",
+ description = "Set delay value in seconds. Defaults to a value of 15 seconds.", def = "15") String delay){
if (!isEnabled()) return;
@@ -165,7 +170,7 @@ private void sellAllDelaySet(CommandSender sender,
}
}
- @Command(identifier = "sellall autosell",
+ @Command(identifier = "sellall set autosell",
description = "Enable SellAll AutoSell. "
+ "For AutoFeatures based sellall, please see the AutoFeatures configs.",
onlyPlayers = false, permissions = "prison.autosell.edit")
@@ -212,12 +217,13 @@ private void sellAllAutoSell(CommandSender sender,
}
}
- @Command(identifier = "sellall autosell perUserToggleable",
+ @Command(identifier = "sellall set autosellPerUserToggleable",
description = "Enable AutoSell perUserToggleable. This will "
+ "enable autosell if it's not already enabled, plus it will allow players to "
- + "turn autosell on/off when they need to using the command `/sellall auto toggle`. "
+ + "turn autosell on/off when they need to using the "
+ + "command `/sellall autoSellToggle` or the alias `/autosell`. "
+ "If user toggleable is disabled through this command, it will also disable "
- + "autosell, so you may need to turn it back on with `/sellall autosell true`.",
+ + "autosell, so you may need to turn it back on with `/sellall set autosell true`.",
onlyPlayers = false, permissions = "prison.autosell.edit")
private void sellAllAutoSellPerUserToggleable(CommandSender sender,
@Arg(name = "boolean",
@@ -330,7 +336,8 @@ else if (p == null){
PlayerAutoRankupTask.autoSubmitPlayerRankupTask( sPlayer, null );
}
- @Command(identifier = "sellall hand", description = "Sell only what is in your hand if sellable.",
+ @Command(identifier = "sellall sellHand",
+ description = "Sell only what is in your hand if it is sellable.",
onlyPlayers = true)
public void sellAllSellHandCommand(CommandSender sender){
@@ -408,8 +415,8 @@ public void sellAllSell(Player p){
- @Command(identifier = "sellall valueof",
- description = "SellAll valueof command will report the total value of the player's inventory "
+ @Command(identifier = "sellall valueOf",
+ description = "SellAll valueOf command will report the total value of the player's inventory "
+ "without selling anything.", onlyPlayers = false)
public void sellAllValueOfCommand(CommandSender sender,
@Arg(name = "player", def = "", description = "An online player name to get the value of their inventory - " +
@@ -448,7 +455,7 @@ else if (p == null){
if ( getPlayer( sender, playerName ) != null ) {
Output.get().sendInfo(sender, "&cSorry but the specified player must be online "
- + "[/sellall valueof %s]", playerName );
+ + "[/sellall valueOf %s]", playerName );
}
else {
@@ -485,7 +492,7 @@ else if (p == null){
PlayerAutoRankupTask.autoSubmitPlayerRankupTask( sPlayer, null );
}
- @Command(identifier = "sellall valueofHand",
+ @Command(identifier = "sellall valueOfHand",
description = "Get the value of what is in your hand if sellable.",
onlyPlayers = true)
public void sellAllValueOfHandCommand(CommandSender sender){
@@ -499,7 +506,7 @@ public void sellAllValueOfHandCommand(CommandSender sender){
}
if (!sellAllUtil.isSellAllHandEnabled){
- Output.get().sendWarn(sender, "The command /sellall valueofHand is disabled from the config! (SellAllHandEnabled)");
+ Output.get().sendWarn(sender, "The command `/sellall valueOfHand` is disabled from the config! (SellAllHandEnabled)");
return;
}
@@ -573,10 +580,12 @@ public void sellAllSellWithDelayCommand(CommandSender sender){
}
- @Command(identifier = "sellall auto toggle",
+ @Command(identifier = "sellall autoSellToggle",
+ aliases = {"autosell"},
description = "When `perUserToggleable` is enabled with autosell, this "
+ "command allow the players to enable or disable their own use of autosell. "
- + "When using this command, autosell will be toggled on/off for the player.",
+ + "When using this command, autosell will be toggled on/off for the player. "
+ + "Can also use the alias `/autosell` to toggle this setting",
altPermissions = "prison.sellall.toggle", onlyPlayers = true)
private void sellAllAutoEnableUser(CommandSender sender){
@@ -676,11 +685,16 @@ private void sellAllGuiBlocksCommand(CommandSender sender,
}
- @Command(identifier = "sellall add", description = "SellAll add an item to the sellAll shop.",
+ @Command(identifier = "sellall items add",
+ description = "This will add an item to the SellAll shop. "
+ + "Use `/mines block search help` to find the correct names "
+ + "for blocks to add to the sellall shop. Use "
+ + "`/mines block searchAll help` to search for items too.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllAddCommand(CommandSender sender,
- @Arg(name = "Item_ID", description = "The Item_ID or block to add to the sellAll Shop.") String itemID,
- @Arg(name = "Value", description = "The value of the item.") Double value){
+ @Arg(name = "Item_ID",
+ description = "The Item_ID or block to add to the sellAll Shop.") String itemID,
+ @Arg(name = "Value", description = "The value of the item.") Double value){
if (!isEnabled()) return;
@@ -750,9 +764,12 @@ public void sellAllAddCommand(XMaterial blockAdd, Double value){
Output.get().logInfo("&3 ITEM [" + itemID + ", " + value + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_add_success));
}
- @Command(identifier = "sellall delete", description = "SellAll delete command, remove an item from shop.",
+ @Command(identifier = "sellall items delete",
+ description = "This command will delete an item from the "
+ + "sellall shop. Use `/sellall list` to identify which items to revmove.",
permissions = "prison.admin", onlyPlayers = false)
- private void sellAllDeleteCommand(CommandSender sender, @Arg(name = "Item_ID", description = "The Item_ID you want to remove.") String itemID){
+ private void sellAllDeleteCommand(CommandSender sender,
+ @Arg(name = "Item_ID", description = "The Item_ID you want to remove.") String itemID){
if (!isEnabled()) return;
@@ -779,11 +796,12 @@ private void sellAllDeleteCommand(CommandSender sender, @Arg(name = "Item_ID", d
}
}
- @Command(identifier = "sellall edit", description = "SellAll edit command, edit an item of Shop.",
+ @Command(identifier = "sellall items edit",
+ description = "Edits an existing SellAll shop item.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllEditCommand(CommandSender sender,
- @Arg(name = "Item_ID", description = "The Item_ID or block to add to the sellAll Shop.") String itemID,
- @Arg(name = "Value", description = "The value of the item.") Double value){
+ @Arg(name = "Item_ID", description = "The Item_ID or block to add to the sellAll Shop.") String itemID,
+ @Arg(name = "Value", description = "The value of the item.") Double value){
if (!isEnabled()) return;
@@ -987,12 +1005,14 @@ private void sellAllDeleteMultiplierCommand(CommandSender sender,
}
}
- @Command(identifier = "sellall trigger",
- description = "Toggle SellAll Shift+Right Click on a tool to trigger the /sellall sell command, "
- + "true -> Enabled or False -> Disabled.",
+ @Command(identifier = "sellall set trigger",
+ description = "Toggle SellAll trigger to enable/disable the Shift+Right Clicking "
+ + "on a tool to trigger the `/sellall sell` command "
+ + "true = enable, false = disable. "
+ + "[true false].",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllToolsTriggerToggle(CommandSender sender,
- @Arg(name = "Boolean", description = "Enable or disable", def = "null") String enable){
+ @Arg(name = "Boolean", description = "Enable or disable", def = "true") String enable){
if (!isEnabled()) return;
@@ -1113,7 +1133,9 @@ private void sellAllTriggerDelete(CommandSender sender,
}
}
- @Command(identifier = "sellall setdefault", description = "SellAll default values ready to go.",
+ @Command(identifier = "sellall items setdefaults",
+ description = "This command will setup all of the shop items with "
+ + "the SellAll default items.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllSetDefaultCommand(CommandSender sender){
From 401820e8e4e2b5d9f82ae80b89e8730ca02007db Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 30 Jul 2023 22:59:44 -0400
Subject: [PATCH 054/151] ranks autoConfigure: Major enhancements to add more
prestige ranks. More options have been added: prestiges prestiges=x
prestigesCost=x prestigesMult=x. Now able to add more prestige ranks without
impacting ranks or mines. Example to add up to 50 new prestige ranks: `/ranks
autoConfigure force presetiges prestiges=50`
---
docs/changelog_v3.3.x.md | 9 +-
.../prison/ranks/commands/RanksCommands.java | 120 +++++++++++++++---
2 files changed, 112 insertions(+), 17 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index e7271a607..a79d62916 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,14 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15b 2023-07-29
+# 3.3.0-alpha.15b 2023-07-30
+
+
+* **ranks autoConfigure: Major enhancements to add more prestige ranks.**
+Added a lot more informatio to the command's help: `/ranks autoConfigure help`.
+More options have been added: prestiges prestiges=x prestigesCost=x prestigesMult=x.
+Now able to add more prestige ranks without impacting ranks or mines.
+Example to add up to 50 new prestige ranks: `/ranks autoConfigure force presetiges prestiges=50`
* **Sellall: Rearrange the sellall commands so they are better organized and updated the help text so its also meaningful.**
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
index d1fae5859..df269b9a5 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
@@ -216,20 +216,43 @@ public boolean createRank(CommandSender sender,
}
- @Command(identifier = "ranks autoConfigure", description = "Auto configures Ranks and Mines using " +
+ @Command(identifier = "ranks autoConfigure",
+ description = "Auto configures Ranks, Mines, and Prestiges using " +
"single letters A through Z for both the rank and mine names. Both ranks and mines are " +
"generated, they will also be linked together automatically. To set the starting price use " +
- "price=x. To set multiplier mult=x. AutoConfigure will try to merge any preexsiting ranks " +
- "and mines, but you must use the 'force' keyword in 'options'. Force will replace all blocks " +
- "in preexisting " +
+ "'price=x'. To set multiplier 'mult=x'. AutoConfigure will try to merge any preexsiting ranks " +
+ "and mines, but you must use the 'force' keyword in 'options' and force will " +
+ "replace all blocks in preexisting " +
"mines. To keep preexisting blocks, use 'forceKeepBlocks' with the 'force' option. " +
- "Default values [full price=50000 mult=1.5]",
+
+ "The option 'full' will enable ranks, mines, and prestiges. No options will default to 'full'. " +
+ "The options 'ranks', 'mines', and 'prestiges' will enable each of these if they are listed. " +
+ "So using just 'mines' will only generate mines and no ranks or prestiges." +
+
+ "The option 'prestiges=x' will set how many initial prestige ranks to create. " +
+ "The option `prestigeCost=x` sets the intial cost for P1; default value is 1_000_000_000. " +
+ "The option 'prestigeMult=x' is an additional multiplier for presetige ranks, with the " +
+ "default value of 1. The cost for each prestige rank is based upon the initial " +
+ "presetigeCost, times the prestige level so p3 will be 3 times the cost of p1 with the " +
+ "prestige multiplier will multipled against that value. So for default values " +
+ " with a 1.75 multipler p3 cost = 1_000_000_000 * 3 * 1.75. " +
+ "Default values [full price=50000 mult=1.5 prestiges=25 presetigeCost=1000000000 " +
+ "prestigeMult=1] " +
+
+ "Example of just adding more prestige ranks using the other default values: " +
+ "'/ranks autoConfigure force prestiges presetiges=1000', no ranks and no mines will " +
+ "be created. " +
+ "Warning: If trying to rerun autoConfigure with existing mines or ranks, then do a " +
+ "prison backup with this command: '/prison support backup save adding more prestiges'",
onlyPlayers = false, permissions = "ranks.set",
aliases = {"prison autoConfigure"} )
public void autoConfigureRanks(CommandSender sender,
@Wildcard(join=true)
@Arg(name = "options",
- description = "Options: [full ranks mines price=x mult=x force forceKeepBlocks dontForceLinerWalls dontForceLinerBottoms]",
+ description = "Options: [full ranks mines prestiges price=x mult=x "
+ + "prestiges=x prestigeCost=x prestigeMult=x "
+ + "force forceKeepBlocks "
+ + "dontForceLinerWalls dontForceLinerBottoms]",
def = "full") String options
) {
@@ -240,6 +263,9 @@ public void autoConfigureRanks(CommandSender sender,
boolean forceLinersWalls = true;
boolean forceLinersBottom = true;
boolean forceKeepBlocks = false;
+ int prestigeRanks = 25;
+ long prestigeCost = 1_000_000_000;
+ double prestigeMult = 10d;
if ( options.contains( "forcekeepblocks" ) ) {
@@ -274,9 +300,13 @@ public void autoConfigureRanks(CommandSender sender,
autoConfigForceWarningMsg( sender );
}
- String optionHelp = "&b[&7full ranks mines price=&dx &7mult=&dx &7force forceKeepBlocks dontForceLinerWalls dontForceLinerBottoms&b]";
+ String optionHelp = "&b[&7full ranks mines prestiges price=&dx &7mult=&dx "
+ + "&7prestiges=&dx &7prestigeCost=&dx &7prestigeMult=&dx "
+ + "&7force forceKeepBlocks dontForceLinerWalls dontForceLinerBottoms&b]";
boolean ranks = false;
boolean mines = false;
+ boolean prestiges = false;
+
double startingPrice = 50000;
double percentMultipler = 1.5;
@@ -292,6 +322,7 @@ public void autoConfigureRanks(CommandSender sender,
if ( options.contains( "full" ) ) {
ranks = true;
mines = true;
+ prestiges = true;
options = options.replace( "full", "" ).trim();
}
if ( options.contains( "ranks" ) ) {
@@ -302,6 +333,7 @@ public void autoConfigureRanks(CommandSender sender,
mines = true;
options = options.replace( "mines", "" ).trim();
}
+
String priceStr = extractParameter("price=", options);
if ( priceStr != null ) {
@@ -329,6 +361,53 @@ public void autoConfigureRanks(CommandSender sender,
// Not a valid double number, or price:
}
}
+
+ String prestigesStr = extractParameter("prestiges=", options);
+ if ( prestigesStr != null ) {
+ options = options.replace( prestigesStr, "" );
+ prestigesStr = prestigesStr.replace( "prestiges=", "" ).trim();
+
+ try {
+ prestigeRanks = Integer.parseInt( prestigesStr );
+ }
+ catch ( NumberFormatException e ) {
+ // Not a valid double number, or price:
+ }
+ }
+
+ String prestigeCostStr = extractParameter("prestigeCost=", options);
+ if ( prestigeCostStr != null ) {
+ options = options.replace( prestigeCostStr, "" );
+ prestigeCostStr = prestigeCostStr.replace( "prestigeCost=", "" ).trim();
+
+ try {
+ prestigeCost = Long.parseLong( prestigeCostStr );
+ }
+ catch ( NumberFormatException e ) {
+ // Not a valid double number, or price:
+ }
+ }
+
+ String prestigeMultStr = extractParameter("prestigeMult=", options);
+ if ( prestigeMultStr != null ) {
+ options = options.replace( prestigeMultStr, "" );
+ prestigeMultStr = prestigeMultStr.replace( "prestigeMult=", "" ).trim();
+
+ try {
+ prestigeMult = Double.parseDouble( prestigeMultStr );
+ }
+ catch ( NumberFormatException e ) {
+ // Not a valid double number, or price:
+ }
+ }
+
+ // This has to be checked after prestiges= or this will destroy that config setting:
+ if ( options.contains( "prestiges" ) ) {
+ prestiges = true;
+ options = options.replace( "prestiges", "" ).trim();
+ }
+
+
// What's left over, if not just a blank string, must be an error:
@@ -491,13 +570,22 @@ public void autoConfigureRanks(CommandSender sender,
int prestigesCount = 0;
// add in 10 prestiges at 1 billion each:
- double prestigeCost = 1000000000;
+// double prestigeCost = 1_000_000_000;
- for ( int i = 0; i < 10; i++ ) {
- String name = "P" + (i + 1);
- String tag = "&5[&d+" + (i > 0 ? i + 1 : "" ) + "&5]";
- createRank(sender, name, (prestigeCost * (i + 1) ), LadderManager.LADDER_PRESTIGES, tag, "noPlaceholderUpdate");
- prestigesCount++;
+ if ( prestiges ) {
+
+ for ( int i = 0; i < prestigeRanks; i++ ) {
+ String name = "P" + (i + 1);
+ String tag = "&5[&d+" + (i > 0 ? i + 1 : "" ) + "&5]";
+ double cost = prestigeCost * (i + 1) * prestigeMult;
+
+ // Only add prestige ranks if they do not already exist:
+ if ( PrisonRanks.getInstance().getRankManager().getRank( name ) == null ) {
+
+ createRank(sender, name, cost, LadderManager.LADDER_PRESTIGES, tag, "noPlaceholderUpdate");
+ prestigesCount++;
+ }
+ }
}
// If mines were created, go ahead and auto assign blocks to the mines:
@@ -517,9 +605,9 @@ public void autoConfigureRanks(CommandSender sender,
// Set the prestiges ladder with a 10% base rank cost multiplier
double rankCostMultiplier = 0.10;
- RankLadder prestiges = PrisonRanks.getInstance().getLadderManager().getLadder( LadderManager.LADDER_PRESTIGES );
- prestiges.setRankCostMultiplierPerRank( rankCostMultiplier );
- PrisonRanks.getInstance().getLadderManager().save( prestiges );
+ RankLadder prestigesLadder = PrisonRanks.getInstance().getLadderManager().getLadderPrestiges();
+ prestigesLadder.setRankCostMultiplierPerRank( rankCostMultiplier );
+ PrisonRanks.getInstance().getLadderManager().save( prestigesLadder );
// Log that the rank cost multiplier has been applied to the ladder
// with information on how to change it.
From 742afe6729d98482074cf901db6b24b7efc8a404 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 30 Jul 2023 23:03:58 -0400
Subject: [PATCH 055/151] RevEnchants: added additional logging and details if
there is a failure trying to hook into the RevEnchant's events. Trying to see
if there is additional causedBy information.
---
docs/changelog_v3.3.x.md | 4 ++++
.../events/AutoManagerRevEnchantsExplosiveEvent.java | 7 ++++++-
.../events/AutoManagerRevEnchantsJackHammerEvent.java | 7 ++++++-
.../tech/mcprison/prison/spigot/sellall/SellAllUtil.java | 3 ++-
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index a79d62916..793ce3c35 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,10 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15b 2023-07-30
+* **RevEnchants: added additional logging and details if there is a failure trying to hook into the RevEnchant's events.**
+Trying to see if there is additional causedBy information.
+
+
* **ranks autoConfigure: Major enhancements to add more prestige ranks.**
Added a lot more informatio to the command's help: `/ranks autoConfigure help`.
More options have been added: prestiges prestiges=x prestigesCost=x prestigesMult=x.
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
index 32b49b5d0..c04881870 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
@@ -241,7 +241,12 @@ public void dumpEventListeners( StringBuilder sb ) {
// CrazyEnchants is not loaded... so ignore.
}
catch ( Exception e ) {
- Output.get().logInfo( "AutoManager: RevEnchants ExplosiveEvent failed to load. [%s]", e.getMessage() );
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: RevEnchants ExplosiveEvent failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy );
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
index 8f29c41d1..8aac7fa3c 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
@@ -249,7 +249,12 @@ public void dumpEventListeners( StringBuilder sb ) {
// CrazyEnchants is not loaded... so ignore.
}
catch ( Exception e ) {
- Output.get().logInfo( "AutoManager: RevEnchants JackHammerEnchants failed to load. [%s]", e.getMessage() );
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: RevEnchants JackHammerEnchants failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy, e.getMessage() );
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index 82f3e4736..8927c8b30 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -1438,7 +1438,8 @@ public boolean addItemTrigger(XMaterial xMaterial){
public void addToDelay(Player p){
if (!isPlayerWaitingSellAllDelay(p)){
activePlayerDelay.add(p);
- Bukkit.getScheduler().scheduleSyncDelayedTask(SpigotPrison.getInstance(), () -> removeFromDelay(p), 20L * defaultSellAllDelay);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(
+ SpigotPrison.getInstance(), () -> removeFromDelay(p), 20L * defaultSellAllDelay);
}
}
From 74aef9a551924657b667faceb37e1e235a24e94f Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Sun, 30 Jul 2023 23:06:48 -0400
Subject: [PATCH 056/151] v3.3.0-alpha.15c 2023-07-30
---
docs/changelog_v3.3.x.md | 5 ++++-
gradle.properties | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 793ce3c35..fc56ee8fe 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,10 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15b 2023-07-30
+# 3.3.0-alpha.15c 2023-07-30
+
+
+**v3.3.0-alpha.15c 2023-07-30**
* **RevEnchants: added additional logging and details if there is a failure trying to hook into the RevEnchant's events.**
diff --git a/gradle.properties b/gradle.properties
index 9aa660bdb..3bf67908a 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,7 +3,7 @@
## # This is actually the "correct" place to define the version for the project.
## # Used within build.gradle with ${project.version}.
## # Can be overridden on the command line: gradle -Pversion=3.2.1-alpha.3
-version=3.3.0-alpha.15b
+version=3.3.0-alpha.15c
From 4339fd4e6f34d7d67a6b7f70a03c8765f35a8aef Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 4 Aug 2023 10:00:30 -0400
Subject: [PATCH 057/151] AutoFeatures: Add support for the XPrison
enchantments. Please be aware that event priorities must be adjusted. You can
change prison's event priorities, but XPrison is hard coded to NORMAL So to
get this work, you may have to adjust prison's priorities so it is after
XPrison's. We cannot support XPrison especially if their event priorities
become a problem, or causes a problem.
---
docs/changelog_v3.3.x.md | 7 ++++-
.../autofeatures/AutoFeaturesFileConfig.java | 4 +++
.../prison/mines/features/MineBlockEvent.java | 11 ++++++-
.../prison/spigot/SpigotPlatform.java | 17 +++++++++++
.../block/OnBlockBreakEventListener.java | 30 ++++++++++++++++++-
5 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index fc56ee8fe..00101085d 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,12 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.15c 2023-07-30
+# 3.3.0-alpha.15c 2023-08-04
+
+
+* **AutoFeatures: Add support for the XPrison enchantments.**
+Please be aware that event priorities must be adjusted. You can change prison's event priorities, but XPrison is hard coded to NORMAL So to get this work, you may have to adjust prison's priorities so it is after XPrison's.
+We cannot support XPrison especially if their event priorities become a problem, or causes a problem.
**v3.3.0-alpha.15c 2023-07-30**
diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesFileConfig.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesFileConfig.java
index b2498aff3..b8d92591d 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesFileConfig.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesFileConfig.java
@@ -127,6 +127,10 @@ public enum AutoFeatures {
PrisonEnchantsExplosiveEventPriority(blockBreakEvents, "DISABLED"),
+ XPrisonExplosionTriggerEventPriority(blockBreakEvents, "DISABLED"),
+ XPrisonLayerTriggerEventPriority(blockBreakEvents, "DISABLED"),
+ XPrisonNukeTriggerEventPriority(blockBreakEvents, "DISABLED"),
+
blockBreakEvents__ReadMe(blockBreakEvents,
"Use the following event priorities with the blockBreakEvents: " +
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineBlockEvent.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineBlockEvent.java
index 7873665d8..c34a3d527 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineBlockEvent.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineBlockEvent.java
@@ -41,12 +41,21 @@ public enum BlockEventType {
RevEnExplosion,
RevEnJackHammer,
+ ExplosionTriggerEvent,
+ LayerTriggerEvent,
+ NukeTriggerEvent,
+
eventTypeAll( all ),
eventBlockBreak( blockBreak ),
eventTEXplosion( TEXplosion ),
eventRevEnExplosion( RevEnExplosion ),
- eventRevEnJackHammer( RevEnJackHammer ),
+ eventRevEnJackHammer( RevEnJackHammer ),
+
+ XPrisonExplosionTriggerEvent( ExplosionTriggerEvent ),
+ XPrisonLayerTriggerEvent( LayerTriggerEvent ),
+ XPrisonNukeTriggerEvent( NukeTriggerEvent ),
+
;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
index 13603d703..31ffd82cb 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
@@ -115,6 +115,9 @@
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerRevEnchantsExplosiveEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerRevEnchantsJackHammerEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerTokenEnchant;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonExplosionTriggerEvent;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonLayerTriggerEvent;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonNukeTriggerEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerZenchantments;
import tech.mcprison.prison.spigot.backpacks.BackpacksUtil;
import tech.mcprison.prison.spigot.block.BlockBreakPriority;
@@ -2660,6 +2663,20 @@ public String dumpEventListenersBlockBreakEvents() {
zenchantments.dumpEventListeners( sb );
+
+ AutoManagerXPrisonExplosionTriggerEvent xpExplosion = new AutoManagerXPrisonExplosionTriggerEvent();
+ xpExplosion.dumpEventListeners( sb );
+
+ AutoManagerXPrisonLayerTriggerEvent xpLayer = new AutoManagerXPrisonLayerTriggerEvent();
+ xpLayer.dumpEventListeners( sb );
+
+ AutoManagerXPrisonNukeTriggerEvent xpNuke = new AutoManagerXPrisonNukeTriggerEvent();
+ xpNuke.dumpEventListeners( sb );
+
+
+
+
+
// Shorten the prison package names:
// 'tmps.' = 'tech.mcprison.prison.spigot.'
// 'tmpsae.' = 'tmps.autofeatures.events.'
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
index a604f1b8a..f693a3c41 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
@@ -17,6 +17,9 @@
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerRevEnchantsExplosiveEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerRevEnchantsJackHammerEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerTokenEnchant;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonExplosionTriggerEvent;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonLayerTriggerEvent;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonNukeTriggerEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerZenchantments;
import tech.mcprison.prison.spigot.autofeatures.events.PrisonDebugBlockInspector;
@@ -111,10 +114,16 @@ public class OnBlockBreakEventListener
private AutoManagerRevEnchantsExplosiveEvent reEEvents;
private AutoManagerRevEnchantsJackHammerEvent reJHEvents;
-
+ private AutoManagerXPrisonExplosionTriggerEvent xpExpEvents;
+ private AutoManagerXPrisonLayerTriggerEvent xpLayerEvents;
+ private AutoManagerXPrisonNukeTriggerEvent xpNukeEvents;
+
+
private PrisonDebugBlockInspector pdBlockInspector;
+
+
public OnBlockBreakEventListener() {
super();
@@ -227,6 +236,15 @@ private void registerEvents() {
reJHEvents = new AutoManagerRevEnchantsJackHammerEvent();
+
+ xpExpEvents = new AutoManagerXPrisonExplosionTriggerEvent();
+
+ xpLayerEvents = new AutoManagerXPrisonLayerTriggerEvent();
+
+ xpNukeEvents = new AutoManagerXPrisonNukeTriggerEvent();
+
+
+
if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
bbEvents.registerEvents();
@@ -245,9 +263,19 @@ private void registerEvents() {
reEEvents.registerEvents();
reJHEvents.registerEvents();
+
+
+ xpExpEvents.registerEvents();
+
+ xpLayerEvents.registerEvents();
+
+ xpNukeEvents.registerEvents();
+
}
pdBlockInspector = PrisonDebugBlockInspector.getInstance();
+ pdBlockInspector.getClass();
+
// pdBlockInspector.init();
}
From 7d74600fcab0b72eca1296ccd6bd01731db96526 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 4 Aug 2023 10:01:50 -0400
Subject: [PATCH 058/151] Fixed the formatting... since this is a demo test
app, it cannot use the global prison decimal formatting since it's not being
loaded.
---
.../mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java b/prison-core/src/main/java/tech/mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java
index a856abc35..5f59bfc4e 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java
@@ -4,8 +4,6 @@
import java.text.DecimalFormat;
import java.util.ArrayList;
-import tech.mcprison.prison.Prison;
-
public class ExampleJavaDoubleVsBigDecimal {
public static void main( String[] args ) {
@@ -36,7 +34,7 @@ private ArrayList runSample() {
StringBuilder sb = new StringBuilder();
sb.append( ".111111" );
- DecimalFormat dFmt = Prison.get().getDecimalFormat( "#,##0.00000" );
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.00000" );
for ( int i = 1; i < 25; i++ ) {
sb.insert( 0, "1" );
From c141735c268026a57be87bd04baec9fd17dc9a8a Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 4 Aug 2023 10:04:17 -0400
Subject: [PATCH 059/151] AutoFeatures BlockInspector: Fixed a bug with not
negating a condition... was causing some problems since it was misreporting
the results.
---
docs/changelog_v3.3.x.md | 4 ++++
.../spigot/autofeatures/events/PrisonDebugBlockInspector.java | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 00101085d..00576b4e0 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,10 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15c 2023-08-04
+
+* ** AutoFeatures BlockInspector: Fixed a bug with not negating a condition... was causing some problems since it was misreporting the results.**
+
+
* **AutoFeatures: Add support for the XPrison enchantments.**
Please be aware that event priorities must be adjusted. You can change prison's event priorities, but XPrison is hard coded to NORMAL So to get this work, you may have to adjust prison's priorities so it is after XPrison's.
We cannot support XPrison especially if their event priorities become a problem, or causes a problem.
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
index a0db0925a..77a531c71 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
@@ -525,7 +525,7 @@ private EventDropsStatus isDropCanceled( BlockBreakEvent bbe ) {
EventDropsStatus results = EventDropsStatus.normal;
try {
- if ( bbe.isDropItems() ) {
+ if ( !bbe.isDropItems() ) {
results = EventDropsStatus.canceled;
}
else {
From 22f521c5231052ef6a11262a5cd595ef7f90814d Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 4 Aug 2023 10:06:36 -0400
Subject: [PATCH 060/151] Prestiges: Bug fix. If no prestige rank, then prevent
a NPE. Totally thought this was fixed a while ago?
---
docs/changelog_v3.3.x.md | 5 ++++-
.../tech/mcprison/prison/ranks/commands/RankUpCommand.java | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 00576b4e0..f46f58547 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,8 +17,11 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15c 2023-08-04
+* **Prestiges: Bug fix. If no prestige rank, then prevent a NPE on a simple check.**
+Totally thought this was fixed a while ago?
-* ** AutoFeatures BlockInspector: Fixed a bug with not negating a condition... was causing some problems since it was misreporting the results.**
+
+* **AutoFeatures BlockInspector: Fixed a bug with not negating a condition... was causing some problems since it was misreporting the results.**
* **AutoFeatures: Add support for the XPrison enchantments.**
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
index d7bb62685..6ca277370 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
@@ -458,7 +458,10 @@ private boolean rankUpPrivate(CommandSender sender, String playerName, String la
PlayerRank rankCurrent = rankPlayer.getPlayerRank(ladder);
- if ( rankCurrent.getRank().getRankNext() == null ) {
+
+
+ // If the player has a rank on the target ladder, mmake sure the next rank is not null
+ if ( rankCurrent != null && rankCurrent.getRank().getRankNext() == null ) {
rankupAtLastRankMsg(sender);
return false;
}
From 3d3195f7bc82d98e80f72320a8f6e7415869e4eb Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 4 Aug 2023 10:33:44 -0400
Subject: [PATCH 061/151] AutoFeatures: Add support for the XPrison
enchantments. Please be aware that event priorities must be adjusted. You can
change prison's event priorities, but XPrison is hard coded to NORMAL So to
get this work, you may have to adjust prison's priorities so it is after
XPrison's. We cannot support XPrison especially if their event priorities
become a problem, or causes a problem.
---
...toManagerXPrisonExplosionTriggerEvent.java | 433 ++++++++++++++++++
.../AutoManagerXPrisonLayerTriggerEvent.java | 433 ++++++++++++++++++
.../AutoManagerXPrisonNukeTriggerEvent.java | 433 ++++++++++++++++++
3 files changed, 1299 insertions(+)
create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonExplosionTriggerEvent.java
create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonLayerTriggerEvent.java
create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonNukeTriggerEvent.java
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonExplosionTriggerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonExplosionTriggerEvent.java
new file mode 100644
index 000000000..63218cbf5
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonExplosionTriggerEvent.java
@@ -0,0 +1,433 @@
+package tech.mcprison.prison.spigot.autofeatures.events;
+
+import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.EventExecutor;
+import org.bukkit.plugin.PluginManager;
+
+import dev.drawethree.xprison.enchants.api.events.ExplosionTriggerEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
+import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent;
+import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures;
+import tech.mcprison.prison.spigot.block.BlockBreakPriority;
+
+public class AutoManagerXPrisonExplosionTriggerEvent
+ extends AutoManagerFeatures
+ implements PrisonEventManager
+{
+
+
+// private ExplosionTriggerEvent ete;
+// private LayerTriggerEvent lte;
+// private NukeTriggerEvent nte;
+
+// dev.drawethree.xprison.enchants.api.events.ExplosionTriggerEvent;
+
+
+
+ private BlockBreakPriority bbPriority;
+
+ public AutoManagerXPrisonExplosionTriggerEvent() {
+ super();
+ }
+
+ public AutoManagerXPrisonExplosionTriggerEvent( BlockBreakPriority bbPriority ) {
+ super();
+
+ this.bbPriority = bbPriority;
+ }
+
+
+ public BlockBreakPriority getBbPriority() {
+ return bbPriority;
+ }
+ public void setBbPriority( BlockBreakPriority bbPriority ) {
+ this.bbPriority = bbPriority;
+ }
+
+ @Override
+ public void registerEvents() {
+
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
+ }
+
+
+ public class AutoManagerXPrisonExplosionTriggerEventListener
+ extends AutoManagerXPrisonExplosionTriggerEvent
+ implements Listener {
+
+ public AutoManagerXPrisonExplosionTriggerEventListener( BlockBreakPriority bbPriority ) {
+ super( bbPriority );
+ }
+
+ @EventHandler(priority=EventPriority.NORMAL)
+ public void onXPrisonExplosionTriggerEvent(
+ ExplosionTriggerEvent e, BlockBreakPriority bbPriority) {
+
+ if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ||
+ bbPriority.isDisabled() ) {
+ return;
+ }
+
+ handleXPrisonExplosionTriggerEvent( e, bbPriority );
+ }
+ }
+
+
+ @Override
+ public void initialize() {
+
+ String eP = getMessage( AutoFeatures.XPrisonExplosionTriggerEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ setBbPriority( bbPriority );
+
+// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( getBbPriority() == BlockBreakPriority.DISABLED ) {
+ return;
+ }
+
+ // Check to see if the class ExplosionTriggerEvent even exists:
+ try {
+ Output.get().logInfo( "AutoManager: checking if loaded: XPrison ExplosionTriggerEvent" );
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.ExplosionTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+ Output.get().logInfo( "AutoManager: Trying to register XPrison ExplosionTriggerEvent" );
+
+ if ( getBbPriority() != BlockBreakPriority.DISABLED ) {
+ if ( bbPriority.isComponentCompound() ) {
+
+ for (BlockBreakPriority subBBPriority : bbPriority.getComponentPriorities()) {
+
+ createListener( subBBPriority );
+ }
+ }
+ else {
+
+ createListener(bbPriority);
+ }
+
+ }
+ }
+ catch ( ClassNotFoundException e ) {
+ // CrazyEnchants is not loaded... so ignore.
+ Output.get().logInfo( "AutoManager: XPrison ExplosionTriggerEvent is not loaded" );
+ }
+ catch ( Exception e ) {
+ Output.get().logInfo( "AutoManager: XPrison ExplosionTriggerEvent failed to load. [%s]", e.getMessage() );
+ }
+ }
+
+ private void createListener( BlockBreakPriority bbPriority ) {
+
+ SpigotPrison prison = SpigotPrison.getInstance();
+ PluginManager pm = Bukkit.getServer().getPluginManager();
+ EventPriority ePriority = bbPriority.getBukkitEventPriority();
+
+
+ AutoManagerXPrisonExplosionTriggerEventListener autoManagerListener =
+ new AutoManagerXPrisonExplosionTriggerEventListener( bbPriority );
+
+ pm.registerEvent(
+ ExplosionTriggerEvent.class,
+ autoManagerListener, ePriority,
+ new EventExecutor() {
+ public void execute(Listener l, Event e) {
+
+ ExplosionTriggerEvent exEvent = (ExplosionTriggerEvent) e;
+
+ ((AutoManagerXPrisonExplosionTriggerEventListener)l)
+ .onXPrisonExplosionTriggerEvent(exEvent, bbPriority);
+ }
+ },
+ prison);
+ prison.getRegisteredBlockListeners().add( autoManagerListener );
+ }
+
+
+ @Override
+ public void unregisterListeners() {
+
+// super.unregisterListeners();
+ }
+
+ @Override
+ public void dumpEventListeners() {
+
+ StringBuilder sb = new StringBuilder();
+
+ dumpEventListeners( sb );
+
+ if ( sb.length() > 0 ) {
+
+
+ for ( String line : sb.toString().split( "\n" ) ) {
+
+ Output.get().logInfo( line );
+ }
+ }
+
+ }
+
+
+ @Override
+ public void dumpEventListeners( StringBuilder sb ) {
+
+ String eP = getMessage( AutoFeatures.XPrisonExplosionTriggerEventPriority );
+ boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( !isEventEnabled ) {
+ return;
+ }
+
+ // Check to see if the class ExplosionTriggerEvent even exists:
+ try {
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.ExplosionTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+
+ HandlerList handlers = ExplosionTriggerEvent.getHandlerList();
+
+// String eP = getMessage( AutoFeatures.blockBreakEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ dumpEventListenersCore( "XPrison ExplosionTriggerEvent", handlers, bbPriority, sb );
+
+
+//
+// BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+//
+//
+// String title = String.format(
+// "ExplosionTriggerEvent (%s)",
+// ( bbPriority == null ? "--none--" : bbPriority.name()) );
+//
+// ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay(
+// title,
+// new SpigotHandlerList( ExplosionTriggerEvent.getHandlerList()) );
+//
+// if ( eventDisplay != null ) {
+// sb.append( eventDisplay.toStringBuilder() );
+// sb.append( "\n" );
+// }
+//
+//
+// if ( bbPriority.isComponentCompound() ) {
+// StringBuilder sbCP = new StringBuilder();
+// for ( BlockBreakPriority bbp : bbPriority.getComponentPriorities() ) {
+// if ( sbCP.length() > 0 ) {
+// sbCP.append( ", " );
+// }
+// sbCP.append( "'" ).append( bbp.name() ).append( "'" );
+// }
+//
+// String msg = String.format( "Note '%s' is a compound of: [%s]",
+// bbPriority.name(),
+// sbCP );
+//
+// sb.append( msg ).append( "\n" );
+// }
+ }
+ catch ( ClassNotFoundException e ) {
+ // XPrison is not loaded... so ignore.
+ }
+ catch ( Exception e ) {
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: XPrison ExplosionTriggerEvent failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy );
+ }
+ }
+
+
+ /**
+ *
Since there are multiple blocks associated with this event, pull out the player first and
+ * get the mine, then loop through those blocks to make sure they are within the mine.
+ *
+ *
+ *
The logic in this function is slightly different compared to genericBlockEvent() because this
+ * event contains multiple blocks so it's far more efficient to process the player data once.
+ * So that basically needed a slight refactoring.
+ *
+ *
+ * @param e
+ */
+ public void handleXPrisonExplosionTriggerEvent( ExplosionTriggerEvent e, BlockBreakPriority bbPriority ) {
+
+ PrisonMinesBlockBreakEvent pmEvent = null;
+ long start = System.nanoTime();
+
+ // If the event is canceled, it still needs to be processed because of the
+ // MONITOR events:
+ // An event will be "canceled" and "ignored" if the block
+ // BlockUtils.isUnbreakable(), or if the mine is actively resetting.
+ // The event will also be ignored if the block is outside of a mine
+ // or if the targetBlock has been set to ignore all block events which
+ // means the block has already been processed.
+ MinesEventResults eventResults = ignoreMinesBlockBreakEvent( e,
+ e.getPlayer(), e.getOriginBlock(),
+ bbPriority, true );
+
+ if ( eventResults.isIgnoreEvent() ) {
+ return;
+ }
+
+
+ StringBuilder debugInfo = new StringBuilder();
+
+ debugInfo.append( String.format( "### ** handleXPrisonExplosionTriggerEvent ** ### " +
+ "(event: ExplosionTriggerEvent, config: %s, priority: %s, canceled: %s) ",
+ bbPriority.name(),
+ bbPriority.getBukkitEventPriority().name(),
+ (e.isCancelled() ? "TRUE " : "FALSE")
+ ) );
+
+ debugInfo.append( eventResults.getDebugInfo() );
+
+
+ // NOTE that check for auto manager has happened prior to accessing this function.
+
+ // Process all priorities if the event has not been canceled, and
+ // process the MONITOR priority even if the event was canceled:
+ if ( !bbPriority.isMonitor() && !e.isCancelled() ||
+ bbPriority.isMonitor() &&
+ e.getBlocksAffected().size() > 0 ) {
+
+
+
+// Block bukkitBlock = e.getBlocks().get( 0 );
+
+ BlockEventType eventType = BlockEventType.XPrisonExplosionTriggerEvent;
+ String triggered = null;
+
+
+ pmEvent = new PrisonMinesBlockBreakEvent(
+ eventResults,
+// bukkitBlock,
+// e.getPlayer(),
+// eventResults.getMine(),
+// bbPriority,
+ eventType, triggered,
+ debugInfo );
+
+
+ // NOTE: Check for the ACCESS priority and if someone does not have access, then return
+ // with a cancel on the event. Both ACCESSBLOCKEVENTS and ACCESSMONITOR will be
+ // converted to just ACCESS at this point, and the other part will run under either
+ // BLOCKEVENTS or MONITOR.
+ // This check has to be performed after creating the pmEvent object since it uses
+ // a lot of the internal variables and objects. There is not much of an impact since
+ // the validateEvent() has not been ran yet.
+ if ( checkIfNoAccess( pmEvent, start ) ) {
+
+ e.setCancelled( true );
+ return;
+ }
+
+
+ for ( int i = 1; i < e.getBlocksAffected().size(); i++ ) {
+ pmEvent.getUnprocessedRawBlocks().add( e.getBlocksAffected().get( i ) );
+ }
+
+
+ if ( !validateEvent( pmEvent ) ) {
+
+ // The event has not passed validation. All logging and Errors have been recorded
+ // so do nothing more. This is to just prevent normal processing from occurring.
+
+ if ( pmEvent.isCancelOriginalEvent() ) {
+
+ e.setCancelled( true );
+ }
+
+ debugInfo.append( "(doAction failed validation) " );
+ }
+
+
+
+ // The validation was successful, but stop processing for the MONITOR priorities.
+ // Note that BLOCKEVENTS processing occurred already within validateEvent():
+ else if ( pmEvent.getBbPriority().isMonitor() ) {
+ // Stop here, and prevent additional processing.
+ // Monitors should never process the event beyond this.
+ }
+
+
+
+ // This is where the processing actually happens:
+ else {
+
+// debugInfo.append( "(normal processing initiating) " );
+
+ // check all external events such as mcMMO and EZBlocks:
+// if ( e instanceof BlockBreakEvent ) {
+// processPMBBExternalEvents( pmEvent, debugInfo, e );
+// }
+//
+
+ EventListenerCancelBy cancelBy = EventListenerCancelBy.none;
+
+ cancelBy = processPMBBEvent( pmEvent );
+
+
+ if ( cancelBy != EventListenerCancelBy.none ) {
+
+ e.setCancelled( true );
+ debugInfo.append( "(event canceled) " );
+ }
+// else if ( cancelBy == EventListenerCancelBy.drops ) {
+// try
+// {
+// e.setDropItems( false );
+// debugInfo.append( "(drop canceled) " );
+// }
+// catch ( NoSuchMethodError e1 )
+// {
+// String message = String.format(
+// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " +
+// "is not valid for this version of Spigot. It's only vaid for spigot v1.12.x and higher. " +
+// "Modify the config settings and set this value to `false`. For now, it is temporarily " +
+// "disabled. [%s]",
+// e1.getMessage() );
+// Output.get().logWarn( message );
+//
+// AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig()
+// .setFeature( AutoFeatures.cancelAllBlockEventBlockDrops, false );
+// }
+//
+// }
+ }
+
+
+ }
+
+ printDebugInfo( pmEvent, start );
+ }
+
+ @Override
+ protected int checkBonusXp( Player player, Block block, ItemStack item ) {
+ int bonusXp = 0;
+
+ return bonusXp;
+ }
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonLayerTriggerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonLayerTriggerEvent.java
new file mode 100644
index 000000000..42bba739a
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonLayerTriggerEvent.java
@@ -0,0 +1,433 @@
+package tech.mcprison.prison.spigot.autofeatures.events;
+
+import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.EventExecutor;
+import org.bukkit.plugin.PluginManager;
+
+import dev.drawethree.xprison.enchants.api.events.LayerTriggerEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
+import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent;
+import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures;
+import tech.mcprison.prison.spigot.block.BlockBreakPriority;
+
+public class AutoManagerXPrisonLayerTriggerEvent
+ extends AutoManagerFeatures
+ implements PrisonEventManager
+{
+
+
+// private ExplosionTriggerEvent ete;
+// private LayerTriggerEvent lte;
+// private NukeTriggerEvent nte;
+
+ //dev.drawethree.xprison.enchants.api.events.LayerTriggerEvent;
+
+
+
+ private BlockBreakPriority bbPriority;
+
+ public AutoManagerXPrisonLayerTriggerEvent() {
+ super();
+ }
+
+ public AutoManagerXPrisonLayerTriggerEvent( BlockBreakPriority bbPriority ) {
+ super();
+
+ this.bbPriority = bbPriority;
+ }
+
+
+ public BlockBreakPriority getBbPriority() {
+ return bbPriority;
+ }
+ public void setBbPriority( BlockBreakPriority bbPriority ) {
+ this.bbPriority = bbPriority;
+ }
+
+ @Override
+ public void registerEvents() {
+
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
+ }
+
+
+ public class AutoManagerXPrisonLayerTriggerEventListener
+ extends AutoManagerXPrisonLayerTriggerEvent
+ implements Listener {
+
+ public AutoManagerXPrisonLayerTriggerEventListener( BlockBreakPriority bbPriority ) {
+ super( bbPriority );
+ }
+
+ @EventHandler(priority=EventPriority.NORMAL)
+ public void onXPrisonLayerTriggerEvent(
+ LayerTriggerEvent e, BlockBreakPriority bbPriority) {
+
+ if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ||
+ bbPriority.isDisabled() ) {
+ return;
+ }
+
+ handleXPrisonLayerTriggerEvent( e, bbPriority );
+ }
+ }
+
+
+ @Override
+ public void initialize() {
+
+ String eP = getMessage( AutoFeatures.XPrisonLayerTriggerEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ setBbPriority( bbPriority );
+
+ // boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( getBbPriority() == BlockBreakPriority.DISABLED ) {
+ return;
+ }
+
+ // Check to see if the class LayerTriggerEvent even exists:
+ try {
+ Output.get().logInfo( "AutoManager: checking if loaded: XPrison LayerTriggerEvent" );
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.LayerTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+ Output.get().logInfo( "AutoManager: Trying to register XPrison LayerTriggerEvent" );
+
+ if ( getBbPriority() != BlockBreakPriority.DISABLED ) {
+ if ( bbPriority.isComponentCompound() ) {
+
+ for (BlockBreakPriority subBBPriority : bbPriority.getComponentPriorities()) {
+
+ createListener( subBBPriority );
+ }
+ }
+ else {
+
+ createListener(bbPriority);
+ }
+
+ }
+ }
+ catch ( ClassNotFoundException e ) {
+ // CrazyEnchants is not loaded... so ignore.
+ Output.get().logInfo( "AutoManager: XPrison LayerTriggerEvent is not loaded" );
+ }
+ catch ( Exception e ) {
+ Output.get().logInfo( "AutoManager: XPrison LayerTriggerEvent failed to load. [%s]", e.getMessage() );
+ }
+ }
+
+ private void createListener( BlockBreakPriority bbPriority ) {
+
+ SpigotPrison prison = SpigotPrison.getInstance();
+ PluginManager pm = Bukkit.getServer().getPluginManager();
+ EventPriority ePriority = bbPriority.getBukkitEventPriority();
+
+
+ AutoManagerXPrisonLayerTriggerEventListener autoManagerListener =
+ new AutoManagerXPrisonLayerTriggerEventListener( bbPriority );
+
+ pm.registerEvent(
+ LayerTriggerEvent.class,
+ autoManagerListener, ePriority,
+ new EventExecutor() {
+ public void execute(Listener l, Event e) {
+
+ LayerTriggerEvent exEvent = (LayerTriggerEvent) e;
+
+ ((AutoManagerXPrisonLayerTriggerEventListener)l)
+ .onXPrisonLayerTriggerEvent(exEvent, bbPriority);
+ }
+ },
+ prison);
+ prison.getRegisteredBlockListeners().add( autoManagerListener );
+ }
+
+
+ @Override
+ public void unregisterListeners() {
+
+ // super.unregisterListeners();
+ }
+
+ @Override
+ public void dumpEventListeners() {
+
+ StringBuilder sb = new StringBuilder();
+
+ dumpEventListeners( sb );
+
+ if ( sb.length() > 0 ) {
+
+
+ for ( String line : sb.toString().split( "\n" ) ) {
+
+ Output.get().logInfo( line );
+ }
+ }
+
+ }
+
+
+@Override
+public void dumpEventListeners( StringBuilder sb ) {
+
+ String eP = getMessage( AutoFeatures.XPrisonLayerTriggerEventPriority );
+ boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( !isEventEnabled ) {
+ return;
+ }
+
+ // Check to see if the class LayerTriggerEvent even exists:
+ try {
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.LayerTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+
+ HandlerList handlers = LayerTriggerEvent.getHandlerList();
+
+// String eP = getMessage( AutoFeatures.blockBreakEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ dumpEventListenersCore( "XPrison LayerTriggerEvent", handlers, bbPriority, sb );
+
+
+//
+// BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+//
+//
+// String title = String.format(
+// "LayerTriggerEvent (%s)",
+// ( bbPriority == null ? "--none--" : bbPriority.name()) );
+//
+// ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay(
+// title,
+// new SpigotHandlerList( LayerTriggerEvent.getHandlerList()) );
+//
+// if ( eventDisplay != null ) {
+// sb.append( eventDisplay.toStringBuilder() );
+// sb.append( "\n" );
+// }
+//
+//
+// if ( bbPriority.isComponentCompound() ) {
+// StringBuilder sbCP = new StringBuilder();
+// for ( BlockBreakPriority bbp : bbPriority.getComponentPriorities() ) {
+// if ( sbCP.length() > 0 ) {
+// sbCP.append( ", " );
+// }
+// sbCP.append( "'" ).append( bbp.name() ).append( "'" );
+// }
+//
+// String msg = String.format( "Note '%s' is a compound of: [%s]",
+// bbPriority.name(),
+// sbCP );
+//
+// sb.append( msg ).append( "\n" );
+// }
+ }
+ catch ( ClassNotFoundException e ) {
+ // XPrison is not loaded... so ignore.
+ }
+ catch ( Exception e ) {
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: XPrison LayerTriggerEvent failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy );
+ }
+}
+
+
+/**
+ *
Since there are multiple blocks associated with this event, pull out the player first and
+ * get the mine, then loop through those blocks to make sure they are within the mine.
+ *
+ *
+ *
The logic in this function is slightly different compared to genericBlockEvent() because this
+ * event contains multiple blocks so it's far more efficient to process the player data once.
+ * So that basically needed a slight refactoring.
+ *
+ *
+ * @param e
+ */
+public void handleXPrisonLayerTriggerEvent( LayerTriggerEvent e, BlockBreakPriority bbPriority ) {
+
+ PrisonMinesBlockBreakEvent pmEvent = null;
+ long start = System.nanoTime();
+
+ // If the event is canceled, it still needs to be processed because of the
+ // MONITOR events:
+ // An event will be "canceled" and "ignored" if the block
+ // BlockUtils.isUnbreakable(), or if the mine is actively resetting.
+ // The event will also be ignored if the block is outside of a mine
+ // or if the targetBlock has been set to ignore all block events which
+ // means the block has already been processed.
+ MinesEventResults eventResults = ignoreMinesBlockBreakEvent( e,
+ e.getPlayer(), e.getOriginBlock(),
+ bbPriority, true );
+
+ if ( eventResults.isIgnoreEvent() ) {
+ return;
+ }
+
+
+ StringBuilder debugInfo = new StringBuilder();
+
+ debugInfo.append( String.format( "### ** handleXPrisonLayerTriggerEvent ** ### " +
+ "(event: LayerTriggerEvent, config: %s, priority: %s, canceled: %s) ",
+ bbPriority.name(),
+ bbPriority.getBukkitEventPriority().name(),
+ (e.isCancelled() ? "TRUE " : "FALSE")
+ ) );
+
+ debugInfo.append( eventResults.getDebugInfo() );
+
+
+ // NOTE that check for auto manager has happened prior to accessing this function.
+
+ // Process all priorities if the event has not been canceled, and
+ // process the MONITOR priority even if the event was canceled:
+ if ( !bbPriority.isMonitor() && !e.isCancelled() ||
+ bbPriority.isMonitor() &&
+ e.getBlocksAffected().size() > 0 ) {
+
+
+
+// Block bukkitBlock = e.getBlocks().get( 0 );
+
+ BlockEventType eventType = BlockEventType.XPrisonLayerTriggerEvent;
+ String triggered = null;
+
+
+ pmEvent = new PrisonMinesBlockBreakEvent(
+ eventResults,
+// bukkitBlock,
+// e.getPlayer(),
+// eventResults.getMine(),
+// bbPriority,
+ eventType, triggered,
+ debugInfo );
+
+
+ // NOTE: Check for the ACCESS priority and if someone does not have access, then return
+ // with a cancel on the event. Both ACCESSBLOCKEVENTS and ACCESSMONITOR will be
+ // converted to just ACCESS at this point, and the other part will run under either
+ // BLOCKEVENTS or MONITOR.
+ // This check has to be performed after creating the pmEvent object since it uses
+ // a lot of the internal variables and objects. There is not much of an impact since
+ // the validateEvent() has not been ran yet.
+ if ( checkIfNoAccess( pmEvent, start ) ) {
+
+ e.setCancelled( true );
+ return;
+ }
+
+
+ for ( int i = 1; i < e.getBlocksAffected().size(); i++ ) {
+ pmEvent.getUnprocessedRawBlocks().add( e.getBlocksAffected().get( i ) );
+ }
+
+
+ if ( !validateEvent( pmEvent ) ) {
+
+ // The event has not passed validation. All logging and Errors have been recorded
+ // so do nothing more. This is to just prevent normal processing from occurring.
+
+ if ( pmEvent.isCancelOriginalEvent() ) {
+
+ e.setCancelled( true );
+ }
+
+ debugInfo.append( "(doAction failed validation) " );
+ }
+
+
+
+ // The validation was successful, but stop processing for the MONITOR priorities.
+ // Note that BLOCKEVENTS processing occurred already within validateEvent():
+ else if ( pmEvent.getBbPriority().isMonitor() ) {
+ // Stop here, and prevent additional processing.
+ // Monitors should never process the event beyond this.
+ }
+
+
+
+ // This is where the processing actually happens:
+ else {
+
+// debugInfo.append( "(normal processing initiating) " );
+
+ // check all external events such as mcMMO and EZBlocks:
+// if ( e instanceof BlockBreakEvent ) {
+// processPMBBExternalEvents( pmEvent, debugInfo, e );
+// }
+//
+
+ EventListenerCancelBy cancelBy = EventListenerCancelBy.none;
+
+ cancelBy = processPMBBEvent( pmEvent );
+
+
+ if ( cancelBy != EventListenerCancelBy.none ) {
+
+ e.setCancelled( true );
+ debugInfo.append( "(event canceled) " );
+ }
+// else if ( cancelBy == EventListenerCancelBy.drops ) {
+// try
+// {
+// e.setDropItems( false );
+// debugInfo.append( "(drop canceled) " );
+// }
+// catch ( NoSuchMethodError e1 )
+// {
+// String message = String.format(
+// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " +
+// "is not valid for this version of Spigot. It's only vaid for spigot v1.12.x and higher. " +
+// "Modify the config settings and set this value to `false`. For now, it is temporarily " +
+// "disabled. [%s]",
+// e1.getMessage() );
+// Output.get().logWarn( message );
+//
+// AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig()
+// .setFeature( AutoFeatures.cancelAllBlockEventBlockDrops, false );
+// }
+//
+// }
+ }
+
+
+ }
+
+ printDebugInfo( pmEvent, start );
+}
+
+ @Override
+ protected int checkBonusXp( Player player, Block block, ItemStack item ) {
+ int bonusXp = 0;
+
+ return bonusXp;
+ }
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonNukeTriggerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonNukeTriggerEvent.java
new file mode 100644
index 000000000..80e60990a
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonNukeTriggerEvent.java
@@ -0,0 +1,433 @@
+package tech.mcprison.prison.spigot.autofeatures.events;
+
+import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.EventExecutor;
+import org.bukkit.plugin.PluginManager;
+
+import dev.drawethree.xprison.enchants.api.events.NukeTriggerEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
+import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent;
+import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures;
+import tech.mcprison.prison.spigot.block.BlockBreakPriority;
+
+public class AutoManagerXPrisonNukeTriggerEvent
+ extends AutoManagerFeatures
+ implements PrisonEventManager
+{
+
+
+// private ExplosionTriggerEvent ete;
+// private LayerTriggerEvent lte;
+// private NukeTriggerEvent nte;
+
+ //dev.drawethree.xprison.enchants.api.events.NukeTriggerEvent;
+
+
+
+ private BlockBreakPriority bbPriority;
+
+ public AutoManagerXPrisonNukeTriggerEvent() {
+ super();
+ }
+
+ public AutoManagerXPrisonNukeTriggerEvent( BlockBreakPriority bbPriority ) {
+ super();
+
+ this.bbPriority = bbPriority;
+ }
+
+
+ public BlockBreakPriority getBbPriority() {
+ return bbPriority;
+ }
+ public void setBbPriority( BlockBreakPriority bbPriority ) {
+ this.bbPriority = bbPriority;
+ }
+
+ @Override
+ public void registerEvents() {
+
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
+ }
+
+
+public class AutoManagerXPrisonNukeTriggerEventListener
+ extends AutoManagerXPrisonNukeTriggerEvent
+ implements Listener {
+
+ public AutoManagerXPrisonNukeTriggerEventListener( BlockBreakPriority bbPriority ) {
+ super( bbPriority );
+ }
+
+ @EventHandler(priority=EventPriority.NORMAL)
+ public void onXPrisonNukeTriggerEvent(
+ NukeTriggerEvent e, BlockBreakPriority bbPriority) {
+
+ if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ||
+ bbPriority.isDisabled() ) {
+ return;
+ }
+
+ handleXPrisonNukeTriggerEvent( e, bbPriority );
+ }
+}
+
+
+@Override
+public void initialize() {
+
+ String eP = getMessage( AutoFeatures.XPrisonNukeTriggerEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ setBbPriority( bbPriority );
+
+// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( getBbPriority() == BlockBreakPriority.DISABLED ) {
+ return;
+ }
+
+ // Check to see if the class NukeTriggerEvent even exists:
+ try {
+ Output.get().logInfo( "AutoManager: checking if loaded: XPrison NukeTriggerEvent" );
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.NukeTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+ Output.get().logInfo( "AutoManager: Trying to register XPrison NukeTriggerEvent" );
+
+ if ( getBbPriority() != BlockBreakPriority.DISABLED ) {
+ if ( bbPriority.isComponentCompound() ) {
+
+ for (BlockBreakPriority subBBPriority : bbPriority.getComponentPriorities()) {
+
+ createListener( subBBPriority );
+ }
+ }
+ else {
+
+ createListener(bbPriority);
+ }
+
+ }
+ }
+ catch ( ClassNotFoundException e ) {
+ // CrazyEnchants is not loaded... so ignore.
+ Output.get().logInfo( "AutoManager: XPrison NukeTriggerEvent is not loaded" );
+ }
+ catch ( Exception e ) {
+ Output.get().logInfo( "AutoManager: XPrison NukeTriggerEvent failed to load. [%s]", e.getMessage() );
+ }
+}
+
+private void createListener( BlockBreakPriority bbPriority ) {
+
+ SpigotPrison prison = SpigotPrison.getInstance();
+ PluginManager pm = Bukkit.getServer().getPluginManager();
+ EventPriority ePriority = bbPriority.getBukkitEventPriority();
+
+
+ AutoManagerXPrisonNukeTriggerEventListener autoManagerListener =
+ new AutoManagerXPrisonNukeTriggerEventListener( bbPriority );
+
+ pm.registerEvent(
+ NukeTriggerEvent.class,
+ autoManagerListener, ePriority,
+ new EventExecutor() {
+ public void execute(Listener l, Event e) {
+
+ NukeTriggerEvent exEvent = (NukeTriggerEvent) e;
+
+ ((AutoManagerXPrisonNukeTriggerEventListener)l)
+ .onXPrisonNukeTriggerEvent(exEvent, bbPriority);
+ }
+ },
+ prison);
+ prison.getRegisteredBlockListeners().add( autoManagerListener );
+}
+
+
+@Override
+public void unregisterListeners() {
+
+// super.unregisterListeners();
+}
+
+@Override
+public void dumpEventListeners() {
+
+ StringBuilder sb = new StringBuilder();
+
+ dumpEventListeners( sb );
+
+ if ( sb.length() > 0 ) {
+
+
+ for ( String line : sb.toString().split( "\n" ) ) {
+
+ Output.get().logInfo( line );
+ }
+ }
+
+}
+
+
+@Override
+public void dumpEventListeners( StringBuilder sb ) {
+
+ String eP = getMessage( AutoFeatures.XPrisonNukeTriggerEventPriority );
+ boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( !isEventEnabled ) {
+ return;
+ }
+
+ // Check to see if the class NukeTriggerEvent even exists:
+ try {
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.NukeTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+
+ HandlerList handlers = NukeTriggerEvent.getHandlerList();
+
+// String eP = getMessage( AutoFeatures.blockBreakEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ dumpEventListenersCore( "XPrison NukeTriggerEvent", handlers, bbPriority, sb );
+
+
+//
+// BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+//
+//
+// String title = String.format(
+// "NukeTriggerEvent (%s)",
+// ( bbPriority == null ? "--none--" : bbPriority.name()) );
+//
+// ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay(
+// title,
+// new SpigotHandlerList( NukeTriggerEvent.getHandlerList()) );
+//
+// if ( eventDisplay != null ) {
+// sb.append( eventDisplay.toStringBuilder() );
+// sb.append( "\n" );
+// }
+//
+//
+// if ( bbPriority.isComponentCompound() ) {
+// StringBuilder sbCP = new StringBuilder();
+// for ( BlockBreakPriority bbp : bbPriority.getComponentPriorities() ) {
+// if ( sbCP.length() > 0 ) {
+// sbCP.append( ", " );
+// }
+// sbCP.append( "'" ).append( bbp.name() ).append( "'" );
+// }
+//
+// String msg = String.format( "Note '%s' is a compound of: [%s]",
+// bbPriority.name(),
+// sbCP );
+//
+// sb.append( msg ).append( "\n" );
+// }
+ }
+ catch ( ClassNotFoundException e ) {
+ // XPrison is not loaded... so ignore.
+ }
+ catch ( Exception e ) {
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: XPrison NukeTriggerEvent failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy );
+ }
+}
+
+
+/**
+ *
Since there are multiple blocks associated with this event, pull out the player first and
+ * get the mine, then loop through those blocks to make sure they are within the mine.
+ *
+ *
+ *
The logic in this function is slightly different compared to genericBlockEvent() because this
+ * event contains multiple blocks so it's far more efficient to process the player data once.
+ * So that basically needed a slight refactoring.
+ *
+ *
+ * @param e
+ */
+public void handleXPrisonNukeTriggerEvent( NukeTriggerEvent e, BlockBreakPriority bbPriority ) {
+
+ PrisonMinesBlockBreakEvent pmEvent = null;
+ long start = System.nanoTime();
+
+ // If the event is canceled, it still needs to be processed because of the
+ // MONITOR events:
+ // An event will be "canceled" and "ignored" if the block
+ // BlockUtils.isUnbreakable(), or if the mine is actively resetting.
+ // The event will also be ignored if the block is outside of a mine
+ // or if the targetBlock has been set to ignore all block events which
+ // means the block has already been processed.
+ MinesEventResults eventResults = ignoreMinesBlockBreakEvent( e,
+ e.getPlayer(), e.getOriginBlock(),
+ bbPriority, true );
+
+ if ( eventResults.isIgnoreEvent() ) {
+ return;
+ }
+
+
+ StringBuilder debugInfo = new StringBuilder();
+
+ debugInfo.append( String.format( "### ** handleXPrisonNukeTriggerEvent ** ### " +
+ "(event: NukeTriggerEvent, config: %s, priority: %s, canceled: %s) ",
+ bbPriority.name(),
+ bbPriority.getBukkitEventPriority().name(),
+ (e.isCancelled() ? "TRUE " : "FALSE")
+ ) );
+
+ debugInfo.append( eventResults.getDebugInfo() );
+
+
+ // NOTE that check for auto manager has happened prior to accessing this function.
+
+ // Process all priorities if the event has not been canceled, and
+ // process the MONITOR priority even if the event was canceled:
+ if ( !bbPriority.isMonitor() && !e.isCancelled() ||
+ bbPriority.isMonitor() &&
+ e.getBlocksAffected().size() > 0 ) {
+
+
+
+// Block bukkitBlock = e.getBlocks().get( 0 );
+
+ BlockEventType eventType = BlockEventType.XPrisonNukeTriggerEvent;
+ String triggered = null;
+
+
+ pmEvent = new PrisonMinesBlockBreakEvent(
+ eventResults,
+// bukkitBlock,
+// e.getPlayer(),
+// eventResults.getMine(),
+// bbPriority,
+ eventType, triggered,
+ debugInfo );
+
+
+ // NOTE: Check for the ACCESS priority and if someone does not have access, then return
+ // with a cancel on the event. Both ACCESSBLOCKEVENTS and ACCESSMONITOR will be
+ // converted to just ACCESS at this point, and the other part will run under either
+ // BLOCKEVENTS or MONITOR.
+ // This check has to be performed after creating the pmEvent object since it uses
+ // a lot of the internal variables and objects. There is not much of an impact since
+ // the validateEvent() has not been ran yet.
+ if ( checkIfNoAccess( pmEvent, start ) ) {
+
+ e.setCancelled( true );
+ return;
+ }
+
+
+ for ( int i = 1; i < e.getBlocksAffected().size(); i++ ) {
+ pmEvent.getUnprocessedRawBlocks().add( e.getBlocksAffected().get( i ) );
+ }
+
+
+ if ( !validateEvent( pmEvent ) ) {
+
+ // The event has not passed validation. All logging and Errors have been recorded
+ // so do nothing more. This is to just prevent normal processing from occurring.
+
+ if ( pmEvent.isCancelOriginalEvent() ) {
+
+ e.setCancelled( true );
+ }
+
+ debugInfo.append( "(doAction failed validation) " );
+ }
+
+
+
+ // The validation was successful, but stop processing for the MONITOR priorities.
+ // Note that BLOCKEVENTS processing occurred already within validateEvent():
+ else if ( pmEvent.getBbPriority().isMonitor() ) {
+ // Stop here, and prevent additional processing.
+ // Monitors should never process the event beyond this.
+ }
+
+
+
+ // This is where the processing actually happens:
+ else {
+
+// debugInfo.append( "(normal processing initiating) " );
+
+ // check all external events such as mcMMO and EZBlocks:
+// if ( e instanceof BlockBreakEvent ) {
+// processPMBBExternalEvents( pmEvent, debugInfo, e );
+// }
+//
+
+ EventListenerCancelBy cancelBy = EventListenerCancelBy.none;
+
+ cancelBy = processPMBBEvent( pmEvent );
+
+
+ if ( cancelBy != EventListenerCancelBy.none ) {
+
+ e.setCancelled( true );
+ debugInfo.append( "(event canceled) " );
+ }
+// else if ( cancelBy == EventListenerCancelBy.drops ) {
+// try
+// {
+// e.setDropItems( false );
+// debugInfo.append( "(drop canceled) " );
+// }
+// catch ( NoSuchMethodError e1 )
+// {
+// String message = String.format(
+// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " +
+// "is not valid for this version of Spigot. It's only vaid for spigot v1.12.x and higher. " +
+// "Modify the config settings and set this value to `false`. For now, it is temporarily " +
+// "disabled. [%s]",
+// e1.getMessage() );
+// Output.get().logWarn( message );
+//
+// AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig()
+// .setFeature( AutoFeatures.cancelAllBlockEventBlockDrops, false );
+// }
+//
+// }
+ }
+
+
+ }
+
+ printDebugInfo( pmEvent, start );
+}
+
+ @Override
+ protected int checkBonusXp( Player player, Block block, ItemStack item ) {
+ int bonusXp = 0;
+
+ return bonusXp;
+ }
+}
\ No newline at end of file
From 03ba06eb01e4600b90cf50654c98c65c2b4bee84 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 4 Aug 2023 10:37:21 -0400
Subject: [PATCH 062/151] Prison Placeholders: Added support to disable
placeholders in disabled worlds. This feature is not enabled by default. Any
disabled world in the prisonCommandHandler configs within config.yml, could
also shutdown the prison placeholders in that world if enabled. The
placeholder text will be replaced with just an empty string.
---
docs/changelog_v3.3.x.md | 6 +++
.../placeholders/PlaceholdersStats.java | 23 +++++++++-
.../placeholder/SpigotPlaceholders.java | 42 +++++++++++++++++++
prison-spigot/src/main/resources/config.yml | 1 +
4 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index f46f58547..1471a29a3 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,12 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15c 2023-08-04
+* **Prison Placeholders: Added support to disable placeholders in disabled worlds.**
+This feature is not enabled by default.
+Any disabled world in the prisonCommandHandler configs within config.yml, could also shutdown the prison placeholders in that world if enabled.
+The placeholder text will be replaced with just an empty string.
+
+
* **Prestiges: Bug fix. If no prestige rank, then prevent a NPE on a simple check.**
Totally thought this was fixed a while ago?
diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java
index bee6b1cf0..56ad91a77 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java
@@ -13,7 +13,10 @@ public class PlaceholdersStats {
private static PlaceholdersStats stats;
- TreeMap placeholders;
+ private TreeMap placeholders;
+
+ private int invalidWorldCount = 0;
+
private PlaceholdersStats() {
super();
@@ -154,6 +157,13 @@ public ArrayList generatePlaceholderReport() {
}
+
+ results.add(
+ String.format( "&7Invalid World Usage Total: &3%10s &b(Placeholders replaced with banks)",
+ iFmt.format( getInvalidWorldCount() ) ));
+
+
+
return results;
}
@@ -174,6 +184,7 @@ public void clearCache(boolean resetCache, boolean removeErrors) {
getPlaceholders().remove( key );
}
+ setInvalidWorldCount( 0 );
Output.get().logInfo( "PlaceholderStats: Cache was purged of %s placeholders. Removed: %s ",
resetCache ? "all" :
@@ -190,5 +201,15 @@ public TreeMap getPlaceholders() {
public void setPlaceholders(TreeMap placeholders) {
this.placeholders = placeholders;
}
+
+ public int incrementInvalidWorldCount() {
+ return invalidWorldCount++;
+ }
+ public int getInvalidWorldCount() {
+ return invalidWorldCount;
+ }
+ public void setInvalidWorldCount(int invalidWorldCount) {
+ this.invalidWorldCount = invalidWorldCount;
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/SpigotPlaceholders.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/SpigotPlaceholders.java
index d95853d7b..f6d4cc99c 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/SpigotPlaceholders.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/SpigotPlaceholders.java
@@ -25,6 +25,7 @@
import tech.mcprison.prison.ranks.managers.PlayerManager;
import tech.mcprison.prison.ranks.managers.RankManager;
import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.game.SpigotPlayer;
public class SpigotPlaceholders
implements Placeholders {
@@ -70,6 +71,38 @@ private void initializePlaceholderManagers() {
}
}
+ private boolean ignorePlayerInDisabledWorlds( SpigotPlayer sPlayer ) {
+ boolean results = false;
+
+ String worldName =
+ sPlayer == null ||
+ sPlayer.getLocation() == null ||
+ sPlayer.getLocation().getWorld() == null ?
+ null :
+ sPlayer.getLocation().getWorld().getName();
+
+ if ( worldName != null && sPlayer.isOnline() ) {
+
+ boolean disable = Prison.get().getPlatform().getConfigBooleanFalse(
+ "prisonCommandHandler.disable-player-placeholders-in-excluded-worlds" );
+ if ( disable ) {
+ List excludedWorlds = Prison.get().getPlatform()
+ .getConfigStringArray( "prisonCommandHandler.exclude-worlds" );
+ for (String world : excludedWorlds) {
+ if ( world.trim().equalsIgnoreCase( worldName ) ) {
+ results = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if ( results ) {
+ PlaceholdersStats.getInstance().incrementInvalidWorldCount();
+ }
+
+ return results;
+ }
@Override
public Map getPlaceholderDetailCounts() {
@@ -425,6 +458,11 @@ private String replaceAllPlaceholders(UUID playerUuid, String playerName, String
String replacementText = processPlaceholderIdentifier(identifier);
if ( identifier.isFoundAMatch() ) {
+
+ if ( ignorePlayerInDisabledWorlds( (SpigotPlayer) identifier.getPlayer() )) {
+ replacementText = "";
+ }
+
results = results.replace( placeholderText, replacementText );
}
@@ -481,6 +519,10 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin
String value = processPlaceholderHavePlaceholderKey( identifier );
+ if ( ignorePlayerInDisabledWorlds( (SpigotPlayer) identifier.getPlayer() )) {
+ value = "";
+ }
+
// Note: STATSMINES will not work here since the sequence is not being addressed.
// if ( mm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) ||
diff --git a/prison-spigot/src/main/resources/config.yml b/prison-spigot/src/main/resources/config.yml
index c9d9ede8a..6d1958918 100644
--- a/prison-spigot/src/main/resources/config.yml
+++ b/prison-spigot/src/main/resources/config.yml
@@ -418,6 +418,7 @@ prisonCommandHandler:
exclude-worlds:
- miniGameWorld
- playerPlotWorld
+ disable-player-placeholders-in-excluded-worlds: false
exclude-non-ops:
exclude-related-aliases: true
commands:
From 0a1b619d401d448ac7752720024202a97ba1f023 Mon Sep 17 00:00:00 2001
From: rbluer <665978+rbluer@users.noreply.github.com>
Date: Fri, 4 Aug 2023 10:43:53 -0400
Subject: [PATCH 063/151] AutoFeatures: Added support for XPrison's
enchantments... forgot to add the API jar which is used to just compile
prison (not used on servers).
---
docs/changelog_v3.3.x.md | 3 +++
.../lib/XPrison-api-1.12.13-RELEASE.jar | Bin 0 -> 13166 bytes
2 files changed, 3 insertions(+)
create mode 100644 prison-spigot/lib/XPrison-api-1.12.13-RELEASE.jar
diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index 1471a29a3..e8d8246a1 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.15c 2023-08-04
+* **AutoFeatures: Added support for XPrison's enchantments... forgot to add the API jar which is used to just compile prison (not used on servers).**
+
+
* **Prison Placeholders: Added support to disable placeholders in disabled worlds.**
This feature is not enabled by default.
Any disabled world in the prisonCommandHandler configs within config.yml, could also shutdown the prison placeholders in that world if enabled.
diff --git a/prison-spigot/lib/XPrison-api-1.12.13-RELEASE.jar b/prison-spigot/lib/XPrison-api-1.12.13-RELEASE.jar
new file mode 100644
index 0000000000000000000000000000000000000000..6ae3be4daa734dfecd75a59a7539f41900c1a5e1
GIT binary patch
literal 13166
zcmbtb1yodB*G5WWkd!V-=`JZr>F%yUQMy3^K^OsP>29REQ@XoBkdQ6`k>;QA4S0P&
z{q*}cYt}lmX5DAsd+u|dea_w+1!)*qEGPs71Sp<&Gip#b3>G{#0Xj0lKq*MyMu7YP
z{pYU=KfDI@&udI<4V{4YPi%p}-?|*<-fXMq_hBJG+Rt+D|YwaXYT4D`RA+Ei7^?iszVQjW$)ZbvaVl
zTU*tP0}|LV+(OKF$FtYdO~Z0#Zi|T?85$Z+AtR6p(390}Qo`MBBU^msn|$Bb_m~2~
zpVax5eybIg7~QGCK+8%0?u)1c!TFf#i_hJ#FCD#cp=S3t0>MlIs;eN7f*NHUJ
zV;~P=1N4n#_ce)Oh89?pwKY*cPqoc?ZXEu83{%d0N0yblg`mQoy0fyLcdR^xx-J1D
zGQH*V+`Hbv5Ia*z$#_tr$(#JdYdj=I
z%7t&Y#rl2M|`Cy|TlO-=>3V5=GH4nAB>Ks>2H#!Lq#xm`F#6Kululh
z`v7%CoGVNZ0h8g7kCoTNka-JqSXK1O{=KU(3A+GY9|q;pR(C|{jv*7z0YjlCuTOHw
zTJ#zVCCOu65%F*q*kuRUdD)J-}>15Ithl#8wc+zs_
zu`@NIOdUKsf3YuAvbt)=bm`CWNW8Lbj*-`S{Jp?v-_gbXj@y&n+_^!&`GQuAxS+(7
zT{n^a@dIP|j-bT;%zhr?i_4UQV}4_|iG=o!XII2Y2n_;kmt-r&yRO_{4|T1~iZ(-{
zUz`sJY!7f5&sdJ4ZePGcG%JBm;R8Di6cj%k6j;N4q;qV)vLcm$#y~Si;6E0nmHdbT
zR(n#d$99b+05;q&6%z=P@=_#R)+ERi*_aJ0l07zrwLpUveoF8H*By(<4>u5m)37gs
zCvSyAk=o
z_Mi;kS*r26H=7Jcd7Kcf@NgtO@{=L7;{e38|`J`
z?i{T^AZUROzq?J^UbxsFAHN43D05HCy^TU1pd#Da~=^XsJs_(xxj@I
z3A-;f)DX@I-)OK*D3auhtHgfV%0{wIUUeeBi;>&?^4UI}Wm1cS=57gp#?W~1ds!}0
zS-HT(g}GJf#mDS5)=^r7SwmCHI2>mBB#kXVz^qf!!h0Gc=tbgN%Fx8FaJ>kFFQ8Xo
zd!?ZYSMB1
zlK);Fc*^RNg)zV}T3z9M;LK!GS*JcZH;0Tb&r{o1?#ViVO*hlK%RJpGp0a6+GfOwe
zh95kS!FD@pC4nzz9}dDAPTWQo!dp;Kqu|evS;PKIuj0>laAWp)zgSHOz{A61!t05{
z*N2a?UWBK%?vI8Aq>idw_W3F3
zsl+BEXhJKdp+*>+nxKiQAy`ie)DTl61GsNnU|SjtrY7+7?|?r)o}r)Z7#-}bEX*u_ll_!G
znex8@e|KL?|Er+D-`4@L-^Bi7sS5r1EH_Bwru57TLkNq%C5`W_NUSaLQN%R#n5E3Q
zc$%57IEI%jrRYgT)1X}KR@jGIp9D|d=g4Bpp5MB>zmx!M=^2+jnoFqu8ehNKdwzMa
zg!6Kh+rW8hK_uUJlcbujlxITVi^YOQW+rO-7$#LEM?Dj}z;dR2nXw3o%~>a1y;9sg
zX3($&h4PbmpQpRQAG)JE$@kdO>CaT2p)fLf6T+00SXNXUt}(oNjbk^~ZI*ttjTHCvuqSITtq#G<1v5nao8
zSCh)6dT)v~tOb#*7_$jZ?iWRm2J+K>{7H*TEnLC@2_-0duRUYsYH^&|tTH7%^~Vom
zc4!03rHUWsy5*eFboif5XfS0KgjA(dii9ruYfF*)0zysvb{KbDny`RhU>nFzfLKM{1x|Gojer9Y>cuyO+nH7&
zl?KN}-Jixqh5wnovXG^%VrBu9wK6d?b-6)gALVU1OfZp0A}hkBiq*u@A7&eA2Vi1e
z-Ietv8Op>;jaVD7aC+$pte8s3KT44irKE^Gh7t(>-0!HIjtG2P?{qY0*T2PIdbYYd
zFb|cO+&)+&mNb+2MRE;B9^tZjRdQZ+7OCtxeZ*eX*jt@LpJ9P{n>^1w&g^oamW2y_
zg^u!z!DroNoC?j)o`#{dx
zp5lu&@}=vfxs?6{Vy@(3eORnvwb>fq;P8U3x&zDr+p!}ovjOiOJ%esr6F#5|Me@sI
zfIJ;eg`(Dm(DI`Tq#<#Ks1#?<#`?VHvrS#4fvL=
zhQTY8wj!l$Ibz;76iOhsIK!2AS@#H$#gsv!fw1n?NTq^1kB(e=#`2qNHbmr}FKhc%
z)OPc1Btxtp^rh;z_`j7}^X=XDP6X=b04wvx+QMKSKuTyp4Yf*FkiOofjk$
zQELSQ>^}_Lkk(f+J9q*6VCl2v^TAr*&N@4oLOMOkM;}=!vvio|`R3r}C+53#RSuVV!8LWBFj_u;lshrBw>Q!|0{p376cZvJ^vl6W$kb
z3_2+!S7Xg9P^=T_JVxkZ6e?H}D$`5WN#R9Ndw48*$44hkF@QbusbB~RPE49c>o5X7
zfe^BOdotXxer7gkkX5LU;{Z9AWWaitcSXJ(p%g1O+&KF5HY7xcawXms0TbBzrvw)G
zRRaGRr6I!mjk-b#l7DWM`dH+lh0x$Wa=j!pFg7w4K}8u+2vHac(MkQBitTOb*~MbL
z6$V88RH(TJbFSFVk7OYey+Wx!*Ym>7Bk>l%MjAJNxs%Rnjxw(v!DFkQI3B1BU#U!&
z*r(?bscVn%IlEahl8UtXLpvb~PW#Gv-DD>##XC&m%WTvfss%mN^`u6Lf_{ve`bVpF
zdf_wq@Yn?G@!WL1lIK-|!B)12jcHsTx*{Z{*6M18nSePy?1&uf3cC41PsnZ=RSX7U
z#6>Kve4DWO`%W*~z|(Q}r+XUV|Hp($T3DO^F=+{5y3)`>SfF{uXU}Ga8yXvH6<&ev
zrw)1{K);uwrKlmWo6I~Csrb-+H7ctBuX_k{syH--0V71gw9?zpyXrD96?1a#dIeSF
zcNb)?Id@P(O`PtrE!jmvmsn#*#0WiK9zo8}Nb9eUG+}c_F{cQFKX}5l=gM!EVO4iSFUoaBspQ!2;iE