From e7006593c3415591a4f7cf3e26dde786393a7d28 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:39:45 -0500 Subject: [PATCH 001/297] Set version to 3.3.0-alpha.7 which picks up from where the prior v3.3.0-alpha releases left off. --- docs/changelog_v3.3.x.md | 27 ++++++++++++++++++++++++++- docs/prison_changelog_v3.2.11.md | 14 ++++++-------- gradle.properties | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index aae7a5a96..ad2ad5e10 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,32 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.2.11 2022-01-22 +# 3.3.0-alpha.7 2022-01-22 + + + + + + + +* **3.3.0-alpha.7 2022-01-22** + +A return to the v3.3.0 release track. The alpha.7 release represents a continuation of where we left off before. Once we got to alpha.6, it became apparent that it was critical to release before v3.3.0 was ready, so we returned to the v3.2.x track, including everything up to and including the v3.3.0-alpha.6. + + + + + + + + + + + + + + + **3.2.11 2022-01-22** diff --git a/docs/prison_changelog_v3.2.11.md b/docs/prison_changelog_v3.2.11.md index ee3fa9319..49d7188c0 100644 --- a/docs/prison_changelog_v3.2.11.md +++ b/docs/prison_changelog_v3.2.11.md @@ -13,15 +13,13 @@ These build logs represent the work that has been going on within prison. # 3.2.11 2022-01-22 -* Prison now supports 258 Placeholders, including aliases. - - - - - Prison supports: - Java 1.8 through Java 17. - Spigot 1.8 through 1.18, and other platforms based upon Spigot. -* Many updates and bug fixes. Please see the change log for all of them. Below is just a limited sumary of some of the more important updates. +* Many updates and bug fixes. Please see the change log for all of them. Below is just a limited summary of some of the more important updates. * Asynchronous mine reset enablement @@ -30,16 +28,16 @@ Prison supports: * Prison can now be disabled completely on a per world basis. See setting in config.yml. -* If the server is missing an economy plugin, prison now does a better job at communicting what the problem is so it can be fixed quickly. An economy plugin is required for the ranks module to function. +* If the server is missing an economy plugin, prison now does a better job at communicating what the problem is so it can be fixed quickly. An economy plugin is required for the ranks module to function. -* Added a debug mode for inspecting a block. To enable, enabl prison debug with `/prison debug` then while holding a prison wand `/mines wand` click a block and it will show a couple of lines tied to the information that prison has recorded for that block. If you shift-right click a block, then prison will check each event listener to see what it does with the block. It will report when a block event is canceled and other details, on a per listener basis. +* Added a debug mode for inspecting a block. To enable, enable prison debug with `/prison debug` then while holding a prison wand `/mines wand` click a block and it will show a couple of lines tied to the information that prison has recorded for that block. If you shift-right click a block, then prison will check each event listener to see what it does with the block. It will report when a block event is canceled and other details, on a per listener basis. * Start to add tokens to prison. Players can now earn tokens while mining. Its a work in progress, but they cannot spend them yet. -* Updated block constraints so blocks can be spawned in spedific layers within a mine, and with a minimum or maximum amouts. +* Updated block constraints so blocks can be spawned in specific layers within a mine, and with a minimum or maximum amounts. * Placeholders - Prison now has 258 placeholders, including aliases. Added many placeholders and improve a few that were having some issues. There are still more that are planned to be added. @@ -48,13 +46,13 @@ Prison supports: * Added new Prison Mine Bombs - Work in progress - Basics exist and have a lot of functionality, but more work will be done to add new features and address issues when found and reported. If you have ideas, or need something specific, please visit our discord server and talk to Blue. -* Coming Soon: Mine Region. Mine effects that are applied to Mine Regions. Mine Effects will include potion effects like night vision, and other effects such as no hunger, no fall damage, and fly. Also may be adding enhantments soon too. +* Coming Soon: Mine Region. Mine effects that are applied to Mine Regions. Mine Effects will include potion effects like night vision, and other effects such as no hunger, no fall damage, and fly. Also may be adding enchantments soon too. * Significant improvements for handling multi-block explosions with a major rewrite to improve the overall performance within the handling of block break events within the auto features. Many changes to improve performance on a per-block basis, and to prevent a block from being counted more than once when many different players are trying to break, or explode the same blocks. -* Signficant updates to most Prison GUIs and sellall +* Significant updates to most Prison GUIs and sellall **NOTE:** It is currently recommended that the old Prison Backpacks should not be used at this time. They will be rewritten shortly to address the current issues. diff --git a/gradle.properties b/gradle.properties index a51d4fbdb..63996a0da 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.2.11 +version=3.3.0-alpha.7 #version=3.2.8.2 #version=3.3.0-alpha.6 From 453329d5f7bf1b78c48231ca30e848918b1c7d11 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 24 Jan 2022 14:51:49 -0500 Subject: [PATCH 002/297] First pass at removing the old block model. Do not use this release!! This compiles and runs on the server. Most commands appear to work, including mine resets, but no visual confirmation has been performed in game yet. Since so much has been changed and it has not yet been tested in-game, this release should not be used until such rudementary testing can be performed. --- docs/changelog_v3.3.x.md | 1008 +---------------- .../prison/commands/CommandHandler.java | 4 +- .../handlers/BlockArgumentHandler.java | 84 +- .../java/tech/mcprison/prison/gui/Button.java | 11 +- .../mcprison/prison/gui/ClickedButton.java | 8 +- .../mcprison/prison/internal/ItemStack.java | 19 +- .../mcprison/prison/internal/block/Block.java | 39 +- .../prison/internal/block/BlockState.java | 2 +- .../mcprison/prison/internal/block/Door.java | 17 +- .../prison/internal/block/PrisonBlock.java | 135 ++- .../internal/block/PrisonBlockTypes.java | 3 +- .../events/block/BlockBreakEvent.java | 17 +- .../events/block/BlockPlaceEvent.java | 13 +- .../events/inventory/FurnaceExtractEvent.java | 21 +- .../internal/inventory/FurnaceRecipe.java | 4 +- .../prison/internal/inventory/Inventory.java | 16 +- .../internal/inventory/ShapedRecipe.java | 8 +- .../internal/inventory/ShapelessRecipe.java | 14 +- .../prison/selection/SelectionManager.java | 6 +- ...{BlockType.java => ObsoleteBlockType.java} | 62 +- .../prison/selection/SelectionTest.java | 19 +- .../prison/mines/MinesConversionAgent.java | 212 ++-- .../mines/commands/MinesBlockCommands.java | 558 ++++----- .../prison/mines/commands/MinesCommands.java | 19 +- .../mcprison/prison/mines/data/BlockOld.java | 22 +- .../tech/mcprison/prison/mines/data/Mine.java | 45 +- .../mcprison/prison/mines/data/MineData.java | 158 +-- .../mcprison/prison/mines/data/MineReset.java | 238 ++-- .../mines/features/MineLinerBuilder.java | 88 +- .../prison/spigot/SpigotListener.java | 10 +- .../prison/spigot/SpigotPlatform.java | 127 ++- .../mcprison/prison/spigot/SpigotUtil.java | 196 ++-- .../prison/spigot/api/PrisonSpigotAPI.java | 56 +- .../autofeatures/AutoManagerFeatures.java | 8 +- .../prison/spigot/block/SpigotBlock.java | 261 +++-- .../prison/spigot/block/SpigotBlockState.java | 10 +- .../prison/spigot/block/SpigotItemStack.java | 40 +- .../spigot/compat/CompatibilityBlocks.java | 9 +- .../spigot/compat/CompatibilityCache.java | 106 +- .../prison/spigot/compat/Spigot113Blocks.java | 179 ++- .../prison/spigot/compat/Spigot18Blocks.java | 433 ++++--- .../prison/spigot/game/SpigotPlayer.java | 2 +- .../spigot/inventory/SpigotFurnaceRecipe.java | 28 +- .../spigot/inventory/SpigotInventory.java | 118 +- .../spigot/inventory/SpigotShapedRecipe.java | 30 +- .../inventory/SpigotShapelessRecipe.java | 79 +- .../prison/spigot/SpigotPlatformTest.java | 11 +- 47 files changed, 1991 insertions(+), 2562 deletions(-) rename prison-core/src/main/java/tech/mcprison/prison/util/{BlockType.java => ObsoleteBlockType.java} (96%) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ad2ad5e10..fd0c274cf 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,9 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.7 2022-01-22 +# 3.3.0-alpha.7 2022-01-24 +* **First pass at removing the old block model. Do not use this release!!** +This compiles and runs on the server. Most commands appear to work, including mine resets, but no visual confirmation has been performed in game yet. Since so much has been changed and it has not yet been tested in-game, this release should not be used until such rudementary testing can be performed. @@ -34,1014 +36,14 @@ A return to the v3.3.0 release track. The alpha.7 release represents a continua - - - - - - -**3.2.11 2022-01-22** - - -* **Added to SpigotPlayer the ability to enable flying and to check to see if the player is flying. This is to prepare for mine effects.** - - -* **Considering adding heads support to prison. Added a few parts, but they are not functional.** - - -* **3.2.11-alpha.17 2022-01-18** - - -* **More updates to the player's rank menu with the ability to add rank specific lore to the configs.** -When referring to ranks, the names much match exactly since they are case sensitive. - - -* **Bug fix with the rank cost calculations since they were not pulling in the last rank in the rang of ranks.** - - -* **Fixed an issue with CI's function that was not returning any ids.** - - -* **Mine auto resets can now be disabled.** -When disabled, they will never reset based upon time. The resets can still be triggered by blocks remaining thresholds. - - -* **3.2.11-alpha.16 2022-01-16** - - -* **Lot of updates to the GUI menus.** -Major improvements to the player's /gui ranks to work better with placeholders. Added comments to the GuiConfig.yml file on how to use it and the placeholders. -Delete the GuiConfig.yml file to regenerate with the updated information on lore settings. - - -* **Update a few of the player's GUIs to support the SpigotGUIMenutools.** -Added capability to control the return command and the paging command so it now works more intuitivily. - - -* **Fix issue with the placeholders related to prison_rankup_cost.** -This now works correctly to include the next prestig rank's cost when at the last rank in the default ladder. - - -* **Bug fix: Get the 32 placeholders related to prison_rankup_cost working correctly when dealing with various prestige conditions.** - - - -* **Bug fix: The player based playSound was not working, but the world's playSound works perfectly. Not sue why bukkit player would be messed up that ** - - -* **Bug fix: Hooking up the rollover to the next prestige rank cost, when at th end of the ladder, had a typo where it would not evaluate any rank.** - - -**3.2.11-alpha.15 2022-01-13** - - -* **Bug Fix: If the wrong sound file was being used it used to throw a NPE.** -Now this is a safer way to find the correct file, and it will fall back upon a plink sound for any version of spigot. - - -* **If upon loading a mine, there is a reson or need to resave the data, since this is an auto update, then this will make a backup copy of the mine's save file before saving it.** - - -* **Bug fix: If spigot version is less than 1.13.0, and trying to use a _WOOD block, XMaterials cannot map that correctly to a Material and then back to the same XMaterial.** -This is causing a problem when using in a mine since it cannot be tied back to the block that was placed. So for these versions, all _WOOD blocks are removed from the server. If a _WOOD block is saved in a mine, it will be remapped to the same _PLANKS block, which will work just fine. - - -* **Bug fix: Prevent stack traces when a broken block cannot be mapped to a PrisonBlockStatusData object.** -This is happening with spigot versions 1.8 through 1.12.2 when using "WOOD" blocks since XSeries translates these blocks to LOGs, so they will never map back to the XMaterial WOOD entries. This was producing a stacktrace and would prevent the proper handling of the auto features. - - -* **3.2.11-alpha.14 2022-01-11** - - -* **Update the failed rank message so it is clearer.** - - - -* **When a player is on the default ladder at the last possible rank, instead of showing nothing for rankup costs, percent, bar, etc, it will now use the next prestige rank if prestiges are enabled.** - - These changes apply to the following placeholders: - - prison_rc prison_rankup_cost prison_rc_laddername prison_rankup_cost_laddername - prison_rcf prison_rankup_cost_formatted prison_rcf_laddername prison_rankup_cost_formatted_laddername - prison_rcp prison_rankup_cost_percent prison_rcp_laddername prison_rankup_cost_percent_laddername - prison_rcb prison_rankup_cost_bar prison_rcb_laddername prison_rankup_cost_bar_laddername - prison_rcr prison_rankup_cost_remaining prison_rcr_laddername prison_rankup_cost_remaining_laddername - prison_rcrf prison_rankup_cost_remaining_formatted prison_rcrf_laddername prison_rankup_cost_remaining_formatted_laddername - prison_rcrp prison_rankup_cost_remaining_percent prison_rcrp_laddername prison_rankup_cost_remaining_percent_laddername - prison_rcrb prison_rankup_cost_remaining_bar prison_rcrb_laddername prison_rankup_cost_remaining_bar_laddername - - - -* **On delayed startup, allow a combination of selectors to target essentials, since the class name has changed in v2.19.x** - - -* **Setup the block inspector to auto select a diamond shovel, a diamond axe, or a diamond pickaxe.** - - -* **On the blockbreak debug information, show the information on either the block that was hit, or if that is null, just dashes to show such a block was not provided.** - - -* **For EssentialsX v2.19.x, the class being used to identify if the economy has been loaded has changed.** -This commit has the references to the proper class to use depeending upon the version of EssentialsX. It should be noted that this only applies if delayed startup is enabled for the EssentialsX economy, which generally does not require it. - - -* **Change in how prison deals with ranks when there isn't an economy plugin loaded.** -Now, instead of printing a simple little message in the console, which everyone appear to miss, it also enables a generic `/ranks` command that only displays a message indicating that no economy was found, with links to documentation. This should make it more obvious. - - -* **Change to auto features for the event listeners: now MONITOR is not enabled unless set to priority of MONITOR.** - - -* **If a language file has a message that is set to an empty string or a space, it will now no longer generate an empty message.** -Instead it will supress the sending of any message that is blank. - - -* **Move the placeholder `prison_player_blocks_total` from being a player mine placeholder, to a player placeholder since it is not tied to a specific mine.** -Added a formatted version (with commas) and this one became unformatted so it can be used within scripts if needed. - - -* **The use of the `/ranks command remove` within the `/ranks info`, or `/ranks command list` was not correctly including the correct row number**; it was using one higher than what it should have due to prior incrementing. - - -* **Issues with SellAll when dealing with varient block types when bukkit version is less than 1.13.** -Eliminate usage of org.bukkit.Material where possible. XMaterial must generate the ItemStack directly, instead of creating a Material object. - - -* **Fix some issues with canceling drops:** -Will not work on 1.8.x and maybe a few other versions of spigot with no work arounds. Works on newer versions. - - -**New Feature: Dump the BlockBreakEvent and monitor changes per listener.** -This provides a great deal of information on what is modifying the blocks. -To use, enter prison debug mode with `/prison debug` and then shift-click on a block using the prison wand (`/mines wand`). - - - -* **Bug Fix: When loading the mines, and if using the old block model, some blocks were not mapping to the new PrisonBlocks.** -When this now happens, the loader now tries to use the old block model's getXMaterialName() function, which returns one or more names that can map to XMaterial objects. It tries all of them until it is able to get a non-null PrisonBlock result. - - -* **Added a safty backup of the player's cache file... if it is detected that the new size is smaller than the prior size, then make a backup copy saving the original version instead of deleting it.** -This implies that stats will always be added to the player's cache and that the file should alwaysbe getting larger. This only makes sense when recording stats. The file could become smaller when balances are reset, such as spending a lot of tokens. -This also implies that some times, such as player inventories, should not be stored in this object... player's backpacks will be removed in the near future. -It should be mentioned that on a test server I saw my player stats for my test player being wipped out. I have no idea if it was because of file system commands that I ran, or if it was a bug in prison that reset it. But because there was a potential loss, I'm making sure certain things cannot happen anymore, or trying to reduce the risk of losses. - - - -* **Fix the sellall block list gui for when there is an invalid XMaterial name**, that it will print out the error to the console, and continue with using COBBLESTONE instead of producing a NPE. - - - -* **For the list of displaying the ranks on a ladder, split them up to show 15 per line which will help when there are a lot of ranks on a given ladder.** - - -* **Increased the confirmation on mine size from 25,000 to 50,000 blocks so as to minimize the number of times this will occur.** - - -* **Add support for specifying the sound to use for inventory full event.** -Valid sounds can be listed with the command /prison utils sounds list. - - -* **Added support for doubles in the AutoFeatures settings.** -The basics were there, but the actual AutoFeatures enum did not have them hooked up. - - -* **Remove an unused function on the PlayerCache.** - - -* **Bug fix for mohist, or other platforms that are trying to use SuperPerms, or other perm plugins that do not support groups.** - - -* **Add *all* to the command /mines set tpAccessByRank.** - - -* **Add '*all*' as an option for applying Access by Rank for mines command: /mines set mineAccessByRank.** - - -* **3.2.11-alpha.13** 2021-12-24 - - -* **Prison command handler: adds the ability to add new aliases from the config file.** - - -* **For ranks that are null, made some changes so either empty strings are used instad, or most of the time the rank name is used.** - - -* **Fixed a potential issue with nulls in the language file parameters. All nulls are replaced with empty strings.** - - -* **Added the ability for admins to add aliases to commands so they can better customize their environment.** - - -* **Disable block break events in the worlds where prison commands are disabled.** - - -* **Added the ability to disable prison command hander is specific worlds.** -The settings are within config.yml. The disabling of prison is only done on the command handler, and will soon be hooked up to the block break events too. -The command /prison now lists worlds in which prison has been disabled - - - -**3.2.11-alpha.12** 2021-12-21 -Alpha 12 released. - - -* **Fixed issue with XMaterial when trying to parse a custom blcok that is not compatible with prison.** -The function will now return a null value and everything that uses it, must ensure it's not null before trying to use it. - - -* **Make sure the targetBlock is not null before trying to process it.** - - -* **Docs: Updated the LuckPerms Tracks and Groups document to provide more details on how to set them up.** - - -* **Bug fix: Ran in to a rare situation where the use of essentialsX economy failed to allow prison to load the players during startup.** -Prison was trying to "rank" the players within each rank that they were in, and that required prison to get their balance.... but bukkit was not able to return an OfflinePlayer instance for any of the plyers. Therefore prison could not access the player through vault. No idea why bukkit is not able to provide the players. The server in question had about 2500 players. -So to prevent this from happening, the initial ranking bypasses the loading of any monetary amounts; they will be updated later. - - -* **Update and create some new LuckPerms docs.** - - -* **Move gui tools menu changes to improve them and hook them up to menus that did not have any paging.** - - -* **Adjustments to improve the way the new gui tools work to reduce the amount of use of lore, or at least the visible lore.** -This visually cleans it up a lot. - - -* **Hooked up some of the new features to the /gui ranks menu, plus added a /gui ladders and hooked that up. Simplified how the ladders page was setup.** - - -* **More work on the GUI menu tools to not only get them to work better (correctly) but also add new capabilities... now supports adding a menu option and the tool auto assigns it to the next available slot.** - - -* **GUI menu tools update...** - - -* **Prison Tokens: Remove the alias so they will not cause conflict with other token plugins.** - - -* **Potential bug fix: There was a situation where with multiverse-core a delayed world loading resulted in the world not being found**, and therefore it was preventing the loading of all locations tied to the mine. This now allows the locations to be loaded without a valid world. Then when the world is finally loaded, it will refresh the references to the world objects. - - -* **GUI Menu: a few minor changes before more radical changes to go with the final "idea".** - - -* **GUI Menu Tools - Added a first page and last page button.** - - -* **GUI Bug fix: If there are more than 45 ranks on a ladder, the GUI will NOW be able to provide paging capabilities to view all ranks.** -By default it will start off with page one, but this can handle an unlimited number of pages. -This paging system can be expanded and easily used on other GUI lists with minimal changes to hook it up. - - -* **Found a bug in XMaterial where it was converting "melon" to melon_slice instead of the melon block.** - - -* **Bug fix: Fixed an incorrect use of XMaterial which prevented it from working properly with spigot 1.8 through 1.12.** -It was using XMaterial to get the Material value, which is wrong, since it's the item stack that contains the variants of the materials. So the change is to extract the item stack directly from XMaterial which solves the problem. -Also there was another error where if amounts are greater than 64, setting them to 1 so the GUI will still work, but it will suppress the incorrect counts for the itemstack. - - -* **Update XSeries to v8.5.0.1 to better support spigot 1.18.** - - -**Prison tokens: Add a few more prison tokens placeholders.** -Fixed the admin token commands to use longs and not integers. - - -* **Ranks GUI Error.** ~~Fixed an error with Ranks GUI.~~ This did not fix anything. - - -* **Some adjustments to admin token functions.** - - -* **Bug fix: Rankup on a ladder in which there is not already a rank was producing an error.** -Similar to prior problem... just did not fix it correctly for all situations. - - -* **Start building the structure for the Top N rankings.** - - -* **Mine Bombs: Noticed the player inventory was not be "updated" through bukkit.** -This could help prevent wrong item amounts. - - -* **Mine Bombs: Set them up to auto refresh the data structure that is being saved, if it is detected that there has been a change.** -Added a version number to the mine bomb save data structure so as to use that to detect when the structure changes. That number will be updated in code when it has been modified. So when running the mine bomb loader, it will detect that the saved data is in an older format, and so it will rename the old file to preserve it as a backup, then write the new data to the file system. This will allow new fields to be added,and then they will appear in the save file upon the next restart. This will make it easier for admins to update and use the new features. - - -* **Bug fix: Was causing a null pointer exception when trying to add a player to a new ladder.** -This now correctly gives the player the requested rank, or if not specified, then the lowest rank on that ladder. - - -* **3.2.11-alpha.11 2021-12-07** - - -* **Mine Bombs: A few other minor fixes and changes.** - - -* **Mine Bombs: Some changes in how they are setup. Added a bombItemId which becomes line one of the lore and is used to identify that it's a mine bomb.** -Added a nameTag that is used to put a nameTag on the armor stand. Added a itemRemovalDelayTicks field to better control when the armor stand is removed (exact time). -Update a lot of Mine Bomb code for creating the time, placing the item (armor stand) etc... It's working better overall. - - -* **Update Tokens to fix an issue with the admin set.** -Added better tracking of adminAdded and adminRemoved stats. - - -* **Bug fix: Fixed a class not found except caused by google guava trying to load functions that it should not have been using for their event manager.** -Moved the PEE event out of this class all together, so now it's safe to use in other areas of prison, such as with guava's event handler. This was not an issue with spigot 1.8.8, but manifested itself with Spigot 1.16.5 since I believe that version of spigot is using a newer version of guava that has that behavior. - - -* **Upgrade XSeries to v8.5.0** - - -* **3.2.11-alpha.10 2021-12-05** - - -* **Bug fix: There was an issue that I found where blocks outside of the explosion events were being marked as mined without actually being broken.** -Therefore prison would not be able to break those blocks. This was caused by the initial explosion setting off a chained reaction explosion through a blockEvent. Now blocks that are part of an explosion cannot be part of a future explosion. - - -* **Added a new debug mode to inspect blocks by click on them with the mine wand tool when prison is in debug mode.** - - -* **Renamed Prison's PlayerListener to PrisonPlayerListener to reduce a conflict and to make it more obvious which object is which.** - - -* **For the bukkit 1.8 through bukkit 1.12, if an object has a different data value than what it normally has**, -it would not be matched through XMaterials... Examples are leaves, chests, etc... if there is no match initially using the block then try to then match on just the name, which eliminates the problem of a failed match. - - -* **Add a selective debug option where only the selected element is loged through the debugger.** - - -* **Removed the DebugTarget value of "support" since it is not using anymore.** - - -* **Bug fix: If a block has been placed in the mine that should not be there, prison was canceling the event which was preventing other plugins, or normal breakage, from breaking the block.** -The event is no longer being canceled. - - -* **Added 12 new placeholders: 4 new ones for player balances and 8 new ones for tokens.** - - -* **Prison tokens: Added admin functions of balance, add, remove, and set.** - - -* **Added the title and actionBar to the Player object so it will work in all forms of Player, such as RankPlayer.** -Had to use the Platform to cross over to spigot from core. - - -* **Added access to the player cache within the Player object so it's easier to use it.** - - -* **Updates some documents.** - - -* **Bug fix: One of the blockEvent placeholders was inserting the wrong value.** -{blocksMinedTotal} was inserted the blockName. - - -* **Slight adjustment to the mine backups's file name.** - - -* **Move the messages for /mines tp to the language files.** - - -* **3.2.11-alpha.9 2021-12-02** -Version v3.2.11-alpha.9 - - -* **Added a new feature to back up a mine and to provide a way to convert a mine to a virtual mine.** -When converting to a virtual, with the command '/mines set area virtual', a back up is made first. -The new backup command is '/mines back help'. - - -* **added mine name to reset notifications** - - -* **Bug fix: If a MONITOR event listener, then it should not process the block break event.** -Monitors were processing the block break events when they shouldn't so monitors are not terminated after validation since their "processing" is handled there. - - -* **Bug fix: The command '/mines reset *all* details' was not working and was only running one mine reset instead of all mines.** - - -* **Rank data refactoring. A few changes to get this working. The ladderRanks collection was not being setup was the main issue.** - - -* **Rank data refactoring. A few changes to get this to work well.** - - -* **Major refactoring of Rank Player data objects.** -This is to transition to easier use of player objects in prison. Some of the key classes have been moved from Ranks module to Core module, with the removal of rank functions being moved back to the ranks module. -This is a work in progress and does not yet work. The player's ladders and ranks have not been linked together yet. - - -* **Fixed the auto sell command within the auto features to include the ability to use autosell based upon the auto features settings.** - - -* **Fixed issue with a block break event happening outside of a mine, which will result in mine being null.** - - - -* **Fixed issue with getMine not striping color codes, but in the function before this one is called, it strips them to check to see if the mine name is valid.** - - - - -**3.2.11-alpha.8 2021-11-28** -Release v3.2.11-alpha.8. - - - -* **Update the last seen time.** -But will not set dirty. If player is not active, then it will not be recorded. - - -* **Expand the last seen information on the command /ranks player, which now includes how long ago instead of just a date and time.** - - -* **Add a listSeenDate to the player's cache data.** -This will be used to track when the player was last on, and more importantly, determine if the player's cache data should be updated for stats reporting for top-n functions. - - -* **Fix a rare condition where the wrapper of the PrisonBlock is null (the actual bukkit block).** -This may not fix everything related to this issue, but it will prevent a NPE at this location. - - -* **Minor changes to clean up auto features a bit:** move functions that are no longer used in the normal block break code to OnBlockBreakPlayerManualCore so it's not confused with the main-core functions and accidentally used. -Also clean up the messaging and sellall usage to eliminate duplication. - - -* **Fixed an issue with the mine state mutex being null.** -Not sure what's causing it, but I suspect it mabe an issue with loading the mine from a saved state on server startup and that field never gets initialized. So fixed it by doing a lazy initialization on the field. - - -* **Fixes a minor issue with the command '/mines set spawn' where it was requiring an option be specified.** -I fixed it by setting a default value of "set" which does nothing, but makes the optional options, optional now. - - -* **Removed from the GUI the hologram on inventory full, and replaced it with actionBar.** - - -* **Some adjustments to the overflow of the drops and other inventory controls.** -On normal drops, disconnected autosell except if it is forced through the pmEvent. -Fix inventory full sounds. For 1.13 and up it had the wrong sound file. Using something less harsh than anvil and turned down the volume which was horribly excessive with the volume set to 10, when normal is 1. - - -* **Prison Tokens: Prison now is able to auto generate player tokens based upon blocks mined.** -It's enabled through AutoFeatures config file's setting 'tokensEnabled' and is able to set the blocks per token earnings rate with 'tokensBlocksPerToken'. -More features will be added soon, such admin functions and top-n token holders.... etc... - - - -* **3.2.11-alpha.7 2021-11-26** -Released alpha.7. Major advancements to mine bombs. - - -* **Mine Bombs: Added the use of a armor stand for holding the item, with an animation of swirling it around.** -The item's armor stand is managed in a task which removes itself when finished. This process is independent from the visual and sound effects. -Removed the static functions that were being used (which is much better). - - -* **Mine Bombs: Added more effects to the examples.** -Removed some that would not work. These are not perfectly selected and may not work for most versions of spigot. The visual effect do not appear to really do much. - - -* **Mine Bombs: Setup some changes in how classes are related to each other so as to prepare for significant changes.** - - -* **Mine Bombs: Got the sounds and visual effects hooked up to the explosions.** -Made many revisions on how all of this works, but pushed the tasks to a new class PrisonUtilsMinBombsTask. - - -* **Mine Bombs: Updated the listings of the mine bombs, which now includes full detail including the visual and sound effects, the list of shapes, list of sounds, and list of visual effects that can be used.** - - -* **Mine Bombs: Updated the junit test for validating that the EffectState is sorted in the proper order when using the MineBombEffectsData as a comparator.** - - -* **Mine Bombs: Setup a test unit test to confirm that the sorting of the EffectStates is as expected.** -Needs to be: placed, explode, finished. - - -* **Mine Bombs: Add the sound effects and visual effects to the default test bombs.** -NOTE: Some of these settings may not work on all versions of spigot, and some may not work on any version. - - -* **Bug fix: Auto features get drops not always working with explosions.** -The get drops was moved around to help ensure it does not try to get the block drops if the block is not what it is expected. This is now passing the needed object used for the check, instead of extracting it from the target blocks, which have not yet been set. - - -* **Bug fix: Auto Features Auto Pickup is now ignored if sellall has not been setup on the server.** -If getting an instance of SellAll when it is disabled, will result in a null value. - - -* **Mine Bombs: Added a few new shapes.** -Disk and Ring. Available in each plane x, y, and z. - - -* **Mine Bombs: Added the collections for sound effects and visual effects.** -Both share the same object, MineBombEffectsData. -An effect has a name, plus an EffectState, and an offset in ticks that will apply that effect based upon the EffectState. -The EffectState can be placed, explode, or finished. - - -* **Ran in to another Java format exception.** -Not sure what caused this problem, but added it to the catch so it can be reported in details so it can be fixed. - - -* **Add the ability to remove a mine's spawn point.** - - -* **Reworked how the drops were processed to prevent dropping the wrong contents.** -There was an issue where the drops were retrieved later in the process that allowed it to incorrectly pickup drops that were related to a decay function. This resolves the incorrect drops. - - -* **Player cache timing improvements.** This fixes issues with tracking the timing when mining. -Not 100% sure it is perfect, but it's actually working much better. Will need to revisit later. - - -* **Added a check to detect that a block has been altered and is not the block that was placed there by the mine reset.** -There have been drops of other materials making it in to an explosion event, and mostly due to block changes that happen due to other means. - - -* **Refactored some of the checks to determin if the event should be processed or not, so this can be used with a new feature that may help to auto manage access when WorldGuard is being used.** - - -* **Setup a mutex for locking the mine resets, which prevents active block break attempts, including explosions, from trying to break blocks while a mine is actively being reset.** -This helps to reduce the chance of hitting a concurrent modification exception. - - -* **Shut down auto manager and all auto features if the setting 'autoManager.isAutoManagerEnabled' is set to 'false' in autoFeaturesConfig.yml.** -If anyone wants to use prison's block events, then they must use the auto manager. - - -* **When using autosell through auto features, if a block cannot be sold, then the block is now placed in the player's inventory, or dropped if their inventory is full.** -If a block is unable to be sold, the amount returned for the item stack will be zero. - - -* **Bug Fix: There was originally a problem with applying block constraints that resulted in being unable to select a block when trying to randomly choose one.** -Initially as a first quick fix was to trying to reselect a block, but if the block chances were really low, then it could still fail to select a block. Then it was attempted to select a default block, but that too failed to work, especially if there were a sizable chance for AIR, and it would fail 100% of the time if the was only one block with a very low chance. The failure was the whole mine could be filled with that one block with the very small chance. -This fix completely redesigns the block selection, by first selecting only the blocks that are valid for that level of the mine. That way, when selecting blocks where blocks should be excluded from that level, those excluded blocks are never in the selected blocks to be considered. Also if AIR is a valid option, then this new process adds an AIR block to the temporary level block list with the percent chance assigned to the air. -Overall, this is working really well now, and it actually simplifies a lot of code and reduces the amount of processing involved. This new process always selects a block on the first pass too so it never haves to try to reselect a block. - - -* **Moved the multi-column formatting of data to the class Text so it can be used in other parts of the project.** -It was originally created for use in /ranks player but is now extended to be usd to list the plugins within the /prison version command. - - -* **Bug fix: If player is mining outside of a mine, then don't process anything.** -May want to allow prison to manage block breaks outside of mines in the future, but for now, prison is only managing mines. - - -* **3.2.11-alpha.6 2021-11-21** - - -* **New feature which lists all of the Player Cache stats in the command `/ranks player`. This includes stats for block breaks, time spent in mines, and earnings per mine.** - - -* **Capture an error within prison's Output class when trying to log content that has an UnknownFormatConversionException error.** -This happens when there is a problem with text formatting characters that conflict with Java's formating class. This tries to log the error with better details so it can be fixed and resolved where the error is happening. This does not "fix" the problem, but just better reports it so it can be identified and fixed. - - -* **Update on how prison manages the tracking of block breaks and earnings when auto features has autosell enabled.** - - -* **Changes to how the event listeners are setup: reduced by 1/3rd.** -Used to be that all three would be set if autopickup was enabled, but now only two will be set... monitor, and then either autopickup or manual drops. -This should improve performance since prison will be processing 1/3 less events. - - -* **3.2.11-alpha.5 2021-11-19** - -Post the alpha.5 release. - - -* **Remove the now obsolete auto features setting isAutoSellPerBlockBreaknliedEnabled.** -It is no longer needed since the auto features autosell per block break is now optimized and has no impact anymore. -Improve the autosell integration in to the auto features for both the auto pickup and also the normal drops. Improved the debug logging to include a list of all blocks being sold, or dropped, and their quantity and value. Also the total counts too. - - -* **Bug fix with SellAll: bug in original logic where the delayed notification when initialized is losing the first amount.** -It now always adds the amount to the delayed queue. - - -* **Autofeatures ignore certain events to improve performance and reduce logging entries when in debug mode.** -Since there are multiple listeners on block break events, which monitor the same event, these changes are able to mark a specific block within the MineTargetPrisonBlock objects that will be able to pass along an "ignore" event status to the other listeners to short-circuit their processing. This is highly beneficial when using large mine bombs and the mine has blockEvents setup to perform explosions... which will help reduce a ton of "dead" events. - - -* **Auto Features Forced Auto Sell Optimization Improvement: AutoSell within auto features now only uses sellall by item stack and not the player interface that accesses all of the player's inventories.** -Since the auto features items are not placed in the player's inventories at this time in the process of auto features, there is no reason to access the player's inventories. Selling directly reduces a lot of sellall overhead and as a result sellall is just calculating the prices. -The old autosell code within autofeatures has not be removed yet, but it cannot be called anymore. - - -* **PrisonDispatchCommandTask: Removed the debug logging since it can be very numerous when used with a large mine bomb and it's pointless since most of the block events being submitted runs in less that one millisecond.** -So this is just cleaning up a messy logging item. - - -* **SellAll: Setup a sellall function that will allow the selling of one ItemStack, which is not tied to any of the player's inventories.** -This is used in prison's auto features when enabling the option to auto sell on a per block break event basis. This is highly optimized and a lot faster than using the normal sellall since it does not deal with any of the player's inventories or backpacks. -This forces a delayed sold amount message since an explosion could includ many ItemStacks. - - -* **Mine bombs: Add cooldown and fuse delay to the mine bomb settings so each bomb can be customized. -Added gravity to the mine bombs too.** Gravity, like glow, was added in minecraft 1.9 so older versions won't work. - - -* **Bug fix: For TokenEnchant's explosive event processing,** need to set PrisonMinesBlockBreakEvent's setForceIfAirBlock( true ) so the explosion event can be processed, even if the initial block has already been processed. -This allows TE explosion events to work correctly now. - - -* **Bug fix: refined the use of a few internal registers that are being used to control block break behavior, and also block counts and block events.* -A few of the settings were being changed in the wrong places, which was out of synch with when they should have been applied. -A few of the side effects was failure of tracking block counts, block events, and handling some explosion events. - - -* **Mine Bombs: More features and fixes.** -Added support for radiusInner (for hollow sphere explosion shapes), removalChance (chance for block inclusion), glowing, autoSell, tool material type, tool fortune level. - Added a new shape which is "cube" and hooked up sphereHollow. Hooked up cube, sphereHollow, removalChance, glowing, the specified tool in hand with the custom fortune level. Did not hook up the forced autosell yet. -Fixed some issues to get things to work a little better too. - - -* **Prison Bombs: enabled the right clicking of AIR to set the bombs.** -If clicking air blocks, then the block tied to the event will be null (at least for spigot 1.13.x) in that case, will use the block location of the player, and then adding the player's vector to it times three. - - - -* **Fixed a bug with how the regex handles block quotes.** -Not only was it not working correctly for multiple block quotes, but it was incorrectly handling the tail end of the processed text and was basically doubling the text. It now works correctly, even with multiple block quotes. - - -* **Fixed an unexpected "bug" with the JumboText font for the letter Q.** -One section was setup to use "\Q" which is an escape character for a regex block quote. This was causing problems since it was forcing large sections of text to be ignored when translating minecraft color codes. By changing it to "\q", a lower case Q, this eliminated the translation from making the mistake. - - -* **Bug fix: The command "/prison support submit ranks" was passing a null sender, which is valid when generated by this support tool.** -The fixes now works well, and treats the null basically the same as an OP'd player, or the command being ran from the console. - - -* **Bug fix. If a null message is sent to this function, it would cause a NPE.** -This now prevents a few failures from causing potential problems. - - -* **Fixes a concurrent modification exception when the PlayerCacheCheckTimersTask is running.** -This happens rarely when a player is logging off while "trying" to process their entries; they have been removed. -So when this happens, the process retries to start over a total of 2 more times and it skips processing players that have already been processed. Any update that was skipped would be covered in the next pass with no real loss. - - -* **The use of a command placeholders for `{actionBar}` and `{title}` were added to the placeholder enumeration so they are included in the placeholders listings.** -The support for these two commands were added a while ago, but because they were not added to the enum, they were not being listed in the help. - - -**3.2.11-alpha.4 2021-11-01** - Released alpha.4. - - -* **Changes to improve the way the upcoming mine bombs.** -They are currently non-functional. - - -* **Adjustments to get block events, such as decays, to work correctly with the new auto feature block event handlers.** - Block events were moved to be processed after the block is broke. Also if a block has already been processed, it now will cancel the event to prevent normal block breakage when none should happen. -At this point, the new auto manager appears to be working really well. - - -* **Changed the location usage with block event placeholders, which now uses the location that is tied to the targetBlock instead of the mined block.** -The mined block may be null so it's not stable. - - -* **Fixed an issue with /mines block list when an incorrect mine name is used.** -Now displays an error stating the name is invalid. - - -* **Starting to add some video documents for prison.** - - -* **Fixed an issue with adding a non-block item to a mine.** -It now validates that the specified item is a block. Also if a specified block is not in a mine when trying to remove it, it will now display a message indicating that nothing was removed. - - -* **Major rewrites to how auto features work.** -Using the PrisonMinesBlockBreakEvent object to carry all of the various parameters that are used within the auto features code. This allowed the elimination of many functions since they have been combined together. It also allowed for more efficient handling of explosions by combining similar blocks together and processing them as a single unit, so massive explosions are handled far more efficiently. If the admin chooses to break the blocks in another thread, then handling of many blocks is optimized to reduce the overhead. The state of the blocks being broken are being tracked through the MineTargetPrisonBlock such that it's flagged as soon as it starts to process the impacted blocks so as to prevent the same block from being processed more than once, even when there are many explosions occurring at the same time. Changes to the block (block break) has been moved out of the depths of the code, to be closer to the event handlers so it's easier to monitor/track. -Due to the many changes and major alterations to the logic, this is a work in progress and needs more testing. - - -* **Async Mine Reset performance Improvements.** Adjustments were made to improve the performance of the asynch mine resets by providing the ability to fine tune the page sizes, and also provide the ability to reset more than one block in the synchronous thread at a time. This is called a slice. Measuring the actual block reset time with nanos for better resolution. -MineTargetBlockKey class was relocated to allow for the use of sub listings on the synchronized block updates. - - -* **Cloning a bomb was not complete. Some details were omitted.** - - -* **Fix for Potion IllegalArgumentException:** Fixed an error with potions in Player inventories when -using sellall sell, potions aren't supported by now and won't be sold, but at least it won't break -sellall anymore. - - - -* **Switched prison block debugging timing to use nanoTime instead of milliseconds since milliseconds is too large of a unit.** - - -* **Bug Fix: When using block constraints,** there was a common situation where an AIR block was being used in the top layers because all other blocks were being rejected due to chance. Order of blocks had an impact on this error, when it shouldn't. Now, if a block cannot be selected, the first block with no constraint issue will be used instead. Also found a bug in the applying of the chance to each block. Under some situations, the percent chance was not being reduced for a bypassed block, when it should have. This now will better select the blocks, and better preserve their intended percentage odds of being spawned. - - -**Prison v3.2.11-alpha.3 2021-10-18** - - -* **Enable the ability to choose between setting the block to air inline, or through submitting a synch task to allow the blockBreak event handler to finish quicker, which may reduce lag.** - - -* **Simplified the configuration of the handling of the block break events.** -Instead of having a separate setting that is a boolean value that indicates it's either enabled or disabled, these are now using the priority value of DISABLED. - - -* **Add millisecond reporting for the time it takes to handle a block break event.** - - - -**3.2.11-alpha.2 2021-10-14** - - -* **A few updates to mine bombs. They have been disabled so they cannot be used.** - - -* **Add the ability to glow the prison bombs when they are dropped/set.** - - -* **For a couple of rankup messages, using the rank tag now instead of the rank name.** - - -* **Fixed a compatibility issue with older versions of spigot.** Should have possibly use the compatibility classes, but if a method does not exist, then this will fall back on a string matching pattern. - - -* **Changed the message about worn out tool to use the SpigotPlayer's setActionBar() function to prevent overloading console messages.** - - -* **Bug fix: Logic was corrected to handle the double negative correctly.** -The was an issue with the /mines set area command when the mine's area was larger than 25,000 blocks. They have to enter either "confirm" or "yes". The bug would require them to enter both to create the mine. - - -* **Added an example of possible backpack object to the PlayerCachePlayerData object.** - - -* **Adjustments to the new auto features for cancel block break events and block drops.** - - -* **Removal of some auto feature commented out old code.** - - -* **New auto features settings: Able to prevent event canceling and also control if the drops are cleared.** -This has not been tested too much, but it may help make prison more compatible with other plugins that are needing to handle the block break events. - - -* **Fortune on a tool was appearing as a negative value: -1000.** -Not sure how it became negative, but this will better deal with negative values. - - -* **Added a listener for PlayerInteractEvent.** - - -* **Add a new feature to the PrisonSpigotAPI to allow for the creation of a new mine through the API.** -This could be used to generate player mines in a plot world. - - - -* **Able to give players bombs, based upon the item type as defined for the bomb.** - - -* **Significant progress on Prison's Mine Bombs:** -Moved the mine bombs primary classes to the prison core so it's accessible from all packages. -Setup 4 default mine bombs if the commands are used and there are none defined. -Setup a new /prison utils bomb commands to list all bombs and to give players bombs. These are not complete and fully tested yet. - - -* **Some initial work to setup the mine bombs configs.** - - -* **Add placeholders {actionBar} and {title} to the blockEvent listing of placeholders that can be used.** -They are shortcuts for the new prison utils commands. - - -* **For the actionBar and title, translate the color codes so they work properly.** - - -* **Hook up the auto features notification to use the new actionBar interface.** -This "should" prevent duplicate messages from being sent to the player while the same message is displayed in the actionbar. - - -* **Fixed an error about backpacks and lore transition:** A single lore was being used for the backpacks utility, if a server -was new and fresh, this would've been missing and an error could occur, this now got fixed with the full transition. - - -* **Full transition of all messages to the .properties lang:** All messages are now on the .properties file and the old -.yml one is unused from now on, you can delete it and start translating the new one. Please note that some messages may -be wrong, as it's still in a young stage and a lot of messages got transitioned. - - -* **The player cache, when being shut down ran in to a problem if the players were removed when they logged off.** -This function was making a new collection based upon the original player cache copy of players, of which, when a few of the players are removed, then they were resulting in nulls. - - -* **Prevented a problem when unloading players, and when a player is null.** -The condition that was causing a null player was that the player was unloaded when the player left the server at the same time when the server was shut down. Basically a race condition with two parallel async tasks trying to shut down the player cache object, each focusing on a different aspect (player vs. server). - - -* **Hooked up XSeries' Titles to the compatibility class instead of using version specific code.** -XSeries says they support 1.8.8 through 1.17.1. -Deleted the support for the Spigot110 classes since it was only to support the use of the ActionBar and also the Title, which are no longer needed for 1.10+. - - -* **Adding a player messaging component to the PlayerCache.** -When used, this will prevent more than one of the same messages from being displayed at the same time. - - -* **For the command /mines set area the confirmation of "yes" was setup incorrectly with being negated.** - - -* **Switch over to using XSeries for the actionBar.** -XSeries claims it works for 1.8.8 through 1.17.1. - - -* **Moved all Lores to the new .properties Language file:** Changes to the old .yml language file about Lore messages -won't take effect, only if you edit the .properties file they will. - - -* **Added the trigger "minebombs" for the utils command bombs.** - - -* **Adjustments to the BlockEvents and how it handles some of the event types.** -Expanded and fixed some of the settings for prison's explosions, and PE's too. -Added the ability to exclude specfic triggers. - - -* **Updates to the Prison's explosion event handling to correct a few problems. ** - - -* **Fixed SellAll Hand not removing item:** SellAll Hand didn't work properly and got now fixed. - - -* **Initial setup of Prison's mine bombs.** -Initially it will be controllable as a utils command, so random chances can be assigned to explosions. - - -* **Cleaned up some of the unused variables in the Utils titles command.** -There were plans for more commands, but they were eliminated. This will soon be rewritten to utilize XSeries's classes for these display items. - - -* **Ran in to a situation where results was actually null. So this prevents a NPE.** - - -* **Fixed issue with tool's durability being cutoff right before reaching the threshold.** -Had to change a > to a >=. - - -* **3.2.11-alpha.1 2021-08-31** -- Release the first alpha.1 - - -* **Replace the block with air through a task to get it out of the auto features thread.** - - -* **If the settings isPreventToolBreage is enabled, then don't allow the tool to break.** - - -* **Update some messages to be clearer as to what they are.** -Removed the MONITOR from auto features since they should not have the monitor setting enabled. The blockBreakEvent has the monitoring event. - - -* **Trying to fix an error related to SpigotRankManager GUI:** I can't reproduce the issue but the NPE shouldn't -give a stacktrace in the console anymore. - - -* **If the primary block was null, which it never should be, then this prevents a failure in this section of code in the OnBlockBreakEventCore.** - - - -* **For the initial startup air count task, which is used to "reset" the block counts on a mine.** -This does not change any blocks, but just finds out where the mine was when the server was last shut down. This is needed to ensure we have valid counts for the mines before the first time they are reset. The other way to update these values is to do a full mine reset which is more costly. -There was an inconclusive error that just listed "null" as the error messags, without identifying the actual line number. This error catching was changed to now generate a stack trace so it can be properly fixed if it occurs in the future. - - -* **Added a few more reporting entries on the block break handling.** -Reporting how many blocks are being processed and if it passes the validation phase. - - -* **Some fixes for teleporting and the removal of the teleport glass block.** - - -* **Updates to the PrisonEnchant's API.** -Minor adjustments to work with the new API from PrisonEnchants. - - -* **Updates to async block updates.** -Included changes to hook up the CustomItems to work with the async updates. - - -* **Clarify some of the messages related to listing of the block events.** - - -* **Added the ability to identify if a block is able to be affected by gravity. Also the mine has a global setting to identify quickly if any block is gravity affected.** -This will be used to alter the mine reset strategy to improve performance so as to hopefully eliminate long resets due to extensive lag from falling blocks. The idea is to get all the other blocks in to place before placing the falling blocks to ensure they are less likely to fall. - - -* **If the Mine's saved file data is corrupted (manually edited with incorrect data), this will prevent the mine from being loaded and will now generate an error message indicating which mine has a problem loading. It will print out the invalid data, and it will default to a value of 0.00001. The function has been updated to "properly" use the localized format, so if it saves in a non US way, then it should now be able to read it back in and parse it correctly. - - -* **If the Mine's saved file data is corrupted (manually edited with incorrect data),** -this will prevent the mine from being loaded and will now generate an error message indicating which mine has a problem loading. It will print out the invalid data, and it will default to a value of 0.00001. - - -* **Checking to ensure the locations are not null when loading.** -There was a failure with bad data on the files system that was resulting in trying to resolve nulls to a location, which obviously cannot happen. - - -* **There was an odd situation where the player was null, when usually they never can be, so this helps prevent possible errors.** -The null was caused by an issue with a placeholder? Don't really remember. - - -* **Adjustments to Prison's TPS calculations.** -They were only taking the average of just two readings which was resulting in very unstable TPS values. Now 10 are being used. -Enabled a new feature where the resolution can be changed from normal (a reading every tick) to high resolution (one reading every 2 ticks). When the resolution changes, the task will auto terminate and resubmit with the new settings. - - -* **For the command /ranks autoConfigure made some adjustments to the block lists being used so the top mines have more valuable ores and blocks. There was a shortage and the wrong blocks were being used. - - -* **Fixed an auto features config setting for prison's ExplosiveBockBreakvents priority; it was missing the word priority.** -Reworked some of the details on autofeatures as displayed through /prison version to update them to better reflect the correct settings and dependencies. - - -* **Fixed a problem with placeholders when using the search feature, but not supplying a player's name.** - - -* **some internal changes to improve the resets** - - -* **eliminate the block access in this class since it handles everything in the submitted task.** -This was causing an error when it was being ran in an async thread. When the task is submitted, it is ran synchoronously so it works correctly. - - -* **Changed prison's TPS calculation to be able to enable a high-res setting when the `/mines stats` is enabled.** -The one problem with enabling high resolution mode is that it could show an unrealistic low TPS during a reset. The /lag command shows a much higher TPS value. - - -* **Setup up the basics for async updates.** -In the code that does the update, it also now reads the block to ensure that the read and update is all done in the synch thread. Otherwise the old code would be risking chunk loading in an async thread. -Using the Location and World to perform the async updates outside of needing access to the spigot module. -At this time, only `/mines set tracer` is using the new async reset. - - -* **Tweaks to the event listener dumps for block breaks.** -Updated the notes about prison's listeners. -PEExplosionEvent was setup with the wrong forClass name. - - -* **Setting up a new way to handle block updates in prison. Adding functions that are intended to be use while running in an async threads.** - - -* **Transitioning over to the correct way to get the compatibility object.** -Just a few classes are using the old way, but they will be switched over when they are done with the edits. - - -* **Fixed the way some of the language files were being generated** -so it can include the spigot module, which makes it self-contained for actual Modules, since it's always based upon the module name. -Core and spigot are not technically modules, so they have special setups. -Changed the Module folder from dataFolder to moduleDataFolder so it would not conflict with the SpigotPrison object. - - -* **Fixed a problem with Prison's ExplosiveBlockBreakHandler** - in that it has a typo in the getHandlerList() and was not included with the registration processes. It also needed to be included with the generation of the listener dumps. - - -* **Added /sellall hand command.** - - -* **Minor changes to SellAll Util.** - - -* **Much better performance for SellAll generally.** - - -* **SellAll Commands internal changes.** - - -* **Minor changes to GUIs:** Some fixes and visual changes. - - -* **SellAllUtil Rewrite:** New internals for SellAll and SellAll API. - +# 3.2.11 2022-01-22 # v3.2.10 2021-08-22 + # v3.2.9 2021-07-03 - release v3.2.9 diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/CommandHandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/CommandHandler.java index 19ac5379b..6ab541761 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/CommandHandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/CommandHandler.java @@ -42,11 +42,11 @@ import tech.mcprison.prison.internal.CommandSender; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.World; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.LogLevel; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.output.RowComponent; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.ChatColor; public class CommandHandler { @@ -94,7 +94,7 @@ public CommandHandler() { registerArgumentHandler(String.class, new StringArgumentHandler()); registerArgumentHandler(Player.class, new PlayerArgumentHandler()); registerArgumentHandler(World.class, new WorldArgumentHandler()); - registerArgumentHandler(BlockType.class, new BlockArgumentHandler()); + registerArgumentHandler(PrisonBlock.class, new BlockArgumentHandler()); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/BlockArgumentHandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/BlockArgumentHandler.java index f2c3e3838..ef7908ea1 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/BlockArgumentHandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/BlockArgumentHandler.java @@ -23,54 +23,62 @@ import tech.mcprison.prison.commands.CommandArgument; import tech.mcprison.prison.commands.TransformError; import tech.mcprison.prison.internal.CommandSender; -import tech.mcprison.prison.util.BlockType; +import tech.mcprison.prison.internal.block.PrisonBlock; -public class BlockArgumentHandler extends ArgumentHandler { +public class BlockArgumentHandler extends ArgumentHandler { public BlockArgumentHandler() { } @Override - public BlockType transform(CommandSender sender, CommandArgument argument, String value) + public PrisonBlock transform(CommandSender sender, CommandArgument argument, String value) throws TransformError { - BlockType m = null; + PrisonBlock b = null; - // Try block legacy (numerical) ID first - try { - m = BlockType.getBlock(Integer.parseInt(value)); - } catch (NumberFormatException ignored) { - } - - if (m != null) { - return m; - } - - // Now try new block IDs - - m = BlockType.getBlock(value); - - if (m != null) { - return m; - } - - // Now try id:data format - if (value.contains(":")) { - int id; - short data; - try { - id = Integer.parseInt(value.split(":")[0]); - data = Short.parseShort(value.split(":")[1]); - } catch (NumberFormatException ignored) { - throw new TransformError( - Prison.get().getLocaleManager().getLocalizable("blockParseError") - .withReplacements(value).localizeFor(sender)); - } - m = BlockType.getBlockWithData(id, data); - } + if ( value != null ) { + b = new PrisonBlock( value ); - if (m != null) { - return m; + if ( b != null ) { + return b; + } } + +// // Try block legacy (numerical) ID first +// try { +// m = BlockType.getBlock(Integer.parseInt(value)); +// } catch (NumberFormatException ignored) { +// } +// +// if (m != null) { +// return m; +// } +// +// // Now try new block IDs +// +// m = BlockType.getBlock(value); +// +// if (m != null) { +// return m; +// } +// +// // Now try id:data format +// if (value.contains(":")) { +// int id; +// short data; +// try { +// id = Integer.parseInt(value.split(":")[0]); +// data = Short.parseShort(value.split(":")[1]); +// } catch (NumberFormatException ignored) { +// throw new TransformError( +// Prison.get().getLocaleManager().getLocalizable("blockParseError") +// .withReplacements(value).localizeFor(sender)); +// } +// m = BlockType.getBlockWithData(id, data); +// } +// +// if (m != null) { +// return m; +// } // No more checks, just fail diff --git a/prison-core/src/main/java/tech/mcprison/prison/gui/Button.java b/prison-core/src/main/java/tech/mcprison/prison/gui/Button.java index 3c7e4ecff..0e317cc9d 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/gui/Button.java +++ b/prison-core/src/main/java/tech/mcprison/prison/gui/Button.java @@ -18,12 +18,13 @@ package tech.mcprison.prison.gui; -import tech.mcprison.prison.util.BlockType; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import tech.mcprison.prison.internal.block.PrisonBlock; + /** * A button is an item in an inventory GUI. When it is clicked, an action is performed. * @@ -32,7 +33,7 @@ */ public class Button { - private BlockType item; + private PrisonBlock item; private Action action; private String name; private List lore; @@ -44,7 +45,7 @@ public class Button { * @param name The name of the button (shown as the item name). * @param closeOnClick Whether to close the GUI on click. */ - public Button(BlockType item, Action action, String name, boolean closeOnClick) { + public Button( PrisonBlock item, Action action, String name, boolean closeOnClick) { this.item = item; this.action = action; this.name = name; @@ -59,7 +60,7 @@ public Button(BlockType item, Action action, String name, boolean closeOnClick) * @param closeOnClick Whether to close the GUI on click. * @param lore The lore text to put under the button. */ - public Button(BlockType item, Action action, String name, boolean closeOnClick, + public Button( PrisonBlock item, Action action, String name, boolean closeOnClick, String... lore) { this.item = item; this.action = action; @@ -68,7 +69,7 @@ public Button(BlockType item, Action action, String name, boolean closeOnClick, this.lore = Arrays.asList(lore); } - public BlockType getItem() { + public PrisonBlock getItem() { return item; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/gui/ClickedButton.java b/prison-core/src/main/java/tech/mcprison/prison/gui/ClickedButton.java index 48a2daab2..fd9683d61 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/gui/ClickedButton.java +++ b/prison-core/src/main/java/tech/mcprison/prison/gui/ClickedButton.java @@ -18,11 +18,11 @@ package tech.mcprison.prison.gui; -import tech.mcprison.prison.internal.Player; -import tech.mcprison.prison.util.BlockType; - import java.util.List; +import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.internal.block.PrisonBlock; + public class ClickedButton { Button originalButton; @@ -35,7 +35,7 @@ public ClickedButton(Button btn, GUI gui, Player player) { clickingPlayer = player; } - public BlockType getItem() { + public PrisonBlock getItem() { return originalButton.getItem(); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/ItemStack.java b/prison-core/src/main/java/tech/mcprison/prison/internal/ItemStack.java index 2eb302345..d250fbe93 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/ItemStack.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/ItemStack.java @@ -26,7 +26,7 @@ import org.apache.commons.lang3.StringUtils; -import tech.mcprison.prison.util.BlockType; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.util.Text; /** @@ -39,7 +39,7 @@ public class ItemStack { private String displayName = null; private int amount; - private BlockType material; + private PrisonBlock material; private List lore; private Map enchantments; @@ -51,7 +51,7 @@ protected ItemStack() { this.enchantments = new HashMap<>(); } - public ItemStack(String displayName, int amount, BlockType material, String... lore) { + public ItemStack(String displayName, int amount, PrisonBlock material, String... lore) { this.displayName = displayName; this.amount = amount; this.material = material; @@ -59,7 +59,7 @@ public ItemStack(String displayName, int amount, BlockType material, String... l this.enchantments = new HashMap<>(); } - public ItemStack(int amount, BlockType material, String... lore) { + public ItemStack(int amount, PrisonBlock material, String... lore) { this.amount = amount; this.material = material; this.lore = new ArrayList<>(Arrays.asList(lore)); @@ -69,8 +69,11 @@ public ItemStack(int amount, BlockType material, String... lore) { * Returns the name of the item stack, derived from its BlockType name. */ public String getName() { - String name = (material != null ? material.name() : - ( getDisplayName() != null ? getDisplayName() : "none")); + String name = (material != null ? + material.getBlockName() : + ( getDisplayName() != null ? + getDisplayName() : + "none")); return StringUtils.capitalize(name.replaceAll("_", " ").toLowerCase()); } @@ -97,10 +100,10 @@ public void setAmount( int amount ) { /** * Returns the type of items in this stack. */ - public BlockType getMaterial() { + public PrisonBlock getMaterial() { return material; } - public void setMaterial( BlockType material ) { + public void setMaterial( PrisonBlock material ) { this.material = material; } 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 04c40649d..7f129ae6a 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 @@ -18,12 +18,11 @@ package tech.mcprison.prison.internal.block; +import java.util.List; + import tech.mcprison.prison.internal.ItemStack; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; -import java.util.List; - /** * Represents a block. Only one block may exist for a location in the world. * @@ -47,23 +46,23 @@ public interface Block { */ Block getRelative(BlockFace face); - /** - * Returns the type of this block. - * - * @return The {@link BlockType}. - */ - BlockType getType(); +// /** +// * Returns the type of this block. +// * +// * @return The {@link BlockType}. +// */ +// BlockType getType(); public PrisonBlock getPrisonBlock(); - /** - * Sets the block to a different type. - * - * @param type The new {@link BlockType}. - */ - void setType(BlockType type); +// /** +// * Sets the block to a different type. +// * +// * @param type The new {@link BlockType}. +// */ +// void setType(BlockType type); public void setPrisonBlock( PrisonBlock prisonBlock ); @@ -82,7 +81,7 @@ public interface Block { * * @return The current {@link BlockState}. */ - BlockState getState(); + public BlockState getState(); /** * Returns whether the block is empty (i.e. the type is air). @@ -90,7 +89,7 @@ public interface Block { * @return true if the block is empty, false otherwise. */ default boolean isEmpty() { - return getType() == BlockType.AIR; + return getPrisonBlock().isAir(); } /** @@ -98,14 +97,14 @@ default boolean isEmpty() { * * @return true if the is broken, false otherwise. */ - boolean breakNaturally(); + public boolean breakNaturally(); /** * Returns a list of items which would be dropped by destroying this block. * * @return A list of dropped items for this type of block */ - List getDrops(); + public List getDrops(); /** * Returns a list of items which would be dropped by destroying this block with @@ -114,6 +113,6 @@ default boolean isEmpty() { * @param tool The tool or item in hand used for breaking the block. * @return A list of dropped items for this type of block. */ - List getDrops(ItemStack tool); + public List getDrops(ItemStack tool); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/BlockState.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/BlockState.java index 01d8c788b..480222cdc 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/BlockState.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/BlockState.java @@ -32,6 +32,6 @@ */ public interface BlockState { - Block getBlock(); + public Block getBlock(); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/Door.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/Door.java index d7f1a681d..3b157900b 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/Door.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/Door.java @@ -18,8 +18,6 @@ package tech.mcprison.prison.internal.block; -import tech.mcprison.prison.util.BlockType; - /** * Represents a door. * @@ -55,10 +53,17 @@ default void toggleOpen() { * @return true if it's a wooden door, false otherwise. */ default boolean isWoodenDoor() { - BlockType block = getBlock().getType(); - return block == BlockType.ACACIA_DOOR_BLOCK || block == BlockType.BIRCH_DOOR_BLOCK - || block == BlockType.DARK_OAK_DOOR_BLOCK || block == BlockType.JUNGLE_DOOR_BLOCK - || block == BlockType.OAK_DOOR_BLOCK || block == BlockType.SPRUCE_DOOR_BLOCK; + + String blockName = getBlock().getPrisonBlock().getBlockName(); + + return blockName != null && + blockName.matches( "ACACIA_DOOR|BIRCH_DOOR|CRIMSON_DOOR|OAK_DOOR|DARK_OAK_DOOR|" + + "JUNGLE_DOOR|SPRUCE_DOOR|WARPED_DOOR" ); + +// BlockType block = getBlock().getType(); +// return block == BlockType.ACACIA_DOOR_BLOCK || block == BlockType.BIRCH_DOOR_BLOCK +// || block == BlockType.DARK_OAK_DOOR_BLOCK || block == BlockType.JUNGLE_DOOR_BLOCK +// || block == BlockType.OAK_DOOR_BLOCK || block == BlockType.SPRUCE_DOOR_BLOCK; } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java index d56a510a5..602db044a 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java @@ -1,6 +1,9 @@ package tech.mcprison.prison.internal.block; +import java.util.List; + import tech.mcprison.prison.Prison; +import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.PrisonBlockTypes.InternalBlockTypes; import tech.mcprison.prison.util.Location; @@ -13,12 +16,15 @@ */ public class PrisonBlock extends PrisonBlockStatusData - implements Comparable, + implements Block, + BlockState, + Comparable, BlockExtendedDescription { public static PrisonBlock AIR; public static PrisonBlock GLASS; public static PrisonBlock PINK_STAINED_GLASS; + public static PrisonBlock BLAZE_ROD; public static PrisonBlock IGNORE; public static PrisonBlock NULL_BLOCK; @@ -40,6 +46,7 @@ public class PrisonBlock AIR = new PrisonBlock( InternalBlockTypes.AIR.name(), false ); GLASS = new PrisonBlock( InternalBlockTypes.GLASS.name(), true ); PINK_STAINED_GLASS = new PrisonBlock( InternalBlockTypes.PINK_STAINED_GLASS.name(), true ); + BLAZE_ROD = new PrisonBlock( InternalBlockTypes.BLAZE_ROD.name(), false ); IGNORE = new PrisonBlock( InternalBlockTypes.IGNORE.name(), false ); NULL_BLOCK = new PrisonBlock( InternalBlockTypes.NULL_BLOCK.name(), false ); } @@ -302,5 +309,131 @@ public int compareTo( PrisonBlock block ) public boolean isAir() { return compareTo( AIR ) == 0; } + @Override + public Block getRelative( BlockFace face ) + { + Block results = null; + + if ( getLocation() != null ) { + + Location loc = new Location( getLocation() ); + + switch ( face ) + { + case NORTH: { + // North is z axis in the negative direction: + loc.setZ( loc.getZ() - 1 ); + break; + } + case SOUTH: { + // South is z axis in the positive direction: + loc.setZ( loc.getZ() + 1 ); + break; + } + case EAST: { + // East is x axis in the positive direction: + loc.setX( loc.getX() + 1 ); + break; + } + case WEST: { + // West is x axis in the negative direction: + loc.setX( loc.getX() - 1 ); + break; + } + case TOP: + case UP: { + // TOP and UP is y axis in the positive direction: + loc.setY( loc.getY() + 1 ); + break; + } + case BOTTOM: + case DOWN: { + // BOTTOM and DOWN is y axis in the negative direction: + loc.setY( loc.getY() - 1 ); + break; + } + + default: + } + + results = loc.getBlockAt(); + } + + return results; + } + + @Override + public PrisonBlock getPrisonBlock() { + return this; + } + @Override + public PrisonBlock getBlock() { + return this; + } + + @Override + public void setPrisonBlock( PrisonBlock prisonBlock ) { + + if ( prisonBlock != null ) { + + PrisonBlock cloned = prisonBlock.clone(); + getLocation().setBlockAsync( cloned ); + } + + } + + @Override + public void setBlockFace( BlockFace blockFace ) { + + Block relativeBlock = getRelative( blockFace ); + + if ( relativeBlock != null && relativeBlock instanceof PrisonBlock ) { + + (( PrisonBlock ) relativeBlock).setPrisonBlock( this ); + +// PrisonBlock cloned = this.clone(); +// +// (( PrisonBlock ) relativeBlock).getLocation().setBlockAsync( cloned ); +// +// PrisonBlockType blockType = getBlockType(); +// +// // Set that block with this block's type: +// (( PrisonBlock ) relativeBlock).setBlockType( blockType ); +// (( PrisonBlock ) relativeBlock).setBlockName( getBlockName() ); + + } + } + + @Override + public BlockState getState() { + return this.clone(); + } + + @Override + public boolean breakNaturally() { + return false; + } + + + /** + * This function needs to be overriden in the platform implementation. + */ + @Override + public List getDrops() + { + // TODO Auto-generated method stub + return null; + } + + + /** + * This function needs to be overriden in the platform implementation. + */ + @Override + public List getDrops( ItemStack tool ) + { + // TODO Auto-generated method stub + return null; + } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java index 5f593abf2..a59ae383f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java @@ -21,8 +21,9 @@ public enum InternalBlockTypes { AIR, GLASS, PINK_STAINED_GLASS, + BLAZE_ROD, IGNORE, - NULL_BLOCK + NULL_BLOCK } public PrisonBlockTypes() { diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/events/block/BlockBreakEvent.java b/prison-core/src/main/java/tech/mcprison/prison/internal/events/block/BlockBreakEvent.java index 149c4bcaa..2a1fe9915 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/events/block/BlockBreakEvent.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/events/block/BlockBreakEvent.java @@ -19,8 +19,8 @@ package tech.mcprison.prison.internal.events.block; import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.events.Cancelable; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; /** @@ -29,19 +29,24 @@ * @author DMP9 * @since API 1.0 */ -public class BlockBreakEvent implements Cancelable { +public class BlockBreakEvent + implements Cancelable +{ - private BlockType block; + private PrisonBlock block; private Location blockLocation; private Player player; private boolean canceled = false; private int exp; - public BlockBreakEvent(BlockType block, Location blockLocation, Player player) { + public BlockBreakEvent( PrisonBlock block, Location blockLocation, Player player) { this(block,blockLocation,player,0); } +// public BlockBreakEvent(BlockType block, Location blockLocation, Player player) { +// this(block,blockLocation,player,0); +// } - public BlockBreakEvent(BlockType block, Location blockLocation, Player player,int xp) { + public BlockBreakEvent( PrisonBlock block, Location blockLocation, Player player, int xp ) { this.block = block; this.blockLocation = blockLocation; this.player = player; @@ -56,7 +61,7 @@ public BlockBreakEvent(BlockType block, Location blockLocation, Player player,in this.canceled = canceled; } - public BlockType getBlock() { + public PrisonBlock getPrisonBlock() { return block; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/events/block/BlockPlaceEvent.java b/prison-core/src/main/java/tech/mcprison/prison/internal/events/block/BlockPlaceEvent.java index 488454272..c041b2cfa 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/events/block/BlockPlaceEvent.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/events/block/BlockPlaceEvent.java @@ -19,8 +19,8 @@ package tech.mcprison.prison.internal.events.block; import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.events.Cancelable; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; /** @@ -30,16 +30,21 @@ */ public class BlockPlaceEvent implements Cancelable { - private BlockType block; + private PrisonBlock block; private Location blockLocation; private Player player; private boolean canceled = false; - public BlockPlaceEvent(BlockType block, Location blockLocation, Player player) { + public BlockPlaceEvent( PrisonBlock block, Location blockLocation, Player player) { this.block = block; this.blockLocation = blockLocation; this.player = player; } +// public BlockPlaceEvent(BlockType block, Location blockLocation, Player player) { +// this.block = block; +// this.blockLocation = blockLocation; +// this.player = player; +// } @Override public boolean isCanceled() { return canceled; @@ -49,7 +54,7 @@ public BlockPlaceEvent(BlockType block, Location blockLocation, Player player) { this.canceled = canceled; } - public BlockType getBlock() { + public PrisonBlock getBlock() { return block; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/events/inventory/FurnaceExtractEvent.java b/prison-core/src/main/java/tech/mcprison/prison/internal/events/inventory/FurnaceExtractEvent.java index fd5a7effd..cd1f29ec3 100755 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/events/inventory/FurnaceExtractEvent.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/events/inventory/FurnaceExtractEvent.java @@ -19,8 +19,7 @@ package tech.mcprison.prison.internal.events.inventory; import tech.mcprison.prison.internal.Player; -import tech.mcprison.prison.internal.block.Block; -import tech.mcprison.prison.util.BlockType; +import tech.mcprison.prison.internal.block.PrisonBlock; /** * Currently undocumented. @@ -31,14 +30,18 @@ public class FurnaceExtractEvent { private int itemAmount; private int expToDrop; - private Block block; - private BlockType blockType; + private PrisonBlock prisonBlock; + +// private Block block; +// private BlockType blockType; + + private PrisonBlock blockType; private Player player; - public FurnaceExtractEvent(Player player, Block block, BlockType itemType, int itemAmount, + public FurnaceExtractEvent(Player player, PrisonBlock prisonBlock, PrisonBlock itemType, int itemAmount, int exp) { this.player = player; - this.block = block; + this.prisonBlock = prisonBlock; this.blockType = itemType; this.itemAmount = itemAmount; this.expToDrop = exp; @@ -48,7 +51,7 @@ public int getItemAmount() { return itemAmount; } - public BlockType getItemType() { + public PrisonBlock getItemType() { return blockType; } @@ -64,8 +67,8 @@ public void setExpToDrop(int exp) { expToDrop = exp; } - public Block getBlock() { - return block; + public PrisonBlock getPrisonBlock() { + return prisonBlock; } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/FurnaceRecipe.java b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/FurnaceRecipe.java index d38fd8adb..da33b0a1f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/FurnaceRecipe.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/FurnaceRecipe.java @@ -19,7 +19,7 @@ package tech.mcprison.prison.internal.inventory; import tech.mcprison.prison.internal.ItemStack; -import tech.mcprison.prison.util.BlockType; +import tech.mcprison.prison.internal.block.PrisonBlock; /** * Represents a recipe used in a furnace, consisting of an input and a result. @@ -41,7 +41,7 @@ public interface FurnaceRecipe extends Recipe { * * @param input the input of this recipe () */ - FurnaceRecipe setInput(BlockType input); + FurnaceRecipe setInput( PrisonBlock input ); /** * Gets the {@link ItemStack} created when the input is smelted. diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/Inventory.java b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/Inventory.java index 1aa117814..3713a757f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/Inventory.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/Inventory.java @@ -18,14 +18,14 @@ package tech.mcprison.prison.internal.inventory; -import tech.mcprison.prison.internal.ItemStack; -import tech.mcprison.prison.internal.Player; -import tech.mcprison.prison.util.BlockType; - import java.util.HashMap; import java.util.Iterator; import java.util.List; +import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.internal.block.PrisonBlock; + /** * Represents an inventory. * An inventory can belong to a player, a chest, or to nothing at all (i.e. as a GUI). @@ -85,7 +85,7 @@ public interface Inventory extends Iterable { * @param type The {@link BlockType} to look for. * @return true if the inventory contains the block type, false otherwise. */ - boolean contains(BlockType type); + boolean contains( PrisonBlock prisonBlock ); Iterator getIterator(); @@ -110,7 +110,7 @@ public interface Inventory extends Iterable { * @return a HashMap with the index of items with matching BlockTypes as the keys, and said items * as the values */ - HashMap getItems(BlockType type); + HashMap getItems( PrisonBlock item ); /** * Creates a {@link HashMap} with items matching the specified {@link ItemStack} @@ -167,7 +167,7 @@ public interface Inventory extends Iterable { * * @param type the {@link BlockType} to remove from the inventory */ - void clear(BlockType type); + void clear( PrisonBlock type); /** * Clears all the slots matching the specified {@link ItemStack} @@ -190,7 +190,7 @@ public interface Inventory extends Iterable { * @param type the {@link BlockType} to get the first index of * @return the first index of the BlockType */ - int first(BlockType type); + int first( PrisonBlock type); /** * Gets the index of the first empty slot in this inventory diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/ShapedRecipe.java b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/ShapedRecipe.java index 73cee8c90..20f1306c2 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/ShapedRecipe.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/ShapedRecipe.java @@ -18,11 +18,11 @@ package tech.mcprison.prison.internal.inventory; -import tech.mcprison.prison.internal.ItemStack; -import tech.mcprison.prison.util.BlockType; - import java.util.Map; +import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.block.PrisonBlock; + /** * Represents a shaped crafting recipe (a recipe that must be of a specific shape to be completed). * An example of this is the crafting recipe for a Bow. @@ -56,7 +56,7 @@ public interface ShapedRecipe extends Recipe { * @param ingredient the ingredient * @return this instance to allow chain calls */ - ShapedRecipe setIngredient(char key, BlockType ingredient); + ShapedRecipe setIngredient(char key, PrisonBlock ingredient); /** * Sets the shape of this recipe

Example: If you assign letter D to Diamond and S to diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/ShapelessRecipe.java b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/ShapelessRecipe.java index 883aed4f2..fde8cca39 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/ShapelessRecipe.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/inventory/ShapelessRecipe.java @@ -18,11 +18,11 @@ package tech.mcprison.prison.internal.inventory; -import tech.mcprison.prison.internal.ItemStack; -import tech.mcprison.prison.util.BlockType; - import java.util.List; +import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.block.PrisonBlock; + /** * Represents a shapeless recipe (a crafting recipe that has no requirement on a specific shape) * @@ -38,7 +38,7 @@ public interface ShapelessRecipe extends Recipe { * @param ingredient the ingredient to add to the recipe * @return this instance to allow chain calls */ - ShapelessRecipe addIngredient(int count, BlockType ingredient); + ShapelessRecipe addIngredient(int count, PrisonBlock ingredient); /** * Adds an ingredient to this recipe @@ -46,7 +46,7 @@ public interface ShapelessRecipe extends Recipe { * @param ingredient the ingredient to add to the recipe * @return this instance to allow chain calls */ - ShapelessRecipe addIngredient(BlockType ingredient); + ShapelessRecipe addIngredient( PrisonBlock ingredient); /** * Gets all the ingredients in this recipe @@ -62,7 +62,7 @@ public interface ShapelessRecipe extends Recipe { * @param ingredient the ingredient to remove from this recipe * @return this instance to allow chain calls */ - ShapelessRecipe removeIngredient(int count, BlockType ingredient); + ShapelessRecipe removeIngredient(int count, PrisonBlock ingredient); /** * Removes an ingredient from this recipe @@ -70,6 +70,6 @@ public interface ShapelessRecipe extends Recipe { * @param ingredient the ingredient to remove from this recipe * @return this instance to allow chain calls */ - ShapelessRecipe removeIngredient(BlockType ingredient); + ShapelessRecipe removeIngredient( PrisonBlock ingredient); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionManager.java b/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionManager.java index 0db9fce0d..9a07f832b 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionManager.java @@ -23,9 +23,9 @@ import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.inventory.Inventory; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.util.BlockType; /** * @author Faizaan A. Datoo @@ -33,7 +33,7 @@ public class SelectionManager { public static final ItemStack SELECTION_TOOL = - new ItemStack("&6Selection Wand", 1, BlockType.BLAZE_ROD, "&7Corner 1 - Left click", + new ItemStack("&6Selection Wand", 1, PrisonBlock.BLAZE_ROD, "&7Corner 1 - Left click", "&7Corner 2 - Right click"); private Map selectionMap; @@ -68,7 +68,7 @@ private int selectionWandCount( Player player) { if ( is != null && // is.getName().toLowerCase().contains( "selection wand" ) && // is.getDisplayName().toLowerCase().contains( "selection wand" ) && - is.getMaterial() == BlockType.BLAZE_ROD ) { + is.getMaterial().equals( PrisonBlock.BLAZE_ROD ) ) { count += is.getAmount(); } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/BlockType.java b/prison-core/src/main/java/tech/mcprison/prison/util/ObsoleteBlockType.java similarity index 96% rename from prison-core/src/main/java/tech/mcprison/prison/util/BlockType.java rename to prison-core/src/main/java/tech/mcprison/prison/util/ObsoleteBlockType.java index 08ea172e2..ea5e72875 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/util/BlockType.java +++ b/prison-core/src/main/java/tech/mcprison/prison/util/ObsoleteBlockType.java @@ -23,7 +23,16 @@ /** - *

All of the blocks in the game. + *

All of the old blocks in the game. This list is obsolete, and was used in + * v3.2.0 and earlier. It because obsolete with the new block model which was + * introduced when incorporating XSeries' XMaterial. + *

+ * + *

The only reasonto keep this enumeration is for conversion processes + * to convert to the new block model. This enum "should" be deleted, but + * for the sake of conversioin use only makes ths valuable. Where it excels, + * is that if an old block name cannot be auto mapped to the XMaterial, then + * this contains the mapping hints to ensure it works correctly. *

* *

The new field altNames contains a list of String values that will help @@ -40,8 +49,9 @@ * @author Faizaan A. Datoo * @author Camouflage100 * @since API 1.0 + * @deprecated since v3.2.6 */ -public enum BlockType { +public enum ObsoleteBlockType { /** * Identifying a block as a MaterialType.BLOCK will allow the @@ -1066,7 +1076,7 @@ public enum BlockType { private final List altNames; - BlockType(int legacyId, String id, int data, MaterialType materialType) { + ObsoleteBlockType(int legacyId, String id, int data, MaterialType materialType) { this.legacyId = legacyId; this.id = (id != null ? id : "minecraft:" + this.name().toLowerCase()); this.data = (short) data; @@ -1077,7 +1087,7 @@ public enum BlockType { } - BlockType(int legacyId, String id, int data, MaterialType materialType, String... altNames) { + ObsoleteBlockType(int legacyId, String id, int data, MaterialType materialType, String... altNames) { this( legacyId, id, data, materialType ); for ( String altName : altNames ) { @@ -1087,7 +1097,7 @@ public enum BlockType { - BlockType(String id, MaterialType materialType, MaterialVersion materialVersion, String... altNames ) { + ObsoleteBlockType(String id, MaterialType materialType, MaterialVersion materialVersion, String... altNames ) { this( id, materialType, materialVersion ); for ( String altName : altNames ) { @@ -1095,7 +1105,7 @@ public enum BlockType { } } - BlockType(String id, MaterialType materialType, MaterialVersion materialVersion ) { + ObsoleteBlockType(String id, MaterialType materialType, MaterialVersion materialVersion ) { this.legacyId = -1; this.id = (id != null ? id : "minecraft:" + this.name().toLowerCase()); this.data = 0; @@ -1105,15 +1115,15 @@ public enum BlockType { this.altNames = new ArrayList<>(); } - BlockType(MaterialType materialType) { + ObsoleteBlockType(MaterialType materialType) { this(0, null, 0, materialType); } - BlockType(int legacyId, String id) { + ObsoleteBlockType(int legacyId, String id) { this(legacyId, id, 0, MaterialType.NOT_SET); } - BlockType(int legacyId, String id, int data) { + ObsoleteBlockType(int legacyId, String id, int data) { this(legacyId, id, data, MaterialType.NOT_SET); } @@ -1152,12 +1162,12 @@ public List getXMaterialAltNames() { return getAltNames(); } - public static BlockType getBlock(int legacyId) { + public static ObsoleteBlockType getBlock(int legacyId) { return getBlock(legacyId, (short) 0); } - public static BlockType getBlock(int legacyId, short data) { - for (BlockType block : values()) { + public static ObsoleteBlockType getBlock(int legacyId, short data) { + for (ObsoleteBlockType block : values()) { if (block.getLegacyId() == legacyId) { if (block.getData() == data) { return block; @@ -1173,7 +1183,7 @@ public static BlockType getBlock(int legacyId, short data) { * @param key * @return */ - public static BlockType fromString( String key ) { + public static ObsoleteBlockType fromString( String key ) { return getBlock( key ); } /** @@ -1184,8 +1194,8 @@ public static BlockType fromString( String key ) { * @param key Block name, id, or number. * @return */ - public static BlockType getBlock(String key) { - BlockType blockType = getBlockByName( key ); + public static ObsoleteBlockType getBlock(String key) { + ObsoleteBlockType blockType = getBlockByName( key ); if ( blockType == null ) { blockType = getBlockById( key ); } @@ -1196,8 +1206,8 @@ public static BlockType getBlock(String key) { return blockType; } - private static BlockType getBlockById(String id) { - for (BlockType block : values()) { + private static ObsoleteBlockType getBlockById(String id) { + for (ObsoleteBlockType block : values()) { if (block.getId().equalsIgnoreCase(id) || block.name().equalsIgnoreCase(id) || block.getId().equalsIgnoreCase( "minecraft:" + id )) { return block; @@ -1219,8 +1229,8 @@ private static BlockType getBlockById(String id) { } // Prison prison = Prison.get(); // if ( prison != null && prison.getItemManager() != null ) { -// Set>> entrySet = prison.getItemManager().getItems().entrySet(); -// for (Map.Entry> entry : entrySet) { +// Set>> entrySet = prison.getItemManager().getItems().entrySet(); +// for (Map.Entry> entry : entrySet) { // if (entry.getValue().contains(id.toLowerCase())) { // return entry.getKey(); // } @@ -1231,8 +1241,8 @@ private static BlockType getBlockById(String id) { return null; } - private static BlockType getBlockByName(String name) { - for (BlockType block : values()) { + private static ObsoleteBlockType getBlockByName(String name) { + for (ObsoleteBlockType block : values()) { if (block.name().equalsIgnoreCase(name)) { return block; } @@ -1240,8 +1250,8 @@ private static BlockType getBlockByName(String name) { return null; } - private static BlockType getBlockByXMaterialName(String name) { - for (BlockType block : values()) { + private static ObsoleteBlockType getBlockByXMaterialName(String name) { + for (ObsoleteBlockType block : values()) { if (block.getXMaterialAltNames().size() > 0 ) { for ( String altName : block.getXMaterialAltNames() ) { @@ -1255,8 +1265,8 @@ private static BlockType getBlockByXMaterialName(String name) { return null; } - public static BlockType getBlockWithData(int id, short data) { - for (BlockType block : values()) { + public static ObsoleteBlockType getBlockWithData(int id, short data) { + for (ObsoleteBlockType block : values()) { if (block.getLegacyId() == id && block.getData() == data) { return block; } @@ -1264,7 +1274,7 @@ public static BlockType getBlockWithData(int id, short data) { return null; } - public static boolean isDoor(BlockType block) { + public static boolean isDoor(ObsoleteBlockType block) { return block == ACACIA_DOOR_BLOCK || block == BIRCH_DOOR_BLOCK || block == DARK_OAK_DOOR_BLOCK || block == IRON_DOOR_BLOCK || block == JUNGLE_DOOR_BLOCK || block == OAK_DOOR_BLOCK || block == SPRUCE_DOOR_BLOCK; diff --git a/prison-core/src/test/java/tech/mcprison/prison/selection/SelectionTest.java b/prison-core/src/test/java/tech/mcprison/prison/selection/SelectionTest.java index 8c01dfa75..9e485c868 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/selection/SelectionTest.java +++ b/prison-core/src/test/java/tech/mcprison/prison/selection/SelectionTest.java @@ -18,24 +18,25 @@ package tech.mcprison.prison.selection; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; + import tech.mcprison.prison.Prison; import tech.mcprison.prison.TestPlatform; import tech.mcprison.prison.TestPlayer; import tech.mcprison.prison.TestWorld; import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.World; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.events.player.PrisonPlayerInteractEvent; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; import tech.mcprison.prison.util.Text; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** * @author Faizaan A. Datoo */ @@ -70,17 +71,23 @@ public class SelectionTest { assertTrue(ourPlayer.getInput().contains("&7Second position set to &8(30, 20, 40)")); } - @Test public void testSelectionToolCheck() throws Exception { + @Test + public void testSelectionToolCheck() throws Exception { Prison.get().getSelectionManager(); // init World ourWorld = new TestWorld("TestWorld"); TestPlayer ourPlayer = new TestPlayer(); int initialAmount = ourPlayer.getInput().size(); + + PrisonBlock acaciaSapling = new PrisonBlock( "ACACIA_SAPLING"); Prison.get().getEventBus().post( - new PrisonPlayerInteractEvent(ourPlayer, new ItemStack("test", 1, BlockType.ACACIA_SAPLING), + new PrisonPlayerInteractEvent(ourPlayer, new ItemStack("test", 1, acaciaSapling ), PrisonPlayerInteractEvent.Action.LEFT_CLICK_BLOCK, new Location(ourWorld, 10, 20, 30))); +// Prison.get().getEventBus().post( +// new PrisonPlayerInteractEvent(ourPlayer, new ItemStack("test", 1, BlockType.ACACIA_SAPLING), +// PrisonPlayerInteractEvent.Action.LEFT_CLICK_BLOCK, new Location(ourWorld, 10, 20, 30))); assertEquals(initialAmount, ourPlayer.getInput() .size()); // nothing should have happened because we have the wrong item in our hand diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/MinesConversionAgent.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/MinesConversionAgent.java index 3bdaf5e6f..3fdc4f550 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/MinesConversionAgent.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/MinesConversionAgent.java @@ -1,117 +1,125 @@ package tech.mcprison.prison.mines; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import tech.mcprison.prison.Prison; -import tech.mcprison.prison.PrisonAPI; import tech.mcprison.prison.convert.ConversionAgent; import tech.mcprison.prison.convert.ConversionResult; -import tech.mcprison.prison.error.Error; -import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.util.BlockType; -import tech.mcprison.prison.util.Bounds; -import tech.mcprison.prison.util.Location; /** * @author Faizaan A. Datoo */ -public class MinesConversionAgent implements ConversionAgent { +public class MinesConversionAgent +implements ConversionAgent +{ @Override public ConversionResult convert() { - File oldFolder = new File(PrisonAPI.getPluginDirectory().getParent(), "Prison.old"); - File minesFolder = new File(oldFolder, "mines"); - - File alreadyConverted = new File(minesFolder, ".converted"); - if (alreadyConverted.exists()) { - return ConversionResult.failure(getName(), - "Already converted. Delete the '/plugins/Prison.old/mines' folder."); - } - - String[] jsonFiles = minesFolder.list((dir, name) -> name.endsWith(".json")); - - try { - - // ----------- - // JSON - // ----------- - - if (jsonFiles != null) { - for (String jsonFile : jsonFiles) { - File jsonFileObj = new File(minesFolder, jsonFile); - String json = new String(Files.readAllBytes(jsonFileObj.toPath())); - JsonObject obj = (JsonObject) JsonParser.parseString(json); - - String name = obj.getAsJsonPrimitive("name").getAsString(); - String world = obj.getAsJsonPrimitive("world").getAsString(); - double minX = obj.getAsJsonPrimitive("minX").getAsInt(); - double minY = obj.getAsJsonPrimitive("minY").getAsInt(); - double minZ = obj.getAsJsonPrimitive("minZ").getAsInt(); - double maxX = obj.getAsJsonPrimitive("maxX").getAsInt(); - double maxY = obj.getAsJsonPrimitive("maxY").getAsInt(); - double maxZ = obj.getAsJsonPrimitive("maxZ").getAsInt(); - - Optional prisonWorld = - Prison.get().getPlatform().getWorld(world); - if (!prisonWorld.isPresent()) { - Output.get().logWarn(String.format( - "Can't convert mine %s because its world %s doesn't exist anymore.", - name, world)); - break; // Skip it, its world didn't exist. - } - - Bounds bounds = new Bounds(new Location(prisonWorld.get(), minX, minY, minZ), - new Location(prisonWorld.get(), maxX, maxY, maxZ)); - - HashMap blocks = new HashMap<>(); - for (Map.Entry blockEntry : obj.getAsJsonObject("blocks") - .entrySet()) { - String[] blockParts = blockEntry.getKey().split(":"); - BlockType type = BlockType.getBlock(Integer.parseInt(blockParts[0]), - Short.parseShort(blockParts[1])); - - // Prison 2 stores chances in values < 1, whereas Prison 3 does it < 100 - int chance = (int) ((blockEntry.getValue().getAsDouble()) * 100); - - blocks.put(type, chance); - } - - Mine ourMine = new Mine(); - ourMine.setName(name); - ourMine.setBounds(bounds); - ourMine.setBlocks(blocks); - - if (PrisonMines.getInstance().getMines().contains(ourMine)) { - break; - } - - PrisonMines.getInstance().getMines().add(ourMine); - } - - PrisonMines.getInstance().getMineManager().saveMines(); - alreadyConverted.createNewFile(); - return new ConversionResult(getName(), ConversionResult.Status.Success, - "Converted " + jsonFiles.length + " mines."); - } else { - alreadyConverted.createNewFile(); - return new ConversionResult(getName(), ConversionResult.Status.Success, - "Converted 0 mines."); - } - } catch (IOException e) { - PrisonMines.getInstance().getErrorManager().throwError( - new Error("Encountered an error while converting mines.") - .appendStackTrace("while loading mines", e)); - return new ConversionResult(getName(), ConversionResult.Status.Failure, - "IOException, check console for details"); - } + + Output.get().logWarn( "&7This version of prison is unable to convert older versions " + + "to this release. Please upgrade first to Prision v3.1.1, then " + + "Prison v3.2.1, then Prison v3.2.11. Once prison is upgraded to " + + "version v3.2.11 then it should be able to convert automatically to " + + "Prison v3.3.0. When upgrading to all of these versions, all that is needed " + + "is to just install the newer Prison jar file, and then start the server. " + + "The configs will be converted for you. Then 'stop' the server and " + + "continue to the next version. You may be able to skip v3.2.1, but it " + + "may be safest to run that version for the incremental adjustments. " + + "It also would not be a bad idea to may a copy of the prison plugin " + + "directory betwen version upgrades: plugins/Prison/. " ); + + Output.get().logWarn( "&7NOTE: This version of prison cannot process the older block types that " + + "were used in the older versions of prison." ); + +// File oldFolder = new File(PrisonAPI.getPluginDirectory().getParent(), "Prison.old"); +// File minesFolder = new File(oldFolder, "mines"); +// +// File alreadyConverted = new File(minesFolder, ".converted"); +// if (alreadyConverted.exists()) { +// return ConversionResult.failure(getName(), +// "Already converted. Delete the '/plugins/Prison.old/mines' folder."); +// } +// +// String[] jsonFiles = minesFolder.list((dir, name) -> name.endsWith(".json")); +// +// try { +// +// // ----------- +// // JSON +// // ----------- +// +// if (jsonFiles != null) { +// for (String jsonFile : jsonFiles) { +// File jsonFileObj = new File(minesFolder, jsonFile); +// String json = new String(Files.readAllBytes(jsonFileObj.toPath())); +// JsonObject obj = (JsonObject) JsonParser.parseString(json); +// +// String name = obj.getAsJsonPrimitive("name").getAsString(); +// String world = obj.getAsJsonPrimitive("world").getAsString(); +// double minX = obj.getAsJsonPrimitive("minX").getAsInt(); +// double minY = obj.getAsJsonPrimitive("minY").getAsInt(); +// double minZ = obj.getAsJsonPrimitive("minZ").getAsInt(); +// double maxX = obj.getAsJsonPrimitive("maxX").getAsInt(); +// double maxY = obj.getAsJsonPrimitive("maxY").getAsInt(); +// double maxZ = obj.getAsJsonPrimitive("maxZ").getAsInt(); +// +// Optional prisonWorld = +// Prison.get().getPlatform().getWorld(world); +// if (!prisonWorld.isPresent()) { +// Output.get().logWarn(String.format( +// "Can't convert mine %s because its world %s doesn't exist anymore.", +// name, world)); +// break; // Skip it, its world didn't exist. +// } +// +// Bounds bounds = new Bounds(new Location(prisonWorld.get(), minX, minY, minZ), +// new Location(prisonWorld.get(), maxX, maxY, maxZ)); +// +// HashMap blocks = new HashMap<>(); +// for (Map.Entry blockEntry : obj.getAsJsonObject("blocks") +// .entrySet()) { +// String[] blockParts = blockEntry.getKey().split(":"); +// BlockType type = BlockType.getBlock(Integer.parseInt(blockParts[0]), +// Short.parseShort(blockParts[1])); +// +// // Prison 2 stores chances in values < 1, whereas Prison 3 does it < 100 +// int chance = (int) ((blockEntry.getValue().getAsDouble()) * 100); +// +// blocks.put(type, chance); +// } +// +// Mine ourMine = new Mine(); +// ourMine.setName(name); +// ourMine.setBounds(bounds); +// ourMine.setBlocks(blocks); +// +// if (PrisonMines.getInstance().getMines().contains(ourMine)) { +// break; +// } +// +// PrisonMines.getInstance().getMines().add(ourMine); +// } +// +// PrisonMines.getInstance().getMineManager().saveMines(); +// alreadyConverted.createNewFile(); +// return new ConversionResult(getName(), ConversionResult.Status.Success, +// "Converted " + jsonFiles.length + " mines."); +// } else { +// alreadyConverted.createNewFile(); +// return new ConversionResult(getName(), ConversionResult.Status.Success, +// "Converted 0 mines."); +// } +// } catch (IOException e) { +// PrisonMines.getInstance().getErrorManager().throwError( +// new Error("Encountered an error while converting mines.") +// .appendStackTrace("while loading mines", e)); +// return new ConversionResult(getName(), ConversionResult.Status.Failure, +// "IOException, check console for details"); +// } + + return ConversionResult.failure(getName(), + "This version of prison cannot perform conversion upgrades. It skips too " + + "many versions. See WARNING in console, and install the suggested older " + + "versions of Prison to ensure all of the old data is updated correctly, " + + "with no losses."); } @Override diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java index 44041d8e8..988ee84b1 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java @@ -1,7 +1,6 @@ package tech.mcprison.prison.mines.commands; import java.text.DecimalFormat; -import java.util.ArrayList; import java.util.List; import tech.mcprison.prison.Prison; @@ -12,15 +11,12 @@ import tech.mcprison.prison.internal.block.PrisonBlockStatusData; import tech.mcprison.prison.internal.block.PrisonBlockTypes; import tech.mcprison.prison.mines.PrisonMines; -import tech.mcprison.prison.mines.data.BlockOld; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.output.BulletedListComponent; import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.LogLevel; import tech.mcprison.prison.output.RowComponent; import tech.mcprison.prison.placeholders.PlaceholdersUtil; -import tech.mcprison.prison.util.BlockType; -import tech.mcprison.prison.util.MaterialType; public class MinesBlockCommands extends MinesCoreCommands @@ -90,59 +86,59 @@ public void addBlockCommand(CommandSender sender, } - else { - - BlockType blockType = BlockType.getBlock(block); - - if (blockType == null || blockType.getMaterialType() != MaterialType.BLOCK ) { - pMines.getMinesMessages().getLocalizable("not_a_block") - .withReplacements(block).sendTo(sender); - return; - } - - if (m.isInMine(blockType)) { - pMines.getMinesMessages().getLocalizable("block_already_added") - .sendTo(sender); - return; - } - - if ( chance <= 0 ) { - sender.sendMessage( "The percent chance must have a value greater than zero." ); - return; - } - - - BlockPercentTotal percentTotal = calculatePercentage( chance, blockType, m ); - - if ( percentTotal.getTotalChance() > 100.0d) { - pMines.getMinesMessages().getLocalizable("mine_full") - .sendTo(sender, LogLevel.ERROR); - return; - } - - // This is an add block function so if we get this far, add it: - if ( percentTotal.getOldBlock() == null ) { - // add the block since it does not exist in the mine: - m.getBlocks().add( new BlockOld( blockType, chance, 0) ); - } - else if ( chance <= 0 ) { - // block exists in mine, but chance is set to zero so remove it: - m.getBlocks().remove( percentTotal.getOldBlock() ); - } - else { - // update the block chance. The block in percentTotal comes from this mine - // so just update the chance: - percentTotal.getOldBlock().setChance( chance ); - } - - // Check if one of the blocks is effected by gravity, and if so, set that indicator. - m.checkGravityAffectedBlocks(); - - pMines.getMineManager().saveMine( m ); - - pMines.getMinesMessages().getLocalizable("block_added") - .withReplacements(block, mineName).sendTo(sender); - } +// else { +// +// BlockType blockType = BlockType.getBlock(block); +// +// if (blockType == null || blockType.getMaterialType() != MaterialType.BLOCK ) { +// pMines.getMinesMessages().getLocalizable("not_a_block") +// .withReplacements(block).sendTo(sender); +// return; +// } +// +// if (m.isInMine(blockType)) { +// pMines.getMinesMessages().getLocalizable("block_already_added") +// .sendTo(sender); +// return; +// } +// +// if ( chance <= 0 ) { +// sender.sendMessage( "The percent chance must have a value greater than zero." ); +// return; +// } +// +// +// BlockPercentTotal percentTotal = calculatePercentage( chance, blockType, m ); +// +// if ( percentTotal.getTotalChance() > 100.0d) { +// pMines.getMinesMessages().getLocalizable("mine_full") +// .sendTo(sender, LogLevel.ERROR); +// return; +// } +// +// // This is an add block function so if we get this far, add it: +// if ( percentTotal.getOldBlock() == null ) { +// // add the block since it does not exist in the mine: +// m.getBlocks().add( new BlockOld( blockType, chance, 0) ); +// } +// else if ( chance <= 0 ) { +// // block exists in mine, but chance is set to zero so remove it: +// m.getBlocks().remove( percentTotal.getOldBlock() ); +// } +// else { +// // update the block chance. The block in percentTotal comes from this mine +// // so just update the chance: +// percentTotal.getOldBlock().setChance( chance ); +// } +// +// // Check if one of the blocks is effected by gravity, and if so, set that indicator. +// m.checkGravityAffectedBlocks(); +// +// pMines.getMineManager().saveMine( m ); +// +// pMines.getMinesMessages().getLocalizable("block_added") +// .withReplacements(block, mineName).sendTo(sender); +// } getBlocksList(m, null, true ).send(sender); @@ -244,24 +240,26 @@ protected BulletedListComponent getBlocksList( Mine m, CommandPagedData cmdPageD } } } - if ( !m.isUseNewBlockModel() || !m.isUseNewBlockModel() && cmdPageData != null && cmdPageData.isDebug() ) - { - - for ( BlockOld block : m.getBlocks() ) - { - double chance = Math.round( block.getChance() * 100.0d ) / 100.0d; - totalChance += chance; - - totals.addStats( block ); - - if ( cmdPageData == null || count++ >= cmdPageData.getPageStart() && count <= cmdPageData.getPageEnd() ) - { - - addBlockStats( m, block, iFmt, dFmt, builder ); - - } - } - } + + // Obsolete... the old block model: +// if ( !m.isUseNewBlockModel() || !m.isUseNewBlockModel() && cmdPageData != null && cmdPageData.isDebug() ) +// { +// +// for ( BlockOld block : m.getBlocks() ) +// { +// double chance = Math.round( block.getChance() * 100.0d ) / 100.0d; +// totalChance += chance; +// +// totals.addStats( block ); +// +// if ( cmdPageData == null || count++ >= cmdPageData.getPageStart() && count <= cmdPageData.getPageEnd() ) +// { +// +// addBlockStats( m, block, iFmt, dFmt, builder ); +// +// } +// } +// } if ( totalChance < 100.0d ) { @@ -458,55 +456,55 @@ public void setBlockCommand(CommandSender sender, // } } - else { - - BlockType blockType = BlockType.getBlock(block); - if (blockType == null) { - pMines.getMinesMessages().getLocalizable("not_a_block"). - withReplacements(block).sendTo(sender); - return; - } - - // Change behavior: If trying to change a block that is not in the mine, then instead add it: - if (!m.isInMine(blockType)) { - addBlockCommand( sender, mineName, block, chance ); -// pMines.getMinesMessages().getLocalizable("block_not_removed") -// .sendTo(sender); - return; - } - - // If it's 0, just delete it! If the block is not in the mine, then nothing will happen. - if (chance <= 0.0d) { - deleteBlock( sender, pMines, m, blockType ); -// delBlockCommand(sender, mine, block); - return; - } - - - BlockPercentTotal percentTotal = calculatePercentage( chance, blockType, m ); - - - if ( percentTotal.getTotalChance() > 100.0d) { - pMines.getMinesMessages().getLocalizable("mine_full"). - sendTo(sender, LogLevel.ERROR); - return; - } - - // Block would have been added or deleted above, so if it gets here, then - // just update the block that's in the mine, which is stored in the percentTotal - // result object: - percentTotal.getOldBlock().setChance( chance ); - - - // Check if one of the blocks is effected by gravity, and if so, set that indicator. - m.checkGravityAffectedBlocks(); - - - pMines.getMineManager().saveMine( m ); - - pMines.getMinesMessages().getLocalizable("block_set") - .withReplacements(block, mineName).sendTo(sender); - } +// else { +// +// BlockType blockType = BlockType.getBlock(block); +// if (blockType == null) { +// pMines.getMinesMessages().getLocalizable("not_a_block"). +// withReplacements(block).sendTo(sender); +// return; +// } +// +// // Change behavior: If trying to change a block that is not in the mine, then instead add it: +// if (!m.isInMine(blockType)) { +// addBlockCommand( sender, mineName, block, chance ); +//// pMines.getMinesMessages().getLocalizable("block_not_removed") +//// .sendTo(sender); +// return; +// } +// +// // If it's 0, just delete it! If the block is not in the mine, then nothing will happen. +// if (chance <= 0.0d) { +// deleteBlock( sender, pMines, m, blockType ); +//// delBlockCommand(sender, mine, block); +// return; +// } +// +// +// BlockPercentTotal percentTotal = calculatePercentage( chance, blockType, m ); +// +// +// if ( percentTotal.getTotalChance() > 100.0d) { +// pMines.getMinesMessages().getLocalizable("mine_full"). +// sendTo(sender, LogLevel.ERROR); +// return; +// } +// +// // Block would have been added or deleted above, so if it gets here, then +// // just update the block that's in the mine, which is stored in the percentTotal +// // result object: +// percentTotal.getOldBlock().setChance( chance ); +// +// +// // Check if one of the blocks is effected by gravity, and if so, set that indicator. +// m.checkGravityAffectedBlocks(); +// +// +// pMines.getMineManager().saveMine( m ); +// +// pMines.getMinesMessages().getLocalizable("block_set") +// .withReplacements(block, mineName).sendTo(sender); +// } getBlocksList(m, null, true ).send(sender); @@ -516,22 +514,22 @@ public void setBlockCommand(CommandSender sender, } - private BlockPercentTotal calculatePercentage( double chance, BlockType blockType, Mine m ) { - BlockPercentTotal results = new BlockPercentTotal(); - results.addChance( chance ); - - for ( BlockOld block : m.getBlocks() ) { - if ( block.getType() == blockType ) { - // do not replace the block's chance since this may fail - results.setOldBlock( block ); - } - else { - results.addChance( block.getChance() ); - } - } - - return results; - } +// private BlockPercentTotal calculatePercentage( double chance, BlockType blockType, Mine m ) { +// BlockPercentTotal results = new BlockPercentTotal(); +// results.addChance( chance ); +// +// for ( BlockOld block : m.getBlocks() ) { +// if ( block.getType() == blockType ) { +// // do not replace the block's chance since this may fail +// results.setOldBlock( block ); +// } +// else { +// results.addChance( block.getChance() ); +// } +// } +// +// return results; +// } private BlockPercentTotal calculatePercentage( double chance, PrisonBlock prisonBlock, Mine m ) { BlockPercentTotal results = new BlockPercentTotal(); @@ -556,7 +554,7 @@ private BlockPercentTotal calculatePercentage( double chance, PrisonBlock prison protected class BlockPercentTotal { private double totalChance = 0d; - private BlockOld oldBlock = null; +// private BlockOld oldBlock = null; private PrisonBlock prisonBlock = null; public BlockPercentTotal() { @@ -572,12 +570,13 @@ public void setTotalChance( double totalChance ) { this.totalChance = totalChance; } - public BlockOld getOldBlock() { - return oldBlock; - } - public void setOldBlock( BlockOld oldBlock ) { - this.oldBlock = oldBlock; - } + // Obsolete... the old block model: +// public BlockOld getOldBlock() { +// return oldBlock; +// } +// public void setOldBlock( BlockOld oldBlock ) { +// this.oldBlock = oldBlock; +// } public PrisonBlock getPrisonBlock() { return prisonBlock; @@ -636,23 +635,23 @@ public void delBlockCommand(CommandSender sender, } } - else { - - BlockType blockType = BlockType.getBlock(block); - if (blockType == null) { - pMines.getMinesMessages().getLocalizable("not_a_block") - .withReplacements(block).sendTo(sender); - return; - } - - if (!m.isInMine(blockType)) { - pMines.getMinesMessages().getLocalizable("block_not_removed") - .sendTo(sender); - return; - } - - deleteBlock( sender, pMines, m, blockType ); - } +// else { +// +// BlockType blockType = BlockType.getBlock(block); +// if (blockType == null) { +// pMines.getMinesMessages().getLocalizable("not_a_block") +// .withReplacements(block).sendTo(sender); +// return; +// } +// +// if (!m.isInMine(blockType)) { +// pMines.getMinesMessages().getLocalizable("block_not_removed") +// .sendTo(sender); +// return; +// } +// +// deleteBlock( sender, pMines, m, blockType ); +// } getBlocksList(m, null, true).send(sender); } @@ -677,34 +676,36 @@ private void deleteBlock( CommandSender sender, PrisonMines pMines, Mine m, Pris withReplacements(prisonBlock.getBlockName(), m.getTag()).sendTo(sender); } } - /** - * Delete only the first occurrence of a block with the given BlockType. - * - * @param sender - * @param pMines - * @param m - * @param blockType - */ - private void deleteBlock( CommandSender sender, PrisonMines pMines, Mine m, BlockType blockType ) - { - BlockOld rBlock = null; - for ( BlockOld block : m.getBlocks() ) { - if ( block.getType() == blockType ) { - rBlock = block; - break; - } - } - if ( m.getBlocks().remove( rBlock )) { - - // Check if one of the blocks is effected by gravity, and if so, set that indicator. - m.checkGravityAffectedBlocks(); - - pMines.getMineManager().saveMine( m ); - - pMines.getMinesMessages().getLocalizable("block_deleted") - .withReplacements(blockType.name(), m.getTag()).sendTo(sender); - } - } + + +// /** +// * Delete only the first occurrence of a block with the given BlockType. +// * +// * @param sender +// * @param pMines +// * @param m +// * @param blockType +// */ +// private void deleteBlock( CommandSender sender, PrisonMines pMines, Mine m, BlockType blockType ) +// { +// BlockOld rBlock = null; +// for ( BlockOld block : m.getBlocks() ) { +// if ( block.getType() == blockType ) { +// rBlock = block; +// break; +// } +// } +// if ( m.getBlocks().remove( rBlock )) { +// +// // Check if one of the blocks is effected by gravity, and if so, set that indicator. +// m.checkGravityAffectedBlocks(); +// +// pMines.getMineManager().saveMine( m ); +// +// pMines.getMinesMessages().getLocalizable("block_deleted") +// .withReplacements(blockType.name(), m.getTag()).sendTo(sender); +// } +// } public void searchBlockCommand(CommandSender sender, String search, @@ -726,11 +727,13 @@ public void searchBlockCommand(CommandSender sender, display = prisonBlockSearchBuilder(search, page, true, blockSeachCommand, commandBlockAdd, targetText ); } - else { - - display = blockSearchBuilder(search, page, true, - blockSeachCommand, commandBlockAdd, targetText ); - } + + // Obsolete... the old block model: +// else { +// +// display = blockSearchBuilder(search, page, true, +// blockSeachCommand, commandBlockAdd, targetText ); +// } display.send(sender); @@ -757,11 +760,13 @@ public void searchBlockAllCommand(CommandSender sender, display = prisonBlockSearchBuilder(search, page, false, blockSeachCommand, commandBlockAdd, targetText ); } - else { - - display = blockSearchBuilder(search, page, false, - blockSeachCommand, commandBlockAdd, targetText ); - } + + // Obsolete... the old block model: +// else { +// +// display = blockSearchBuilder(search, page, false, +// blockSeachCommand, commandBlockAdd, targetText ); +// } display.send(sender); @@ -829,75 +834,76 @@ private ChatDisplay prisonBlockSearchBuilder(String search, String page, return display; } - private ChatDisplay blockSearchBuilder(String search, String page, - boolean restrictToBlocks, - String commandBlockSearch, - String commandBlockAdd, - String targetText ) - { - List blocks = new ArrayList<>(); - for (BlockType block : BlockType.values()) - { - if ( (!restrictToBlocks || restrictToBlocks && block.getMaterialType() == MaterialType.BLOCK) && - (block.getId().contains(search.toLowerCase()) || - block.name().toLowerCase().contains(search.toLowerCase())) ) - { - blocks.add(block); - } - } - - - CommandPagedData cmdPageData = new CommandPagedData( - "/" + commandBlockSearch + " " + search, blocks.size(), - 0, page ); - - // Same page logic as in mines info -// int curPage = 1; -// int pageSize = 10; -// int pages = (blocks.size() / pageSize) + 1; -// try -// { -// curPage = Integer.parseInt(page); -// } -// catch ( NumberFormatException e ) + // Obsolete... the old block model: +// private ChatDisplay blockSearchBuilder(String search, String page, +// boolean restrictToBlocks, +// String commandBlockSearch, +// String commandBlockAdd, +// String targetText ) +// { +// List blocks = new ArrayList<>(); +// for (BlockType block : BlockType.values()) // { -// // Ignore: Not an integer, will use the default value. +// if ( (!restrictToBlocks || restrictToBlocks && block.getMaterialType() == MaterialType.BLOCK) && +// (block.getId().contains(search.toLowerCase()) || +// block.name().toLowerCase().contains(search.toLowerCase())) ) +// { +// blocks.add(block); +// } // } -// curPage = ( curPage < 1 ? 1 : (curPage > pages ? pages : curPage )); -// int pageStart = (curPage - 1) * pageSize; -// int pageEnd = ((pageStart + pageSize) > blocks.size() ? blocks.size() : pageStart + pageSize); - - - ChatDisplay display = new ChatDisplay("Block Search (" + blocks.size() + ")"); - display.addText("&8Click a block to add it to a " + targetText + "."); - - BulletedListComponent.BulletedListBuilder builder = - new BulletedListComponent.BulletedListBuilder(); - for ( int i = cmdPageData.getPageStart(); i < cmdPageData.getPageEnd(); i++ ) - { - BlockType block = blocks.get(i); - FancyMessage msg = - new FancyMessage( - String.format("&7%s %s (%s)%s (%s)", - Integer.toString(i), block.name(), - block.getId().replace("minecraft:", ""), - (block.getMaterialVersion() == null ? "" : - "(" + block.getMaterialVersion() + ")"), - (block.isBlock() ? "block": "item")) - ) - .suggest("/" + commandBlockAdd + " " + getLastMineReferenced() + " " + block.name() + " %") - .tooltip("&7Click to add block to a " + targetText + "."); - builder.add(msg); - } - display.addComponent(builder.build()); - - // This command plus parameters used: -// String pageCmd = "/mines block search " + search; - - cmdPageData.generatePagedCommandFooter( display ); - - return display; - } +// +// +// CommandPagedData cmdPageData = new CommandPagedData( +// "/" + commandBlockSearch + " " + search, blocks.size(), +// 0, page ); +// +// // Same page logic as in mines info +//// int curPage = 1; +//// int pageSize = 10; +//// int pages = (blocks.size() / pageSize) + 1; +//// try +//// { +//// curPage = Integer.parseInt(page); +//// } +//// catch ( NumberFormatException e ) +//// { +//// // Ignore: Not an integer, will use the default value. +//// } +//// curPage = ( curPage < 1 ? 1 : (curPage > pages ? pages : curPage )); +//// int pageStart = (curPage - 1) * pageSize; +//// int pageEnd = ((pageStart + pageSize) > blocks.size() ? blocks.size() : pageStart + pageSize); +// +// +// ChatDisplay display = new ChatDisplay("Block Search (" + blocks.size() + ")"); +// display.addText("&8Click a block to add it to a " + targetText + "."); +// +// BulletedListComponent.BulletedListBuilder builder = +// new BulletedListComponent.BulletedListBuilder(); +// for ( int i = cmdPageData.getPageStart(); i < cmdPageData.getPageEnd(); i++ ) +// { +// BlockType block = blocks.get(i); +// FancyMessage msg = +// new FancyMessage( +// String.format("&7%s %s (%s)%s (%s)", +// Integer.toString(i), block.name(), +// block.getId().replace("minecraft:", ""), +// (block.getMaterialVersion() == null ? "" : +// "(" + block.getMaterialVersion() + ")"), +// (block.isBlock() ? "block": "item")) +// ) +// .suggest("/" + commandBlockAdd + " " + getLastMineReferenced() + " " + block.name() + " %") +// .tooltip("&7Click to add block to a " + targetText + "."); +// builder.add(msg); +// } +// display.addComponent(builder.build()); +// +// // This command plus parameters used: +//// String pageCmd = "/mines block search " + search; +// +// cmdPageData.generatePagedCommandFooter( display ); +// +// return display; +// } @@ -944,9 +950,10 @@ public void listBlockCommand(CommandSender sender, if ( m.isUseNewBlockModel() ) { blockSize = m.getPrisonBlocks().size(); } - else { - blockSize = m.getBlocks().size(); - } + +// else { +// blockSize = m.getBlocks().size(); +// } if ( blockSize == 0 ) { String message = blockSize != 0 ? null : " &cNo Blocks Defined"; @@ -1026,9 +1033,10 @@ public void constraintsBlockCommand(CommandSender sender, if ( m.isUseNewBlockModel() ) { block = m.getPrisonBlock( blockName ); } - else { - block = m.getBlockOld( blockName ); - } + +// else { +// block = m.getBlockOld( blockName ); +// } if ( "min".equalsIgnoreCase( constraint ) ) { 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 322edb930..624511635 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 @@ -817,12 +817,13 @@ public void infoCommand(CommandSender sender, "/mines info " + m.getName(), m.getPrisonBlocks().size(), 1, page ); } - else { - - cmdPageData = new CommandPagedData( - "/mines info " + m.getName(), m.getBlocks().size(), - 1, page ); - } + +// else { +// +// cmdPageData = new CommandPagedData( +// "/mines info " + m.getName(), m.getBlocks().size(), +// 1, page ); +// } // // Same page logic as in mines block search: // int curPage = 1; @@ -849,9 +850,9 @@ public void infoCommand(CommandSender sender, if ( m.isUseNewBlockModel() ) { blockSize = m.getPrisonBlocks().size(); } - else { - blockSize = m.getBlocks().size(); - } +// else { +// blockSize = m.getBlocks().size(); +// } String message = blockSize != 0 ? null : " &cNo Blocks Defined"; cmdPageData.generatePagedCommandFooter( chatDisplay, message ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/BlockOld.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/BlockOld.java index 18048626f..adaeb4fc7 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/BlockOld.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/BlockOld.java @@ -19,37 +19,39 @@ package tech.mcprison.prison.mines.data; import tech.mcprison.prison.internal.block.PrisonBlockStatusData; -import tech.mcprison.prison.util.BlockType; +import tech.mcprison.prison.util.ObsoleteBlockType; /** * Represents a block in a mine + * + * @deprecated */ public class BlockOld extends PrisonBlockStatusData implements Comparable { - public static final BlockOld AIR = new BlockOld( BlockType.AIR ); - public static final BlockOld IGNORE = new BlockOld( BlockType.IGNORE ); - public static final BlockOld NULL_BLOCK = new BlockOld( BlockType.NULL_BLOCK ); + public static final BlockOld AIR = new BlockOld( ObsoleteBlockType.AIR ); + public static final BlockOld IGNORE = new BlockOld( ObsoleteBlockType.IGNORE ); + public static final BlockOld NULL_BLOCK = new BlockOld( ObsoleteBlockType.NULL_BLOCK ); /** * The {@link BlockType} represented by this {@link BlockOld} */ - private BlockType type; // = BlockType.AIR; + private ObsoleteBlockType type; // = BlockType.AIR; /** * The chance of this block appearing in it's associated mine */ // private double chance; // = 100.0d; - protected BlockOld( BlockType block ) { + protected BlockOld( ObsoleteBlockType block ) { this( block, 0.0d, 0L ); } /** * Assigns the type and chance */ - public BlockOld(BlockType block, double chance, long blockCountTotal) { + public BlockOld(ObsoleteBlockType block, double chance, long blockCountTotal) { super((block == null ? BlockOld.AIR.getBlockName() : block.name()), chance, blockCountTotal); this.type = block; @@ -61,7 +63,7 @@ public BlockOld(String blockType, double chance, long blockCountTotal) { // this.chance = chance; - BlockType block = BlockType.fromString( blockType ); + ObsoleteBlockType block = ObsoleteBlockType.fromString( blockType ); this.type = block; // Update blockName since mapping to BlockType may result in a different name: setBlockName( block.name() ); @@ -100,11 +102,11 @@ public int compareTo( BlockOld block ) return results; } - public BlockType getType() + public ObsoleteBlockType getType() { return type; } - public void setType( BlockType type ) + public void setType( ObsoleteBlockType type ) { this.type = type; } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java index cb4b00034..38e819520 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java @@ -37,13 +37,14 @@ import tech.mcprison.prison.selection.Selection; import tech.mcprison.prison.sorting.PrisonSortable; import tech.mcprison.prison.store.Document; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Bounds; import tech.mcprison.prison.util.Location; +import tech.mcprison.prison.util.ObsoleteBlockType; /** * @author Dylan M. Perks */ +@SuppressWarnings( "deprecation" ) public class Mine extends MineScheduler implements PrisonSortable, Comparable { @@ -198,7 +199,7 @@ protected void initialize() { * @param document * @throws MineException */ - @SuppressWarnings( "unchecked" ) + @SuppressWarnings( { "unchecked" } ) private void loadFromDocument( Document document ) throws MineException { @@ -335,7 +336,7 @@ private void loadFromDocument( Document document ) if ( blockTypeName != null && !validateBlockNames.contains( blockTypeName )) { // Use the BlockType.name() load the block type: - BlockType blockType = BlockType.getBlock(blockTypeName); + ObsoleteBlockType blockType = ObsoleteBlockType.getBlock(blockTypeName); if ( blockType != null ) { @@ -354,9 +355,9 @@ private void loadFromDocument( Document document ) "mine %s. %s is not a valid block type. Using " + "%s instead. If this is incorrect please fix manually."; - if ( blockType == BlockType.REDSTONE ) { - BlockType itemType = blockType; - blockType = BlockType.REDSTONE_ORE; + if ( blockType == ObsoleteBlockType.REDSTONE ) { + ObsoleteBlockType itemType = blockType; + blockType = ObsoleteBlockType.REDSTONE_ORE; Output.get().logError( String.format( errorMessage, itemType.name(), getName(), @@ -364,9 +365,9 @@ private void loadFromDocument( Document document ) dirty = true; } - else if ( blockType == BlockType.NETHER_BRICK ) { - BlockType itemType = blockType; - blockType = BlockType.DOUBLE_NETHER_BRICK_SLAB; + else if ( blockType == ObsoleteBlockType.NETHER_BRICK ) { + ObsoleteBlockType itemType = blockType; + blockType = ObsoleteBlockType.DOUBLE_NETHER_BRICK_SLAB; Output.get().logError( String.format( errorMessage, itemType.name(), getName(), @@ -498,6 +499,8 @@ else if ( validateBlockNames.contains( prisonBlock.getBlockName() ) ) { checkGravityAffectedBlocks(); + // Using the Obsolete old block model for conversion to the new block model + // NOTE: This is the ONLY place were we are allowed to use the old block model! ;) if ( isUseNewBlockModel() && getPrisonBlocks().size() == 0 && getBlocks().size() > 0 ) { // Need to perform the initial conversion: @@ -580,7 +583,7 @@ else if ( validateBlockNames.contains( prisonBlock.getBlockName() ) ) { } - public Document toDocument() { + public Document toDocument() { Document ret = new Document(); // If world name is not set, try to get it from the bounds: @@ -644,6 +647,10 @@ public Document toDocument() { // This is a validation set to ensure only one block is written to file system: Set validateBlockNames = new HashSet<>(); + // NOTE: This is using the obsolete old block model!! + // This is the ONLY SECOND place where we can use the old block model! + // We want to "preserve" the old blocks that may have been setup up in the mines + // originally. In a future release, these may be purged. List blockStrings = new ArrayList<>(); for (BlockOld block : getBlocks()) { if ( !validateBlockNames.contains( block.getType().name() )) { @@ -782,14 +789,16 @@ public String getBlockListString() sb.append( block.toString() ); } } - else { - for ( BlockOld block : getBlocks() ) { - if ( sb.length() > 0 ) { - sb.append( ", " ); - } - sb.append( block.toString() ); - } - } + + // Obsolete... the old block model: +// else { +// for ( BlockOld block : getBlocks() ) { +// if ( sb.length() > 0 ) { +// sb.append( ", " ); +// } +// sb.append( block.toString() ); +// } +// } sb.insert( 0, ": [" ); sb.append( "]" ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java index e6dcf50cc..3ba70e1d4 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java @@ -1,10 +1,8 @@ package tech.mcprison.prison.mines.data; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.TreeMap; @@ -12,7 +10,6 @@ import tech.mcprison.prison.Prison; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.World; -import tech.mcprison.prison.internal.block.Block; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; @@ -23,7 +20,6 @@ import tech.mcprison.prison.modules.ModuleElement; import tech.mcprison.prison.modules.ModuleElementType; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Bounds; import tech.mcprison.prison.util.Location; @@ -84,11 +80,15 @@ public abstract class MineData private int resetCount = 0; /** + * These blocks are obsolete, and are no longer used in prison, but they + * are preserved for now. Will be removed in the future. + * * This list of blocks represents the old Prison block model. It is being * phased out since it has limited flexibility and complex issues with * supporting magic values with the older bukkit versions. */ - private List blocks; + @SuppressWarnings( "deprecation" ) + private List blocks; /** * This list of PrisonBlocks represents the new Prison block model. Its @@ -462,7 +462,17 @@ public void setBounds(Bounds bounds) { - public List getBlocks() { + /** + *

This is the old block model's blocks and is depreacated for now. + * We don't want to purge the old blocks yet, but they won't be used in + * any source code in Prison. + *

+ * + * @deprecated + * @return + */ + @SuppressWarnings( "deprecation" ) + public List getBlocks() { return blocks; } @@ -506,30 +516,31 @@ public boolean removePrisonBlock( PrisonBlock prisonBlock ) { return results; } - /** - * This is only used in an obsolete conversion utility. - * - * Adding the newer PrisonBlocks for compatibility. - * - * Sets the blocks for this mine - * - * @param blockMap the new blockmap with the {@link BlockType} as the key, and the chance of the - * block appearing as the value. - */ - public void setBlocks(HashMap blockMap) { - this.blocks.clear(); - this.prisonBlocks.clear(); - - for (Map.Entry entry : blockMap.entrySet()) { - blocks.add(new BlockOld(entry.getKey(), entry.getValue(), 0)); - - PrisonBlock prisonBlock = Prison.get().getPlatform().getPrisonBlock( entry.getKey().name() ); - if ( prisonBlock != null ) { - prisonBlock.setChance( entry.getValue() ); - prisonBlocks.add( prisonBlock ); - } - } - } + // Obsolete... the old block model: +// /** +// * This is only used in an obsolete conversion utility. +// * +// * Adding the newer PrisonBlocks for compatibility. +// * +// * Sets the blocks for this mine +// * +// * @param blockMap the new blockmap with the {@link BlockType} as the key, and the chance of the +// * block appearing as the value. +// */ +// public void setBlocks(HashMap blockMap) { +// this.blocks.clear(); +// this.prisonBlocks.clear(); +// +// for (Map.Entry entry : blockMap.entrySet()) { +// blocks.add(new BlockOld(entry.getKey(), entry.getValue(), 0)); +// +// PrisonBlock prisonBlock = Prison.get().getPlatform().getPrisonBlock( entry.getKey().name() ); +// if ( prisonBlock != null ) { +// prisonBlock.setChance( entry.getValue() ); +// prisonBlocks.add( prisonBlock ); +// } +// } +// } public PrisonBlock getPrisonBlock(String blockName ) { PrisonBlock results = null; @@ -546,20 +557,20 @@ public PrisonBlock getPrisonBlock(String blockName ) { return results; } - public BlockOld getBlockOld(String blockName ) { - BlockOld results = null; - - if ( blockName != null && !blockName.trim().isEmpty() ) { - for ( BlockOld b : getBlocks() ) { - if ( b.getBlockName().equalsIgnoreCase( blockName ) ) { - results = b; - break; - } - } - } - - return results; - } +// public BlockOld getBlockOld(String blockName ) { +// BlockOld results = null; +// +// if ( blockName != null && !blockName.trim().isEmpty() ) { +// for ( BlockOld b : getBlocks() ) { +// if ( b.getBlockName().equalsIgnoreCase( blockName ) ) { +// results = b; +// break; +// } +// } +// } +// +// return results; +// } public boolean hasBlock( String blockName ) { boolean results = false; @@ -569,9 +580,11 @@ public boolean hasBlock( String blockName ) { if ( isUseNewBlockModel() ) { results = getPrisonBlock( blockName ) != null; } - else { - results = getBlockOld( blockName ) != null; - } + + // Obsolete... the old block model: +// else { +// results = getBlockOld( blockName ) != null; +// } } return results; @@ -723,7 +736,7 @@ public boolean incrementBlockMiningCount( MineTargetPrisonBlock targetPrisonBloc // } - abstract public MineTargetPrisonBlock getTargetPrisonBlock( Block block ); + abstract public MineTargetPrisonBlock getTargetPrisonBlock( PrisonBlock block ); // abstract public String getTargetPrisonBlockName( Block block ); @@ -824,17 +837,19 @@ public PrisonBlockStatusData getBlockStats( String blockName ) { } } } - else { - - for ( BlockOld block : getBlocks() ) { - if ( block.getBlockName().equalsIgnoreCase( blockName ) ) { - getBlockStats().put( block.getBlockName(), block ); - - results = block; - break; - } - } - } + + // Obsolete... the old block model: +// else { +// +// for ( BlockOld block : getBlocks() ) { +// if ( block.getBlockName().equalsIgnoreCase( blockName ) ) { +// getBlockStats().put( block.getBlockName(), block ); +// +// results = block; +// break; +// } +// } +// } } else { @@ -866,18 +881,19 @@ public boolean isInMineIncludeTopBottomOfMine(Location location) { return getBounds().withinIncludeTopBottomOfMine( location ); } - public boolean isInMine(BlockType blockType) { - //TODO Not sure if virtual should return false... they do have blocks. -// if ( isVirtual() ) { -// return false; -// } - for (BlockOld block : getBlocks()) { - if (blockType == block.getType()) { - return true; - } - } - return false; - } + // Obsolete... the old block model: +// public boolean isInMine(BlockType blockType) { +// //TODO Not sure if virtual should return false... they do have blocks. +//// if ( isVirtual() ) { +//// return false; +//// } +// for (BlockOld block : getBlocks()) { +// if (blockType == block.getType()) { +// return true; +// } +// } +// return false; +// } public boolean isInMine(PrisonBlock blockType) { //TODO Not sure if virtual should return false... they do have blocks. diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index 174e0ed4a..8aa3b19cd 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -30,7 +30,6 @@ import tech.mcprison.prison.tasks.PrisonCommandTask; import tech.mcprison.prison.tasks.PrisonRunnable; import tech.mcprison.prison.tasks.PrisonTaskSubmitter; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Bounds; import tech.mcprison.prison.util.Bounds.Edges; import tech.mcprison.prison.util.Location; @@ -597,22 +596,24 @@ public void generateBlockListAsync() { airCount++; } } - else { - - - BlockOld tBlock = randomlySelectBlock( random, currentLevel ); - - // Increment the mine's block count. This block is one of the control blocks: - incrementResetBlockCount( tBlock ); - - addMineTargetPrisonBlock( tBlock, x, y, z, isEdge ); -// mtb = new MineTargetBlock( tBlock.getType(), x, y, z); - - if ( tBlock.equals( BlockOld.AIR ) ) { -// mAirBlocks[i++] = true; - airCount++; - } - } + +// // Obsolete... the old block model: +// else { +// +// +// BlockOld tBlock = randomlySelectBlock( random, currentLevel ); +// +// // Increment the mine's block count. This block is one of the control blocks: +// incrementResetBlockCount( tBlock ); +// +// addMineTargetPrisonBlock( tBlock, x, y, z, isEdge ); +//// mtb = new MineTargetBlock( tBlock.getType(), x, y, z); +// +// if ( tBlock.equals( BlockOld.AIR ) ) { +//// mAirBlocks[i++] = true; +// airCount++; +// } +// } } } @@ -1157,16 +1158,16 @@ else if ( isUseNewBlockModel() && // not registered and tracked within prison, and hence will report incorrect errors. setAirCount( 0 ); } - else if ( !isUseNewBlockModel() && - getBlocks().size() == 1 && - getBlocks().get( 0 ).getType() == BlockType.IGNORE ) { - - // This mine is set to ignore all blocks when trying to do a reset, - // so for now ignore the types and just set air count to zero. - // Basically, this mine, if using natural spawned landscape, may contain blocks that are - // not registered and tracked within prison, and hence will report incorrect errors. - setAirCount( 0 ); - } +// else if ( !isUseNewBlockModel() && +// getBlocks().size() == 1 && +// getBlocks().get( 0 ).getType() == BlockType.IGNORE ) { +// +// // This mine is set to ignore all blocks when trying to do a reset, +// // so for now ignore the types and just set air count to zero. +// // Basically, this mine, if using natural spawned landscape, may contain blocks that are +// // not registered and tracked within prison, and hence will report incorrect errors. +// setAirCount( 0 ); +// } else { long start = System.currentTimeMillis(); Optional worldOptional = getWorld(); @@ -1238,21 +1239,23 @@ else if ( !isUseNewBlockModel() && airCount++; } } - else { - - BlockOld oBlock = new BlockOld( tBlock.getType() ); - - if ( oBlock != null ) { - - // Increment the mine's block count. This block is one of the control blocks: - addMineTargetPrisonBlock( incrementResetBlockCount( oBlock ), x, y, z, isEdge ); - - } - - if ( tBlock.getType() == BlockType.AIR ) { - airCount++; - } - } + + // Obsolete... the old block model: +// else { +// +// BlockOld oBlock = new BlockOld( tBlock.getType() ); +// +// if ( oBlock != null ) { +// +// // Increment the mine's block count. This block is one of the control blocks: +// addMineTargetPrisonBlock( incrementResetBlockCount( oBlock ), x, y, z, isEdge ); +// +// } +// +// if ( tBlock.getType() == BlockType.AIR ) { +// airCount++; +// } +// } } catch ( Exception e ) { // Updates to the "world" should never be ran async. Upon review of the above @@ -1538,69 +1541,70 @@ else if ( getPercentRemainingBlockCount() > getSkipResetPercent() ) { // return prisonBlock; // } - private BlockOld randomlySelectBlock( Random random, int currentLevel ) { - - int targetBlockPosition = getMineTargetPrisonBlocks().size(); - - BlockOld results = BlockOld.AIR; - - - // this fallbackBlock field will provide a valid block that can be used when all other - // blocks have failed to be matched due to constraints not aligning with the random chance. - // As a result of failing to find a block, would result in an AIR block being used instead. - BlockOld fallbackBlock = null; - - - - // If a chosen block was skipped, try to find another block, but try no more than 10 times - // to prevent a possible endless loop. Side effects of failing to find a block in 10 attempts - // would be an air block. - boolean success = false; - int attempts = 0; - while ( !success && attempts++ < 10 ) { - double chance = random.nextDouble() * 100.0d; - - for (BlockOld block : getBlocks()) { - boolean isBlockEnabled = block.isBlockConstraintsEnbled( currentLevel, targetBlockPosition ); - - if ( fallbackBlock == null && isBlockEnabled && !block.isAir() ) { - fallbackBlock = block; - } - - if ( chance <= block.getChance() && isBlockEnabled ) { - - // If this block is chosen and it was not skipped, then use this block and exit. - // Otherwise the chance will be recalculated and tried again to find a valid block, - // since the odds have been thrown off... - results = block; - - // stop trying to locate a block so success will terminate the search: - success = true; - - break; - } else { - chance -= block.getChance(); - } - } - } - - if ( !success && fallbackBlock != null ) { - results = fallbackBlock; - success = true; - } - -// for (BlockOld block : getBlocks()) { -// if (block.checkConstraints( currentLevel, targetBlockPosition ) && -// chance <= block.getChance() && -// (block.getConstraintMax() == 0 || block.getResetBlockCount() < block.getConstraintMax())) { -// results = block; -// break; -// } else { -// chance -= block.getChance(); + // Obsolete... the old block model: +// private BlockOld randomlySelectBlock( Random random, int currentLevel ) { +// +// int targetBlockPosition = getMineTargetPrisonBlocks().size(); +// +// BlockOld results = BlockOld.AIR; +// +// +// // this fallbackBlock field will provide a valid block that can be used when all other +// // blocks have failed to be matched due to constraints not aligning with the random chance. +// // As a result of failing to find a block, would result in an AIR block being used instead. +// BlockOld fallbackBlock = null; +// +// +// +// // If a chosen block was skipped, try to find another block, but try no more than 10 times +// // to prevent a possible endless loop. Side effects of failing to find a block in 10 attempts +// // would be an air block. +// boolean success = false; +// int attempts = 0; +// while ( !success && attempts++ < 10 ) { +// double chance = random.nextDouble() * 100.0d; +// +// for (BlockOld block : getBlocks()) { +// boolean isBlockEnabled = block.isBlockConstraintsEnbled( currentLevel, targetBlockPosition ); +// +// if ( fallbackBlock == null && isBlockEnabled && !block.isAir() ) { +// fallbackBlock = block; +// } +// +// if ( chance <= block.getChance() && isBlockEnabled ) { +// +// // If this block is chosen and it was not skipped, then use this block and exit. +// // Otherwise the chance will be recalculated and tried again to find a valid block, +// // since the odds have been thrown off... +// results = block; +// +// // stop trying to locate a block so success will terminate the search: +// success = true; +// +// break; +// } else { +// chance -= block.getChance(); +// } // } // } - return results; - } +// +// if ( !success && fallbackBlock != null ) { +// results = fallbackBlock; +// success = true; +// } +// +//// for (BlockOld block : getBlocks()) { +//// if (block.checkConstraints( currentLevel, targetBlockPosition ) && +//// chance <= block.getChance() && +//// (block.getConstraintMax() == 0 || block.getResetBlockCount() < block.getConstraintMax())) { +//// results = block; +//// break; +//// } else { +//// chance -= block.getChance(); +//// } +//// } +// return results; +// } private void constraintsApplyMin() { @@ -1611,12 +1615,14 @@ private void constraintsApplyMin() { constraintsApplyMin( block, isUseNewBlockModel() ); } } - else { - - for ( PrisonBlockStatusData block : getBlocks() ) { - constraintsApplyMin( block, isUseNewBlockModel() ); - } - } + + // Obsolete... the old block model: +// else { +// +// for ( PrisonBlockStatusData block : getBlocks() ) { +// constraintsApplyMin( block, isUseNewBlockModel() ); +// } +// } } @@ -1812,12 +1818,18 @@ public TreeMap getMineTargetPrisonBlo return mineTargetPrisonBlocksMap; } - public MineTargetPrisonBlock getTargetPrisonBlock( Block block ) { + public MineTargetPrisonBlock getTargetPrisonBlock( PrisonBlock block ) { + MineTargetPrisonBlock results = null; - Location loc = block.getLocation(); - MineTargetBlockKey key = new MineTargetBlockKey( loc ); + if ( block != null && block.getLocation() != null ) { + + Location loc = block.getLocation(); + MineTargetBlockKey key = new MineTargetBlockKey( loc ); + + results = getMineTargetPrisonBlocksMap().get( key ); + } - return getMineTargetPrisonBlocksMap().get( key ); + return results; } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java index 81aad5ad0..c91620676 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java @@ -12,7 +12,6 @@ import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.mines.features.MineLinerData.LadderType; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Bounds; import tech.mcprison.prison.util.Bounds.Edges; import tech.mcprison.prison.util.Location; @@ -406,50 +405,53 @@ else if ( isForced || } } - else { - - if ( REPAIR_LINER.equalsIgnoreCase( nextBlockName ) ) { - - -// Output.get().logInfo( "#### repair : isLadderBlock: %s block types: tb: %s tb1: %s tb2: %s", -// (isLadderBlock ? "Y" : "-" ), -// tBlock.getType(), tBlockPlus1.getType(), tBlockPlus2.getType() ); + + + // Obsolte old block model: +// else { +// +// if ( REPAIR_LINER.equalsIgnoreCase( nextBlockName ) ) { // - if ( isLadderBlock ) { - - tBlock.setType( tBlockPlus2.getType() ); - tBlockPlus1.setType( tBlockPlus2.getType() ); - } - else { - - tBlock.setType( tBlockPlus1.getType() ); - } - } - - else if ( isForced || - !tBlock.isEmpty() || - isLadderBlock && !tBlockPlus1.isEmpty() ) { - - BlockType nextBlockType = BlockType.fromString( nextBlockName ); -// if ( nextBlockType == null ) { -// nextBlockType = BlockType.fromString( nextBlockName ); +// +//// Output.get().logInfo( "#### repair : isLadderBlock: %s block types: tb: %s tb1: %s tb2: %s", +//// (isLadderBlock ? "Y" : "-" ), +//// tBlock.getType(), tBlockPlus1.getType(), tBlockPlus2.getType() ); +//// +// if ( isLadderBlock ) { +// +// tBlock.setType( tBlockPlus2.getType() ); +// tBlockPlus1.setType( tBlockPlus2.getType() ); // } - - if ( isLadderBlock ) { - - tBlockPlus1.setType( nextBlockType ); - - BlockType ladderBlockType = BlockType.LADDER; - tBlock.setType( ladderBlockType ); - tBlock.setBlockFace( blockFace ); - } - else { - - tBlock.setType( nextBlockType ); - } - - } - } +// else { +// +// tBlock.setType( tBlockPlus1.getType() ); +// } +// } +// +// else if ( isForced || +// !tBlock.isEmpty() || +// isLadderBlock && !tBlockPlus1.isEmpty() ) { +// +// BlockType nextBlockType = BlockType.fromString( nextBlockName ); +//// if ( nextBlockType == null ) { +//// nextBlockType = BlockType.fromString( nextBlockName ); +//// } +// +// if ( isLadderBlock ) { +// +// tBlockPlus1.setType( nextBlockType ); +// +// BlockType ladderBlockType = BlockType.LADDER; +// tBlock.setType( ladderBlockType ); +// tBlock.setBlockFace( blockFace ); +// } +// else { +// +// tBlock.setType( nextBlockType ); +// } +// +// } +// } } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java index 96c407585..d51f0289d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java @@ -50,11 +50,11 @@ import tech.mcprison.prison.internal.events.world.PrisonWorldLoadEvent; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; +import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.compat.Compatibility; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.game.SpigotWorld; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.ChatColor; import tech.mcprison.prison.util.Location; @@ -170,11 +170,11 @@ public void onPlayerSuffocation( EntityDamageEvent e ) { @EventHandler public void onBlockPlace(BlockPlaceEvent e) { org.bukkit.Location block = e.getBlockPlaced().getLocation(); - BlockType blockType = SpigotUtil.blockToBlockType( e.getBlock() ); + SpigotBlock sBlock = new SpigotBlock( e.getBlock() ); tech.mcprison.prison.internal.events.block.BlockPlaceEvent event = new tech.mcprison.prison.internal.events.block.BlockPlaceEvent( - blockType, + sBlock, new Location(new SpigotWorld(block.getWorld()), block.getX(), block.getY(), block.getZ()), (new SpigotPlayer(e.getPlayer()))); Prison.get().getEventBus().post(event); @@ -183,11 +183,11 @@ public void onBlockPlace(BlockPlaceEvent e) { @EventHandler public void onBlockBreak(BlockBreakEvent e) { org.bukkit.Location block = e.getBlock().getLocation(); - BlockType blockType = SpigotUtil.blockToBlockType( e.getBlock() ); + SpigotBlock sBlock = new SpigotBlock( e.getBlock() ); tech.mcprison.prison.internal.events.block.BlockBreakEvent event = new tech.mcprison.prison.internal.events.block.BlockBreakEvent( - blockType, + sBlock, new Location(new SpigotWorld(block.getWorld()), block.getX(), block.getY(), block.getZ()), (new SpigotPlayer(e.getPlayer())),e.getExpToDrop()); Prison.get().getEventBus().post(event); 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 1db975034..5c0c3c64d 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 @@ -112,7 +112,6 @@ import tech.mcprison.prison.spigot.util.ActionBarUtil; import tech.mcprison.prison.spigot.util.SpigotYamlFileIO; import tech.mcprison.prison.store.Storage; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Bounds.Edges; import tech.mcprison.prison.util.Location; import tech.mcprison.prison.util.PrisonJarReporter; @@ -1500,9 +1499,9 @@ public void autoCreateMineBlockAssignment( List rankMineNames, boolean f // blockList = buildBlockListXMaterial(); } - else { - blockList = buildBlockListBlockType(); - } +// else { +// blockList = buildBlockListBlockType(); +// } MineManager mm = PrisonMines.getInstance().getMineManager(); //List mines = mm.getMines(); @@ -1689,6 +1688,16 @@ protected List mineBlockList( List blockList, int startPos, int return results; } + protected List mineBlockList( int startPos, int length, List blockList ) { + + List results = new ArrayList<>(); + for (int i = (startPos >= blockList.size() ? blockList.size() - 1 : startPos); i >= 0 && i >= startPos - length + 1; i--) { + results.add( blockList.get( i ).getBlock().name() ); + } + + return results; + } + /** * This listing of blocks is based strictly upon XMaterial. @@ -1862,61 +1871,61 @@ public List buildBlockListXMaterial() { return blockList; } - /** - * This listing of blocks is based strictly upon the old prison's block - * model. - * - * Please note, that right now these names match exactly with XMaterial only - * because I renamed a few of them to make them match. But if more are added - * in the future, then there may be mismatches. - * - * @return - */ - protected List buildBlockListBlockType() { - List blockList = new ArrayList<>(); - - blockList.add( BlockType.COBBLESTONE.name() ); - blockList.add( BlockType.ANDESITE.name() ); - blockList.add( BlockType.DIORITE.name() ); - blockList.add( BlockType.COAL_ORE.name() ); - - blockList.add( BlockType.GRANITE.name() ); - blockList.add( BlockType.STONE.name() ); - blockList.add( BlockType.IRON_ORE.name() ); - blockList.add( BlockType.POLISHED_ANDESITE.name() ); - -// blockList.add( BlockType.POLISHED_DIORITE.name() ); -// blockList.add( BlockType.POLISHED_GRANITE.name() ); - blockList.add( BlockType.GOLD_ORE.name() ); - - - blockList.add( BlockType.MOSSY_COBBLESTONE.name() ); - blockList.add( BlockType.COAL_BLOCK.name() ); - blockList.add( BlockType.NETHER_QUARTZ_ORE.name() ); - blockList.add( BlockType.LAPIS_ORE.name() ); - - - blockList.add( BlockType.END_STONE.name() ); - blockList.add( BlockType.IRON_BLOCK.name() ); - - blockList.add( BlockType.REDSTONE_ORE.name() ); - blockList.add( BlockType.DIAMOND_ORE.name() ); - - blockList.add( BlockType.QUARTZ_BLOCK.name() ); - blockList.add( BlockType.EMERALD_ORE.name() ); - - blockList.add( BlockType.GOLD_BLOCK.name() ); - blockList.add( BlockType.PRISMARINE.name() ); - blockList.add( BlockType.LAPIS_BLOCK.name() ); - blockList.add( BlockType.REDSTONE_BLOCK.name() ); - - blockList.add( BlockType.OBSIDIAN.name() ); - blockList.add( BlockType.DIAMOND_BLOCK.name() ); - blockList.add( BlockType.DARK_PRISMARINE.name() ); - blockList.add( BlockType.EMERALD_BLOCK.name() ); - - return blockList; - } +// /** +// * This listing of blocks is based strictly upon the old prison's block +// * model. +// * +// * Please note, that right now these names match exactly with XMaterial only +// * because I renamed a few of them to make them match. But if more are added +// * in the future, then there may be mismatches. +// * +// * @return +// */ +// protected List buildBlockListBlockType() { +// List blockList = new ArrayList<>(); +// +// blockList.add( BlockType.COBBLESTONE.name() ); +// blockList.add( BlockType.ANDESITE.name() ); +// blockList.add( BlockType.DIORITE.name() ); +// blockList.add( BlockType.COAL_ORE.name() ); +// +// blockList.add( BlockType.GRANITE.name() ); +// blockList.add( BlockType.STONE.name() ); +// blockList.add( BlockType.IRON_ORE.name() ); +// blockList.add( BlockType.POLISHED_ANDESITE.name() ); +// +//// blockList.add( BlockType.POLISHED_DIORITE.name() ); +//// blockList.add( BlockType.POLISHED_GRANITE.name() ); +// blockList.add( BlockType.GOLD_ORE.name() ); +// +// +// blockList.add( BlockType.MOSSY_COBBLESTONE.name() ); +// blockList.add( BlockType.COAL_BLOCK.name() ); +// blockList.add( BlockType.NETHER_QUARTZ_ORE.name() ); +// blockList.add( BlockType.LAPIS_ORE.name() ); +// +// +// blockList.add( BlockType.END_STONE.name() ); +// blockList.add( BlockType.IRON_BLOCK.name() ); +// +// blockList.add( BlockType.REDSTONE_ORE.name() ); +// blockList.add( BlockType.DIAMOND_ORE.name() ); +// +// blockList.add( BlockType.QUARTZ_BLOCK.name() ); +// blockList.add( BlockType.EMERALD_ORE.name() ); +// +// blockList.add( BlockType.GOLD_BLOCK.name() ); +// blockList.add( BlockType.PRISMARINE.name() ); +// blockList.add( BlockType.LAPIS_BLOCK.name() ); +// blockList.add( BlockType.REDSTONE_BLOCK.name() ); +// +// blockList.add( BlockType.OBSIDIAN.name() ); +// blockList.add( BlockType.DIAMOND_BLOCK.name() ); +// blockList.add( BlockType.DARK_PRISMARINE.name() ); +// blockList.add( BlockType.EMERALD_BLOCK.name() ); +// +// return blockList; +// } @Override public List getActiveFeatures() { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java index cc817bd44..0e11767da 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java @@ -29,7 +29,6 @@ import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; @@ -53,7 +52,6 @@ import tech.mcprison.prison.spigot.compat.SpigotCompatibility; import tech.mcprison.prison.spigot.game.SpigotWorld; import tech.mcprison.prison.spigot.integrations.IntegrationMinepacksPlugin; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; import tech.mcprison.prison.util.Text; import tech.mcprison.prison.util.Vector; @@ -81,22 +79,22 @@ public static XMaterial getXMaterial( String materialName ) { return XMaterial.matchXMaterial( materialName ).orElse( null ); } - /** - *

Gets the XMaterial based upon the BlockType name, and if it fails to hit - * anything, then it falls back on to the id, of which XMaterial strips the - * prefix of "minecraft:". - *

- * - * @param prisonBlockType - * @return - */ - public static XMaterial getXMaterial( BlockType prisonBlockType ) { - - XMaterial xMat = SpigotCompatibility.getInstance() - .getXMaterial( prisonBlockType ); - - return xMat; - } +// /** +// *

Gets the XMaterial based upon the BlockType name, and if it fails to hit +// * anything, then it falls back on to the id, of which XMaterial strips the +// * prefix of "minecraft:". +// *

+// * +// * @param prisonBlockType +// * @return +// */ +// public static XMaterial getXMaterial( BlockType prisonBlockType ) { +// +// XMaterial xMat = SpigotCompatibility.getInstance() +// .getXMaterial( prisonBlockType ); +// +// return xMat; +// } public static XMaterial getXMaterial( PrisonBlock prisonBlock ) { @@ -105,50 +103,50 @@ public static XMaterial getXMaterial( PrisonBlock prisonBlock ) { return xMat; } - public static Material getMaterial( BlockType prisonBlockType ) { - XMaterial xMat = getXMaterial( prisonBlockType ); - - return xMat == null ? null : xMat.parseMaterial(); - } +// public static Material getMaterial( BlockType prisonBlockType ) { +// XMaterial xMat = getXMaterial( prisonBlockType ); +// +// return xMat == null ? null : xMat.parseMaterial(); +// } - public static BlockType blockToBlockType( Block spigotBlock ) { - BlockType results = SpigotCompatibility.getInstance() - .getBlockType( spigotBlock ); - +// public static BlockType blockToBlockType( Block spigotBlock ) { +// BlockType results = SpigotCompatibility.getInstance() +// .getBlockType( spigotBlock ); // -// XMaterial xMatMatch = XMaterial.matchXMaterial( material ); +//// +//// XMaterial xMatMatch = XMaterial.matchXMaterial( material ); +//// +//// for ( BlockType blockType : BlockType.values() ) { +//// XMaterial xMat = getXMaterial( blockType ); +//// if ( xMat != null ) { +//// results = blockType; +//// break; +//// } +//// } // -// for ( BlockType blockType : BlockType.values() ) { -// XMaterial xMat = getXMaterial( blockType ); -// if ( xMat != null ) { -// results = blockType; -// break; -// } -// } - - return results; - } +// return results; +// } - public static BlockType prisonBlockToBlockType( PrisonBlock prisonBlock ) { - - BlockType results = BlockType.getBlock( prisonBlock.getBlockName() ); - - return results; - } +// public static BlockType prisonBlockToBlockType( PrisonBlock prisonBlock ) { +// +// BlockType results = BlockType.getBlock( prisonBlock.getBlockName() ); +// +// return results; +// } /** - *

Returns a stack of BlockType or a stack of air. + *

Returns a stack of PrisonBlock or a stack of air. *

* * @param prisonBlockType * @param amount * @return */ - public static ItemStack getItemStack( BlockType prisonBlockType, int amount ) { + public static ItemStack getItemStack( PrisonBlock prisonBlock, int amount ) { ItemStack bukkitStack = null; - XMaterial xMat = getXMaterial( prisonBlockType ); + XMaterial xMat = getXMaterial( prisonBlock ); if ( xMat != null ) { bukkitStack = xMat.parseItem(); bukkitStack.setAmount( amount ); @@ -704,29 +702,31 @@ public static List getAllCustomBlockTypes() { */ public static PrisonBlock getPrisonBlock( String blockName ) { - PrisonBlock results = null; - BlockType bTypeObsolete = null; - - XMaterial xMat = getXMaterial( blockName ); + PrisonBlock results = new PrisonBlock( blockName ); + results.setValid( false ); - if ( xMat == null ) { - // Try to get the material through the old prison blocks: - bTypeObsolete = BlockType.getBlock( blockName ); - - xMat = getXMaterial( bTypeObsolete ); - } - - if ( xMat != null ) { - results = new PrisonBlock( xMat.name() ); - - if ( bTypeObsolete != null ) { - results.setLegacyBlock( true ); - } - } - else { - results = new PrisonBlock( blockName ); - results.setValid( false ); - } +// BlockType bTypeObsolete = null; +// +// XMaterial xMat = getXMaterial( blockName ); +// +// if ( xMat == null ) { +// // Try to get the material through the old prison blocks: +// bTypeObsolete = BlockType.getBlock( blockName ); +// +// xMat = getXMaterial( bTypeObsolete ); +// } +// +// if ( xMat != null ) { +// results = new PrisonBlock( xMat.name() ); +// +// if ( bTypeObsolete != null ) { +// results.setLegacyBlock( true ); +// } +// } +// else { +// results = new PrisonBlock( blockName ); +// results.setValid( false ); +// } return results; } @@ -757,33 +757,34 @@ public static void testAllPrisonBlockTypes() { int supportedBlockCountPrison = 0; int supportedBlockCountXMaterial = 0; - for ( BlockType block : BlockType.values() ) { - - if ( block.isBlock() ) { - XMaterial xMat = getXMaterial( block ); - - if ( xMat == null ) { - if ( sbNoMap.length() > 0 ) { - sbNoMap.append( " " ); - } - - Material mat = getMaterial( block ); - - String bName = block.name() + (mat == null ? "" : "(" + mat.name() + ")"); - sbNoMap.append( bName ); - } - else if ( !xMat.isSupported() ) { - if ( sbNotSupported.length() > 0 ) { - sbNotSupported.append( " " ); - } - sbNotSupported.append( block.name() ); - } - else { - supportedBlockCountPrison++; - } - } - } +// for ( BlockType block : BlockType.values() ) { +// +// if ( block.isBlock() ) { +// XMaterial xMat = getXMaterial( block ); +// +// if ( xMat == null ) { +// if ( sbNoMap.length() > 0 ) { +// sbNoMap.append( " " ); +// } +// +// Material mat = getMaterial( block ); +// +// String bName = block.name() + (mat == null ? "" : "(" + mat.name() + ")"); +// sbNoMap.append( bName ); +// } +// else if ( !xMat.isSupported() ) { +// if ( sbNotSupported.length() > 0 ) { +// sbNotSupported.append( " " ); +// } +// sbNotSupported.append( block.name() ); +// } +// else { +// supportedBlockCountPrison++; +// } +// } +// } + // Validate which XMaterial for ( XMaterial xMat : XMaterial.values() ) { if ( xMat.isSupported() ) { @@ -806,7 +807,10 @@ else if ( !xMat.isSupported() ) { for ( Material spigotMaterial : Material.values() ) { if ( spigotMaterial.isBlock() && - BlockType.getBlock( spigotMaterial.name() ) == null ) { + XMaterial.matchXMaterial( spigotMaterial ) == null + +// BlockType.getBlock( spigotMaterial.name() ) == null + ) { String name = spigotMaterial.name().toLowerCase(); if ( !name.contains( "banner" ) && !name.contains( "button" ) && 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 9347363d9..2cc9f36aa 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 @@ -32,9 +32,7 @@ import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.game.SpigotWorld; import tech.mcprison.prison.spigot.sellall.SellAllUtil; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; -import tech.mcprison.prison.util.MaterialType; /** *

These are some api end points to help access some core components within prison. @@ -156,13 +154,15 @@ public String getPrisonBlockName( String blockName ) { results = prisonBlock.getBlockName(); } } - else { - - BlockType blockType = BlockType.getBlock(blockName); - if (blockType != null && blockType.getMaterialType() == MaterialType.BLOCK ) { - results = blockType.getMaterialType().name(); - } - } + + // Obsolete... prison old block model: +// else { +// +// BlockType blockType = BlockType.getBlock(blockName); +// if (blockType != null && blockType.getMaterialType() == MaterialType.BLOCK ) { +// results = blockType.getMaterialType().name(); +// } +// } return results; } @@ -180,7 +180,7 @@ public List getMines( String prisonBlockName ) { if ( prisonBlockName != null && prisonBlockName.trim().length() > 0 ) { PrisonBlock prisonBlock = null; - BlockType blockType = null; +// BlockType blockType = null; if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { @@ -189,28 +189,44 @@ public List getMines( String prisonBlockName ) { prisonBlock = null; } } - else { - - blockType = BlockType.getBlock( prisonBlockName ); - if (blockType != null && blockType.getMaterialType() != MaterialType.BLOCK ) { - blockType = null; - } - } - if ( prisonBlock != null || blockType != null ) { + // Obsolete... prison old block model: +// else { +// +// blockType = BlockType.getBlock( prisonBlockName ); +// if (blockType != null && blockType.getMaterialType() != MaterialType.BLOCK ) { +// blockType = null; +// } +// } + + if ( prisonBlock != null ) { if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { MineManager mm = PrisonMines.getInstance().getMineManager(); List mines = mm.getMines(); for ( Mine mine : mines ) { - if ( prisonBlock != null && mine.isInMine( blockType ) || - blockType != null && mine.isInMine( blockType ) ) { + if ( prisonBlock != null && mine.isInMine( prisonBlock ) ) { results.add( mine ); break; } } } } + +// if ( prisonBlock != null || blockType != null ) { +// if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { +// MineManager mm = PrisonMines.getInstance().getMineManager(); +// +// List mines = mm.getMines(); +// for ( Mine mine : mines ) { +// if ( prisonBlock != null && mine.isInMine( prisonBlock ) || +// blockType != null && mine.isInMine( blockType ) ) { +// results.add( mine ); +// break; +// } +// } +// } +// } } return results; 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 c4c12c63d..59666180d 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 @@ -38,7 +38,6 @@ import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.sellall.SellAllUtil; import tech.mcprison.prison.spigot.spiget.BluesSpigetSemVerComparator; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Text; /** @@ -2405,7 +2404,9 @@ private List calculateDropAdditionsGravelFlint(SpigotItemStack List drops ) { List adds = new ArrayList(); - if (itemStack.getMaterial() == BlockType.GRAVEL && !hasSilkTouch(itemInHand)) { + PrisonBlock gravel = SpigotUtil.getPrisonBlock( XMaterial.GRAVEL ); + + if (itemStack.getMaterial().compareTo( gravel ) == 0 && !hasSilkTouch(itemInHand)) { int quantity = 1; int threshold = 10; @@ -2443,7 +2444,8 @@ private List calculateDropAdditionsGravelFlint(SpigotItemStack } // ItemStack flintStack = new ItemStack(Material.FLINT, quantity); - SpigotItemStack flintStack = new SpigotItemStack( quantity, BlockType.FLINT); + PrisonBlock flint = SpigotUtil.getPrisonBlock( XMaterial.FLINT ); + SpigotItemStack flintStack = new SpigotItemStack( quantity, flint ); adds.add(flintStack); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java index bf33df38e..c2e846841 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java @@ -32,17 +32,18 @@ import tech.mcprison.prison.internal.block.BlockFace; import tech.mcprison.prison.internal.block.BlockState; 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.spigot.SpigotUtil; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; /** * @author Faizaan A. Datoo */ -public class SpigotBlock implements Block { +public class SpigotBlock + extends PrisonBlock +// implements Block +{ private org.bukkit.block.Block bBlock; @@ -56,6 +57,7 @@ public class SpigotBlock implements Block { public SpigotBlock(org.bukkit.block.Block bBlock) { + super( SpigotCompatibility.getInstance().getPrisonBlock( bBlock ) ); this.bBlock = bBlock; this.prisonBlockTypes = new HashSet<>(); @@ -72,57 +74,60 @@ public String toString() { return sb.toString(); } - public String getBlockName() { - return getPrisonBlock().getBlockName(); - } +// public String getBlockName() { +// return super.getBlockName(); +// } @Override public Location getLocation() { return getWrapper() == null ? null : SpigotUtil.bukkitLocationToPrison(getWrapper().getLocation()); } - @Override public Block getRelative(BlockFace face) { + @Override public PrisonBlock getRelative(BlockFace face) { return new SpigotBlock( getWrapper().getRelative( org.bukkit.block.BlockFace.valueOf( face.name()))); } - @Override public BlockType getType() { - return SpigotCompatibility.getInstance().getBlockType( getWrapper() ); -// return SpigotUtil.materialToBlockType(bBlock.getType()); - } +// @Override public BlockType getType() { +// return SpigotCompatibility.getInstance().getBlockType( getWrapper() ); +//// return SpigotUtil.materialToBlockType(bBlock.getType()); +// } - @Override +// @Override public PrisonBlock getPrisonBlock() { - PrisonBlock results = null; - if ( getPrisonBlockTypes() != null ) { - - // Need to see if any PrisonBlockTypes exist in the mine where this block is located. - for ( PrisonBlockType blockType : getPrisonBlockTypes() ) { - - results = getPrisonBlockFromCustomBlockIntegration( blockType ); - if ( results != null ) { - - break; - } - } - } - - if ( results == null && getWrapper() != null ) { - results = SpigotCompatibility.getInstance().getPrisonBlock( getWrapper() ); - } - - if ( results != null && results.getLocation() == null && getLocation() != null ) { - // Clone the block that was found in the mine. This will allow us to - // set the location: - results = new PrisonBlock( results ); - - results.setLocation( getLocation() ); - } + return this; - return results; +// PrisonBlock results = null; +// +// if ( getPrisonBlockTypes() != null ) { +// +// // Need to see if any PrisonBlockTypes exist in the mine where this block is located. +// for ( PrisonBlockType blockType : getPrisonBlockTypes() ) { +// +// results = getPrisonBlockFromCustomBlockIntegration( blockType ); +// if ( results != null ) { +// +// break; +// } +// } +// } +// +// if ( results == null && getWrapper() != null ) { +// results = SpigotCompatibility.getInstance().getPrisonBlock( getWrapper() ); +// } +// +// if ( results != null && results.getLocation() == null && getLocation() != null ) { +// // Clone the block that was found in the mine. This will allow us to +// // set the location: +// results = new PrisonBlock( results ); +// +// results.setLocation( getLocation() ); +// } +// +// return results; } private PrisonBlock getPrisonBlockFromCustomBlockIntegration( PrisonBlockType blockType ) { @@ -209,88 +214,120 @@ public void setBlockFace( BlockFace blockFace ) { SpigotCompatibility.getInstance() .setBlockFace( getWrapper(), blockFace ); } - /** - *

When setting the Data and Type, turn off apply physics which will reduce the over head on block updates - * by about 1/3. Really do not need to apply physics in the mines especially if no air blocks and nothing - * that could fall (sand) or flow is placed. - *

- */ - @Override - public void setType(BlockType blockType) { - - SpigotCompatibility.getInstance() - .updateSpigotBlock( blockType, getWrapper() ); - -// if ( type != null && type != BlockType.IGNORE ) { -// -// Material mat = SpigotUtil.getMaterial( type ); -// if ( mat != null ) { -// bBlock.setType( mat, false ); -// } -// -//// Optional xMatO = XMaterial.matchXMaterial( type.name() ); + +// /** +// *

When setting the Data and Type, turn off apply physics which will reduce the over head on block updates +// * by about 1/3. Really do not need to apply physics in the mines especially if no air blocks and nothing +// * that could fall (sand) or flow is placed. +// *

+// */ +// @Override +// public void setType( PrisonBlock blockType) { +// +// SpigotCompatibility.getInstance() +// .updateSpigotBlock( blockType, getWrapper() ); +// +//// if ( type != null && type != BlockType.IGNORE ) { //// -//// if ( xMatO.isPresent() ) { -//// XMaterial xMat = xMatO.get(); -//// Optional matO = xMat.parseMaterial(); +//// Material mat = SpigotUtil.getMaterial( type ); +//// if ( mat != null ) { +//// bBlock.setType( mat, false ); +//// } +//// +////// Optional xMatO = XMaterial.matchXMaterial( type.name() ); +////// +////// if ( xMatO.isPresent() ) { +////// XMaterial xMat = xMatO.get(); +////// Optional matO = xMat.parseMaterial(); +////// +////// if ( matO.isPresent() ) { +////// Material mat = matO.get(); +////// +////// bBlock.setType( mat, false ); +////// +////// } +////// } +//// else { +//// // spigot 1.8.8 support for XMaterial: +//// // MOSS_STONE LAPIS_LAZULI_ORE LAPIS_LAZULI_BLOCK PILLAR_QUARTZ_BLOCK +//// // +//// +//// Output.get().logWarn( "SpigotBlock.setType: could not match BlockType " + +//// type.name() + " defaulting to AIR instead."); //// -//// if ( matO.isPresent() ) { -//// Material mat = matO.get(); -//// -//// bBlock.setType( mat, false ); -//// -//// } +//// mat = SpigotUtil.getMaterial( BlockType.AIR ); +//// if ( mat != null ) { +//// bBlock.setType( mat, false ); +//// } //// } -// else { -// // spigot 1.8.8 support for XMaterial: -// // MOSS_STONE LAPIS_LAZULI_ORE LAPIS_LAZULI_BLOCK PILLAR_QUARTZ_BLOCK -// // -// -// Output.get().logWarn( "SpigotBlock.setType: could not match BlockType " + -// type.name() + " defaulting to AIR instead."); -// -// mat = SpigotUtil.getMaterial( BlockType.AIR ); -// if ( mat != null ) { -// bBlock.setType( mat, false ); -// } -// } -// -//// try { -//// MaterialData materialData = SpigotUtil.blockTypeToMaterial(type); -//// bBlock.setType(materialData.getItemType(), false); -//// if ( type.getMaterialVersion() == MaterialVersion.v1_8) { -//// -//// bBlock.setData(materialData.getData(), false); -//// } -//// } -//// catch ( Exception e ) { -//// Output.get().logError( -//// String.format( "BlockType could not be set: %s %s ", -//// (type == null ? "(null)" : type.name()), e.getMessage()) ); -//// } -// } - } +//// +////// try { +////// MaterialData materialData = SpigotUtil.blockTypeToMaterial(type); +////// bBlock.setType(materialData.getItemType(), false); +////// if ( type.getMaterialVersion() == MaterialVersion.v1_8) { +////// +////// bBlock.setData(materialData.getData(), false); +////// } +////// } +////// catch ( Exception e ) { +////// Output.get().logError( +////// String.format( "BlockType could not be set: %s %s ", +////// (type == null ? "(null)" : type.name()), e.getMessage()) ); +////// } +//// } +// } + + @Override + public BlockState getState() { + + BlockState results = null; + + XMaterial xMat = SpigotUtil.getXMaterial( getPrisonBlock() ); + + switch ( xMat ) { + case LEVER: + results = new SpigotLever(this); + break; + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case CRIMSON_SIGN: + case CRIMSON_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: + case WARPED_SIGN: + case WARPED_WALL_SIGN: + results = new SpigotSign(this); + break; + + case ACACIA_DOOR: + case BIRCH_DOOR: + case CRIMSON_DOOR: + case DARK_OAK_DOOR: + case IRON_DOOR: + case JUNGLE_DOOR: + case OAK_DOOR: + case SPRUCE_DOOR: + case WARPED_DOOR: + results = new SpigotDoor(this); + break; - @Override public BlockState getState() { - switch (getType()) { - case LEVER: - return new SpigotLever(this); - case SIGN: - return new SpigotSign(this); - case ACACIA_DOOR_BLOCK: - case OAK_DOOR_BLOCK: - case BIRCH_DOOR_BLOCK: - case SPRUCE_DOOR_BLOCK: - case DARK_OAK_DOOR_BLOCK: - case IRON_DOOR_BLOCK: - case JUNGLE_DOOR_BLOCK: - return new SpigotDoor(this); default: - return new SpigotBlockState(this); + results = new SpigotBlockState(this); } + + return results; } - @Override public boolean breakNaturally() { + @Override + public boolean breakNaturally() { boolean results = false; if ( getWrapper() != null ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockState.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockState.java index 35d7900d5..22a7e8689 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockState.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockState.java @@ -28,12 +28,14 @@ public class SpigotBlockState implements BlockState { public SpigotBlock block; - public SpigotBlockState(SpigotBlock block) { + public SpigotBlockState( SpigotBlock block ) { this.block = block; } - @Override public Block getBlock() { - return block; - } + @Override + public Block getBlock() + { + return block.getPrisonBlock(); + } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java index eece37be3..f7a76494b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java @@ -9,10 +9,12 @@ import org.bukkit.Material; import org.bukkit.inventory.meta.ItemMeta; +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.Prison; import tech.mcprison.prison.internal.ItemStack; -import tech.mcprison.prison.spigot.compat.SpigotCompatibility; -import tech.mcprison.prison.util.BlockType; +import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.spigot.SpigotUtil; public class SpigotItemStack extends ItemStack { @@ -26,7 +28,7 @@ public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) { if (bukkitStack == null || bukkitStack.getType().equals(Material.AIR)) { setAmount( 0 ); - setMaterial( BlockType.AIR ); + setMaterial( PrisonBlock.AIR ); setDisplayName( "air" ); } else { @@ -44,8 +46,12 @@ public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) { // in the bukkitStack: int amount = bukkitStack.getAmount(); - BlockType type = SpigotCompatibility.getInstance() - .getBlockType( bukkitStack ); + XMaterial xMat = XMaterial.matchXMaterial( bukkitStack ); + + PrisonBlock type = SpigotUtil.getPrisonBlock( xMat ); + +// BlockType type = SpigotCompatibility.getInstance() +// .getBlockType( bukkitStack ); // BlockType type = materialToBlockType(bukkitStack.getType()); @@ -55,7 +61,7 @@ public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) { displayName = meta.getDisplayName(); } else if ( type != null ) { - displayName = type.name().toLowerCase(); + displayName = type.getBlockName().toLowerCase(); } List lores = new ArrayList<>(); @@ -75,6 +81,17 @@ else if ( type != null ) { } + + + public SpigotItemStack(String displayName, int amount, PrisonBlock material, String... lore) { + super(displayName, amount, material, lore ); + } + + public SpigotItemStack(int amount, PrisonBlock material, String... lore) { + super( amount, material, lore ); + } + + /** *

This function overrides the Prison's ItemStack class's setAmount() to perform the * same behavior of setting the amount to the requested value, but it also updates @@ -96,7 +113,7 @@ public void setAmount( int amount ) { public boolean isAir() { boolean results = false; - if ( getMaterial() != null && getMaterial() == BlockType.AIR || + if ( getMaterial() != null && getMaterial().isAir() || getName() != null && "air".equalsIgnoreCase( getName() ) ) { results = true; } @@ -122,15 +139,6 @@ public boolean isBlock() { } - - public SpigotItemStack(String displayName, int amount, BlockType material, String... lore) { - super(displayName, amount, material, lore ); - } - - public SpigotItemStack(int amount, BlockType material, String... lore) { - super( amount, material, lore ); - } - public org.bukkit.inventory.ItemStack getBukkitStack() { return bukkitStack; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java index 17393edfa..ddb7c9851 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java @@ -8,13 +8,12 @@ import tech.mcprison.prison.internal.block.BlockFace; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; public interface CompatibilityBlocks extends CompatibilityPlayer { - public BlockType getBlockType(Block spigotBlock); +// public BlockType getBlockType(Block spigotBlock); public PrisonBlock getPrisonBlock(Block spigotBlock); @@ -22,13 +21,13 @@ public interface CompatibilityBlocks public XMaterial getXMaterial( PrisonBlock prisonBlock ); - public XMaterial getXMaterial( BlockType blockType ); +// public XMaterial getXMaterial( BlockType blockType ); - public BlockType getBlockType( ItemStack spigotStack ); +// public BlockType getBlockType( ItemStack spigotStack ); - public void updateSpigotBlock( BlockType blockType, Block spigotBlock ); +// public void updateSpigotBlock( BlockType blockType, Block spigotBlock ); public void updateSpigotBlock( PrisonBlock prisonBlock, Block spigotBlock ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityCache.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityCache.java index 76973803a..70d3a6095 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityCache.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityCache.java @@ -4,13 +4,11 @@ import java.util.TreeMap; import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; import com.cryptomorin.xseries.XMaterial; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.spigot.SpigotPrison; -import tech.mcprison.prison.util.BlockType; /** *

This function provides a way to cache BlockTypes and XMaterial @@ -26,7 +24,7 @@ public class CompatibilityCache { public static final XMaterial NULL_TOKEN = XMaterial.VOID_AIR; - private Map blockTypeCache; +// private Map blockTypeCache; private Map xMaterialCache; @@ -37,7 +35,7 @@ public class CompatibilityCache { public CompatibilityCache() { super(); - this.blockTypeCache = new TreeMap<>(); +// this.blockTypeCache = new TreeMap<>(); this.xMaterialCache = new TreeMap<>(); initializeForcedCache(); @@ -59,40 +57,40 @@ private void initializeForcedCache() { } - public BlockType getCachedBlockType( Block spigotBlock, byte data ) { - String key = spigotBlock.getType().name() + ( data <= 0 ? "" : ":" +data); - - BlockType blockType = blockTypeCache.get( key ); - - return blockType; //blockType == BlockType.NULL_BLOCK ? null : blockType; - } - public void putCachedBlockType( Block spigotBlock, byte data, BlockType blockType ) { - if ( spigotBlock != null ) { - String key = spigotBlock.getType().name() + ( data <= 0 ? "" : ":" + data); - - if ( !blockTypeCache.containsKey( key ) ) { - blockTypeCache.put( key, blockType == null ? BlockType.NULL_BLOCK : blockType ); - } - } - } - - - public BlockType getCachedBlockType( ItemStack spigotStack, byte data ) { - String key = spigotStack.getType().name() + ( data <= 0 ? "" : ":" + data); - - BlockType blockType = blockTypeCache.get( key ); - - return blockType; // blockType == BlockType.NULL_BLOCK ? null : blockType; - } - public void putCachedBlockType( ItemStack spigotStack, byte data, BlockType blockType ) { - if ( spigotStack != null ) { - String key = spigotStack.getType().name() + ( data <= 0 ? "" : ":" + data); - - if ( !blockTypeCache.containsKey( key ) ) { - blockTypeCache.put( key, blockType == null ? BlockType.NULL_BLOCK : blockType ); - } - } - } +// public BlockType getCachedBlockType( Block spigotBlock, byte data ) { +// String key = spigotBlock.getType().name() + ( data <= 0 ? "" : ":" +data); +// +// BlockType blockType = blockTypeCache.get( key ); +// +// return blockType; //blockType == BlockType.NULL_BLOCK ? null : blockType; +// } +// public void putCachedBlockType( Block spigotBlock, byte data, BlockType blockType ) { +// if ( spigotBlock != null ) { +// String key = spigotBlock.getType().name() + ( data <= 0 ? "" : ":" + data); +// +// if ( !blockTypeCache.containsKey( key ) ) { +// blockTypeCache.put( key, blockType == null ? BlockType.NULL_BLOCK : blockType ); +// } +// } +// } + + +// public BlockType getCachedBlockType( ItemStack spigotStack, byte data ) { +// String key = spigotStack.getType().name() + ( data <= 0 ? "" : ":" + data); +// +// BlockType blockType = blockTypeCache.get( key ); +// +// return blockType; // blockType == BlockType.NULL_BLOCK ? null : blockType; +// } +// public void putCachedBlockType( ItemStack spigotStack, byte data, BlockType blockType ) { +// if ( spigotStack != null ) { +// String key = spigotStack.getType().name() + ( data <= 0 ? "" : ":" + data); +// +// if ( !blockTypeCache.containsKey( key ) ) { +// blockTypeCache.put( key, blockType == null ? BlockType.NULL_BLOCK : blockType ); +// } +// } +// } @@ -134,22 +132,22 @@ public void putCachedXMaterial( Block spigotBlock, byte data, XMaterial xMat ) { } } - public XMaterial getCachedXMaterial( BlockType blockType, byte data ) { - String key = blockType.name() + ( data <= 0 ? "" : ":" +data); - - XMaterial xMat = xMaterialCache.get( key ); - - // Using VOID_AIR as temp placeholder for null values: - return xMat; // xMat == XMaterial.VOID_AIR ? null : xMat; - } - public void putCachedXMaterial( BlockType blockType, byte data, XMaterial xMat ) { - String key = blockType.name() + ( data <= 0 ? "" : ":" +data); - - if ( !xMaterialCache.containsKey( key ) ) { - // Using VOID_AIR as temp placeholder for null values: - xMaterialCache.put( key, xMat == null ? NULL_TOKEN : xMat ); - } - } +// public XMaterial getCachedXMaterial( BlockType blockType, byte data ) { +// String key = blockType.name() + ( data <= 0 ? "" : ":" +data); +// +// XMaterial xMat = xMaterialCache.get( key ); +// +// // Using VOID_AIR as temp placeholder for null values: +// return xMat; // xMat == XMaterial.VOID_AIR ? null : xMat; +// } +// public void putCachedXMaterial( BlockType blockType, byte data, XMaterial xMat ) { +// String key = blockType.name() + ( data <= 0 ? "" : ":" +data); +// +// if ( !xMaterialCache.containsKey( key ) ) { +// // Using VOID_AIR as temp placeholder for null values: +// xMaterialCache.put( key, xMat == null ? NULL_TOKEN : xMat ); +// } +// } public SpigotPrison getPlugin() { return plugin; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java index 8492a4bb4..b68d979a9 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java @@ -17,36 +17,35 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; public abstract class Spigot113Blocks extends Spigot19Player implements CompatibilityBlocks { - @Override - public BlockType getBlockType(Block spigotBlock) { - BlockType results = getCachedBlockType( spigotBlock, NO_DATA_VALUE ); - - if ( results == null ) { - if ( spigotBlock != null ) { - - results = BlockType.getBlock( spigotBlock.getType().name() ); - -// if ( results == null ) { -// Output.get().logInfo( "#### 1.13 getBlockType() Cannot map block from spigot to prison:" + -// " spigotBlock.getType().name() = %s " + -// " BlockType.getBlock() = %s ", -// spigotBlock.getType().name(), -// (results == null ? "" : results.name() )); -// } - - putCachedBlockType( spigotBlock, NO_DATA_VALUE, results ); - } - } - - return results == BlockType.NULL_BLOCK ? null : results; - } +// @Override +// public BlockType getBlockType(Block spigotBlock) { +// BlockType results = getCachedBlockType( spigotBlock, NO_DATA_VALUE ); +// +// if ( results == null ) { +// if ( spigotBlock != null ) { +// +// results = BlockType.getBlock( spigotBlock.getType().name() ); +// +//// if ( results == null ) { +//// Output.get().logInfo( "#### 1.13 getBlockType() Cannot map block from spigot to prison:" + +//// " spigotBlock.getType().name() = %s " + +//// " BlockType.getBlock() = %s ", +//// spigotBlock.getType().name(), +//// (results == null ? "" : results.name() )); +//// } +// +// putCachedBlockType( spigotBlock, NO_DATA_VALUE, results ); +// } +// } +// +// return results == BlockType.NULL_BLOCK ? null : results; +// } @Override public PrisonBlock getPrisonBlock(Block spigotBlock) { @@ -63,21 +62,21 @@ public PrisonBlock getPrisonBlock(Block spigotBlock) { return pBlock; } - @Override - public BlockType getBlockType(ItemStack spigotStack) { - BlockType results = getCachedBlockType( spigotStack, NO_DATA_VALUE ); - - if ( results == null ) { - if ( spigotStack != null ) { - - results = BlockType.getBlock( spigotStack.getType().name() ); - - putCachedBlockType( spigotStack, NO_DATA_VALUE, results ); - } - } - - return results == BlockType.NULL_BLOCK ? null : results; - } +// @Override +// public BlockType getBlockType(ItemStack spigotStack) { +// BlockType results = getCachedBlockType( spigotStack, NO_DATA_VALUE ); +// +// if ( results == null ) { +// if ( spigotStack != null ) { +// +// results = BlockType.getBlock( spigotStack.getType().name() ); +// +// putCachedBlockType( spigotStack, NO_DATA_VALUE, results ); +// } +// } +// +// return results == BlockType.NULL_BLOCK ? null : results; +// } @Override public XMaterial getXMaterial( Block spigotBlock ) { @@ -136,59 +135,59 @@ public XMaterial getXMaterial( PrisonBlock prisonBlock ) { } - /** - *

This function tries to use up to three different sources to get a match - * on the XMaterial. Just because the XMateral may be a match, does not - * mean it actually is a valid Block for that version of spigot. - *

- * - * @param blockType - * @return - */ - @Override - public XMaterial getXMaterial( BlockType blockType ) { - XMaterial results = getCachedXMaterial( blockType, NO_DATA_VALUE ); - - if ( results == null ) { - if ( blockType != null && blockType != BlockType.IGNORE ) { - - results = XMaterial.matchXMaterial( blockType.getXMaterialName() ).orElse( null ); - - if ( results == null ) { - results = XMaterial.matchXMaterial( blockType.getXMaterialNameLegacy() ).orElse( null ); - - } - - if ( results == null ) { - - for ( String altName : blockType.getXMaterialAltNames() ) { - results = XMaterial.matchXMaterial( altName ).orElse( null ); - - if ( results != null ) { - break; - } - } - } - - putCachedXMaterial( blockType, NO_DATA_VALUE, results ); - } - - } - - return results == NULL_TOKEN ? null : results; - } +// /** +// *

This function tries to use up to three different sources to get a match +// * on the XMaterial. Just because the XMateral may be a match, does not +// * mean it actually is a valid Block for that version of spigot. +// *

+// * +// * @param blockType +// * @return +// */ +// @Override +// public XMaterial getXMaterial( BlockType blockType ) { +// XMaterial results = getCachedXMaterial( blockType, NO_DATA_VALUE ); +// +// if ( results == null ) { +// if ( blockType != null && blockType != BlockType.IGNORE ) { +// +// results = XMaterial.matchXMaterial( blockType.getXMaterialName() ).orElse( null ); +// +// if ( results == null ) { +// results = XMaterial.matchXMaterial( blockType.getXMaterialNameLegacy() ).orElse( null ); +// +// } +// +// if ( results == null ) { +// +// for ( String altName : blockType.getXMaterialAltNames() ) { +// results = XMaterial.matchXMaterial( altName ).orElse( null ); +// +// if ( results != null ) { +// break; +// } +// } +// } +// +// putCachedXMaterial( blockType, NO_DATA_VALUE, results ); +// } +// +// } +// +// return results == NULL_TOKEN ? null : results; +// } - @Override - public void updateSpigotBlock( BlockType blockType, Block spigotBlock ) { - - if ( blockType != null && blockType != BlockType.IGNORE && spigotBlock != null ) { - - XMaterial xMat = getXMaterial( blockType ); - - updateSpigotBlock( xMat, spigotBlock ); - } - } +// @Override +// public void updateSpigotBlock( BlockType blockType, Block spigotBlock ) { +// +// if ( blockType != null && blockType != BlockType.IGNORE && spigotBlock != null ) { +// +// XMaterial xMat = getXMaterial( blockType ); +// +// updateSpigotBlock( xMat, spigotBlock ); +// } +// } @Override 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 e71862590..19f5382c6 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 @@ -14,7 +14,6 @@ import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; -import tech.mcprison.prison.util.BlockType; import tech.mcprison.prison.util.Location; public abstract class Spigot18Blocks @@ -22,64 +21,64 @@ public abstract class Spigot18Blocks implements CompatibilityBlocks { - /** - *

This function provides a minecraft v1.8 way of getting - * the prison BlockType from a bukkit Block. This function - * should be used for all block types prior to 1.13.x because - * of the use of magic numbers. The variations of types for a - * base material cannot be accessed in any other way. - * For example the item lapis lazuli, which is not a block type, - * but it is one of the primary problem item. - *

- * - *

For versions 1.13.x and higher, a different function would - * need to be used to get the BlockType. - *

- * - * @param spigotBlock - * @return - */ - @SuppressWarnings( "deprecation" ) - @Override - public BlockType getBlockType(Block spigotBlock) { - BlockType results = BlockType.NULL_BLOCK; - - if ( spigotBlock != null ) { - - int id = spigotBlock.getType().getId(); - short data = spigotBlock.getData(); - - results = getCachedBlockType( spigotBlock, (byte) data ); - if ( results == null ) { - - // NOTE: namespace is 1.13+ -// Output.get().logInfo( "### getBlockType: " + spigotBlock.getType().name() + " " + -// spigotBlock.getType().getKey().getKey() + " " + -// spigotBlock.getType().getKey().getNamespace() ); - - results = BlockType.getBlock(id, data); - - if ( results == null ) { - - results = BlockType.getBlock( spigotBlock.getType().name() ); - - if ( results == null ) { - - Output.get().logWarn( "Spigot18Blocks.getBlockType() : " + - "Spigot block cannot be mapped to a prison BlockType : " + - spigotBlock.getType().name() + - " id = " + id + " data = " + data + - " BlockType = " + ( results == null ? "null" : results.name())); - - } - } - - putCachedBlockType( spigotBlock, (byte) data, results ); - } - } - - return results == BlockType.NULL_BLOCK ? null : results; - } +// /** +// *

This function provides a minecraft v1.8 way of getting +// * the prison BlockType from a bukkit Block. This function +// * should be used for all block types prior to 1.13.x because +// * of the use of magic numbers. The variations of types for a +// * base material cannot be accessed in any other way. +// * For example the item lapis lazuli, which is not a block type, +// * but it is one of the primary problem item. +// *

+// * +// *

For versions 1.13.x and higher, a different function would +// * need to be used to get the BlockType. +// *

+// * +// * @param spigotBlock +// * @return +// */ +// @SuppressWarnings( "deprecation" ) +// @Override +// public BlockType getBlockType(Block spigotBlock) { +// BlockType results = BlockType.NULL_BLOCK; +// +// if ( spigotBlock != null ) { +// +// int id = spigotBlock.getType().getId(); +// short data = spigotBlock.getData(); +// +// results = getCachedBlockType( spigotBlock, (byte) data ); +// if ( results == null ) { +// +// // NOTE: namespace is 1.13+ +//// Output.get().logInfo( "### getBlockType: " + spigotBlock.getType().name() + " " + +//// spigotBlock.getType().getKey().getKey() + " " + +//// spigotBlock.getType().getKey().getNamespace() ); +// +// results = BlockType.getBlock(id, data); +// +// if ( results == null ) { +// +// results = BlockType.getBlock( spigotBlock.getType().name() ); +// +// if ( results == null ) { +// +// Output.get().logWarn( "Spigot18Blocks.getBlockType() : " + +// "Spigot block cannot be mapped to a prison BlockType : " + +// spigotBlock.getType().name() + +// " id = " + id + " data = " + data + +// " BlockType = " + ( results == null ? "null" : results.name())); +// +// } +// } +// +// putCachedBlockType( spigotBlock, (byte) data, results ); +// } +// } +// +// return results == BlockType.NULL_BLOCK ? null : results; +// } @Override public PrisonBlock getPrisonBlock(Block spigotBlock) { @@ -98,109 +97,109 @@ public PrisonBlock getPrisonBlock(Block spigotBlock) { } - @SuppressWarnings( "deprecation" ) - @Override - public BlockType getBlockType( ItemStack spigotStack ) { - BlockType results = BlockType.NULL_BLOCK; - - if ( spigotStack != null ) { - - int id = spigotStack.getType().getId(); - short data = spigotStack.getData().getData(); - - results = getCachedBlockType( spigotStack, (byte) data ); - if ( results == null ) { - - results = BlockType.getBlock(id, data); - - if ( results == null ) { - - // NOTE: Some items may have invalid data values. Example are with pickaxes - // should have a value of zero, but could range from +- 256. - // Try to use XMaterial to map back to a BlockType (old block model). - XMaterial xMat = xMatMatchXMaterial( spigotStack ); - - if ( xMat != null ) { - results = BlockType.getBlock( xMat.name() ); - } - - if ( results == null ) { - - String message = String.format( "Spigot18Blocks: getBlockType(): " + - "Unable to map to a BlockType. XMaterial = %s :: %s %s " + - "Material = %s ", - (xMat == null ? "null" : xMat.name()), - Integer.toString( id ), Integer.toString( data ), - spigotStack.getType().name() ); - - Output.get().logInfo( message ); - } - } - - putCachedBlockType( spigotStack, (byte) data, results ); - } - } - - return results == BlockType.NULL_BLOCK ? null : results; - } +// @SuppressWarnings( "deprecation" ) +// @Override +// public BlockType getBlockType( ItemStack spigotStack ) { +// BlockType results = BlockType.NULL_BLOCK; +// +// if ( spigotStack != null ) { +// +// int id = spigotStack.getType().getId(); +// short data = spigotStack.getData().getData(); +// +// results = getCachedBlockType( spigotStack, (byte) data ); +// if ( results == null ) { +// +// results = BlockType.getBlock(id, data); +// +// if ( results == null ) { +// +// // NOTE: Some items may have invalid data values. Example are with pickaxes +// // should have a value of zero, but could range from +- 256. +// // Try to use XMaterial to map back to a BlockType (old block model). +// XMaterial xMat = xMatMatchXMaterial( spigotStack ); +// +// if ( xMat != null ) { +// results = BlockType.getBlock( xMat.name() ); +// } +// +// if ( results == null ) { +// +// String message = String.format( "Spigot18Blocks: getBlockType(): " + +// "Unable to map to a BlockType. XMaterial = %s :: %s %s " + +// "Material = %s ", +// (xMat == null ? "null" : xMat.name()), +// Integer.toString( id ), Integer.toString( data ), +// spigotStack.getType().name() ); +// +// Output.get().logInfo( message ); +// } +// } +// +// putCachedBlockType( spigotStack, (byte) data, results ); +// } +// } +// +// return results == BlockType.NULL_BLOCK ? null : results; +// } - /** - *

Something is causing XMaterial to throw an exception that makes no sense - * since the item listed does not exist in game. - *

- * - *
-	 *  Caused by: java.lang.IllegalArgumentException: Unsupported material from item: BED (14)
-	at tech.mcprison.prison.cryptomorin.xseries.XMaterial.lambda$matchXMaterial$1(XMaterial.java:1559) ~[?:?]
-	at tech.mcprison.prison.cryptomorin.xseries.XMaterial$$Lambda$197/0x0000000069039ff0.get(Unknown Source) ~[?:?]
-	at java.util.Optional.orElseThrow(Optional.java:290) ~[?:1.8.0_272]
-	at tech.mcprison.prison.cryptomorin.xseries.XMaterial.matchXMaterial(XMaterial.java:1559) ~[?:?]
-	at tech.mcprison.prison.spigot.compat.Spigot18Blocks.getBlockType(Spigot18Blocks.java:116) ~[?:?]
-	at tech.mcprison.prison.spigot.block.SpigotItemStack.(SpigotItemStack.java:45) ~[?:?]
-	at tech.mcprison.prison.spigot.SpigotUtil.bukkitItemStackToPrison(SpigotUtil.java:583) ~[?:?]
-	at tech.mcprison.prison.spigot.SpigotListener.onPlayerInteract(SpigotListener.java:172) ~[?:?]
-	at sun.reflect.GeneratedMethodAccessor64.invoke(Unknown Source) ~[?:?]
-	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_272]
-	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_272]
-	at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot-1.12.2.jar:git-Spigot-eb3d921-2b93d83]
-	... 17 more
-	 *  
- * - * - * NOTE: Some items may have invalid data values. Example are with pickaxes - * should have a value of zero, but could range from +- 256. - * Try to use XMaterial to map back to a BlockType (old block model). - * - * @param spigotStack - * @return - */ - @SuppressWarnings( "deprecation" ) - private XMaterial xMatMatchXMaterial( ItemStack spigotStack ) { - XMaterial xMat = null; - - if ( spigotStack != null ) { - - try { - xMat = XMaterial.matchXMaterial( spigotStack ); - } - catch ( Exception e ) { - - int id = spigotStack.getType().getId(); - short data = spigotStack.getData().getData(); - - // Invalid type from the stack: - Output.get().logDebug( "Spigot188Blocks: unable to matchXMaterial. " + - "Type=%s Qty=%s id=%s data=%s Error=[%s]", - spigotStack.getType().name(), - Integer.toString( spigotStack.getAmount() ), - Integer.toString( id ), - Integer.toString( data ), - e.getMessage() ); - } - } - - return xMat; - } +// /** +// *

Something is causing XMaterial to throw an exception that makes no sense +// * since the item listed does not exist in game. +// *

+// * +// *
+//	 *  Caused by: java.lang.IllegalArgumentException: Unsupported material from item: BED (14)
+//	at tech.mcprison.prison.cryptomorin.xseries.XMaterial.lambda$matchXMaterial$1(XMaterial.java:1559) ~[?:?]
+//	at tech.mcprison.prison.cryptomorin.xseries.XMaterial$$Lambda$197/0x0000000069039ff0.get(Unknown Source) ~[?:?]
+//	at java.util.Optional.orElseThrow(Optional.java:290) ~[?:1.8.0_272]
+//	at tech.mcprison.prison.cryptomorin.xseries.XMaterial.matchXMaterial(XMaterial.java:1559) ~[?:?]
+//	at tech.mcprison.prison.spigot.compat.Spigot18Blocks.getBlockType(Spigot18Blocks.java:116) ~[?:?]
+//	at tech.mcprison.prison.spigot.block.SpigotItemStack.(SpigotItemStack.java:45) ~[?:?]
+//	at tech.mcprison.prison.spigot.SpigotUtil.bukkitItemStackToPrison(SpigotUtil.java:583) ~[?:?]
+//	at tech.mcprison.prison.spigot.SpigotListener.onPlayerInteract(SpigotListener.java:172) ~[?:?]
+//	at sun.reflect.GeneratedMethodAccessor64.invoke(Unknown Source) ~[?:?]
+//	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_272]
+//	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_272]
+//	at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot-1.12.2.jar:git-Spigot-eb3d921-2b93d83]
+//	... 17 more
+//	 *  
+// * +// * +// * NOTE: Some items may have invalid data values. Example are with pickaxes +// * should have a value of zero, but could range from +- 256. +// * Try to use XMaterial to map back to a BlockType (old block model). +// * +// * @param spigotStack +// * @return +// */ +// @SuppressWarnings( "deprecation" ) +// private XMaterial xMatMatchXMaterial( ItemStack spigotStack ) { +// XMaterial xMat = null; +// +// if ( spigotStack != null ) { +// +// try { +// xMat = XMaterial.matchXMaterial( spigotStack ); +// } +// catch ( Exception e ) { +// +// int id = spigotStack.getType().getId(); +// short data = spigotStack.getData().getData(); +// +// // Invalid type from the stack: +// Output.get().logDebug( "Spigot188Blocks: unable to matchXMaterial. " + +// "Type=%s Qty=%s id=%s data=%s Error=[%s]", +// spigotStack.getType().name(), +// Integer.toString( spigotStack.getAmount() ), +// Integer.toString( id ), +// Integer.toString( data ), +// e.getMessage() ); +// } +// } +// +// return xMat; +// } @SuppressWarnings( "deprecation" ) @Override @@ -278,49 +277,49 @@ public XMaterial getXMaterial( PrisonBlock prisonBlock ) { } - @Override - public XMaterial getXMaterial( BlockType blockType ) { - XMaterial results = NULL_TOKEN; - - if ( blockType != null && blockType != BlockType.IGNORE ) { - short data = blockType.getData(); - - results = getCachedXMaterial( blockType, (byte) data ); - if ( results == null ) { - - // First match by BlockType name: - results = XMaterial.matchXMaterial( blockType.getXMaterialName() ).orElse( null ); - - // do not use... redundant with blockType.getXMaterialName(): -// results = XMaterial.matchXMaterial( blockType.name() ).orElse( null ); - - if ( results == null ) { - - // Try to match on altNames if they exist: - for ( String altName : blockType.getXMaterialAltNames() ) { - - results = XMaterial.matchXMaterial( altName ).orElse( null ); - - if ( results != null ) { - break; - } - } - - if ( results == null ) { - - // Finally, Try to match on legacy name and magic number: - results = XMaterial.matchXMaterial( blockType.getXMaterialNameLegacy() ).orElse( null ); - } - - putCachedXMaterial( blockType, (byte) data, results ); - } - - } - - } - - return results == NULL_TOKEN ? null : results; - } +// @Override +// public XMaterial getXMaterial( BlockType blockType ) { +// XMaterial results = NULL_TOKEN; +// +// if ( blockType != null && blockType != BlockType.IGNORE ) { +// short data = blockType.getData(); +// +// results = getCachedXMaterial( blockType, (byte) data ); +// if ( results == null ) { +// +// // First match by BlockType name: +// results = XMaterial.matchXMaterial( blockType.getXMaterialName() ).orElse( null ); +// +// // do not use... redundant with blockType.getXMaterialName(): +//// results = XMaterial.matchXMaterial( blockType.name() ).orElse( null ); +// +// if ( results == null ) { +// +// // Try to match on altNames if they exist: +// for ( String altName : blockType.getXMaterialAltNames() ) { +// +// results = XMaterial.matchXMaterial( altName ).orElse( null ); +// +// if ( results != null ) { +// break; +// } +// } +// +// if ( results == null ) { +// +// // Finally, Try to match on legacy name and magic number: +// results = XMaterial.matchXMaterial( blockType.getXMaterialNameLegacy() ).orElse( null ); +// } +// +// putCachedXMaterial( blockType, (byte) data, results ); +// } +// +// } +// +// } +// +// return results == NULL_TOKEN ? null : results; +// } // public Material getMaterial( BlockType blockType ) { @@ -358,19 +357,19 @@ public XMaterial getXMaterial( BlockType blockType ) { // } - @Override - public void updateSpigotBlock( BlockType blockType, Block spigotBlock ) { - - if ( blockType != null && blockType != BlockType.IGNORE && spigotBlock != null ) { - - XMaterial xMat = getXMaterial( blockType ); - - if ( xMat != null ) { - - updateSpigotBlock( xMat, spigotBlock ); - } - } - } +// @Override +// public void updateSpigotBlock( BlockType blockType, Block spigotBlock ) { +// +// if ( blockType != null && blockType != BlockType.IGNORE && spigotBlock != null ) { +// +// XMaterial xMat = getXMaterial( blockType ); +// +// if ( xMat != null ) { +// +// updateSpigotBlock( xMat, spigotBlock ); +// } +// } +// } @Override 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 601356849..57248f181 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 @@ -124,7 +124,7 @@ public Optional getLocale() { } @Override - public tech.mcprison.prison.internal.block.Block getLineOfSightBlock() { + public SpigotBlock getLineOfSightBlock() { SpigotBlock results = null; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotFurnaceRecipe.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotFurnaceRecipe.java index f34f9cfd1..528c545e3 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotFurnaceRecipe.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotFurnaceRecipe.java @@ -18,31 +18,43 @@ package tech.mcprison.prison.spigot.inventory; -import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.inventory.FurnaceRecipe; import tech.mcprison.prison.spigot.SpigotUtil; -import tech.mcprison.prison.util.BlockType; /** * Created by DMP9 on 04/02/2017. */ -public class SpigotFurnaceRecipe extends SpigotRecipe implements FurnaceRecipe { +public class SpigotFurnaceRecipe + extends SpigotRecipe + implements FurnaceRecipe { public SpigotFurnaceRecipe(org.bukkit.inventory.FurnaceRecipe wrapper) { super(wrapper); } - @Override public ItemStack getInput() { + @Override + public ItemStack getInput() { return SpigotUtil.bukkitItemStackToPrison( ((org.bukkit.inventory.FurnaceRecipe) getWrapper()).getInput()); } - @Override public FurnaceRecipe setInput(BlockType input) { - Material material = SpigotUtil.getMaterial( input ); - ((org.bukkit.inventory.FurnaceRecipe) getWrapper()) - .setInput(material); + @Override + public FurnaceRecipe setInput( PrisonBlock input) { + + XMaterial xMat = SpigotUtil.getXMaterial( input ); + + if ( xMat != null ) { + ((org.bukkit.inventory.FurnaceRecipe) getWrapper()) + .setInput( xMat.parseMaterial() ); + } + +// Material material = SpigotUtil.getMaterial( input ); +// ((org.bukkit.inventory.FurnaceRecipe) getWrapper()) +// .setInput(material); return this; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotInventory.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotInventory.java index 39e1878c5..ed58a832b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotInventory.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotInventory.java @@ -28,14 +28,16 @@ import org.bukkit.inventory.BeaconInventory; import org.bukkit.inventory.BrewerInventory; +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.inventory.Inventory; import tech.mcprison.prison.internal.inventory.InventoryHolder; import tech.mcprison.prison.internal.inventory.InventoryType; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.game.SpigotPlayer; -import tech.mcprison.prison.util.BlockType; /** * Created by DMP9 on 03/02/2017. @@ -92,45 +94,57 @@ public org.bukkit.inventory.Inventory getWrapper() { } @SuppressWarnings( "deprecation" ) - @Override public String getTitle() { + @Override + public String getTitle() { return wrapper.getTitle(); } - @Override public List getViewers() { + @Override + public List getViewers() { List players = new ArrayList<>(); wrapper.getViewers() .forEach(x -> players.add(new SpigotPlayer((org.bukkit.entity.Player) x))); return players; } - @Override public int getSize() { + @Override + public int getSize() { return wrapper.getSize(); } - @Override public int getMaxStackSize() { + @Override + public int getMaxStackSize() { return wrapper.getMaxStackSize(); } - @Override public void setMaxStackSize(int size) { + @Override + public void setMaxStackSize(int size) { wrapper.setMaxStackSize(size); } @SuppressWarnings( "deprecation" ) - @Override public String getName() { + @Override + public String getName() { return wrapper.getName(); } - @Override public boolean isEmpty() { + @Override + public boolean isEmpty() { return wrapper.getContents().length == 0; } - @Override public boolean contains(ItemStack itemStack) { + @Override + public boolean contains(ItemStack itemStack) { return wrapper.contains(SpigotUtil.prisonItemStackToBukkit(itemStack)); } - @Override public boolean contains(BlockType type) { - org.bukkit.inventory.ItemStack bukkitStack = SpigotUtil.getItemStack( type, 1 ); - return wrapper.contains(bukkitStack); + @Override + public boolean contains( PrisonBlock type ) { + XMaterial xMat = SpigotUtil.getXMaterial( type ); + return wrapper.contains( xMat.parseItem() ); + +// org.bukkit.inventory.ItemStack bukkitStack = SpigotUtil.getItemStack( type, 1 ); +// return wrapper.contains(bukkitStack); // MaterialData materialData = SpigotUtil.blockTypeToMaterial(type); // org.bukkit.inventory.ItemStack stack = // new org.bukkit.inventory.ItemStack(materialData.getItemType()); @@ -138,29 +152,33 @@ public org.bukkit.inventory.Inventory getWrapper() { // return wrapper.contains(stack); } - @Override public Iterator getIterator() { + @Override + public Iterator getIterator() { ArrayList prisonStacks = new ArrayList<>(); Arrays.asList(wrapper.getContents()) .forEach(x -> prisonStacks.add(SpigotUtil.bukkitItemStackToPrison(x))); return prisonStacks.iterator(); } - @Override public ItemStack[] getItems() { + @Override + public ItemStack[] getItems() { ArrayList prisonStacks = new ArrayList<>(); Arrays.asList(wrapper.getContents()) .forEach(x -> prisonStacks.add(SpigotUtil.bukkitItemStackToPrison(x))); return prisonStacks.toArray(new ItemStack[]{}); } - @Override public void setItems(List items) { + @Override + public void setItems(List items) { List stacks = new ArrayList<>(); items.forEach(x -> stacks.add(SpigotUtil.prisonItemStackToBukkit(x))); } - @Override public HashMap getItems(BlockType type) { + @Override + public HashMap getItems( PrisonBlock type ) { HashMap result = new HashMap<>(); List items = Arrays.asList(getItems()); - items.removeIf(x -> x.getMaterial() != type); + items.removeIf(x -> !x.getMaterial().equals( type ) ); items.forEach(y -> result.put(items.indexOf(y), y)); return result; } @@ -173,11 +191,13 @@ public org.bukkit.inventory.Inventory getWrapper() { return result; } - @Override public ItemStack getItem(int index) { + @Override + public ItemStack getItem(int index) { return SpigotUtil.bukkitItemStackToPrison(wrapper.getItem(index)); } - @Override public void addItem(ItemStack... itemStack) { + @Override + public void addItem(ItemStack... itemStack) { ArrayList stacks = new ArrayList<>(); for (ItemStack stack : itemStack) { stacks.add(SpigotUtil.prisonItemStackToBukkit(stack)); @@ -185,7 +205,8 @@ public org.bukkit.inventory.Inventory getWrapper() { wrapper.addItem(stacks.toArray(new org.bukkit.inventory.ItemStack[]{})); } - @Override public void removeItem(ItemStack... itemStack) { + @Override + public void removeItem(ItemStack... itemStack) { ArrayList stacks = new ArrayList<>(); for (ItemStack stack : itemStack) { stacks.add(SpigotUtil.prisonItemStackToBukkit(stack)); @@ -193,21 +214,32 @@ public org.bukkit.inventory.Inventory getWrapper() { wrapper.removeItem(stacks.toArray(new org.bukkit.inventory.ItemStack[]{})); } - @Override public void clearAll() { + @Override + public void clearAll() { wrapper.clear(); } - @Override public void clearAll(int index) { + @Override + public void clearAll(int index) { wrapper.setContents(Arrays.copyOfRange(wrapper.getContents(), 0, index)); } - @Override public void clear(int index) { + @Override + public void clear(int index) { wrapper.clear(index); } - @Override public void clear(BlockType type) { - org.bukkit.inventory.ItemStack bukkitStack = SpigotUtil.getItemStack( type, 1 ); - wrapper.remove( bukkitStack ); + @Override + public void clear( PrisonBlock type ) { + + XMaterial xMat = SpigotUtil.getXMaterial( type ); + + if ( xMat != null ) { + wrapper.remove( xMat.parseItem() ); + } + +// org.bukkit.inventory.ItemStack bukkitStack = SpigotUtil.getItemStack( type, 1 ); +// wrapper.remove( bukkitStack ); // MaterialData materialData = SpigotUtil.blockTypeToMaterial(type); // org.bukkit.inventory.ItemStack stack = // new org.bukkit.inventory.ItemStack(materialData.getItemType()); @@ -215,17 +247,29 @@ public org.bukkit.inventory.Inventory getWrapper() { // wrapper.remove(stack); } - @Override public void clear(ItemStack stack) { + @Override + public void clear(ItemStack stack) { wrapper.remove(SpigotUtil.prisonItemStackToBukkit(stack)); } - @Override public int first(ItemStack stack) { + @Override + public int first(ItemStack stack) { return wrapper.first(SpigotUtil.prisonItemStackToBukkit(stack)); } - @Override public int first(BlockType type) { - org.bukkit.inventory.ItemStack bukkitStack = SpigotUtil.getItemStack( type, 1 ); - return wrapper.first(bukkitStack); + @Override + public int first( PrisonBlock type) { + int results = -1; + + XMaterial xMat = SpigotUtil.getXMaterial( type ); + + if ( xMat != null ) { + results = wrapper.first( xMat.parseItem() ); + } + + return results; +// org.bukkit.inventory.ItemStack bukkitStack = SpigotUtil.getItemStack( type, 1 ); +// return wrapper.first(bukkitStack); // MaterialData materialData = SpigotUtil.blockTypeToMaterial(type); // org.bukkit.inventory.ItemStack stack = // new org.bukkit.inventory.ItemStack(materialData.getItemType()); @@ -233,19 +277,23 @@ public org.bukkit.inventory.Inventory getWrapper() { // return wrapper.first(stack); } - @Override public int firstEmpty() { + @Override + public int firstEmpty() { return wrapper.firstEmpty(); } - @Override public InventoryHolder getHolder() { + @Override + public InventoryHolder getHolder() { return new SpigotInventoryHolder(wrapper.getHolder()); } - @Override public InventoryType getType() { + @Override + public InventoryType getType() { return SpigotUtil.bukkitInventoryTypeToPrison(wrapper.getType()); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return getIterator(); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotShapedRecipe.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotShapedRecipe.java index 7bb070f6a..5d9538cfa 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotShapedRecipe.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotShapedRecipe.java @@ -21,12 +21,12 @@ import java.util.HashMap; import java.util.Map; -import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.inventory.ShapedRecipe; import tech.mcprison.prison.spigot.SpigotUtil; -import tech.mcprison.prison.util.BlockType; /** * Created by DMP9 on 04/02/2017. @@ -37,27 +37,39 @@ public SpigotShapedRecipe(org.bukkit.inventory.ShapedRecipe wrapper) { super(wrapper); } - @Override public Map getIngredientMap() { + @Override + public Map getIngredientMap() { Map stackMap = ((org.bukkit.inventory.ShapedRecipe) getWrapper()).getIngredientMap(); + Map result = new HashMap<>(); stackMap.forEach((x, y) -> result.put(x, SpigotUtil.bukkitItemStackToPrison(y))); return result; } - @Override public String[] getShape() { + @Override + public String[] getShape() { return ((org.bukkit.inventory.ShapedRecipe) getWrapper()).getShape(); } - @Override public ShapedRecipe setIngredient(char key, BlockType ingredient) { - Material mat = SpigotUtil.getMaterial( ingredient ); + @Override + public ShapedRecipe setIngredient(char key, PrisonBlock ingredient) { - ((org.bukkit.inventory.ShapedRecipe) getWrapper()) - .setIngredient(key, mat); + XMaterial xMat = SpigotUtil.getXMaterial( ingredient ); + + if ( xMat != null ) { + ((org.bukkit.inventory.ShapedRecipe) getWrapper()) + .setIngredient( key, xMat.parseMaterial() ); + } +// Material mat = SpigotUtil.getMaterial( ingredient ); + +// ((org.bukkit.inventory.ShapedRecipe) getWrapper()) +// .setIngredient(key, mat); return this; } - @Override public ShapedRecipe shape(String... shape) { + @Override + public ShapedRecipe shape(String... shape) { ((org.bukkit.inventory.ShapedRecipe) getWrapper()).shape(shape); return this; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotShapelessRecipe.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotShapelessRecipe.java index 12a9bb7cb..960f1fe60 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotShapelessRecipe.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotShapelessRecipe.java @@ -21,37 +21,58 @@ import java.util.ArrayList; import java.util.List; -import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.inventory.ShapelessRecipe; import tech.mcprison.prison.spigot.SpigotUtil; -import tech.mcprison.prison.util.BlockType; /** * Created by DMP9 on 04/02/2017. */ -public class SpigotShapelessRecipe extends SpigotRecipe implements ShapelessRecipe { +public class SpigotShapelessRecipe + extends SpigotRecipe + implements ShapelessRecipe { public SpigotShapelessRecipe(org.bukkit.inventory.ShapelessRecipe wrapper) { super(wrapper); } - @Override public ShapelessRecipe addIngredient(int count, BlockType ingredient) { - Material mat = SpigotUtil.getMaterial( ingredient ); - ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) - .addIngredient(count, mat); + @Override + public ShapelessRecipe addIngredient( int count, PrisonBlock ingredient ) { + + XMaterial xMat = SpigotUtil.getXMaterial( ingredient ); + + if ( xMat != null ) { + ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) + .addIngredient(count, xMat.parseMaterial() ); + } + +// Material mat = SpigotUtil.getMaterial( ingredient ); +// ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) +// .addIngredient(count, mat); return this; } - @Override public ShapelessRecipe addIngredient(BlockType ingredient) { - Material mat = SpigotUtil.getMaterial( ingredient ); - ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) - .addIngredient(mat); + @Override + public ShapelessRecipe addIngredient( PrisonBlock ingredient ) { + + XMaterial xMat = SpigotUtil.getXMaterial( ingredient ); + + if ( xMat != null ) { + ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) + .addIngredient( xMat.parseMaterial() ); + } + +// Material mat = SpigotUtil.getMaterial( ingredient ); +// ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) +// .addIngredient(mat); return this; } - @Override public List getIngredientList() { + @Override + public List getIngredientList() { List bukkit = ((org.bukkit.inventory.ShapelessRecipe) getWrapper()).getIngredientList(); List result = new ArrayList<>(); @@ -59,17 +80,35 @@ public SpigotShapelessRecipe(org.bukkit.inventory.ShapelessRecipe wrapper) { return result; } - @Override public ShapelessRecipe removeIngredient(int count, BlockType ingredient) { - Material mat = SpigotUtil.getMaterial( ingredient ); - ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) - .removeIngredient(count, mat); + @Override + public ShapelessRecipe removeIngredient(int count, PrisonBlock ingredient ) { + + XMaterial xMat = SpigotUtil.getXMaterial( ingredient ); + + if ( xMat != null ) { + ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) + .removeIngredient(count, xMat.parseMaterial() ); + } + +// Material mat = SpigotUtil.getMaterial( ingredient ); +// ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) +// .removeIngredient(count, mat); return this; } - @Override public ShapelessRecipe removeIngredient(BlockType ingredient) { - Material mat = SpigotUtil.getMaterial( ingredient ); - ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) - .removeIngredient(mat); + @Override + public ShapelessRecipe removeIngredient( PrisonBlock ingredient ) { + + XMaterial xMat = SpigotUtil.getXMaterial( ingredient ); + + if ( xMat != null ) { + ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) + .removeIngredient( xMat.parseMaterial() ); + } + +// Material mat = SpigotUtil.getMaterial( ingredient ); +// ((org.bukkit.inventory.ShapelessRecipe) getWrapper()) +// .removeIngredient(mat); return this; } diff --git a/prison-spigot/src/test/java/tech/mcprison/prison/spigot/SpigotPlatformTest.java b/prison-spigot/src/test/java/tech/mcprison/prison/spigot/SpigotPlatformTest.java index 87940c71e..d696401fb 100644 --- a/prison-spigot/src/test/java/tech/mcprison/prison/spigot/SpigotPlatformTest.java +++ b/prison-spigot/src/test/java/tech/mcprison/prison/spigot/SpigotPlatformTest.java @@ -4,6 +4,8 @@ import java.util.List; +import tech.mcprison.prison.spigot.sellall.SellAllBlockData; + public class SpigotPlatformTest //extends SpigotPlatform { @@ -13,7 +15,9 @@ public class SpigotPlatformTest public void testMineBlockList() { - List blockList = sp.buildBlockListBlockType(); + List blockList = sp.buildBlockListXMaterial(); + + // List blockList = sp.buildBlockListBlockType(); int i = -1; @@ -52,8 +56,9 @@ public void testMineBlockList() } - protected List mineBlockList( List blockList, int startPos, int length ) { - List results = sp.mineBlockList( blockList, startPos, length); + protected List mineBlockList( List blockList, int startPos, int length ) { + + List results = sp.mineBlockList( startPos, length, blockList ); System.out.println( results ); From 00f7ab7c61f12f6c38521c215cf25b36c82aaa9e Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 25 Jan 2022 03:08:44 -0500 Subject: [PATCH 003/297] Fix some block issues, mostly getting the correct block bukkit block and limit it to only one location and function that ultimately provides these hooks. This release appears to be more functional, but it still should not be used since it's not fully tested. --- docs/changelog_v3.3.x.md | 6 +- .../prison/internal/block/PrisonBlock.java | 20 +++-- .../mcprison/prison/mines/data/MineTasks.java | 7 +- .../mines/features/MineLinerBuilder.java | 20 +++-- .../mines/tasks/MineChangeBlockTask.java | 8 +- .../prison/spigot/SpigotListener.java | 4 +- .../prison/spigot/SpigotPlatform.java | 87 +++++++++++------- .../api/PrisonMinesBlockBreakEvent.java | 2 +- .../api/PrisonMinesBlockEventEvent.java | 2 +- .../prison/spigot/api/PrisonSpigotAPI.java | 2 +- .../spigot/block/OnBlockBreakEventCore.java | 14 +-- .../spigot/block/OnBlockBreakMines.java | 4 +- .../prison/spigot/block/SpigotBlock.java | 37 ++++++-- .../spigot/block/SpigotBrewingStand.java | 2 +- .../spigot/compat/CompatibilityBlocks.java | 3 +- .../prison/spigot/compat/Spigot113Blocks.java | 40 ++++++--- .../prison/spigot/compat/Spigot18Blocks.java | 41 +++++---- .../customblock/CustomItemsWrapper.java | 7 +- .../prison/spigot/game/SpigotPlayer.java | 4 +- .../prison/spigot/game/SpigotWorld.java | 67 ++++++++++---- .../spigot/utils/PrisonBombListener.java | 2 +- .../spigot/utils/PrisonUtilsListeners.java | 2 +- .../prison/spigot/SpigotPlatformTest.java | 90 ++++++++++++------- 23 files changed, 307 insertions(+), 164 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index fd0c274cf..8b63d1e7e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.7 2022-01-24 +# 3.3.0-alpha.7 2022-01-25 + + +* **Fix some block issues, mostly getting the correct block bukkit block and limit it to only one location and function that ultimately provides these hooks.** +This release appears to be more functional, but it still should not be used since it's not fully tested. * **First pass at removing the old block model. Do not use this release!!** diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java index 602db044a..ec7922d98 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java @@ -92,7 +92,10 @@ public PrisonBlock( PrisonBlockType blockType, String blockName, double chance, } public PrisonBlock( PrisonBlock clonable ) { - this( clonable.getBlockType(), clonable.getBlockName(), clonable.getChance(), clonable.getBlockCountTotal() ); + this( clonable.getBlockType(), + clonable.getBlockName(), + clonable.getChance(), + clonable.getBlockCountTotal() ); this.useBlockTypeAsPrefix = clonable.isUseBlockTypeAsPrefix(); this.valid = clonable.isValid(); @@ -322,41 +325,40 @@ public Block getRelative( BlockFace face ) { case NORTH: { // North is z axis in the negative direction: - loc.setZ( loc.getZ() - 1 ); + results = loc.getBlockAtDelta( 0, 0, -1 ); break; } case SOUTH: { // South is z axis in the positive direction: - loc.setZ( loc.getZ() + 1 ); + results = loc.getBlockAtDelta( 0, 0, 1 ); break; } case EAST: { // East is x axis in the positive direction: - loc.setX( loc.getX() + 1 ); + results = loc.getBlockAtDelta( 1, 0, 0 ); break; } case WEST: { // West is x axis in the negative direction: - loc.setX( loc.getX() - 1 ); + results = loc.getBlockAtDelta( -1, 0, 0 ); break; } case TOP: case UP: { // TOP and UP is y axis in the positive direction: - loc.setY( loc.getY() + 1 ); + results = loc.getBlockAtDelta( 0, 1, 0 ); break; } case BOTTOM: case DOWN: { // BOTTOM and DOWN is y axis in the negative direction: - loc.setY( loc.getY() - 1 ); + results = loc.getBlockAtDelta( 0, -1, 0 ); break; } default: + break; } - - results = loc.getBlockAt(); } return results; diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java index 5bdc66723..59e9b8cc4 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java @@ -5,6 +5,7 @@ import tech.mcprison.prison.Prison; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.World; +import tech.mcprison.prison.internal.block.Block; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.MineScheduler.MineJob; @@ -165,8 +166,10 @@ public Location teleportPlayerOut(Player player, String targetLocation) { // glass block: Location targetGround = new Location( tpTargetLocation ); targetGround.setY( tpTargetLocation.getBlockY() - 1 ); - if ( targetGround.getBlockAt().isEmpty() ) { - targetGround.getBlockAt().setPrisonBlock( PrisonBlock.GLASS );; + + Block pBlock = targetGround.getBlockAt(); + if ( pBlock.isEmpty() ) { + pBlock.setPrisonBlock( PrisonBlock.GLASS );; } player.teleport( tpTargetLocation ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java index c91620676..9bc910425 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java @@ -610,32 +610,34 @@ private boolean isLadderBlock( int curr, int min, int max ) { */ private Block getRelativeBlock( Location location, Edges edge, int offset ) { - Location relLoc = new Location( location ); + Location relLoc = null; + switch ( edge ) { case north: - relLoc.setZ( relLoc.getBlockZ() - offset ); + relLoc = location.getLocationAtDelta( 0, 0, offset * -1 ); break; case south: - relLoc.setZ( relLoc.getBlockZ() + offset ); + relLoc = location.getLocationAtDelta( 0, 0, offset ); break; case east: - relLoc.setX( relLoc.getBlockX() + offset ); + relLoc = location.getLocationAtDelta( offset, 0, 0 ); break; case west: - relLoc.setX( relLoc.getBlockX() - offset ); + relLoc = location.getLocationAtDelta( offset * -1, 0, 0 ); break; case top: - relLoc.setY( relLoc.getBlockY() + offset ); + relLoc = location.getLocationAtDelta( 0, offset, 0 ); break; case bottom: - relLoc.setY( relLoc.getBlockY() - offset ); + relLoc = location.getLocationAtDelta( 0, offset * -1, 0 ); break; - + default: + relLoc = new Location( location ); break; } - + Block block = relLoc.getBlockAt(); return block; diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MineChangeBlockTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MineChangeBlockTask.java index 8d4067692..095c4b68e 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MineChangeBlockTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MineChangeBlockTask.java @@ -1,5 +1,6 @@ package tech.mcprison.prison.mines.tasks; +import tech.mcprison.prison.internal.block.Block; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.tasks.PrisonRunnable; import tech.mcprison.prison.util.Location; @@ -32,11 +33,14 @@ public void run() { // Replace the targetBlock if there is no checkBlock. If there is a checkBlock, // then make sure the block that will be replaced is that type of a block. + + Block block = getLocation().getBlockAt(); + if ( checkBlock == null || !topOfMineLocation.getBlockAt().isEmpty() && - getLocation().getBlockAt().getPrisonBlock().equals( getCheckBlock() ) ) { + block.getPrisonBlock().equals( getCheckBlock() ) ) { - getLocation().getBlockAt().setPrisonBlock( getTargetBlock() ); + block.setPrisonBlock( getTargetBlock() ); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java index d51f0289d..720bad63d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java @@ -170,7 +170,7 @@ public void onPlayerSuffocation( EntityDamageEvent e ) { @EventHandler public void onBlockPlace(BlockPlaceEvent e) { org.bukkit.Location block = e.getBlockPlaced().getLocation(); - SpigotBlock sBlock = new SpigotBlock( e.getBlock() ); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock( e.getBlock() ); tech.mcprison.prison.internal.events.block.BlockPlaceEvent event = new tech.mcprison.prison.internal.events.block.BlockPlaceEvent( @@ -183,7 +183,7 @@ public void onBlockPlace(BlockPlaceEvent e) { @EventHandler public void onBlockBreak(BlockBreakEvent e) { org.bukkit.Location block = e.getBlock().getLocation(); - SpigotBlock sBlock = new SpigotBlock( e.getBlock() ); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock( e.getBlock() ); tech.mcprison.prison.internal.events.block.BlockBreakEvent event = new tech.mcprison.prison.internal.events.block.BlockBreakEvent( 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 5c0c3c64d..7ecac1a97 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 @@ -1520,7 +1520,8 @@ public void autoCreateMineBlockAssignment( List rankMineNames, boolean f Mine mine = mm.getMine( mineName ); - boolean hasBlocks = mine.getPrisonBlocks().size() > 0 || mine.getBlocks().size() > 0; + boolean hasBlocks = mine.getPrisonBlocks().size() > 0; +// boolean hasBlocks = mine.getPrisonBlocks().size() > 0 || mine.getBlocks().size() > 0; // If the mines already has blocks, log them, then clear them since this will replace them: if ( hasBlocks && !forceKeepBlocks ) { @@ -1532,7 +1533,7 @@ public void autoCreateMineBlockAssignment( List rankMineNames, boolean f Output.get().logInfo( message ); mine.getPrisonBlocks().clear(); - mine.getBlocks().clear(); +// mine.getBlocks().clear(); } else if ( hasBlocks && forceKeepBlocks ) { @@ -1546,7 +1547,7 @@ else if ( hasBlocks && forceKeepBlocks ) { continue; } - List mBlocks = mineBlockList( blockList, startPos++, mineBlockSize ); + List mBlocks = mineBlockList( blockList, startPos++, percents.size() ); // If startPos > percents.size(), which means we are past the initial // ramp up to the full variety of blocks per mine. At that point, if @@ -1556,9 +1557,12 @@ else if ( hasBlocks && forceKeepBlocks ) { // This should only happen at the tail end of processing and will only // have a decrease by one per mine so there should never be a need to // to check more than once, or remove more than one. - if ( startPos > percents.size() && percents.size() > mBlocks.size() ) { + if ( startPos > percents.size() && startPos > ( blockList.size() - mineBlockSize + 1 ) ) { percents.remove( 0 ); } +// if ( startPos > percents.size() && percents.size() > mBlocks.size() ) { +// percents.remove( 0 ); +// } double total = 0; for ( int i = 0; i < mBlocks.size(); i++ ) @@ -1569,7 +1573,8 @@ else if ( hasBlocks && forceKeepBlocks ) { PrisonBlock prisonBlock = Prison.get().getPlatform().getPrisonBlock( mBlocks.get( i ) ); if ( prisonBlock != null ) { - prisonBlock.setChance( percents.get( i ) ); + double chance = percents.size() > i ? percents.get( i ) : 0; + prisonBlock.setChance( chance ); prisonBlock.setBlockCountTotal( 0 ); mine.getPrisonBlocks().add( prisonBlock ); @@ -1580,6 +1585,7 @@ else if ( hasBlocks && forceKeepBlocks ) { // add the balance to the last block. if ( i == (mBlocks.size() - 1) && total < 100.0d ) { double remaining = 100.0d - total; + total += remaining; prisonBlock.setChance( remaining + prisonBlock.getChance() ); } } @@ -1590,23 +1596,23 @@ else if ( hasBlocks && forceKeepBlocks ) { mBlocks.get( i ) ) ); } } - else { - - tech.mcprison.prison.mines.data.BlockOld block = - new tech.mcprison.prison.mines.data.BlockOld( - mBlocks.get( i ), percents.get( i ), 0 ); - - mine.getBlocks().add( block ); - - total += block.getChance(); - - // If this is the last block and the totals are not 100%, then - // add the balance to the last block. - if ( i == (mBlocks.size() - 1) && total < 100.0d ) { - double remaining = 100.0d - total; - block.setChance( remaining + block.getChance() ); - } - } +// else { +// +// tech.mcprison.prison.mines.data.BlockOld block = +// new tech.mcprison.prison.mines.data.BlockOld( +// mBlocks.get( i ), percents.get( i ), 0 ); +// +// mine.getBlocks().add( block ); +// +// total += block.getChance(); +// +// // If this is the last block and the totals are not 100%, then +// // add the balance to the last block. +// if ( i == (mBlocks.size() - 1) && total < 100.0d ) { +// double remaining = 100.0d - total; +// block.setChance( remaining + block.getChance() ); +// } +// } } @@ -1681,22 +1687,37 @@ private LinerPatterns getRandomLinerType() { protected List mineBlockList( List blockList, int startPos, int length ) { List results = new ArrayList<>(); - for (int i = (startPos >= blockList.size() ? blockList.size() - 1 : startPos); i >= 0 && i >= startPos - length + 1; i--) { + int iStart = (startPos >= blockList.size() ? blockList.size() - 1 : startPos); + int iEnd = startPos - length + 1; + + for (int i = iStart; i >= 0 && i >= iEnd; i--) { results.add( blockList.get( i ) ); } return results; } - protected List mineBlockList( int startPos, int length, List blockList ) { - - List results = new ArrayList<>(); - for (int i = (startPos >= blockList.size() ? blockList.size() - 1 : startPos); i >= 0 && i >= startPos - length + 1; i--) { - results.add( blockList.get( i ).getBlock().name() ); - } - - return results; - } +// /** +// * This function grabs a rolling sub set of blocks from the startPos and working backwards +// * up to the specified length. The result set will be less than the specified length if at +// * the beginning of the list, or at the end. +// * +// * @param startPos +// * @param length +// * @param blockList +// * @return +// */ +// protected List mineBlockList( int startPos, int length, List blockList ) { +// +// List results = new ArrayList<>(); +// int iStart = (startPos >= blockList.size() ? blockList.size() - 1 : startPos); +// +// for (int i = iStart; i >= 0 && i >= startPos - length + 1; i--) { +// results.add( blockList.get( i ).getBlock().name() ); +// } +// +// return results; +// } /** @@ -1780,7 +1801,7 @@ public List buildBlockListXMaterial() { blockList.add( new SellAllBlockData( XMaterial.QUARTZ, 34 ) ); - blockList.add( new SellAllBlockData( XMaterial.QUARTZ_SLAB, 68, true) ); + blockList.add( new SellAllBlockData( XMaterial.QUARTZ_SLAB, 68) ); blockList.add( new SellAllBlockData( XMaterial.CHISELED_QUARTZ_BLOCK, 136 ) ); blockList.add( new SellAllBlockData( XMaterial.QUARTZ_BRICKS, 136 ) ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java index 627317d97..69ae4f74d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java @@ -213,7 +213,7 @@ public MineTargetPrisonBlock getOriginalTargetBlock( SpigotBlock spigotBlock ) { public MineTargetPrisonBlock getOriginalTargetBlock( Block bukkitBlock ) { - SpigotBlock spigotBlock = new SpigotBlock(bukkitBlock); + SpigotBlock spigotBlock = SpigotBlock.getSpigotBlock(bukkitBlock); return getOriginalTargetBlock( spigotBlock ); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockEventEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockEventEvent.java index 1ff0b45cb..15631197a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockEventEvent.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockEventEvent.java @@ -147,7 +147,7 @@ public MineTargetPrisonBlock getOriginalTargetBlock( SpigotBlock spigotBlock ) { public MineTargetPrisonBlock getOriginalTargetBlock( Block bukkitBlock ) { - SpigotBlock spigotBlock = new SpigotBlock(bukkitBlock); + SpigotBlock spigotBlock = SpigotBlock.getSpigotBlock(bukkitBlock); return getOriginalTargetBlock( spigotBlock ); } 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 2cc9f36aa..ec50848be 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 @@ -305,7 +305,7 @@ public Mine getPrisonMine( Player player, Block block, boolean isCanceledEvent) if ( isCanceledEvent && isAir || !isCanceledEvent ) { // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock spigotBlock = new SpigotBlock(block); + SpigotBlock spigotBlock = SpigotBlock.getSpigotBlock(block); Long playerUUIDLSB = Long.valueOf( player.getUniqueId().getLeastSignificantBits() ); 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 91923243c..c91e617ca 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 @@ -355,7 +355,7 @@ protected void genericBlockEvent( BlockBreakEvent e, boolean monitor, boolean bl { // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = new SpigotBlock(e.getBlock()); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); BlockEventType eventType = BlockEventType.blockBreak; @@ -759,7 +759,7 @@ private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder for ( Block bukkitBlock : pmEvent.getUnprocessedRawBlocks() ) { - SpigotBlock sBlock = new SpigotBlock( bukkitBlock ); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock( bukkitBlock ); // Thanks to CrazyEnchant, there is no telling which block was actually hit, so // if using CrazyEnchant one of the unprocessedRawBlocks may be the same as the @@ -800,7 +800,7 @@ else if ( targetExplodedBlock.isMined() ) { // Check to make sure the block is the same block that was placed there. // If not, then do not process it. - SpigotBlock sBlockMined = new SpigotBlock( bukkitBlock ); + SpigotBlock sBlockMined = SpigotBlock.getSpigotBlock( bukkitBlock ); PrisonBlock pBlockMined = sBlockMined.getPrisonBlock(); PrisonBlockStatusData pbTargetExploded = targetExplodedBlock.getPrisonBlock(); @@ -1173,7 +1173,7 @@ private void genericBlockExplodeEvent( TEBlockExplodeEvent e, boolean monitor, b // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = new SpigotBlock(e.getBlock()); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); BlockEventType eventType = BlockEventType.TEXplosion; @@ -1371,7 +1371,7 @@ protected void genericBlastUseEvent( BlastUseEvent e, boolean monitor, boolean b Block bukkitBlock = e.getBlockList().get( 0 ); // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = new SpigotBlock( bukkitBlock ); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock( bukkitBlock ); SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); BlockEventType eventType = BlockEventType.CEXplosion; @@ -1535,7 +1535,7 @@ protected void genericExplosiveEvent( PEExplosionEvent e, boolean monitor, boole // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = new SpigotBlock(e.getBlockBroken()); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlockBroken()); SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); BlockEventType eventType = BlockEventType.PEExplosive; @@ -1673,7 +1673,7 @@ protected void genericExplosiveEvent( ExplosiveBlockBreakEvent e, boolean monito // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = new SpigotBlock(e.getBlock()); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); BlockEventType eventType = BlockEventType.PrisonExplosion; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java index 903ddecfe..671f1098a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java @@ -85,7 +85,7 @@ public Mine findMine( UUID playerUUID, SpigotBlock sBlock, List altBlocks for ( Block bBlock : altBlocksSource ) { - SpigotBlock sBlockAltBlock = new SpigotBlock( bBlock ); + SpigotBlock sBlockAltBlock = SpigotBlock.getSpigotBlock( bBlock ); mine = findMineLocation( sBlockAltBlock ); if ( mine != null ) { @@ -138,7 +138,7 @@ public Mine findMine( UUID playerUUID, SpigotBlock sBlock, List altBlocks protected MinesEventResults ignoreMinesBlockBreakEvent( Player player, Block block ) { MinesEventResults results = new MinesEventResults(); - SpigotBlock sBlock = new SpigotBlock( block ); + SpigotBlock sBlock = SpigotBlock.getSpigotBlock( block ); if ( BlockUtils.getInstance().isUnbreakable( sBlock ) ) { results.setCancelEvent( true ); results.setIgnoreEvent( true ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java index c2e846841..0b4271406 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java @@ -55,14 +55,39 @@ public class SpigotBlock */ private transient Set prisonBlockTypes; + private SpigotBlock( String blockName, org.bukkit.block.Block bBlock ) { + super( blockName ); + + this.bBlock = bBlock; + + this.prisonBlockTypes = new HashSet<>(); + + } - public SpigotBlock(org.bukkit.block.Block bBlock) { - super( SpigotCompatibility.getInstance().getPrisonBlock( bBlock ) ); - this.bBlock = bBlock; - - this.prisonBlockTypes = new HashSet<>(); + public SpigotBlock( org.bukkit.block.Block bBlock, PrisonBlock targetBlockType ) { + this( targetBlockType.getBlockName(), bBlock ); + } + + public static SpigotBlock getSpigotBlock( org.bukkit.block.Block bukkitBlock) { + SpigotBlock sBlock = null; + + XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( bukkitBlock ); + + if ( xMat != null ) { + sBlock = new SpigotBlock( xMat.name(), bukkitBlock ); + } + + +// SpigotBlock sBlock = SpigotCompatibility.getInstance().getPrisonBlock( bBlock ); + +// super( SpigotCompatibility.getInstance().getPrisonBlock( bBlock ) ); +// super( XMaterial.matchXMaterial( bBlock.getType() ).name() ); +// super( XBlock. .getType( bBlock ).name() ); + + return sBlock; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -84,7 +109,7 @@ public String toString() { } @Override public PrisonBlock getRelative(BlockFace face) { - return new SpigotBlock( + return getSpigotBlock( getWrapper().getRelative( org.bukkit.block.BlockFace.valueOf( face.name()))); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBrewingStand.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBrewingStand.java index 69c75c0ec..82a93299e 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBrewingStand.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBrewingStand.java @@ -47,6 +47,6 @@ public SpigotBrewingStand(org.bukkit.block.BrewingStand wrapper) { } @Override public Block getBlock() { - return new SpigotBlock(wrapper.getBlock()); + return SpigotBlock.getSpigotBlock(wrapper.getBlock()); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java index ddb7c9851..1c983191f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java @@ -7,6 +7,7 @@ import tech.mcprison.prison.internal.block.BlockFace; import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.util.Location; @@ -15,7 +16,7 @@ public interface CompatibilityBlocks // public BlockType getBlockType(Block spigotBlock); - public PrisonBlock getPrisonBlock(Block spigotBlock); + public SpigotBlock getSpigotBlock(Block spigotBlock); public XMaterial getXMaterial( Block spigotBlock ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java index b68d979a9..b27af2194 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java @@ -47,19 +47,28 @@ public abstract class Spigot113Blocks // return results == BlockType.NULL_BLOCK ? null : results; // } + /** + *

This function should never be accessed directly. Use the function + * getBlockAt() functions within the Prison Location or SpigotWorld + * classes. The function SpigotWorld.getBlockAt( location ) should be the + * "only" class that calls this function. Access needs to be limited to + * ensure the wrong code, under the wrong conditions, do not mess it up. + *

+ */ @Override - public PrisonBlock getPrisonBlock(Block spigotBlock) { - PrisonBlock pBlock = null; - - XMaterial xMat = getXMaterial( spigotBlock ); - - if ( xMat != null ) { - pBlock = new PrisonBlock( xMat.name() ); - } - // ignore nulls because errors were logged in getXMaterial() so they only - // are logged once - - return pBlock; + public SpigotBlock getSpigotBlock( Block bukkitBlock ) { + return SpigotBlock.getSpigotBlock( bukkitBlock ); +// SpigotBlock sBlock = null; +// +// XMaterial xMat = getXMaterial( bukkitBlock ); +// +// if ( xMat != null ) { +// sBlock = new SpigotBlock( xMat.name(), bukkitBlock ); +// } +// // ignore nulls because errors were logged in getXMaterial() so they only +// // are logged once +// +// return sBlock; } // @Override @@ -293,10 +302,13 @@ public void updateSpigotBlockAsync( PrisonBlock prisonBlock, Location location ) public void run() { // No physics update: - Block spigotBlock = ((SpigotBlock) location.getBlockAt()).getWrapper(); + + SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); + + Block bBlock = sBlock.getWrapper(); // For 1.13.x and higher: - spigotBlock.setType( newType, false ); + bBlock.setType( newType, false ); } }.runTaskLater( getPlugin(), 0 ); 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 19f5382c6..4a04b41c4 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 @@ -11,7 +11,6 @@ import tech.mcprison.prison.internal.block.BlockFace; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.util.Location; @@ -81,19 +80,23 @@ public abstract class Spigot18Blocks // } @Override - public PrisonBlock getPrisonBlock(Block spigotBlock) { - PrisonBlock pBlock = null; - - XMaterial xMat = getXMaterial( spigotBlock ); - - if ( xMat != null ) { - pBlock = SpigotPrison.getInstance().getPrisonBlockTypes().getBlockTypesByName( xMat.name() ); -// pBlock = new PrisonBlock( xMat.name() ); - } - // ignore nulls because errors were logged in getXMaterial() so they only - // are logged once - - return pBlock; + public SpigotBlock getSpigotBlock( Block bukkitBlock ) { + return SpigotBlock.getSpigotBlock( bukkitBlock ); +// SpigotBlock sBlock = null; +// +// XMaterial xMat = getXMaterial( bukkitBlock ); +// +// if ( xMat != null ) { +// +// sBlock = new SpigotBlock( xMat.name(), bukkitBlock ); +// +//// pBlock = SpigotPrison.getInstance().getPrisonBlockTypes().getBlockTypesByName( xMat.name() ); +//// pBlock = new PrisonBlock( xMat.name() ); +// } +// // ignore nulls because errors were logged in getXMaterial() so they only +// // are logged once +// +// return sBlock; } @@ -503,15 +506,19 @@ public void updateSpigotBlockAsync( PrisonBlock prisonBlock, Location location ) @Override public void run() { - // No physics update: - Block spigotBlock = ((SpigotBlock) location.getBlockAt()).getWrapper(); + // Using the World's location to get the block, will ensure that + // the wrapper contains the bukkit's block: + SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); + + + Block bBlock = sBlock.getWrapper(); // For 1.13.x and higher: // spigotblock.setType( newType, false ); // No physics update: - BlockState bState = spigotBlock.getState(); + BlockState bState = bBlock.getState(); // Set the block state with the new type and rawData: bState.setType( newType ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java index def042598..9367e3352 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java @@ -45,7 +45,7 @@ public Block setCustomBlockId( Block block, String customId, boolean doBlockUpda org.bukkit.block.Block resultBlock = CustomItemsAPI.setCustomItemIDAtBlock( spigotBlock, customId, doBlockUpdate ); - return new SpigotBlock( resultBlock ); + return SpigotBlock.getSpigotBlock( resultBlock ); } @@ -68,7 +68,10 @@ public void setCustomBlockIdAsync( PrisonBlock prisonBlock, Location location ) public void run() { // No physics update: - org.bukkit.block.Block spigotBlock = ((SpigotBlock) location.getBlockAt()).getWrapper(); + + SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); + + org.bukkit.block.Block spigotBlock = sBlock.getWrapper(); //org.bukkit.block.Block spigotBlock = ((SpigotBlock) prisonBlock).getWrapper(); // Request the block change, but we don't need the results so ignore it 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 57248f181..0179fd4c0 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 @@ -157,7 +157,7 @@ public SpigotBlock getLineOfSightBlock() { // return the first non-null and non-AIR block, which will // be the one the player is looking at: - results = new SpigotBlock( block ); + results = SpigotBlock.getSpigotBlock( block ); } } @@ -185,7 +185,7 @@ public List getLineOfSightBlocks() { // return the first non-null and non-AIR block, which will // be the one the player is looking at: - results.add( new SpigotBlock( block ) ); + results.add( SpigotBlock.getSpigotBlock( block ) ); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java index 1b715f182..9689ece74 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java @@ -35,6 +35,7 @@ import tech.mcprison.prison.internal.block.MineResetType; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.block.SpigotBlock; @@ -67,20 +68,38 @@ public SpigotWorld(org.bukkit.World bukkitWorld) { } /** - *

This does get the actual from the world, but it only reads, and does not + *

This should be the ONLY usage in the whole Prison plugin that gets the + * bukkit block from the world and converts it to a SpigotBlock.. + *

+ * + *

This gets the actual block from the world, but it only reads, and does not * update. I cannot say this is safe to run asynchronously, but so far I have * not see any related problems when it is. * */ @Override - public Block getBlockAt(Location location) { - return new SpigotBlock( - bukkitWorld.getBlockAt(SpigotUtil.prisonLocationToBukkit(location))); - } - public SpigotBlock getSpigotBlockAt(Location location) { - return new SpigotBlock( - bukkitWorld.getBlockAt(SpigotUtil.prisonLocationToBukkit(location))); + public Block getBlockAt( Location location ) { + SpigotBlock sBlock = null; + + if ( location != null ) { + + org.bukkit.Location bLocation = getBukkitLocation( location ); + org.bukkit.block.Block bBlock = bukkitWorld.getBlockAt( bLocation ); + + sBlock = SpigotCompatibility.getInstance().getSpigotBlock( bBlock ); + + if ( sBlock == null ) { + + sBlock = new SpigotBlock( bBlock, PrisonBlock.AIR.clone() ); + } + } + + return sBlock; } +// public SpigotBlock getSpigotBlockAt(Location location) { +// return new SpigotBlock( +// bukkitWorld.getBlockAt(SpigotUtil.prisonLocationToBukkit(location))); +// } public org.bukkit.Location getBukkitLocation(Location location) { return SpigotUtil.prisonLocationToBukkit(location); @@ -160,18 +179,36 @@ public void run() { long start = System.nanoTime(); - for ( MineTargetPrisonBlock tBlock : tBlocks ) + MineTargetPrisonBlock current = null; + try { - final PrisonBlock pBlock = tBlock.getPrisonBlock( resetType ); - - if ( pBlock != null ) { + for ( MineTargetPrisonBlock tBlock : tBlocks ) + { + current = tBlock; - Location location = tBlock.getLocation(); + final PrisonBlock pBlock = tBlock.getPrisonBlock( resetType ); - SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); - sBlock.setPrisonBlock( pBlock ); + if ( pBlock != null ) { + + Location location = tBlock.getLocation(); + + SpigotBlock sBlock = (SpigotBlock) getBlockAt( location ); +// SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); + + sBlock.setPrisonBlock( pBlock ); + } } } + catch ( Exception e ) { + String blkName = current.getPrisonBlock().getBlockName(); + PrisonBlock pBlock = current.getPrisonBlock( resetType ); + String resetTypeBlockName = pBlock == null ? "null" : pBlock.getBlockName(); + + Output.get().logError( + String.format( "SpigotWorld.setBlocksSynchronously: %s resetType: %s %s", + blkName, resetType.name(), resetTypeBlockName ), e ); +// e.printStackTrace(); + } long elapsedNanos = System.nanoTime() - start; 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 bdd871a7b..9efcadbf0 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 @@ -69,7 +69,7 @@ public void onInteract( PlayerInteractEvent event ) { sBlock = (SpigotBlock) loc.add( loc.getDirection().multiply( 3 ) ) .getBlockAt(); } else { - sBlock = new SpigotBlock( event.getClickedBlock() ); + sBlock = SpigotBlock.getSpigotBlock( event.getClickedBlock() ); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsListeners.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsListeners.java index 782528df3..9b70cdf6b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsListeners.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsListeners.java @@ -53,7 +53,7 @@ public PrisonUtilsListeners() { public void unbreakableBlock( BlockBreakEvent e ) { if ( !e.isCancelled() ) { - PrisonBlock block = new SpigotBlock( e.getBlock() ).getPrisonBlock(); + PrisonBlock block = SpigotBlock.getSpigotBlock( e.getBlock() ).getPrisonBlock(); if ( BlockUtils.getInstance().isUnbreakable( block ) ) { e.setCancelled( true ); diff --git a/prison-spigot/src/test/java/tech/mcprison/prison/spigot/SpigotPlatformTest.java b/prison-spigot/src/test/java/tech/mcprison/prison/spigot/SpigotPlatformTest.java index d696401fb..fb6960700 100644 --- a/prison-spigot/src/test/java/tech/mcprison/prison/spigot/SpigotPlatformTest.java +++ b/prison-spigot/src/test/java/tech/mcprison/prison/spigot/SpigotPlatformTest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertEquals; +import java.util.ArrayList; import java.util.List; import tech.mcprison.prison.spigot.sellall.SellAllBlockData; @@ -14,51 +15,72 @@ public class SpigotPlatformTest //@Test public void testMineBlockList() { + List blockList = new ArrayList<>(); - List blockList = sp.buildBlockListXMaterial(); + for ( SellAllBlockData xMatCost : sp.buildBlockListXMaterial() ) { + + // Add only the primary blocks to this blockList which will be used to generate the + // mine's block contents: + if ( xMatCost.isPrimary() ) { + blockList.add( xMatCost.getBlock().name() ); + } + } - // List blockList = sp.buildBlockListBlockType(); +// List blockList = sp.buildBlockListXMaterial(); + + + + List percents = new ArrayList<>(); + percents.add(5d); + percents.add(10d); + percents.add(20d); + percents.add(20d); + percents.add(20d); + percents.add(25d); + int i = -1; - assertEquals( 0, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 1, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 2, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: A - assertEquals( 3, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 4, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: E - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: J - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: O - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: S - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: T - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 5, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 4, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: W - assertEquals( 3, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 2, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: Y - assertEquals( 1, mineBlockList( blockList, i++, 5 ).size() ); // Mine name: Z - assertEquals( 0, mineBlockList( blockList, i++, 5 ).size() ); - assertEquals( 0, mineBlockList( blockList, i++, 5 ).size() ); + assertEquals( 0, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 1, mineBlockList( blockList, i++, percents.size() ).size() ); + + // i represents startPos which starts at 1, but testing with -1. + assertEquals( 2, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: A + assertEquals( 3, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 4, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: E + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: J + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: O + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: S + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: T + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 5, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 4, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: W + assertEquals( 3, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 2, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: Y + assertEquals( 1, mineBlockList( blockList, i++, percents.size() ).size() ); // Mine name: Z + assertEquals( 0, mineBlockList( blockList, i++, percents.size() ).size() ); + assertEquals( 0, mineBlockList( blockList, i++, percents.size() ).size() ); } - protected List mineBlockList( List blockList, int startPos, int length ) { + protected List mineBlockList( List blockList, int startPos, int length ) { - List results = sp.mineBlockList( startPos, length, blockList ); + List results = sp.mineBlockList( blockList, startPos, length ); System.out.println( results ); From 36f5f29c6ea6e7dba9015e0aec6ec2a6904c7fe7 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:00:03 -0500 Subject: [PATCH 004/297] Added comments that usage of auto features cancel drops will not work from spigot v1.8 through 1.12.x. Should work with v1.13.x and newer. --- docs/changelog_v3.3.x.md | 7 +++++- .../autofeatures/AutoFeaturesFileConfig.java | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 8b63d1e7e..d4a99cbe5 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,12 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.7 2022-01-25 +# 3.3.0-alpha.7 2022-01-26 + + + +* **Added comments that usage of auto features cancel drops will not work from spigot v1.8 through 1.12.x.** +Should work with v1.13.x and newer. * **Fix some block issues, mostly getting the correct block bukkit block and limit it to only one location and function that ultimately provides these hooks.** 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 64fe470c1..14b8d59fc 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 @@ -20,6 +20,29 @@ public class AutoFeaturesFileConfig { private Map config; + /** + * + *

Pertaining to canceling a block break even, or just canceling the drops, the ability to + * cancel the drops was added in v1.12.x. Therefore v1.8 through v1.11 cannot use that technique + * and instead must use the even canceling. + *

+ * + *
BlockBreakEvent.setDropItems(false)

+ * + *

To cancel a BlockBreakEvent use: + *

+ * + *
cancelAllBlockBreakEvents: true
+ *
cancelAllBlockEventBlockDrops: false
+ * + *

To cancel the drops, just reverse those two settings' values: + *

+ * + *
cancelAllBlockBreakEvents: false
+ *
cancelAllBlockEventBlockDrops: true
+ * + * + */ public enum AutoFeatures { @@ -50,10 +73,12 @@ public enum AutoFeatures { blockBreakEvents(options), // Setting this to true will cancel the block break events (normal prison behavior): + // Canceling events is mandatory for Spigot v1.8 through v1.11.x. cancelAllBlockBreakEvents(blockBreakEvents, true), // Setting this to false will not zero out the block drops (normal prison behavior). // When set to true, it will zero it out so if the block break event is not canceled, // then it will prevent double drops: + // Canceling the drops was added in Spigot v1.12.x. cancelAllBlockEventBlockDrops(blockBreakEvents, false), From f59bf76bb066161cdf85a19de22814f3bbefa13d Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:04:45 -0500 Subject: [PATCH 005/297] Added the new command: '/sellall list' that will list all blocks and their prices. --- docs/changelog_v3.3.x.md | 2 + .../commands/PrisonSpigotSellAllCommands.java | 76 ++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d4a99cbe5..f35779714 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,8 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.7 2022-01-26 +* **Added the new command: '/sellall list' that will list all blocks and their prices.** + * **Added comments that usage of auto features cancel drops will not work from spigot v1.8 through 1.12.x.** Should work with v1.13.x and newer. 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 7bc955e16..03a0c2f1d 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 @@ -1,6 +1,9 @@ package tech.mcprison.prison.spigot.commands; +import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Set; +import java.util.TreeMap; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -14,6 +17,7 @@ import tech.mcprison.prison.commands.Wildcard; import tech.mcprison.prison.integration.EconomyCurrencyIntegration; import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPlatform; import tech.mcprison.prison.spigot.SpigotPrison; @@ -610,7 +614,7 @@ private void sellAllEditCommand(CommandSender sender, } } - @Command(identifier = "sellall multiplier", description = "SellAll multiplier command list", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall multiplier list", description = "SellAll multiplier command list", permissions = "prison.admin", onlyPlayers = false) private void sellAllMultiplierCommand(CommandSender sender){ if (!isEnabled()) return; @@ -818,4 +822,74 @@ private void sellAllSetDefaultCommand(CommandSender sender){ Output.get().sendInfo(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_default_values_success)); } + + + @Command(identifier = "sellall list", description = "SellAll list all items", permissions = "prison.admin", onlyPlayers = false) + private void sellAllListItems( CommandSender sender ) { + + if (!isEnabled()) return; + + SellAllUtil sellAllUtil = SellAllUtil.get(); + if (sellAllUtil == null){ + return; + } + + TreeMap items = new TreeMap<>( sellAllUtil.getSellAllBlocks() ); + DecimalFormat fFmt = new DecimalFormat("#,##0.00"); + + 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(); + } + String val = fFmt.format( items.get( key ) ); + if ( val.length() > maxLenVal ) { + maxLenVal = val.length(); + } + } + + + ChatDisplay chatDisplay = new ChatDisplay("&bSellall Item list: &3(&b" + keys.size() + "&3)" ); + + int lines = 0; + StringBuilder sb = new StringBuilder(); + for ( XMaterial key : keys ) { + boolean first = sb.length() == 0; + + Double cost = items.get( key ); + + if ( !first ) { + sb.append( " " ); + } + + sb.append( String.format( "%-" + maxLenCode + "s %" + maxLenVal + "s", + key.name(), fFmt.format( cost ) ) ); +// sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s %-" + maxLenCode + "s", +// key.toString(), fFmt.format( cost ), key.name() ) ); + + if ( !first ) { + chatDisplay.addText( sb.toString() ); + + if ( ++lines % 10 == 0 && lines > 1 ) { + chatDisplay.addText( " " ); + } + + sb.setLength( 0 ); + } + } + if ( sb.length() > 0 ) { + chatDisplay.addText( sb.toString() ); + } + + chatDisplay.send( sender ); + + } + } \ No newline at end of file From 44a1c0b004a3be854f787be2eb1dfec0ab10241c Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:10:40 -0500 Subject: [PATCH 006/297] Clean up some of the refrences to the new/old block models. --- docs/changelog_v3.3.x.md | 3 + .../mines/commands/MinesBlockCommands.java | 199 +++++++++--------- .../prison/mines/commands/MinesCommands.java | 158 +++++++------- .../tech/mcprison/prison/mines/data/Mine.java | 20 +- .../mcprison/prison/mines/data/MineData.java | 46 ++-- .../mcprison/prison/mines/data/MineReset.java | 73 +++---- .../mines/features/MineLinerBuilder.java | 58 ++--- 7 files changed, 280 insertions(+), 277 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index f35779714..ee885c1e1 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.7 2022-01-26 +* **Clean up some of the refrences to the new/old block models.** + + * **Added the new command: '/sellall list' that will list all blocks and their prices.** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java index 988ee84b1..bdca73aeb 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java @@ -50,42 +50,42 @@ public void addBlockCommand(CommandSender sender, - if ( m.isUseNewBlockModel() ) { - - block = block == null ? null : block.trim().toLowerCase(); - PrisonBlock prisonBlock = null; - - PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); - - if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { - prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); - } - - if ( prisonBlock == null ) { - pMines.getMinesMessages().getLocalizable("not_a_block"). - withReplacements(block).sendTo(sender); - return; - } - - if ( !prisonBlock.isBlock() ) { - pMines.getMinesMessages().getLocalizable("not_a_block"). - withReplacements(block).sendTo(sender); - return; - } - - + block = block == null ? null : block.trim().toLowerCase(); + PrisonBlock prisonBlock = null; + + PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); + + if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { + prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); + } + + if ( prisonBlock == null ) { + pMines.getMinesMessages().getLocalizable("not_a_block"). + withReplacements(block).sendTo(sender); + return; + } + + if ( !prisonBlock.isBlock() ) { + pMines.getMinesMessages().getLocalizable("not_a_block"). + withReplacements(block).sendTo(sender); + return; + } + + // if (m.isInMine(prisonBlock)) { // pMines.getMinesMessages().getLocalizable("block_already_added"). // sendTo(sender); // return; // } // - updateMinePrisonBlock( sender, m, prisonBlock, chance, pMines ); - - + updateMinePrisonBlock( sender, m, prisonBlock, chance, pMines ); - - } + +// if ( m.isUseNewBlockModel() ) { +// +// +// +// } // else { // // BlockType blockType = BlockType.getBlock(block); @@ -222,25 +222,25 @@ protected BulletedListComponent getBlocksList( Mine m, CommandPagedData cmdPageD PrisonBlock totals = new PrisonBlock( "Totals" ); - if ( m.isUseNewBlockModel() ) + for ( PrisonBlock block : m.getPrisonBlocks() ) { - - for ( PrisonBlock block : m.getPrisonBlocks() ) + double chance = Math.round( block.getChance() * 100.0d ) / 100.0d; + totalChance += chance; + + totals.addStats( block ); + + if ( cmdPageData == null || count++ >= cmdPageData.getPageStart() && count <= cmdPageData.getPageEnd() ) { - double chance = Math.round( block.getChance() * 100.0d ) / 100.0d; - totalChance += chance; - - totals.addStats( block ); - - if ( cmdPageData == null || count++ >= cmdPageData.getPageStart() && count <= cmdPageData.getPageEnd() ) - { - - addBlockStats( m, block, iFmt, dFmt, builder ); - - } + + addBlockStats( m, block, iFmt, dFmt, builder ); + } } - +// if ( m.isUseNewBlockModel() ) +// { +// +// } +// // Obsolete... the old block model: // if ( !m.isUseNewBlockModel() || !m.isUseNewBlockModel() && cmdPageData != null && cmdPageData.isDebug() ) // { @@ -383,30 +383,30 @@ public void setBlockCommand(CommandSender sender, // } - if ( m.isUseNewBlockModel() ) { - - block = block == null ? null : block.trim().toLowerCase(); - PrisonBlock prisonBlock = null; - - PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); - - if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { - prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); - } - - - - // Change behavior: If trying to change a block that is not in the mine, then instead add it: - if (!m.isInMine(prisonBlock)) { - addBlockCommand( sender, mineName, block, chance ); + block = block == null ? null : block.trim().toLowerCase(); + PrisonBlock prisonBlock = null; + + PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); + + if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { + prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); + } + + + + // Change behavior: If trying to change a block that is not in the mine, then instead add it: + if (!m.isInMine(prisonBlock)) { + addBlockCommand( sender, mineName, block, chance ); // pMines.getMinesMessages().getLocalizable("block_not_removed") // .sendTo(sender); - return; - } - - updateMinePrisonBlock( sender, m, prisonBlock, chance, pMines ); - + return; + } + + updateMinePrisonBlock( sender, m, prisonBlock, chance, pMines ); + +// if ( m.isUseNewBlockModel() ) { +// // // If it's 0, just delete it! // if (chance <= 0.0d) { @@ -455,7 +455,7 @@ public void setBlockCommand(CommandSender sender, // } // } - } +// } // else { // // BlockType blockType = BlockType.getBlock(block); @@ -602,39 +602,39 @@ public void delBlockCommand(CommandSender sender, Mine m = pMines.getMine(mineName); - if ( m.isUseNewBlockModel() ) { - - block = block == null ? null : block.trim().toLowerCase(); - PrisonBlock prisonBlock = null; - - - PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); - - if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { - prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); - } - - // Cannot delete a block if it does not exist: + block = block == null ? null : block.trim().toLowerCase(); + PrisonBlock prisonBlock = null; + + + PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); + + if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { + prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); + } + + // Cannot delete a block if it does not exist: // if (!m.isInMine(prisonBlock)) { // return; // } + + // make sure the deleteBlock is deleting the actual block stored in the mine: + PrisonBlock preexistingPrisonBlock = m.getPrisonBlock( prisonBlock ); + + if ( preexistingPrisonBlock != null ) { - // make sure the deleteBlock is deleting the actual block stored in the mine: - PrisonBlock preexistingPrisonBlock = m.getPrisonBlock( prisonBlock ); - - if ( preexistingPrisonBlock != null ) { - - deleteBlock( sender, pMines, m, preexistingPrisonBlock ); - } - else { - - pMines.getMinesMessages().getLocalizable("block_not_removed") - .sendTo(sender); - return; - } + deleteBlock( sender, pMines, m, preexistingPrisonBlock ); + } + else { + pMines.getMinesMessages().getLocalizable("block_not_removed") + .sendTo(sender); + return; } + +// if ( m.isUseNewBlockModel() ) { +// +// } // else { // // BlockType blockType = BlockType.getBlock(block); @@ -941,15 +941,14 @@ public void listBlockCommand(CommandSender sender, chatDisplay.addText("&3Blocks:"); - chatDisplay.addText("&8Click on a block's name to edit its chances of appearing.%s", - (m.isUseNewBlockModel() ? ".." : "")); + chatDisplay.addText("&8Click on a block's name to edit its chances of appearing..." ); BulletedListComponent list = getBlocksList(m, null, true ); chatDisplay.addComponent(list); - if ( m.isUseNewBlockModel() ) { - blockSize = m.getPrisonBlocks().size(); - } + blockSize = m.getPrisonBlocks().size(); +// if ( m.isUseNewBlockModel() ) { +// } // else { // blockSize = m.getBlocks().size(); @@ -1030,9 +1029,9 @@ public void constraintsBlockCommand(CommandSender sender, PrisonBlockStatusData block = null; - if ( m.isUseNewBlockModel() ) { - block = m.getPrisonBlock( blockName ); - } + block = m.getPrisonBlock( blockName ); +// if ( m.isUseNewBlockModel() ) { +// } // else { // block = m.getBlockOld( blockName ); 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 624511635..18b3e7abd 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 @@ -811,12 +811,12 @@ public void infoCommand(CommandSender sender, CommandPagedData cmdPageData = null; - if ( m.isUseNewBlockModel() ) { + cmdPageData = new CommandPagedData( + "/mines info " + m.getName(), m.getPrisonBlocks().size(), + 1, page ); - cmdPageData = new CommandPagedData( - "/mines info " + m.getName(), m.getPrisonBlocks().size(), - 1, page ); - } +// if ( m.isUseNewBlockModel() ) { +// } // else { // @@ -846,10 +846,10 @@ public void infoCommand(CommandSender sender, ChatDisplay chatDisplay = mineInfoDetails( sender, mMan.isMineStats(), m, cmdPageData ); - int blockSize = 0; - if ( m.isUseNewBlockModel() ) { - blockSize = m.getPrisonBlocks().size(); - } + int blockSize = m.getPrisonBlocks().size(); + +// if ( m.isUseNewBlockModel() ) { +// } // else { // blockSize = m.getBlocks().size(); // } @@ -1248,10 +1248,10 @@ else if ( cmdPageData.isShowAll() ) { } - if ( cmdPageData.isShowAll() ) { - chatDisplay.addText( "&3Block model: &7%s", - ( m.isUseNewBlockModel() ? "New" : "Old") ); - } +// if ( cmdPageData.isShowAll() ) { +// chatDisplay.addText( "&3Block model: &7%s", +// ( m.isUseNewBlockModel() ? "New" : "Old") ); +// } if ( cmdPageData.isShowAll() || cmdPageData.getCurPage() > 1 ) { // if ( cmdPageData.isDebug() ) { @@ -1259,8 +1259,7 @@ else if ( cmdPageData.isShowAll() ) { // ( m.isUseNewBlockModel() ? "New" : "Old") ); // } chatDisplay.addText("&3Blocks:"); - chatDisplay.addText("&8Click on a block's name to edit its chances of appearing.%s", - (m.isUseNewBlockModel() ? ".." : "")); + chatDisplay.addText("&8Click on a block's name to edit its chances of appearing..." ); BulletedListComponent list = getBlocksList(m, cmdPageData, true ); chatDisplay.addComponent(list); @@ -4090,30 +4089,30 @@ public void blockEventBlockAdd(CommandSender sender, // Display a list of blocks for the mine: int blockRow = 0; - // Old block model is not supported with blockEvent block filers: - if ( m.isUseNewBlockModel() ) { + for ( PrisonBlock block : m.getPrisonBlocks() ) + { - for ( PrisonBlock block : m.getPrisonBlocks() ) - { - - RowComponent rowB = new RowComponent(); - - rowB.addTextComponent( " &3Row: &d%d ", ++blockRow ); - - String message = String.format( "&7%s %s", - block.getBlockName(), dFmt.format( block.getChance() ) ); - - String command = String.format( "%s %d", commandBlockEvent, blockRow ); - - FancyMessage msgAddBlock = new FancyMessage( message ) - .suggest( command ) - .tooltip("Add selected block to blockEvent - Click to Add"); - - rowB.addFancy( msgAddBlock ); - - display.addComponent( rowB ); - } + RowComponent rowB = new RowComponent(); + + rowB.addTextComponent( " &3Row: &d%d ", ++blockRow ); + + String message = String.format( "&7%s %s", + block.getBlockName(), dFmt.format( block.getChance() ) ); + + String command = String.format( "%s %d", commandBlockEvent, blockRow ); + + FancyMessage msgAddBlock = new FancyMessage( message ) + .suggest( command ) + .tooltip("Add selected block to blockEvent - Click to Add"); + + rowB.addFancy( msgAddBlock ); + + display.addComponent( rowB ); } + +// // Old block model is not supported with blockEvent block filers: +// if ( m.isUseNewBlockModel() ) { +// } display.send( sender ); return; @@ -4121,20 +4120,20 @@ public void blockEventBlockAdd(CommandSender sender, // Old block model is not supported with blockEvent block filers: - if ( m.isUseNewBlockModel() ) { - PrisonBlock block = m.getPrisonBlocks().get( rowBlockName - 1 ); + PrisonBlock block = m.getPrisonBlocks().get( rowBlockName - 1 ); + + if ( block != null ) { - if ( block != null ) { - - blockEvent.addPrisonBlock( block ); - - pMines.getMineManager().saveMine( m ); - - sender.sendMessage( "Block has been added to BlockEvent" ); - - return; - } + blockEvent.addPrisonBlock( block ); + + pMines.getMineManager().saveMine( m ); + + sender.sendMessage( "Block has been added to BlockEvent" ); + + return; } +// if ( m.isUseNewBlockModel() ) { +// } // PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); // PrisonBlock block = prisonBlockTypes.getBlockTypesByName( blockName ); @@ -4258,31 +4257,31 @@ public void blockEventBlockRemove(CommandSender sender, int blockRow = 0; // Old block model is not supported with blockEvent block filers: - if ( m.isUseNewBlockModel() ) { + + for ( PrisonBlock block : blockEvent.getPrisonBlocks() ) + { + + RowComponent rowB = new RowComponent(); - for ( PrisonBlock block : blockEvent.getPrisonBlocks() ) - { - - RowComponent rowB = new RowComponent(); - - rowB.addTextComponent( " &3Row: &d%d ", ++blockRow ); - - String message = String.format( "&7%s", - block.getBlockName() ); + rowB.addTextComponent( " &3Row: &d%d ", ++blockRow ); + + String message = String.format( "&7%s", + block.getBlockName() ); // String message = String.format( "&7%s %s", // block.getBlockName(), dFmt.format( block.getChance() ) ); - - String command = String.format( "%s %d", commandBlockEvent, blockRow ); - - FancyMessage msgAddBlock = new FancyMessage( message ) - .suggest( command ) - .tooltip("Remove a selected block from a blockEvent - Click to Remove"); - - rowB.addFancy( msgAddBlock ); - - display.addComponent( rowB ); - } + + String command = String.format( "%s %d", commandBlockEvent, blockRow ); + + FancyMessage msgAddBlock = new FancyMessage( message ) + .suggest( command ) + .tooltip("Remove a selected block from a blockEvent - Click to Remove"); + + rowB.addFancy( msgAddBlock ); + + display.addComponent( rowB ); } +// if ( m.isUseNewBlockModel() ) { +// } display.send( sender ); return; @@ -4290,17 +4289,18 @@ public void blockEventBlockRemove(CommandSender sender, // Old block model is not supported with blockEvent block filers: - if ( m.isUseNewBlockModel() ) { + if ( blockEvent.removePrisonBlock( rowBlockName ) ) { - if ( blockEvent.removePrisonBlock( rowBlockName ) ) { - - pMines.getMineManager().saveMine( m ); - - sender.sendMessage( "Block has been removed from the BlockEvent" ); - - return; - } + pMines.getMineManager().saveMine( m ); + + sender.sendMessage( "Block has been removed from the BlockEvent" ); + + return; } + +// if ( m.isUseNewBlockModel() ) { +// +// } // PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); // PrisonBlock block = prisonBlockTypes.getBlockTypesByName( blockName ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java index 38e819520..19a8fccd5 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java @@ -501,7 +501,7 @@ else if ( validateBlockNames.contains( prisonBlock.getBlockName() ) ) { // Using the Obsolete old block model for conversion to the new block model // NOTE: This is the ONLY place were we are allowed to use the old block model! ;) - if ( isUseNewBlockModel() && + if ( // isUseNewBlockModel() && getPrisonBlocks().size() == 0 && getBlocks().size() > 0 ) { // Need to perform the initial conversion: @@ -781,15 +781,15 @@ public String getBlockListString() { StringBuilder sb = new StringBuilder(); - if ( isUseNewBlockModel() ) { - for ( PrisonBlock block : getPrisonBlocks()) { - if ( sb.length() > 0 ) { - sb.append( ", " ); - } - sb.append( block.toString() ); - } - } - + for ( PrisonBlock block : getPrisonBlocks()) { + if ( sb.length() > 0 ) { + sb.append( ", " ); + } + sb.append( block.toString() ); + } +// if ( isUseNewBlockModel() ) { +// } +// // Obsolete... the old block model: // else { // for ( BlockOld block : getBlocks() ) { diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java index 3ba70e1d4..23f79b084 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java @@ -51,7 +51,7 @@ public abstract class MineData private String accessPermission = null; - private boolean useNewBlockModel = false; +// private boolean useNewBlockModel = false; private boolean tpAccessByRank = false; @@ -250,13 +250,13 @@ public MineData() { this.mineSweeperBlocksChanged = 0; - if ( Prison.get().getPlatform() == null ) { - // For unit testing purposes: - this.useNewBlockModel = false; - } - else { - this.useNewBlockModel = Prison.get().getPlatform().isUseNewPrisonBlockModel(); - } +// if ( Prison.get().getPlatform() == null ) { +// // For unit testing purposes: +// this.useNewBlockModel = false; +// } +// else { +// this.useNewBlockModel = Prison.get().getPlatform().isUseNewPrisonBlockModel(); +// } } /** @@ -326,9 +326,9 @@ public void setSortOrder( int sortOrder ) { } - public boolean isUseNewBlockModel() { - return useNewBlockModel; - } +// public boolean isUseNewBlockModel() { +// return useNewBlockModel; +// } /** * Mines do not use an id. So these will always @@ -577,9 +577,9 @@ public boolean hasBlock( String blockName ) { if ( blockName != null && !blockName.trim().isEmpty() ) { - if ( isUseNewBlockModel() ) { - results = getPrisonBlock( blockName ) != null; - } + results = getPrisonBlock( blockName ) != null; +// if ( isUseNewBlockModel() ) { +// } // Obsolete... the old block model: // else { @@ -826,17 +826,17 @@ public PrisonBlockStatusData getBlockStats( String blockName ) { if ( !getBlockStats().containsKey( blockName ) ) { - if ( isUseNewBlockModel() ) { - - for ( PrisonBlock block : getPrisonBlocks() ) { - if ( block.getBlockName().equalsIgnoreCase( blockName ) ) { - getBlockStats().put( block.getBlockName(), block ); - - results = block; - break; - } + for ( PrisonBlock block : getPrisonBlocks() ) { + if ( block.getBlockName().equalsIgnoreCase( blockName ) ) { + getBlockStats().put( block.getBlockName(), block ); + + results = block; + break; } } +// if ( isUseNewBlockModel() ) { +// +// } // Obsolete... the old block model: // else { diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index 8aa3b19cd..2c4003f4e 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -576,26 +576,26 @@ public void generateBlockListAsync() { // MineTargetBlock mtb = null; - if ( isUseNewBlockModel() ) { - - // track the constraints: (obsolete) - //trackConstraints( currentLevel, constrainedBlocks ); - - PrisonBlock prisonBlock = mineLevelBlockList.randomlySelectPrisonBlock(); - + // track the constraints: (obsolete) + //trackConstraints( currentLevel, constrainedBlocks ); + + PrisonBlock prisonBlock = mineLevelBlockList.randomlySelectPrisonBlock(); + // PrisonBlock prisonBlock = randomlySelectPrisonBlock( random, currentLevel ); - - // Increment the mine's block count. This block is one of the control blocks: - incrementResetBlockCount( prisonBlock ); - - addMineTargetPrisonBlock( prisonBlock, x, y, z, isEdge ); + + // Increment the mine's block count. This block is one of the control blocks: + incrementResetBlockCount( prisonBlock ); + + addMineTargetPrisonBlock( prisonBlock, x, y, z, isEdge ); // mtb = new MineTargetPrisonBlock( prisonBlock, x, y, z); - - if ( prisonBlock.equals( PrisonBlock.AIR ) ) { + + if ( prisonBlock.equals( PrisonBlock.AIR ) ) { // mAirBlocks[i++] = true; - airCount++; - } + airCount++; } +// if ( isUseNewBlockModel() ) { +// +// } // // Obsolete... the old block model: // else { @@ -1148,7 +1148,7 @@ protected void refreshAirCountAsyncTask() "Ensure world exists. mine= %s ", getName() )); } - else if ( isUseNewBlockModel() && + else if ( // isUseNewBlockModel() && getPrisonBlocks().size() == 1 && getPrisonBlocks().get( 0 ).equals( PrisonBlock.IGNORE ) ) { @@ -1224,22 +1224,22 @@ else if ( isUseNewBlockModel() && yEdge && zEdge; - if ( isUseNewBlockModel() ) { + + PrisonBlock pBlock = tBlock.getPrisonBlock(); + + if ( pBlock != null ) { - PrisonBlock pBlock = tBlock.getPrisonBlock(); - - if ( pBlock != null ) { - - // Increment the mine's block count. This block is one of the control blocks: - addMineTargetPrisonBlock( incrementResetBlockCount( pBlock ), x, y, z, isEdge ); - - } + // Increment the mine's block count. This block is one of the control blocks: + addMineTargetPrisonBlock( incrementResetBlockCount( pBlock ), x, y, z, isEdge ); - if ( pBlock == null || pBlock.isAir() ) { - airCount++; - } } + if ( pBlock == null || pBlock.isAir() ) { + airCount++; + } +// if ( isUseNewBlockModel() ) { +// } +// // Obsolete... the old block model: // else { // @@ -1609,12 +1609,13 @@ else if ( getPercentRemainingBlockCount() > getSkipResetPercent() ) { private void constraintsApplyMin() { - if ( isUseNewBlockModel() ) { - - for ( PrisonBlockStatusData block : getPrisonBlocks() ) { - constraintsApplyMin( block, isUseNewBlockModel() ); - } - } + for ( PrisonBlockStatusData block : getPrisonBlocks() ) { + constraintsApplyMin( block ); +// constraintsApplyMin( block, isUseNewBlockModel() ); + } +// if ( isUseNewBlockModel() ) { +// +// } // Obsolete... the old block model: // else { @@ -1641,7 +1642,7 @@ private void constraintsApplyMin() { * @param block * @param useNewBlockModel */ - private void constraintsApplyMin( PrisonBlockStatusData block, boolean useNewBlockModel ) + private void constraintsApplyMin( PrisonBlockStatusData block ) { if ( block.getConstraintMin() > 0 ) { diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java index 9bc910425..73b290afb 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java @@ -369,43 +369,43 @@ private void generatePattern( Edges edge, World world, int xMin, int xMax, int y // tBlockPlus2.getLocation().toBlockCoordinates(), // x, y, z, nextBlockName); - if ( getMine().isUseNewBlockModel() ) { + if ( REPAIR_LINER.equalsIgnoreCase( nextBlockName ) ) { - if ( REPAIR_LINER.equalsIgnoreCase( nextBlockName ) ) { + if ( isLadderBlock ) { - if ( isLadderBlock ) { - - tBlock.setPrisonBlock( tBlockPlus2.getPrisonBlock() ); - tBlockPlus1.setPrisonBlock( tBlockPlus2.getPrisonBlock() ); - } - else { - - tBlock.setPrisonBlock( tBlockPlus1.getPrisonBlock() ); - } + tBlock.setPrisonBlock( tBlockPlus2.getPrisonBlock() ); + tBlockPlus1.setPrisonBlock( tBlockPlus2.getPrisonBlock() ); } - - else if ( isForced || - !tBlock.isEmpty() || - isLadderBlock && !tBlockPlus1.isEmpty() ) { - - PrisonBlock nextBlockType = new PrisonBlock(nextBlockName); + else { - if ( isLadderBlock ) { - - tBlockPlus1.setPrisonBlock( nextBlockType ); - - PrisonBlock ladderBlockType = new PrisonBlock("ladder"); - tBlock.setPrisonBlock( ladderBlockType ); - tBlock.setBlockFace( blockFace ); - } - else { - - tBlock.setPrisonBlock( nextBlockType ); - } + tBlock.setPrisonBlock( tBlockPlus1.getPrisonBlock() ); } + } + + else if ( isForced || + !tBlock.isEmpty() || + isLadderBlock && !tBlockPlus1.isEmpty() ) { + PrisonBlock nextBlockType = new PrisonBlock(nextBlockName); + + if ( isLadderBlock ) { + + tBlockPlus1.setPrisonBlock( nextBlockType ); + + PrisonBlock ladderBlockType = new PrisonBlock("ladder"); + tBlock.setPrisonBlock( ladderBlockType ); + tBlock.setBlockFace( blockFace ); + } + else { + + tBlock.setPrisonBlock( nextBlockType ); + } } +// if ( getMine().isUseNewBlockModel() ) { +// +// } +// // Obsolte old block model: // else { From 1b04c6f9b1fd765877d2e5f9e9ee8df27b4beefc Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:35:28 -0500 Subject: [PATCH 007/297] Clean up some of the refrences to the new/old block models. --- .../mines/commands/MinesBlockCommands.java | 237 +----------------- .../prison/mines/commands/MinesCommands.java | 35 +-- .../tech/mcprison/prison/mines/data/Mine.java | 13 +- .../mcprison/prison/mines/data/MineData.java | 38 --- .../mcprison/prison/mines/data/MineReset.java | 65 +---- .../mines/features/MineLinerBuilder.java | 50 ---- .../mines/features/MineTracerBuilder.java | 7 - 7 files changed, 16 insertions(+), 429 deletions(-) diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java index bdca73aeb..e8f204a1a 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java @@ -81,64 +81,6 @@ public void addBlockCommand(CommandSender sender, updateMinePrisonBlock( sender, m, prisonBlock, chance, pMines ); -// if ( m.isUseNewBlockModel() ) { -// -// -// -// } -// else { -// -// BlockType blockType = BlockType.getBlock(block); -// -// if (blockType == null || blockType.getMaterialType() != MaterialType.BLOCK ) { -// pMines.getMinesMessages().getLocalizable("not_a_block") -// .withReplacements(block).sendTo(sender); -// return; -// } -// -// if (m.isInMine(blockType)) { -// pMines.getMinesMessages().getLocalizable("block_already_added") -// .sendTo(sender); -// return; -// } -// -// if ( chance <= 0 ) { -// sender.sendMessage( "The percent chance must have a value greater than zero." ); -// return; -// } -// -// -// BlockPercentTotal percentTotal = calculatePercentage( chance, blockType, m ); -// -// if ( percentTotal.getTotalChance() > 100.0d) { -// pMines.getMinesMessages().getLocalizable("mine_full") -// .sendTo(sender, LogLevel.ERROR); -// return; -// } -// -// // This is an add block function so if we get this far, add it: -// if ( percentTotal.getOldBlock() == null ) { -// // add the block since it does not exist in the mine: -// m.getBlocks().add( new BlockOld( blockType, chance, 0) ); -// } -// else if ( chance <= 0 ) { -// // block exists in mine, but chance is set to zero so remove it: -// m.getBlocks().remove( percentTotal.getOldBlock() ); -// } -// else { -// // update the block chance. The block in percentTotal comes from this mine -// // so just update the chance: -// percentTotal.getOldBlock().setChance( chance ); -// } -// -// // Check if one of the blocks is effected by gravity, and if so, set that indicator. -// m.checkGravityAffectedBlocks(); -// -// pMines.getMineManager().saveMine( m ); -// -// pMines.getMinesMessages().getLocalizable("block_added") -// .withReplacements(block, mineName).sendTo(sender); -// } getBlocksList(m, null, true ).send(sender); @@ -236,30 +178,7 @@ protected BulletedListComponent getBlocksList( Mine m, CommandPagedData cmdPageD } } -// if ( m.isUseNewBlockModel() ) -// { -// -// } -// - // Obsolete... the old block model: -// if ( !m.isUseNewBlockModel() || !m.isUseNewBlockModel() && cmdPageData != null && cmdPageData.isDebug() ) -// { -// -// for ( BlockOld block : m.getBlocks() ) -// { -// double chance = Math.round( block.getChance() * 100.0d ) / 100.0d; -// totalChance += chance; -// -// totals.addStats( block ); -// -// if ( cmdPageData == null || count++ >= cmdPageData.getPageStart() && count <= cmdPageData.getPageEnd() ) -// { -// -// addBlockStats( m, block, iFmt, dFmt, builder ); -// -// } -// } -// } + if ( totalChance < 100.0d ) { @@ -405,106 +324,6 @@ public void setBlockCommand(CommandSender sender, updateMinePrisonBlock( sender, m, prisonBlock, chance, pMines ); -// if ( m.isUseNewBlockModel() ) { -// - -// // If it's 0, just delete it! -// if (chance <= 0.0d) { -// deleteBlock( sender, pMines, m, prisonBlock ); -//// delBlockCommand(sender, mine, block); -// return; -// } -// -// -// double totalChance = chance; -// PrisonBlock blockToUpdate = null; -// for ( PrisonBlock blk : m.getPrisonBlocks() ) { -// if ( blk.getBlockName().equalsIgnoreCase( prisonBlock.getBlockName() ) ) { -// totalChance -= blk.getChance(); -// blockToUpdate = blk; -// } -// else { -// totalChance += blk.getChance(); -// } -// } -// -// if (totalChance > 100.0d) { -// pMines.getMinesMessages().getLocalizable("mine_full"). -// sendTo(sender, LogLevel.ERROR); -// return; -// } -// -// blockToUpdate.setChance( chance ); -// -// // total chance is not being calculated correctly... -// -// final double[] totalComp = {chance}; -// m.getPrisonBlocks().forEach(block1 -> { -// totalComp[0] -= block1.getChance(); -// }); -// -// if (totalComp[0] > 100.0d) { -// pMines.getMinesMessages().getLocalizable("mine_full") -// .sendTo(sender, Localizable.Level.ERROR); -// return; -// } -// -// for (PrisonBlock blockObject : m.getPrisonBlocks()) { -// if (blockObject.getBlockName().equalsIgnoreCase( prisonBlock.getBlockName() )) { -// blockObject.setChance(chance); -// } -// } - -// } -// else { -// -// BlockType blockType = BlockType.getBlock(block); -// if (blockType == null) { -// pMines.getMinesMessages().getLocalizable("not_a_block"). -// withReplacements(block).sendTo(sender); -// return; -// } -// -// // Change behavior: If trying to change a block that is not in the mine, then instead add it: -// if (!m.isInMine(blockType)) { -// addBlockCommand( sender, mineName, block, chance ); -//// pMines.getMinesMessages().getLocalizable("block_not_removed") -//// .sendTo(sender); -// return; -// } -// -// // If it's 0, just delete it! If the block is not in the mine, then nothing will happen. -// if (chance <= 0.0d) { -// deleteBlock( sender, pMines, m, blockType ); -//// delBlockCommand(sender, mine, block); -// return; -// } -// -// -// BlockPercentTotal percentTotal = calculatePercentage( chance, blockType, m ); -// -// -// if ( percentTotal.getTotalChance() > 100.0d) { -// pMines.getMinesMessages().getLocalizable("mine_full"). -// sendTo(sender, LogLevel.ERROR); -// return; -// } -// -// // Block would have been added or deleted above, so if it gets here, then -// // just update the block that's in the mine, which is stored in the percentTotal -// // result object: -// percentTotal.getOldBlock().setChance( chance ); -// -// -// // Check if one of the blocks is effected by gravity, and if so, set that indicator. -// m.checkGravityAffectedBlocks(); -// -// -// pMines.getMineManager().saveMine( m ); -// -// pMines.getMinesMessages().getLocalizable("block_set") -// .withReplacements(block, mineName).sendTo(sender); -// } getBlocksList(m, null, true ).send(sender); @@ -632,26 +451,6 @@ public void delBlockCommand(CommandSender sender, return; } -// if ( m.isUseNewBlockModel() ) { -// -// } -// else { -// -// BlockType blockType = BlockType.getBlock(block); -// if (blockType == null) { -// pMines.getMinesMessages().getLocalizable("not_a_block") -// .withReplacements(block).sendTo(sender); -// return; -// } -// -// if (!m.isInMine(blockType)) { -// pMines.getMinesMessages().getLocalizable("block_not_removed") -// .sendTo(sender); -// return; -// } -// -// deleteBlock( sender, pMines, m, blockType ); -// } getBlocksList(m, null, true).send(sender); } @@ -722,11 +521,11 @@ public void searchBlockCommand(CommandSender sender, ChatDisplay display = null; - if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { - - display = prisonBlockSearchBuilder(search, page, true, - blockSeachCommand, commandBlockAdd, targetText ); - } + display = prisonBlockSearchBuilder(search, page, true, + blockSeachCommand, commandBlockAdd, targetText ); +// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { +// +// } // Obsolete... the old block model: // else { @@ -755,11 +554,11 @@ public void searchBlockAllCommand(CommandSender sender, ChatDisplay display = null; - if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { - - display = prisonBlockSearchBuilder(search, page, false, - blockSeachCommand, commandBlockAdd, targetText ); - } + display = prisonBlockSearchBuilder(search, page, false, + blockSeachCommand, commandBlockAdd, targetText ); +// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { +// +// } // Obsolete... the old block model: // else { @@ -947,12 +746,7 @@ public void listBlockCommand(CommandSender sender, chatDisplay.addComponent(list); blockSize = m.getPrisonBlocks().size(); -// if ( m.isUseNewBlockModel() ) { -// } - -// else { -// blockSize = m.getBlocks().size(); -// } + if ( blockSize == 0 ) { String message = blockSize != 0 ? null : " &cNo Blocks Defined"; @@ -1030,12 +824,7 @@ public void constraintsBlockCommand(CommandSender sender, PrisonBlockStatusData block = null; block = m.getPrisonBlock( blockName ); -// if ( m.isUseNewBlockModel() ) { -// } - -// else { -// block = m.getBlockOld( blockName ); -// } + if ( "min".equalsIgnoreCase( constraint ) ) { 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 18b3e7abd..2d3b61f29 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 @@ -815,15 +815,6 @@ public void infoCommand(CommandSender sender, "/mines info " + m.getName(), m.getPrisonBlocks().size(), 1, page ); -// if ( m.isUseNewBlockModel() ) { -// } - -// else { -// -// cmdPageData = new CommandPagedData( -// "/mines info " + m.getName(), m.getBlocks().size(), -// 1, page ); -// } // // Same page logic as in mines block search: // int curPage = 1; @@ -848,11 +839,6 @@ public void infoCommand(CommandSender sender, int blockSize = m.getPrisonBlocks().size(); -// if ( m.isUseNewBlockModel() ) { -// } -// else { -// blockSize = m.getBlocks().size(); -// } String message = blockSize != 0 ? null : " &cNo Blocks Defined"; cmdPageData.generatePagedCommandFooter( chatDisplay, message ); @@ -1248,16 +1234,9 @@ else if ( cmdPageData.isShowAll() ) { } -// if ( cmdPageData.isShowAll() ) { -// chatDisplay.addText( "&3Block model: &7%s", -// ( m.isUseNewBlockModel() ? "New" : "Old") ); -// } if ( cmdPageData.isShowAll() || cmdPageData.getCurPage() > 1 ) { -// if ( cmdPageData.isDebug() ) { -// chatDisplay.addText( "&3Block model: &7%s", -// ( m.isUseNewBlockModel() ? "New" : "Old") ); -// } + chatDisplay.addText("&3Blocks:"); chatDisplay.addText("&8Click on a block's name to edit its chances of appearing..." ); @@ -4110,9 +4089,6 @@ public void blockEventBlockAdd(CommandSender sender, display.addComponent( rowB ); } -// // Old block model is not supported with blockEvent block filers: -// if ( m.isUseNewBlockModel() ) { -// } display.send( sender ); return; @@ -4132,8 +4108,6 @@ public void blockEventBlockAdd(CommandSender sender, return; } -// if ( m.isUseNewBlockModel() ) { -// } // PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); // PrisonBlock block = prisonBlockTypes.getBlockTypesByName( blockName ); @@ -4256,7 +4230,6 @@ public void blockEventBlockRemove(CommandSender sender, // Display a list of blocks for the mine: int blockRow = 0; - // Old block model is not supported with blockEvent block filers: for ( PrisonBlock block : blockEvent.getPrisonBlocks() ) { @@ -4280,15 +4253,12 @@ public void blockEventBlockRemove(CommandSender sender, display.addComponent( rowB ); } -// if ( m.isUseNewBlockModel() ) { -// } display.send( sender ); return; } - // Old block model is not supported with blockEvent block filers: if ( blockEvent.removePrisonBlock( rowBlockName ) ) { pMines.getMineManager().saveMine( m ); @@ -4298,9 +4268,6 @@ public void blockEventBlockRemove(CommandSender sender, return; } -// if ( m.isUseNewBlockModel() ) { -// -// } // PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); // PrisonBlock block = prisonBlockTypes.getBlockTypesByName( blockName ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java index 19a8fccd5..7e5d4f6a9 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java @@ -787,18 +787,7 @@ public String getBlockListString() } sb.append( block.toString() ); } -// if ( isUseNewBlockModel() ) { -// } -// - // Obsolete... the old block model: -// else { -// for ( BlockOld block : getBlocks() ) { -// if ( sb.length() > 0 ) { -// sb.append( ", " ); -// } -// sb.append( block.toString() ); -// } -// } + sb.insert( 0, ": [" ); sb.append( "]" ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java index 23f79b084..19504fd96 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java @@ -51,9 +51,6 @@ public abstract class MineData private String accessPermission = null; -// private boolean useNewBlockModel = false; - - private boolean tpAccessByRank = false; private boolean mineAccessByRank = false; @@ -249,14 +246,6 @@ public MineData() { this.mineSweeperTotalMs = 0; this.mineSweeperBlocksChanged = 0; - -// if ( Prison.get().getPlatform() == null ) { -// // For unit testing purposes: -// this.useNewBlockModel = false; -// } -// else { -// this.useNewBlockModel = Prison.get().getPlatform().isUseNewPrisonBlockModel(); -// } } /** @@ -325,10 +314,6 @@ public void setSortOrder( int sortOrder ) { this.sortOrder = sortOrder; } - -// public boolean isUseNewBlockModel() { -// return useNewBlockModel; -// } /** * Mines do not use an id. So these will always @@ -578,13 +563,6 @@ public boolean hasBlock( String blockName ) { if ( blockName != null && !blockName.trim().isEmpty() ) { results = getPrisonBlock( blockName ) != null; -// if ( isUseNewBlockModel() ) { -// } - - // Obsolete... the old block model: -// else { -// results = getBlockOld( blockName ) != null; -// } } return results; @@ -834,22 +812,6 @@ public PrisonBlockStatusData getBlockStats( String blockName ) { break; } } -// if ( isUseNewBlockModel() ) { -// -// } - - // Obsolete... the old block model: -// else { -// -// for ( BlockOld block : getBlocks() ) { -// if ( block.getBlockName().equalsIgnoreCase( blockName ) ) { -// getBlockStats().put( block.getBlockName(), block ); -// -// results = block; -// break; -// } -// } -// } } else { diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index 2c4003f4e..463a13b14 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -593,27 +593,6 @@ public void generateBlockListAsync() { // mAirBlocks[i++] = true; airCount++; } -// if ( isUseNewBlockModel() ) { -// -// } - -// // Obsolete... the old block model: -// else { -// -// -// BlockOld tBlock = randomlySelectBlock( random, currentLevel ); -// -// // Increment the mine's block count. This block is one of the control blocks: -// incrementResetBlockCount( tBlock ); -// -// addMineTargetPrisonBlock( tBlock, x, y, z, isEdge ); -//// mtb = new MineTargetBlock( tBlock.getType(), x, y, z); -// -// if ( tBlock.equals( BlockOld.AIR ) ) { -//// mAirBlocks[i++] = true; -// airCount++; -// } -// } } } @@ -1148,8 +1127,7 @@ protected void refreshAirCountAsyncTask() "Ensure world exists. mine= %s ", getName() )); } - else if ( // isUseNewBlockModel() && - getPrisonBlocks().size() == 1 && + else if ( getPrisonBlocks().size() == 1 && getPrisonBlocks().get( 0 ).equals( PrisonBlock.IGNORE ) ) { // This mine is set to ignore all blocks when trying to do a reset, @@ -1158,16 +1136,6 @@ else if ( // isUseNewBlockModel() && // not registered and tracked within prison, and hence will report incorrect errors. setAirCount( 0 ); } -// else if ( !isUseNewBlockModel() && -// getBlocks().size() == 1 && -// getBlocks().get( 0 ).getType() == BlockType.IGNORE ) { -// -// // This mine is set to ignore all blocks when trying to do a reset, -// // so for now ignore the types and just set air count to zero. -// // Basically, this mine, if using natural spawned landscape, may contain blocks that are -// // not registered and tracked within prison, and hence will report incorrect errors. -// setAirCount( 0 ); -// } else { long start = System.currentTimeMillis(); Optional worldOptional = getWorld(); @@ -1237,25 +1205,6 @@ else if ( // isUseNewBlockModel() && if ( pBlock == null || pBlock.isAir() ) { airCount++; } -// if ( isUseNewBlockModel() ) { -// } -// - // Obsolete... the old block model: -// else { -// -// BlockOld oBlock = new BlockOld( tBlock.getType() ); -// -// if ( oBlock != null ) { -// -// // Increment the mine's block count. This block is one of the control blocks: -// addMineTargetPrisonBlock( incrementResetBlockCount( oBlock ), x, y, z, isEdge ); -// -// } -// -// if ( tBlock.getType() == BlockType.AIR ) { -// airCount++; -// } -// } } catch ( Exception e ) { // Updates to the "world" should never be ran async. Upon review of the above @@ -1611,19 +1560,7 @@ private void constraintsApplyMin() { for ( PrisonBlockStatusData block : getPrisonBlocks() ) { constraintsApplyMin( block ); -// constraintsApplyMin( block, isUseNewBlockModel() ); } -// if ( isUseNewBlockModel() ) { -// -// } - - // Obsolete... the old block model: -// else { -// -// for ( PrisonBlockStatusData block : getBlocks() ) { -// constraintsApplyMin( block, isUseNewBlockModel() ); -// } -// } } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java index 73b290afb..7d61ecec1 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java @@ -402,56 +402,6 @@ else if ( isForced || } } -// if ( getMine().isUseNewBlockModel() ) { -// -// } -// - - // Obsolte old block model: -// else { -// -// if ( REPAIR_LINER.equalsIgnoreCase( nextBlockName ) ) { -// -// -//// Output.get().logInfo( "#### repair : isLadderBlock: %s block types: tb: %s tb1: %s tb2: %s", -//// (isLadderBlock ? "Y" : "-" ), -//// tBlock.getType(), tBlockPlus1.getType(), tBlockPlus2.getType() ); -//// -// if ( isLadderBlock ) { -// -// tBlock.setType( tBlockPlus2.getType() ); -// tBlockPlus1.setType( tBlockPlus2.getType() ); -// } -// else { -// -// tBlock.setType( tBlockPlus1.getType() ); -// } -// } -// -// else if ( isForced || -// !tBlock.isEmpty() || -// isLadderBlock && !tBlockPlus1.isEmpty() ) { -// -// BlockType nextBlockType = BlockType.fromString( nextBlockName ); -//// if ( nextBlockType == null ) { -//// nextBlockType = BlockType.fromString( nextBlockName ); -//// } -// -// if ( isLadderBlock ) { -// -// tBlockPlus1.setType( nextBlockType ); -// -// BlockType ladderBlockType = BlockType.LADDER; -// tBlock.setType( ladderBlockType ); -// tBlock.setBlockFace( blockFace ); -// } -// else { -// -// tBlock.setType( nextBlockType ); -// } -// -// } -// } } } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineTracerBuilder.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineTracerBuilder.java index d8814b9f8..84737cb1b 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineTracerBuilder.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineTracerBuilder.java @@ -120,16 +120,9 @@ public void clearMine( Mine mine, boolean tracer ) { // boolean isEdge = xEdge && yEdge || xEdge && zEdge || // yEdge && zEdge; // -// if ( mine.isUseNewBlockModel() ) { // // targetBlock.getBlockAt().setPrisonBlock( // tracer && isEdge ? blockRedPB : blockAirPB ); -// } -//// else { -//// -//// targetBlock.getBlockAt().setType( -//// tracer && isEdge ? blockRedBT : blockAirBT ); -//// } // } // } // } From ff3f4524a958ccf9bc5361e1846023235f72c62a Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:45:11 -0500 Subject: [PATCH 008/297] Clean up some of the refrences to the new/old block models. --- .../prison/internal/platform/Platform.java | 62 ++++----- .../tech/mcprison/prison/TestPlatform.java | 63 +++++---- .../prison/spigot/SpigotPlatform.java | 130 +++++++++--------- .../prison/spigot/api/PrisonSpigotAPI.java | 30 ++-- .../spigot/gui/mine/SpigotMinesBlocksGUI.java | 70 +++++----- 5 files changed, 187 insertions(+), 168 deletions(-) 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 acd287923..cfe2a4da0 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 @@ -55,7 +55,7 @@ public interface Platform { /** * Returns the world with the specified name. */ - Optional getWorld(String name); + public Optional getWorld(String name); /** @@ -72,17 +72,17 @@ public interface Platform { /** * Returns the player with the specified name. */ - Optional getPlayer(String name); + public Optional getPlayer(String name); /** * Returns the player with the specified UUID. */ - Optional getPlayer(UUID uuid); + public Optional getPlayer(UUID uuid); /** * Returns a list of all online players. */ - List getOnlinePlayers(); + public List getOnlinePlayers(); public List getOfflinePlayers(); @@ -96,20 +96,20 @@ public interface Platform { /** * Returns the plugin's version. */ - String getPluginVersion(); + public String getPluginVersion(); /** * Returns the {@link File} representing the plugin's designated storage folder. * This directory must have already been created by the implementation. */ - File getPluginDirectory(); + public File getPluginDirectory(); /** * Registers a command with the server implementation. * * @param command The {@link PluginCommand} to register. */ - void registerCommand(PluginCommand command); + public void registerCommand(PluginCommand command); /** * Unregisters a registered command. @@ -126,14 +126,14 @@ public interface Platform { /** * Returns a list of all registered commands. */ - List getCommands(); + public List getCommands(); /** * Runs a command as the console (i.e. with all privileges). * * @param cmd The command to run, without the '/'. */ - void dispatchCommand(String cmd); + public void dispatchCommand(String cmd); /** * Runs a command as the sender and with only the sender's privileges. @@ -146,7 +146,7 @@ public interface Platform { /** * Returns the {@link Scheduler}, which can be used to schedule tasks. */ - Scheduler getScheduler(); + public Scheduler getScheduler(); /** * Creates a new {@link GUI} to show to players. @@ -161,7 +161,7 @@ public interface Platform { * * @param doorLocation The {@link Location} of the door. */ - void toggleDoor(Location doorLocation); + public void toggleDoor(Location doorLocation); /** * Log a colored message to the console (if supported). @@ -181,21 +181,21 @@ public interface Platform { * @param message The message. May include color codes, amp-prefixed. * @param format The The objects inserted via {@link String#format(String, Object...)}. */ - void debug(String message, Object... format); + public void debug(String message, Object... format); /** * Runs the converter for this platform. * * @return The output of the converter. It will be sent to whoever ran the converter system (e.g. usually a command sender). */ - default String runConverter() { + public default String runConverter() { return "This operation is unsupported on this platform."; } /** * Returns a map of capabilities and whether or not this internal has them. */ - Map getCapabilities(); + public Map getCapabilities(); /** * Send a title to a player @@ -205,7 +205,7 @@ default String runConverter() { * @param subtitle The text of the subtitle * @param fade The length of the fade */ - void showTitle(Player player, String title, String subtitle, int fade); + public void showTitle(Player player, String title, String subtitle, int fade); /** * Send an actionbar to a player @@ -214,17 +214,17 @@ default String runConverter() { * @param text The text of the actionbar * @param duration The amount of time to show the action bar, in seconds. Set to -1 for no duration (i.e. vanilla standard duration of ~3 seconds). */ - void showActionBar(Player player, String text, int duration); + public void showActionBar(Player player, String text, int duration); /** * Returns the scoreboard manager. */ - ScoreboardManager getScoreboardManager(); + public ScoreboardManager getScoreboardManager(); /** * Returns the storage manager. */ - Storage getStorage(); + public Storage getStorage(); /** * Retrieves the {@link PluginCommand} object for a command with a certain label. @@ -232,7 +232,7 @@ default String runConverter() { * @param label The command's label. * @return The {@link PluginCommand}, or null if no command exists by that label. */ - default Optional getCommand(String label) { + public default Optional getCommand(String label) { for (PluginCommand command : getCommands()) { if (command.getLabel().equalsIgnoreCase(label)) { return Optional.of(command); @@ -246,7 +246,7 @@ default Optional getCommand(String label) { * Returns true if the server should show alerts to in-game players, false otherwise. * This is a configuration option.kkjksdf;erljnkx.jcsmka.f.fdlwe;s.x. frrer5 */ - boolean shouldShowAlerts(); + public boolean shouldShowAlerts(); @@ -281,17 +281,17 @@ default Optional getCommand(String label) { public boolean getConfigBooleanFalse( String key ); - /** - *

This is the only way to find out if the new block model is enabled. - *

- * - *

This should be the only place within prison to use the actual String value of the - * permission. This will allow for a simple change in the future. - *

- * - * @return - */ - public boolean isUseNewPrisonBlockModel(); +// /** +// *

This is the only way to find out if the new block model is enabled. +// *

+// * +// *

This should be the only place within prison to use the actual String value of the +// * permission. This will allow for a simple change in the future. +// *

+// * +// * @return +// */ +// public boolean isUseNewPrisonBlockModel(); /** 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 0299dad54..2648d569d 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java +++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java @@ -65,7 +65,8 @@ public TestPlatform(File pluginDirectory, boolean suppressOutput) { this.suppressOutput = suppressOutput; } - @Override public Optional getWorld(String name) { + @Override + public Optional getWorld(String name) { return Optional.of(new TestWorld(name)); } @@ -74,15 +75,18 @@ public void getWorldLoadErrors( ChatDisplay display ) { } - @Override public Optional getPlayer(String name) { + @Override + public Optional getPlayer(String name) { return null; } - @Override public Optional getPlayer(UUID uuid) { + @Override + public Optional getPlayer(UUID uuid) { return null; } - @Override public List getOnlinePlayers() { + @Override + public List getOnlinePlayers() { return new ArrayList<>(); } @Override @@ -101,11 +105,13 @@ public Optional getOfflinePlayer( UUID uuid ) { return null; } - @Override public String getPluginVersion() { + @Override + public String getPluginVersion() { return "Tests"; } - @Override public File getPluginDirectory() { + @Override + public File getPluginDirectory() { return pluginDirectory; } @@ -114,7 +120,8 @@ public boolean shouldShowAlerts() { return false; } - @Override public void registerCommand(PluginCommand command) { + @Override + public void registerCommand(PluginCommand command) { } @@ -128,25 +135,30 @@ public void unregisterAllCommands() { } - @Override public List getCommands() { + @Override + public List getCommands() { return Collections.emptyList(); } - @Override public void dispatchCommand(String cmd) { + @Override + public void dispatchCommand(String cmd) { } @Override public void dispatchCommand( CommandSender sender, String cmd ) { } - @Override public Scheduler getScheduler() { + @Override + public Scheduler getScheduler() { return new TestScheduler(); } - @Override public void toggleDoor(Location doorLocation) { + @Override + public void toggleDoor(Location doorLocation) { } - @Override public void log(String message, Object... format) { + @Override + public void log(String message, Object... format) { if (suppressOutput) { return; } @@ -166,27 +178,33 @@ public void logPlain( String message ) { System.out.println(message); } - @Override public void debug(String message, Object... format) { + @Override + public void debug(String message, Object... format) { log(message, format); } - @Override public Map getCapabilities() { + @Override + public Map getCapabilities() { return null; } - @Override public void showTitle(Player player, String title, String subtitle, int fade) { + @Override + public void showTitle(Player player, String title, String subtitle, int fade) { } - @Override public void showActionBar(Player player, String text, int duration) { + @Override + public void showActionBar(Player player, String text, int duration) { } - @Override public ScoreboardManager getScoreboardManager() { + @Override + public ScoreboardManager getScoreboardManager() { return null; } - @Override public Storage getStorage() { + @Override + public Storage getStorage() { return new FileStorage(getPluginDirectory()); } @@ -206,7 +224,6 @@ public void identifyRegisteredPlugins() { } - public Map getPlaceholderDetailCounts() { Map placeholderDetails = new TreeMap<>(); @@ -248,10 +265,10 @@ public String getConfigString( String key, String defaultValue ) { return defaultValue; } - @Override - public boolean isUseNewPrisonBlockModel() { - return false; - } +// @Override +// public boolean isUseNewPrisonBlockModel() { +// return false; +// } @Override public boolean getConfigBooleanFalse( String key ) { 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 7ecac1a97..8517f7a97 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 @@ -846,33 +846,33 @@ public boolean getConfigBooleanFalse( String key ) { return ( val != null && val.trim().equalsIgnoreCase( "true" ) ); } - /** - *

Prison is now automatically enabling the new prison block model. - * The old block model still exists, but it has to be explicitly - * enabled in config.yml. - *

- * - *

No one should ever use the old block model. If there is an issue with - * the new model then it should be fixed and not avoided. But if they - * must, then the following must be added to the `plugins/Prison/config.yml`. - *

- * - *
-	 * # Warning: The use of the OLD prison block model will be removed
-	 * #          from future releases in the near future.  This old
-	 * #          model is to be used only on an emergency basis 
-	 * #          until any issues with the new model have been resolved.
-	 * use-old-prison-block-model: true
-	 * 
- * - * @return - */ - @Override - public boolean isUseNewPrisonBlockModel() { - -// return getConfigBooleanFalse( "use-new-prison-block-model" ); - return !getConfigBooleanFalse( "use-old-prison-block-model" ); - } +// /** +// *

Prison is now automatically enabling the new prison block model. +// * The old block model still exists, but it has to be explicitly +// * enabled in config.yml. +// *

+// * +// *

No one should ever use the old block model. If there is an issue with +// * the new model then it should be fixed and not avoided. But if they +// * must, then the following must be added to the `plugins/Prison/config.yml`. +// *

+// * +// *
+//	 * # Warning: The use of the OLD prison block model will be removed
+//	 * #          from future releases in the near future.  This old
+//	 * #          model is to be used only on an emergency basis 
+//	 * #          until any issues with the new model have been resolved.
+//	 * use-old-prison-block-model: true
+//	 * 
+// * +// * @return +// */ +// @Override +// public boolean isUseNewPrisonBlockModel() { +// +//// return getConfigBooleanFalse( "use-new-prison-block-model" ); +// return !getConfigBooleanFalse( "use-old-prison-block-model" ); +// } /** *

This returns the boolean value that is associated with the key. @@ -1486,19 +1486,19 @@ public void autoCreateMineBlockAssignment( List rankMineNames, boolean f - if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { - - for ( SellAllBlockData xMatCost : buildBlockListXMaterial() ) { - - // Add only the primary blocks to this blockList which will be used to generate the - // mine's block contents: - if ( xMatCost.isPrimary() ) { - blockList.add( xMatCost.getBlock().name() ); - } + for ( SellAllBlockData xMatCost : buildBlockListXMaterial() ) { + + // Add only the primary blocks to this blockList which will be used to generate the + // mine's block contents: + if ( xMatCost.isPrimary() ) { + blockList.add( xMatCost.getBlock().name() ); } - -// blockList = buildBlockListXMaterial(); - } + } +// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { +// +// +//// blockList = buildBlockListXMaterial(); +// } // else { // blockList = buildBlockListBlockType(); // } @@ -1568,34 +1568,34 @@ else if ( hasBlocks && forceKeepBlocks ) { for ( int i = 0; i < mBlocks.size(); i++ ) { - if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { + PrisonBlock prisonBlock = Prison.get().getPlatform().getPrisonBlock( mBlocks.get( i ) ); + if ( prisonBlock != null ) { + + double chance = percents.size() > i ? percents.get( i ) : 0; + prisonBlock.setChance( chance ); + prisonBlock.setBlockCountTotal( 0 ); + + mine.getPrisonBlocks().add( prisonBlock ); + + total += prisonBlock.getChance(); - PrisonBlock prisonBlock = Prison.get().getPlatform().getPrisonBlock( mBlocks.get( i ) ); - if ( prisonBlock != null ) { - - double chance = percents.size() > i ? percents.get( i ) : 0; - prisonBlock.setChance( chance ); - prisonBlock.setBlockCountTotal( 0 ); - - mine.getPrisonBlocks().add( prisonBlock ); - - total += prisonBlock.getChance(); - - // If this is the last block and the totals are not 100%, then - // add the balance to the last block. - if ( i == (mBlocks.size() - 1) && total < 100.0d ) { - double remaining = 100.0d - total; - total += remaining; - prisonBlock.setChance( remaining + prisonBlock.getChance() ); - } - } - else { - Output.get().logInfo( - String.format( "AutoConfigure block assignment failure: New Block Model: " + - "Unable to map to a valid PrisonBlock for this version of mc. [%s]", - mBlocks.get( i ) ) ); - } + // If this is the last block and the totals are not 100%, then + // add the balance to the last block. + if ( i == (mBlocks.size() - 1) && total < 100.0d ) { + double remaining = 100.0d - total; + total += remaining; + prisonBlock.setChance( remaining + prisonBlock.getChance() ); + } + } + else { + Output.get().logInfo( + String.format( "AutoConfigure block assignment failure: New Block Model: " + + "Unable to map to a valid PrisonBlock for this version of mc. [%s]", + mBlocks.get( i ) ) ); } + +// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { +// } // else { // // tech.mcprison.prison.mines.data.BlockOld block = 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 ec50848be..83bed1716 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 @@ -147,14 +147,14 @@ public List getRanks() { public String getPrisonBlockName( String blockName ) { String results = null; - if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { - - PrisonBlock prisonBlock = Prison.get().getPlatform().getPrisonBlock( blockName ); - if ( prisonBlock != null && prisonBlock.isBlock() ) { - results = prisonBlock.getBlockName(); - } - } - + PrisonBlock prisonBlock = Prison.get().getPlatform().getPrisonBlock( blockName ); + if ( prisonBlock != null && prisonBlock.isBlock() ) { + results = prisonBlock.getBlockName(); + } + +// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { +// } +// // Obsolete... prison old block model: // else { // @@ -182,14 +182,14 @@ public List getMines( String prisonBlockName ) { PrisonBlock prisonBlock = null; // BlockType blockType = null; - if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { - - prisonBlock = Prison.get().getPlatform().getPrisonBlock( prisonBlockName ); - if ( prisonBlock != null && !prisonBlock.isBlock() ) { - prisonBlock = null; - } - } + prisonBlock = Prison.get().getPlatform().getPrisonBlock( prisonBlockName ); + if ( prisonBlock != null && !prisonBlock.isBlock() ) { + prisonBlock = null; + } +// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { +// } +// // Obsolete... prison old block model: // else { // diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java index b5443b669..3d5ccd1e8 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java @@ -43,47 +43,49 @@ public void open(){ // Get Mine Mine m = PrisonMines.getInstance().getMine(mineName); - boolean useNewBlockModel = Prison.get().getPlatform().isUseNewPrisonBlockModel(); +// boolean useNewBlockModel = Prison.get().getPlatform().isUseNewPrisonBlockModel(); ButtonLore addBlockLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_add), null); // Add the button to the GUI. gui.addButton(new Button(dimension - 1, XMaterial.LIME_STAINED_GLASS_PANE, addBlockLore, "&aAdd " + mineName)); - if (useNewBlockModel) { - - // For every block makes a button - for (PrisonBlock block : m.getPrisonBlocks()) { - - // Get the block material as a string and displayname - String blockmaterial = block.getBlockName(); - String blockmaterialdisplay = blockmaterial; - - // Check if a block's air and changed the item of it to BARRIER - if (blockmaterial.equalsIgnoreCase("air")){ - blockmaterial = "BARRIER"; - blockmaterialdisplay = blockmaterial; - } - - // Get XMaterial. - XMaterial xMat = SpigotUtil.getXMaterial(blockmaterial); - if (PrisonBlock.IGNORE.getBlockName().equalsIgnoreCase(blockmaterial)) { - xMat = XMaterial.BARRIER; - } - if (xMat == null ) { - xMat = XMaterial.STONE; - } - - ButtonLore blocksLore = new ButtonLore(createLore(loreClickToEditBlock, loreShiftRightClickToDelete), createLore(loreInfo)); - - // Add a lore - blocksLore.addLineLoreDescription(SpigotPrison.format(loreChance + block.getChance() + "%")); - blocksLore.addLineLoreDescription(SpigotPrison.format(loreBlockType + blockmaterial)); - - // Add the button to the GUI. - gui.addButton(new Button(null, xMat, blocksLore, "&3" + blockmaterialdisplay + " " + mineName + " " + block.getChance())); + + // For every block makes a button + for (PrisonBlock block : m.getPrisonBlocks()) { + + // Get the block material as a string and displayname + String blockmaterial = block.getBlockName(); + String blockmaterialdisplay = blockmaterial; + + // Check if a block's air and changed the item of it to BARRIER + if (blockmaterial.equalsIgnoreCase("air")){ + blockmaterial = "BARRIER"; + blockmaterialdisplay = blockmaterial; + } + + // Get XMaterial. + XMaterial xMat = SpigotUtil.getXMaterial(blockmaterial); + if (PrisonBlock.IGNORE.getBlockName().equalsIgnoreCase(blockmaterial)) { + xMat = XMaterial.BARRIER; } - } /*else { + if (xMat == null ) { + xMat = XMaterial.STONE; + } + + ButtonLore blocksLore = new ButtonLore(createLore(loreClickToEditBlock, loreShiftRightClickToDelete), createLore(loreInfo)); + + // Add a lore + blocksLore.addLineLoreDescription(SpigotPrison.format(loreChance + block.getChance() + "%")); + blocksLore.addLineLoreDescription(SpigotPrison.format(loreBlockType + blockmaterial)); + + // Add the button to the GUI. + gui.addButton(new Button(null, xMat, blocksLore, "&3" + blockmaterialdisplay + " " + mineName + " " + block.getChance())); + } + /* + if (useNewBlockModel) { + } + else { // For every block makes a button for (BlockOld block : m.getBlocks()) { From f26d80e5cbcf0ae4bd09d758328bf9b750133858 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:50:08 -0500 Subject: [PATCH 009/297] Try to use a different way to identify the item stack, especially if the bukkit item stack does not exist. This was a random error when using gravel, sand, and dirt on spigot/paper 1.12.2. --- docs/changelog_v3.3.x.md | 4 +++ .../autofeatures/AutoManagerFeatures.java | 25 +++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ee885c1e1..7d1cb5a63 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.7 2022-01-26 +* **Try to use a different way to identify the item stack, especially if the bukkit item stack does not exist.** +This was a random error when using gravel, sand, and dirt on spigot/paper 1.12.2. + + * **Clean up some of the refrences to the new/old block models.** 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 59666180d..4470d37b0 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 @@ -467,14 +467,14 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, // Smelt if ( isAutoSmelt ) { - debugInfo.append( "(smelting: itemStacks)" ); + debugInfo.append( "(autoSmelting: itemStacks)" ); normalDropSmelt( drops ); } // Block if ( isAutoBlock ) { - debugInfo.append( "(blocking: itemStacks)" ); + debugInfo.append( "(autoBlocking: itemStacks)" ); normalDropBlock( drops ); } @@ -640,13 +640,13 @@ public int calculateNormalDrop( PrisonMinesBlockBreakEvent pmEvent, StringBuilde if ( isBoolean( AutoFeatures.normalDropSmelt ) ) { - + debugInfo.append( "(normSmelting: itemStacks)" ); normalDropSmelt( drops ); } if ( isBoolean( AutoFeatures.normalDropBlock ) ) { - + debugInfo.append( "(normBlocking: itemStacks)" ); normalDropBlock( drops ); } @@ -1577,11 +1577,22 @@ protected void normalDropSmelt( List drops ) { Set xMats = new HashSet<>(); for ( SpigotItemStack sItemStack : drops ) { - XMaterial source = XMaterial.matchXMaterial( sItemStack.getBukkitStack() ); - if ( !xMats.contains( source ) ) { - xMats.add( source ); + XMaterial xMat = null; + + if ( sItemStack.getBukkitStack() != null ) { + + xMat = XMaterial.matchXMaterial( sItemStack.getBukkitStack() ); + } + else if ( sItemStack.getMaterial() != null ) { + + xMat = SpigotCompatibility.getInstance().getXMaterial( sItemStack.getMaterial() ); } + + if ( xMat != null && !xMats.contains( xMat ) ) { + xMats.add( xMat ); + } + } From d6ad2ae3b9bce288ad8f4c7a64dadcbc745f1a73 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 21:59:26 -0500 Subject: [PATCH 010/297] Clean up some of the refrences to the new/old block models. --- .../prison/internal/platform/Platform.java | 13 --- .../tech/mcprison/prison/TestPlatform.java | 5 - .../mines/commands/MinesBlockCommands.java | 91 ------------------- .../prison/spigot/SpigotPlatform.java | 27 ------ .../prison/spigot/api/PrisonSpigotAPI.java | 22 ----- .../spigot/gui/mine/SpigotMinesBlocksGUI.java | 46 ---------- .../spigot/gui/mine/SpigotMinesGUI.java | 13 --- 7 files changed, 217 deletions(-) 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 cfe2a4da0..19bd0d96e 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 @@ -281,19 +281,6 @@ public default Optional getCommand(String label) { public boolean getConfigBooleanFalse( String key ); -// /** -// *

This is the only way to find out if the new block model is enabled. -// *

-// * -// *

This should be the only place within prison to use the actual String value of the -// * permission. This will allow for a simple change in the future. -// *

-// * -// * @return -// */ -// public boolean isUseNewPrisonBlockModel(); - - /** *

This returns the boolean value that is associated with the key. * It has to match on true to return a true value, but if the key does 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 2648d569d..c0951c5a9 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java +++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java @@ -265,11 +265,6 @@ public String getConfigString( String key, String defaultValue ) { return defaultValue; } -// @Override -// public boolean isUseNewPrisonBlockModel() { -// return false; -// } - @Override public boolean getConfigBooleanFalse( String key ) { return false; diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java index e8f204a1a..19cc4303c 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java @@ -523,16 +523,6 @@ public void searchBlockCommand(CommandSender sender, display = prisonBlockSearchBuilder(search, page, true, blockSeachCommand, commandBlockAdd, targetText ); -// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { -// -// } - - // Obsolete... the old block model: -// else { -// -// display = blockSearchBuilder(search, page, true, -// blockSeachCommand, commandBlockAdd, targetText ); -// } display.send(sender); @@ -556,16 +546,6 @@ public void searchBlockAllCommand(CommandSender sender, display = prisonBlockSearchBuilder(search, page, false, blockSeachCommand, commandBlockAdd, targetText ); -// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { -// -// } - - // Obsolete... the old block model: -// else { -// -// display = blockSearchBuilder(search, page, false, -// blockSeachCommand, commandBlockAdd, targetText ); -// } display.send(sender); @@ -633,77 +613,6 @@ private ChatDisplay prisonBlockSearchBuilder(String search, String page, return display; } - // Obsolete... the old block model: -// private ChatDisplay blockSearchBuilder(String search, String page, -// boolean restrictToBlocks, -// String commandBlockSearch, -// String commandBlockAdd, -// String targetText ) -// { -// List blocks = new ArrayList<>(); -// for (BlockType block : BlockType.values()) -// { -// if ( (!restrictToBlocks || restrictToBlocks && block.getMaterialType() == MaterialType.BLOCK) && -// (block.getId().contains(search.toLowerCase()) || -// block.name().toLowerCase().contains(search.toLowerCase())) ) -// { -// blocks.add(block); -// } -// } -// -// -// CommandPagedData cmdPageData = new CommandPagedData( -// "/" + commandBlockSearch + " " + search, blocks.size(), -// 0, page ); -// -// // Same page logic as in mines info -//// int curPage = 1; -//// int pageSize = 10; -//// int pages = (blocks.size() / pageSize) + 1; -//// try -//// { -//// curPage = Integer.parseInt(page); -//// } -//// catch ( NumberFormatException e ) -//// { -//// // Ignore: Not an integer, will use the default value. -//// } -//// curPage = ( curPage < 1 ? 1 : (curPage > pages ? pages : curPage )); -//// int pageStart = (curPage - 1) * pageSize; -//// int pageEnd = ((pageStart + pageSize) > blocks.size() ? blocks.size() : pageStart + pageSize); -// -// -// ChatDisplay display = new ChatDisplay("Block Search (" + blocks.size() + ")"); -// display.addText("&8Click a block to add it to a " + targetText + "."); -// -// BulletedListComponent.BulletedListBuilder builder = -// new BulletedListComponent.BulletedListBuilder(); -// for ( int i = cmdPageData.getPageStart(); i < cmdPageData.getPageEnd(); i++ ) -// { -// BlockType block = blocks.get(i); -// FancyMessage msg = -// new FancyMessage( -// String.format("&7%s %s (%s)%s (%s)", -// Integer.toString(i), block.name(), -// block.getId().replace("minecraft:", ""), -// (block.getMaterialVersion() == null ? "" : -// "(" + block.getMaterialVersion() + ")"), -// (block.isBlock() ? "block": "item")) -// ) -// .suggest("/" + commandBlockAdd + " " + getLastMineReferenced() + " " + block.name() + " %") -// .tooltip("&7Click to add block to a " + targetText + "."); -// builder.add(msg); -// } -// display.addComponent(builder.build()); -// -// // This command plus parameters used: -//// String pageCmd = "/mines block search " + search; -// -// cmdPageData.generatePagedCommandFooter( display ); -// -// return display; -// } - public void listBlockCommand(CommandSender sender, 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 8517f7a97..7372953a6 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 @@ -1494,14 +1494,6 @@ public void autoCreateMineBlockAssignment( List rankMineNames, boolean f blockList.add( xMatCost.getBlock().name() ); } } -// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { -// -// -//// blockList = buildBlockListXMaterial(); -// } -// else { -// blockList = buildBlockListBlockType(); -// } MineManager mm = PrisonMines.getInstance().getMineManager(); //List mines = mm.getMines(); @@ -1594,25 +1586,6 @@ else if ( hasBlocks && forceKeepBlocks ) { mBlocks.get( i ) ) ); } -// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { -// } -// else { -// -// tech.mcprison.prison.mines.data.BlockOld block = -// new tech.mcprison.prison.mines.data.BlockOld( -// mBlocks.get( i ), percents.get( i ), 0 ); -// -// mine.getBlocks().add( block ); -// -// total += block.getChance(); -// -// // If this is the last block and the totals are not 100%, then -// // add the balance to the last block. -// if ( i == (mBlocks.size() - 1) && total < 100.0d ) { -// double remaining = 100.0d - total; -// block.setChance( remaining + block.getChance() ); -// } -// } } 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 83bed1716..47e5df6c1 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 @@ -152,17 +152,6 @@ public String getPrisonBlockName( String blockName ) { results = prisonBlock.getBlockName(); } -// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { -// } -// - // Obsolete... prison old block model: -// else { -// -// BlockType blockType = BlockType.getBlock(blockName); -// if (blockType != null && blockType.getMaterialType() == MaterialType.BLOCK ) { -// results = blockType.getMaterialType().name(); -// } -// } return results; } @@ -187,17 +176,6 @@ public List getMines( String prisonBlockName ) { if ( prisonBlock != null && !prisonBlock.isBlock() ) { prisonBlock = null; } -// if ( Prison.get().getPlatform().isUseNewPrisonBlockModel() ) { -// } -// - // Obsolete... prison old block model: -// else { -// -// blockType = BlockType.getBlock( prisonBlockName ); -// if (blockType != null && blockType.getMaterialType() != MaterialType.BLOCK ) { -// blockType = null; -// } -// } if ( prisonBlock != null ) { if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java index 3d5ccd1e8..6489885f1 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java @@ -43,7 +43,6 @@ public void open(){ // Get Mine Mine m = PrisonMines.getInstance().getMine(mineName); -// boolean useNewBlockModel = Prison.get().getPlatform().isUseNewPrisonBlockModel(); ButtonLore addBlockLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_add), null); @@ -82,51 +81,6 @@ public void open(){ // Add the button to the GUI. gui.addButton(new Button(null, xMat, blocksLore, "&3" + blockmaterialdisplay + " " + mineName + " " + block.getChance())); } - /* - if (useNewBlockModel) { - } - else { - - // For every block makes a button - for (BlockOld block : m.getBlocks()) { - - // Get the block material as a string and displayname - String blockmaterial = block.getType().name(); - String blockmaterialdisplay = blockmaterial; - - // Check if a block's air and changed the item of it to BARRIER - if (blockmaterial.equalsIgnoreCase("air")){ - blockmaterial = "BARRIER"; - blockmaterialdisplay = blockmaterial; - } - - // Create the lore - List blockslore = createLore( - loreShiftRightClickToDelete, - loreClickToEditBlock, - "", - loreInfo - ); - - boolean isEnum = true; - try { - Material.valueOf(blockmaterial); - } catch (Exception e) { - isEnum = false; - } - - if (!(isEnum)) { - blockmaterial = "BARRIER"; - } - - // Add a lore - blockslore.add(SpigotPrison.format(loreChance + block.getChance() + "%")); - blockslore.add(SpigotPrison.format(loreBlockType + blockmaterial)); - - // Add the button to the GUI. - gui.addButton(new Button(null, XMaterial.valueOf(blockmaterial), blockslore, "&3" + blockmaterialdisplay + " " + mineName + " " + block.getChance())); - } - }*/ // Open the inventory gui.open(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java index 179d2a2c6..c9579d958 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java @@ -87,8 +87,6 @@ public void open(){ String loreVolume = messages.getString(MessagesConfig.StringID.spigot_gui_lore_volume); String loreBlocks = messages.getString(MessagesConfig.StringID.spigot_gui_lore_blocks); - // Global boolean. -// boolean useNewBlockModel = Prison.get().getPlatform().isUseNewPrisonBlockModel(); for ( Mine m : minesDisplay ) { @@ -164,7 +162,6 @@ public void open(){ // DecimalFormat dFmt = new DecimalFormat("##0.00"); // double totalChance = 0.0d; // -// if (useNewBlockModel) { // // for (PrisonBlock block : m.getPrisonBlocks()) { // double chance = Math.round(block.getChance() * 100.0d) / 100.0d; @@ -174,16 +171,6 @@ public void open(){ // StringUtils.capitalize(block.getBlockName().replaceAll("_", " ").toLowerCase()); // minesLore.addLineLoreDescription("&7" + chance + "% - " + block.getBlockName() + " (" + blockName + ")"); // } -// } /*else { -// -// for (BlockOld block : m.getBlocks()) { -// double chance = Math.round(block.getChance() * 100.0d) / 100.0d; -// totalChance += chance; -// String blockName = -// StringUtils.capitalize(block.getType().name().replaceAll("_", " ").toLowerCase()); -// minesLore.add(SpigotPrison.format("&7" + chance + "% - " + block.getType().name() + " (" + blockName + ")")); -// } -// }*/ // // if (totalChance < 100.0d) { // minesLore.addLineLoreDescription("&e " + dFmt.format(100.0d - totalChance) + "% - Air"); From 7ac5a09dcfdea8eb4a623a66ac3a3b8c86bd0c7a Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 22:50:31 -0500 Subject: [PATCH 011/297] Deprecated the MessagesConfig class since it is not implemented correctly. The messages should have been handled through Prison's multi-language tool, of which this does not use. --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/spigot/configs/MessagesConfig.java | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7d1cb5a63..23cc56108 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.7 2022-01-26 +* **Deprecated the MessagesConfig class since it is not implemented correctly.** +The messages should have been handled through Prison's multi-language tool, of which this does not use. + + * **Try to use a different way to identify the item stack, especially if the bukkit item stack does not exist.** This was a random error when using gravel, sand, and dirt on spigot/paper 1.12.2. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java index 71174ab27..4306127ac 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java @@ -5,6 +5,16 @@ import java.io.*; import java.util.Properties; +/** + *

This class was supposed to use the multi-language support tools within prison, of which it does not. + * Therefore, it needs to be trashed and replaced with the proper tools. + *

+ * + *

Do not use! + *

+ * + */ +@Deprecated public class MessagesConfig { private static MessagesConfig instance; @@ -15,6 +25,7 @@ public class MessagesConfig { /** * Get MessagesConfig class and initialize it if necessary. * */ + @Deprecated public static MessagesConfig get(){ if (instance == null){ instance = new MessagesConfig(); @@ -26,6 +37,7 @@ public static MessagesConfig get(){ /** * Initialize the config, reading and caching data. * */ + @Deprecated private void initConfig(){ try(FileInputStream data = new FileInputStream(SpigotPrison.getInstance().getDataFolder() + path + defaultLanguage + ".properties")){ @@ -52,6 +64,7 @@ public String getString(StringID message){ return msg; } + @Deprecated public void reload(){ initConfig(); } From c12e54e6456a3ad95f28efc92c49db17a058ed20 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 26 Jan 2022 23:01:14 -0500 Subject: [PATCH 012/297] Format the earnings amount properly, so it will have a consistant format. Once in a while, instead of showing a value like 165.00 it shows 165.000000000000001. This is caused by the fact that doubles are binary, not base-10 so it canot always show the correct values. --- docs/changelog_v3.3.x.md | 4 ++++ .../resources/lang/spigot/en_US.properties | 2 +- .../prison/spigot/sellall/SellAllUtil.java | 23 +++++++++++++++---- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 23cc56108..911c58663 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.7 2022-01-26 +* **Format the earnings amount properly, so it will have a consistant format.** +Once in a while, instead of showing a value like 165.00 it shows 165.000000000000001. This is caused by the fact that doubles are binary, not base-10 so it canot always show the correct values. + + * **Deprecated the MessagesConfig class since it is not implemented correctly.** The messages should have been handled through Prison's multi-language tool, of which this does not use. diff --git a/prison-core/src/main/resources/lang/spigot/en_US.properties b/prison-core/src/main/resources/lang/spigot/en_US.properties index ee4df1d54..4ea8c78af 100644 --- a/prison-core/src/main/resources/lang/spigot/en_US.properties +++ b/prison-core/src/main/resources/lang/spigot/en_US.properties @@ -258,7 +258,7 @@ spigot_message_sellall_delay_enabled=SellAll Delay enabled with success. spigot_message_sellall_delay_not_number=SellAll Delay number isn't valid. spigot_message_sellall_delay_wait=Please wait the end of the delay before using again the command. spigot_message_sellall_gui_disabled=SellAll GUI is disabled. -spigot_message_sellall_money_earned=You got &a$ +spigot_message_sellall_money_earned=You earned &a$ spigot_message_sellall_multiplier_add_success=SellAll Multiplier added with success. spigot_message_sellall_multiplier_are_disabled=Sorry, SellAll Multipliers are disabled. spigot_message_sellall_multiplier_cant_find=Sorry, can't find SellAll Multiplier. 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 5a85800b6..8585d4fb6 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 @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,6 +26,7 @@ import tech.mcprison.prison.integration.EconomyCurrencyIntegration; import tech.mcprison.prison.modules.Module; import tech.mcprison.prison.modules.ModuleManager; +import tech.mcprison.prison.output.LogLevel; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.data.PlayerRank; @@ -1276,7 +1278,11 @@ public void removeFromDelay(Player p){ * */ public void removeFromAutoSellDelayAndNotify(Player p){ if (autoSellEarningsNotificationWaiting.containsKey(p) && autoSellEarningsNotificationWaiting.get(p) > 0.00){ - Output.get().sendInfo(new SpigotPlayer(p), SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + autoSellEarningsNotificationWaiting.get(p))); + + DecimalFormat fFmt = new DecimalFormat("#,##0.00"); + String amt = fFmt.format( autoSellEarningsNotificationWaiting.get(p) ); + Output.get().send( new SpigotPlayer(p), + messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt ); } autoSellEarningsNotificationWaiting.remove(p); } @@ -1546,7 +1552,10 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile addDelayedEarningAutoSellNotification(p, money); } else if (notifyPlayerEarned){ - Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + money); + DecimalFormat fFmt = new DecimalFormat("#,##0.00"); + String amt = fFmt.format( money ); + + Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt ); } } return true; @@ -1607,7 +1616,10 @@ public double sellAllSell(Player p, SpigotItemStack itemStack, addDelayedEarningAutoSellNotification(p, money); } else if (notifyPlayerEarned){ - Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + money); + DecimalFormat fFmt = new DecimalFormat("#,##0.00"); + String amt = fFmt.format( money ); + + Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt ); } } } @@ -1709,7 +1721,10 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack addDelayedEarningAutoSellNotification(p, money); } } else if (notifyPlayerEarned){ - Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + money); + DecimalFormat fFmt = new DecimalFormat("#,##0.00"); + String amt = fFmt.format( money ); + + Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt ); } } } else { From 52639786c29253fac4cb3cf4391554b5889e01ab Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 27 Jan 2022 15:00:25 -0500 Subject: [PATCH 013/297] Initially setup to use the actionBar for the messages, but that is not working correctly with such high volume of messages. So disabled them for now, but will switch them over shortly... --- docs/changelog_v3.3.x.md | 6 ++++- .../prison/spigot/sellall/SellAllUtil.java | 23 ++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 911c58663..3a1e6303a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.7 2022-01-26 +# 3.3.0-alpha.7 2022-01-27 + + +* **Initially setup to use the actionBar for the messages, but that is not working correctly with such high volume of messages.** +So disabled them for now, but will switch them over shortly... * **Format the earnings amount properly, so it will have a consistant format.** 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 8585d4fb6..b9f99ebd5 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 @@ -1281,8 +1281,9 @@ public void removeFromAutoSellDelayAndNotify(Player p){ DecimalFormat fFmt = new DecimalFormat("#,##0.00"); String amt = fFmt.format( autoSellEarningsNotificationWaiting.get(p) ); - Output.get().send( new SpigotPlayer(p), - messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt ); + String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; +// new SpigotPlayer(p).setActionBar( message ); + Output.get().send( new SpigotPlayer(p), message ); } autoSellEarningsNotificationWaiting.remove(p); } @@ -1554,8 +1555,10 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile } else if (notifyPlayerEarned){ DecimalFormat fFmt = new DecimalFormat("#,##0.00"); String amt = fFmt.format( money ); - - Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt ); + String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; +// new SpigotPlayer(p).setActionBar( message ); + Output.get().send( new SpigotPlayer(p), message ); + } } return true; @@ -1618,8 +1621,10 @@ public double sellAllSell(Player p, SpigotItemStack itemStack, else if (notifyPlayerEarned){ DecimalFormat fFmt = new DecimalFormat("#,##0.00"); String amt = fFmt.format( money ); - - Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt ); + String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; +// new SpigotPlayer(p).setActionBar( message ); + Output.get().send( new SpigotPlayer(p), message ); + } } } @@ -1723,8 +1728,10 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack } else if (notifyPlayerEarned){ DecimalFormat fFmt = new DecimalFormat("#,##0.00"); String amt = fFmt.format( money ); - - Output.get().sendInfo(sPlayer, messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt ); + String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; +// new SpigotPlayer(p).setActionBar( message ); + Output.get().send( new SpigotPlayer(p), message ); + } } } else { From 3455449f7fe8b08a7575d2b2172bb66574541f80 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 27 Jan 2022 15:04:47 -0500 Subject: [PATCH 014/297] Bug Fix: The new Ranks error message handler which intercepts all ranks messags was failing to load properly when prison startup was not set for a delayed startup, which was because the ranks gui command (/ranks) was always being set even when ranks module failed to load. Now /ranks gui loads only if ranks was successful in being started. --- docs/changelog_v3.3.x.md | 6 +++- .../mcprison/prison/spigot/SpigotPrison.java | 29 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 3a1e6303a..2d0dc6433 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.7 2022-01-27 +# 3.3.0-beta.1 (alpha.7) 2022-01-27 + + +* **Bug Fix: The new Ranks error message handler which intercepts all ranks messags was failing to load properly when prison startup was not set for a delayed startup,** + which was because the ranks gui command (/ranks) was always being set even when ranks module failed to load. Now /ranks gui loads only if ranks was successful in being started. * **Initially setup to use the actionBar for the messages, but that is not working correctly with such high volume of messages.** 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 56ce81571..9298d5545 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 @@ -47,6 +47,7 @@ import tech.mcprison.prison.PrisonCommand; import tech.mcprison.prison.alerts.Alerts; import tech.mcprison.prison.integration.Integration; +import tech.mcprison.prison.integration.IntegrationType; import tech.mcprison.prison.internal.block.PrisonBlockTypes; import tech.mcprison.prison.localization.LocaleManager; import tech.mcprison.prison.mines.PrisonMines; @@ -690,19 +691,29 @@ private void initModulesAndCommands() { Prison.get().getModuleManager().getDisabledModules().add( PrisonMines.MODULE_NAME ); } - if (modulesConf.getBoolean("ranks")) { - Prison.get().getModuleManager() - .registerModule(new PrisonRanks(getDescription().getVersion())); + if (modulesConf.getBoolean("ranks") ) { + PrisonRanks rankModule = new PrisonRanks(getDescription().getVersion() ); + + // Register and enable Ranks: + Prison.get().getModuleManager().registerModule( rankModule ); - Prison.get().getCommandHandler().registerCommands( new PrisonSpigotRanksCommands() ); - // NOTE: If ranks module is enabled, then try to register prestiges commands if enabled: - if ( isPrisonConfig( "prestiges") || isPrisonConfig( "prestige.enabled" ) ) { - // Enable the setup of the prestige related commands only if prestiges is enabled: - Prison.get().getCommandHandler().registerCommands( new PrisonSpigotPrestigeCommands() ); + // Only allow the GUI ranks command to be registered if there is an economy and ranks is enabled. + if ( rankModule.isEnabled() && PrisonAPI.getIntegrationManager().hasForType(IntegrationType.ECONOMY) ) { + + Prison.get().getCommandHandler().registerCommands( new PrisonSpigotRanksCommands() ); + + // NOTE: If ranks module is enabled, then try to register prestiges commands if enabled: + if ( isPrisonConfig( "prestiges") || isPrisonConfig( "prestige.enabled" ) ) { + // Enable the setup of the prestige related commands only if prestiges is enabled: + Prison.get().getCommandHandler().registerCommands( new PrisonSpigotPrestigeCommands() ); + } } - } else { + + + } + else { Output.get().logInfo("&3Modules: &cPrison Ranks, Ladders, and Players are disabled and were not Loaded. "); Output.get().logInfo("&7 Prestiges cannot be enabled without ranks being enabled. "); Output.get().logInfo("&7 Prison Ranks have been disabled in &2plugins/Prison/modules.yml&7."); From a03483b4cd33c57185b793f60552e336860794d0 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 27 Jan 2022 22:11:33 -0500 Subject: [PATCH 015/297] Prevent sellall from loading if ranks does not load. Sellall uses too many rank functions to stand alone. --- docs/changelog_v3.3.x.md | 3 ++ .../mcprison/prison/spigot/SpigotPrison.java | 40 +++++++++++-------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 2d0dc6433..613062342 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-27 +* **Prevent sellall from loading if ranks does not load. Sellall uses too many rank functions to stand alone.** + + * **Bug Fix: The new Ranks error message handler which intercepts all ranks messags was failing to load properly when prison startup was not set for a delayed startup,** which was because the ranks gui command (/ranks) was always being set even when ranks module failed to load. Now /ranks gui loads only if ranks was successful in being started. 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 9298d5545..0c024899f 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 @@ -75,7 +75,10 @@ import tech.mcprison.prison.spigot.commands.PrisonSpigotSellAllCommands; import tech.mcprison.prison.spigot.compat.Compatibility; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; -import tech.mcprison.prison.spigot.configs.*; +import tech.mcprison.prison.spigot.configs.BackpacksConfig; +import tech.mcprison.prison.spigot.configs.GuiConfig; +import tech.mcprison.prison.spigot.configs.MessagesConfig; +import tech.mcprison.prison.spigot.configs.SellAllConfig; import tech.mcprison.prison.spigot.customblock.CustomItems; import tech.mcprison.prison.spigot.economies.EssentialsEconomy; import tech.mcprison.prison.spigot.economies.GemsEconomy; @@ -677,6 +680,8 @@ public void resetModulesAndCommands() { private void initModulesAndCommands() { YamlConfiguration modulesConf = loadConfig("modules.yml"); + + boolean isRanksEnabled = false; // TODO: This business logic needs to be moved to the Module Manager: if (modulesConf.getBoolean("mines")) { @@ -697,21 +702,10 @@ private void initModulesAndCommands() { // Register and enable Ranks: Prison.get().getModuleManager().registerModule( rankModule ); - - // Only allow the GUI ranks command to be registered if there is an economy and ranks is enabled. if ( rankModule.isEnabled() && PrisonAPI.getIntegrationManager().hasForType(IntegrationType.ECONOMY) ) { - Prison.get().getCommandHandler().registerCommands( new PrisonSpigotRanksCommands() ); - - // NOTE: If ranks module is enabled, then try to register prestiges commands if enabled: - if ( isPrisonConfig( "prestiges") || isPrisonConfig( "prestige.enabled" ) ) { - // Enable the setup of the prestige related commands only if prestiges is enabled: - Prison.get().getCommandHandler().registerCommands( new PrisonSpigotPrestigeCommands() ); - } + isRanksEnabled = true; } - - - } else { Output.get().logInfo("&3Modules: &cPrison Ranks, Ladders, and Players are disabled and were not Loaded. "); @@ -729,9 +723,23 @@ private void initModulesAndCommands() { // linkMinesAndRanks(); // } - // Load sellAll if enabled - if (isSellAllEnabled){ - Prison.get().getCommandHandler().registerCommands( new PrisonSpigotSellAllCommands() ); + + // Do not enable sellall if ranks is not loaded since it uses player ranks: + if ( isRanksEnabled ) { + + Prison.get().getCommandHandler().registerCommands( new PrisonSpigotRanksCommands() ); + + // NOTE: If ranks module is enabled, then try to register prestiges commands if enabled: + if ( isPrisonConfig( "prestiges") || isPrisonConfig( "prestige.enabled" ) ) { + // Enable the setup of the prestige related commands only if prestiges is enabled: + Prison.get().getCommandHandler().registerCommands( new PrisonSpigotPrestigeCommands() ); + } + + // Load sellAll if enabled + if (isSellAllEnabled){ + Prison.get().getCommandHandler().registerCommands( new PrisonSpigotSellAllCommands() ); + } + } // Load backpacks commands if enabled From 77287ce64b166756d799b7643efd2e7ed9bb4310 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 27 Jan 2022 22:13:47 -0500 Subject: [PATCH 016/297] Bug Fix: Damage was being applied all the time. Found a field being initialized with a value of 1 when it should have been 0. --- docs/changelog_v3.3.x.md | 4 ++++ .../mcprison/prison/spigot/block/OnBlockBreakEventCore.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 613062342..28df70328 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-27 +* **Bug Fix: Damage was being applied all the time.** +Found a field being initialized with a value of 1 when it should have been 0. + + * **Prevent sellall from loading if ranks does not load. Sellall uses too many rank functions to stand alone.** 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 c91e617ca..e663d8a94 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 @@ -2500,7 +2500,7 @@ protected void calculateAndApplyDurability(Player player, SpigotItemStack itemIn int maxDurability = compat.getDurabilityMax( itemInHand ); int durability = compat.getDurability( itemInHand ); - short totalDamage = 1; // Generally 1 unless instant break block then zero. + short totalDamage = 0; // Generally 1 unless instant break block then zero. int durabilityLevel = 0; boolean toolBreak = false; From 19b2972e6ea9c33e986fdc547eac6d16268eddc8 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 28 Jan 2022 13:30:06 -0500 Subject: [PATCH 017/297] Bug fix: Lapis_ore appently does not drop lapis_laluzi when using the bukkit's getDrops() function, it instead drops blue_dye, then when it gets to the player's inventory, it is then converted to lapis_lazuli. Therefore, auto sell cannot sell lapis_ore drops unles blue_dye is within the shop. I added blue_dye with the same value of lapis_lazuli to the sellall shop. This allows it to be sold now through auto pickup and auto sell. --- docs/changelog_v3.3.x.md | 6 ++- .../prison/internal/block/PrisonBlock.java | 2 + .../internal/block/PrisonBlockTypes.java | 1 + .../prison/spigot/SpigotPlatform.java | 3 ++ .../mcprison/prison/spigot/SpigotUtil.java | 40 ++++++++++++------- 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 28df70328..c8fc28634 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.1 (alpha.7) 2022-01-27 +# 3.3.0-beta.1 (alpha.7) 2022-01-28 + +* **Bug fix: Lapis_ore appently does not drop lapis_laluzi when using the bukkit's getDrops() function, it instead drops blue_dye, then when it gets to the player's inventory, it is then converted to lapis_lazuli.** +Therefore, auto sell cannot sell lapis_ore drops unles blue_dye is within the shop. I added blue_dye with the same value of lapis_lazuli to the sellall shop. This allows it to be sold now through auto pickup and auto sell. + * **Bug Fix: Damage was being applied all the time.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java index ec7922d98..d5dbd42af 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java @@ -25,6 +25,7 @@ public class PrisonBlock public static PrisonBlock GLASS; public static PrisonBlock PINK_STAINED_GLASS; public static PrisonBlock BLAZE_ROD; + public static PrisonBlock LAPIS_ORE; public static PrisonBlock IGNORE; public static PrisonBlock NULL_BLOCK; @@ -47,6 +48,7 @@ public class PrisonBlock GLASS = new PrisonBlock( InternalBlockTypes.GLASS.name(), true ); PINK_STAINED_GLASS = new PrisonBlock( InternalBlockTypes.PINK_STAINED_GLASS.name(), true ); BLAZE_ROD = new PrisonBlock( InternalBlockTypes.BLAZE_ROD.name(), false ); + LAPIS_ORE = new PrisonBlock( InternalBlockTypes.LAPIS_ORE.name(), false ); IGNORE = new PrisonBlock( InternalBlockTypes.IGNORE.name(), false ); NULL_BLOCK = new PrisonBlock( InternalBlockTypes.NULL_BLOCK.name(), false ); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java index a59ae383f..1ea97c5d4 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java @@ -22,6 +22,7 @@ public enum InternalBlockTypes { GLASS, PINK_STAINED_GLASS, BLAZE_ROD, + LAPIS_ORE, IGNORE, NULL_BLOCK } 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 7372953a6..cd4a6bb5d 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 @@ -1798,7 +1798,10 @@ public List buildBlockListXMaterial() { blockList.add( new SellAllBlockData( XMaterial.FLINT, 9 ) ); + // BLUE_DYE is used as LAPIS_LAZULI for bukkit v1.8.x etc... blockList.add( new SellAllBlockData( XMaterial.LAPIS_LAZULI, 14 ) ); + blockList.add( new SellAllBlockData( XMaterial.BLUE_DYE, 14 ) ); + blockList.add( new SellAllBlockData( XMaterial.MOSSY_STONE_BRICKS, 14 ) ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java index 0e11767da..d2ff0de9b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java @@ -1027,21 +1027,33 @@ public static ItemStack prisonItemStackToBukkit( return bukkitStack; } - public static List getDrops(SpigotBlock block, SpigotItemStack tool) { - List ret = new ArrayList<>(); - - Collection drops = block.getWrapper().getDrops( tool.getBukkitStack() ); - - for ( ItemStack drop : drops ) - { - ret.add( SpigotUtil.bukkitItemStackToPrison(drop) ); + + /** + *

Drops for lapis_ore is odd before the flattening (bukkit 1.8.x through 1.12.2) since it + * drops as blue_dye, but when it makes it to the player's inventory, it is then converted to + * lapis_lazuli. So in order for auto sell to work, it has to sell on blue_dye and not + * lapis_lazuli, or it will be placed in the player's inventory. So it's important that + * blue_dye is added to the shop for the same price as lapis_lazuli. + *

+ * + * @param block + * @param tool + * @return + */ + public static List getDrops(SpigotBlock block, SpigotItemStack tool) { + List ret = new ArrayList<>(); + + Collection drops = block.getWrapper().getDrops( tool.getBukkitStack() ); + + for ( ItemStack drop : drops ) { + ret.add( SpigotUtil.bukkitItemStackToPrison(drop) ); + } + + // block.getWrapper().getDrops( tool.getBukkitStack() ) + // .forEach(itemStack -> ret.add(SpigotUtil.bukkitItemStackToPrison(itemStack))); + + return ret; } - -// block.getWrapper().getDrops( tool.getBukkitStack() ) -// .forEach(itemStack -> ret.add(SpigotUtil.bukkitItemStackToPrison(itemStack))); - - return ret; -} // public static void clearDrops(SpigotBlock block) { From 8be719e7bd91282cab9c31b90e380c20d94ce50f Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 28 Jan 2022 13:32:24 -0500 Subject: [PATCH 018/297] New Feature: Added support for Quests so that block breakage within mines can now be tracked and be applied towards quests. --- docs/changelog_v3.3.x.md | 4 ++ .../tech/mcprison/prison/PrisonCommand.java | 4 ++ .../autofeatures/AutoFeaturesFileConfig.java | 2 + .../block/OnBlockBreakExternalEvents.java | 67 +++++++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c8fc28634..154cfb2a4 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -15,6 +15,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-28 + +* **New Feature: Added support for Quests so that block breakage within mines can now be tracked and be applied towards quests.** + + * **Bug fix: Lapis_ore appently does not drop lapis_laluzi when using the bukkit's getDrops() function, it instead drops blue_dye, then when it gets to the player's inventory, it is then converted to lapis_lazuli.** Therefore, auto sell cannot sell lapis_ore drops unles blue_dye is within the shop. I added blue_dye with the same value of lapis_lazuli to the sellall shop. This allows it to be sold now through auto pickup and auto sell. 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 ea12bb5aa..8100b54c4 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -965,6 +965,10 @@ public void autoFeaturesInformation(CommandSender sender) { display.addText( "&b " ); display.addText( "&b options.isProcessMcMMOBlockBreakEvents %s", afw.isBoolean( AutoFeatures.isProcessMcMMOBlockBreakEvents )); + display.addText( "&b options.isProcessEZBlocksBlockBreakEvents %s", + afw.isBoolean( AutoFeatures.isProcessEZBlocksBlockBreakEvents )); + display.addText( "&b options.isProcessQuestsBlockBreakEvents %s", + afw.isBoolean( AutoFeatures.isProcessQuestsBlockBreakEvents )); display.addText( "&b " ); 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 14b8d59fc..d1e440b4f 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 @@ -68,6 +68,8 @@ public enum AutoFeatures { isProcessMcMMOBlockBreakEvents(otherPlugins, true), isProcessEZBlocksBlockBreakEvents(otherPlugins, false), + + isProcessQuestsBlockBreakEvents(otherPlugins, true), blockBreakEvents(options), diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java index b3e822929..87d2f576a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java @@ -26,6 +26,9 @@ public class OnBlockBreakExternalEvents { private boolean isEZBlockChecked = false; private RegisteredListener registeredListenerEZBlock = null; + private boolean isQuestsChecked = false; + private RegisteredListener registeredListenerQuests = null; + private AutoFeaturesWrapper autoFeatureWrapper = null; @@ -85,6 +88,10 @@ protected void registerAllExternalEvents() { registerEZBlock(); + + registerQuests(); + + // Removed because there is a directly callable target with /prison debug now: // if ( Output.get().isDebug( DebugTarget.blockBreakListeners ) ) { // @@ -120,6 +127,9 @@ protected void checkAllExternalEvents( BlockBreakEvent e ) { checkEZBlock( e ); + + checkQuests( e ); + } protected void checkAllExternalEvents( Player player, Block block ) { @@ -129,6 +139,9 @@ protected void checkAllExternalEvents( Player player, Block block ) { checkEZBlock( player, block ); + + + checkQuests( player, block ); } @@ -344,4 +357,58 @@ private void checkEZBlock( BlockBreakEvent e ) { + /** + *

Checks to see if Quests is able to be enabled, and if it is, then call it's registered + * function that will do it's processing before prison will process the blocks. + *

+ * + *

This adds Quests support within mines for block break related quests. + *

+ * + * @param e + */ + private void registerQuests() { + + if ( !isQuestsChecked ) { + + boolean isProcessQuestsBreakEvents = isBoolean( AutoFeatures.isProcessQuestsBlockBreakEvents ); + + if ( isProcessQuestsBreakEvents ) { + + for ( RegisteredListener rListener : BlockBreakEvent.getHandlerList().getRegisteredListeners() ) { + + if ( rListener.getPlugin().isEnabled() && + rListener.getPlugin().getName().equalsIgnoreCase( "Quests" ) ) { + + registeredListenerQuests = rListener; + } + } + + } + + isQuestsChecked = true; + } + } + + private void checkQuests( Player player, Block block ) { + if ( registeredListenerQuests != null ) { + BlockBreakEvent bEvent = new BlockBreakEvent( block, player ); + checkEZBlock( bEvent ); + } + } + + private void checkQuests( BlockBreakEvent e ) { + if ( registeredListenerQuests != null ) { + + try { + registeredListenerQuests.callEvent( e ); + } + catch ( EventException e1 ) { + e1.printStackTrace(); + } + } + } + + + } From 6e288c1a120c8f2a59fe57d0982e760cd317f954 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 00:50:12 -0500 Subject: [PATCH 019/297] Created updated documents for the placeholderAPI wiki. These are local copies of the content since the prior content was removed/vandelized. --- docs/changelog_v3.3.x.md | 7 +- docs/prison_docs_000_toc.md | 4 + docs/prison_placeholderapi_wiki_docs.md | 413 ++++++++++++++++++++++++ 3 files changed, 423 insertions(+), 1 deletion(-) create mode 100644 docs/prison_placeholderapi_wiki_docs.md diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 154cfb2a4..a0130e90f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,12 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.1 (alpha.7) 2022-01-28 +# 3.3.0-beta.1 (alpha.7) 2022-01-29 + + +* **Created updated documents for the placeholderAPI wiki.** +These are local copies of the content since the prior content was removed/vandelized. + * **New Feature: Added support for Quests so that block breakage within mines can now be tracked and be applied towards quests.** diff --git a/docs/prison_docs_000_toc.md b/docs/prison_docs_000_toc.md index 1e48226ee..82607d3f1 100644 --- a/docs/prison_docs_000_toc.md +++ b/docs/prison_docs_000_toc.md @@ -268,6 +268,10 @@ Auto configure can get you up and running with as little as two commands. The f Installing the plugins +* [Prison's PlaceholderAPI wiki page content](prison_placeholderapi_wiki_docs.md) + This document contains the Prison's content that is published on PlaceholderAPI's wiki. + + * [Setting up PlaceholderAPI](prison_docs_0xx_setting_up_PlaceholderAPI.md) - Strongly Suggested if using placeholders. Troubleshooting.
diff --git a/docs/prison_placeholderapi_wiki_docs.md b/docs/prison_placeholderapi_wiki_docs.md new file mode 100644 index 000000000..bf9d3c823 --- /dev/null +++ b/docs/prison_placeholderapi_wiki_docs.md @@ -0,0 +1,413 @@ +### Prison Documentation +[Prison Documents - Table of Contents](prison_docs_000_toc.md) + +## Prison - Setting Prison with Auto Configure + +This document provides information on how to get started quickly using Prison's `/ranks autoConfigure`. + + +[Prison Log File Examples - Starting Prison & auto configure](prison_docs_101_auto_configure_log_examples.md) + + +*Documented updated: 2022-01-29* + +
+ +# Overview + + +These are the values that are supplied to the PlaceholderAPI wiki. They are stored in this document for backup copies, and for easy references. + + + +
+ +The following are Prison's entries in the file **Plugins-using-PlaceholderAPI.md**: + + +- **[Prison](https://www.spigotmc.org/resources/1223/)** + - [x] Supports placeholders. + - [x] Provides own placeholders. [**[[Link|Placeholders#prison]]**] + + +
+ + +The following are Prison's entries in the file **Placeholders.md**: + + +## **P** + +- **[Prison](#prison)** + +---- + +- ### **[Prison](https://www.spigotmc.org/resources/1223/)** +> NO DOWNLOAD COMMAND + +Each placeholder has a shorter alias, which follows the primary placeholder below. + +Prison uses PlaceholderAPI to support any plugin placeholders within the GUI Ranks Lore and the GUI Mine Lore. + + +**Prison Placeholder Attributes:** + +Prison supports Placeholder Attributes which allows an infinite way to customize most placeholders, such as numeric formatting, hex colors, and reductions. Can customize any bar-graph for character codes, colors, and size. + +Simple examples using placeholder attributes with the results following each example. Colors are not shown. + +``` +%prison_mines_size_mine5::nFormat:#,##0% +654,321 +%prison_mines_size_mine5::nFormat:#,##0.00:1:kmg% +654.32 k +%prison_mines_size_mine5::nFormat:'#af33ff'#,##0.00:1:binary:hex% +638.99 KB +%prison_mines_timeleft_bar_mine5::bar:40:&2:O:&d:x:debug% +OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOxxxxxxxx + +``` + + +**PLAYER placeholders (110, 55 aliases):** + +PLAYER placeholders are used directly with a player, such as with player chat prefixes and scoreboards. + +Rank related placeholders apply to all ranks that a player may have, and may return more than one value. Use the LADDER placeholders to control the order that is displayed. Rank based placeholder can return zero, one, or more rank related values depending upon how many ladders the player is on. + +``` +%prison_rank% +%prison_r% +%prison_rank_number% +%prison_rn% +%prison_rank_tag% +%prison_rt% +%prison_rank_ladder_position% +%prison_rlp% +%prison_rankup_cost% +%prison_rc% +%prison_rankup_cost_formatted% +%prison_rcf% +%prison_rankup_cost_percent% +%prison_rcp% +%prison_rankup_cost_bar% +%prison_rcb% +%prison_rankup_cost_remaining% +%prison_rcr% +%prison_rankup_cost_remaining_formatted% +%prison_rcrf% +%prison_rankup_cost_remaining_percent% +%prison_rcrp +%prison_rankup_cost_remaining_bar% +%prison_rcrb% +%prison_rankup_rank% +%prison_rr% +%prison_rankup_rank_tag% +%prison_rrt% +%prison_player_balance% +%prison_pb% +%prison_player_balance_formatted% +%prison_pbf% +%prison_player_balance_earnings_per_minute% +%prison_pb_epm% +%prison_player_balance_earnings_per_minute_formatted% +%prison_pb_epmf% +%prison_player_token_balance% +%prison_ptb% +%prison_player_token_balance_formatted% +%prison_ptbf% +%prison_player_token_balance_formatted_metric% +%prison_ptbfm% +%prison_player_token_balance_formatted_kmbt% +%prison_ptbfk% +%prison_player_token_balance_earnings_per_minute% +%prison_ptb_epm% +%prison_player_token_balance_earnings_per_minute_formatted% +%prison_ptb_epmf% +%prison_player_sellall_multiplier% +%prison_psm% +%prison_player_blocks_total% +%prison_pbt% +%prison_player_blocks_total_formatted% +%prison_pbtf% +%prison_player_tool_id% +%prison_ptid% +%prison_player_tool_name% +%prison_ptn% +%prison_player_tool_type% +%prison_ptt% +%prison_player_tool_material_type% +%prison_ptmt% +%prison_player_tool_data% +%prison_ptdata% +%prison_player_tool_lore% +%prison_ptlore% +%prison_player_tool_durability_used% +%prison_ptdu% +%prison_player_tool_durability_max% +%prison_ptdm% +%prison_player_tool_durability_remaining% +%prison_ptdr% +%prison_player_tool_durability_percent% +%prison_ptdp% +%prison_player_tool_durability_bar% +%prison_ptdb% +%prison_player_tool_enchantment_fortune% +%prison_ptef% +%prison_player_tool_enchantment_efficency% +%prison_ptee% +%prison_player_tool_enchantment_silktouch% +%prison_ptes% +%prison_player_tool_enchantment_unbreaking% +%prison_pteu% +%prison_player_tool_enchantment_mending% +%prison_ptem% +%prison_player_tool_enchantment_luck% +%prison_ptel% +%prison_player_health% +%prison_ph% +%prison_player_health_max% +%prison_phm% +%prison_player_air_max% +%prison_pam% +%prison_player_air_remaining% +%prison_par% +%prison_player_food_level% +%prison_pfl% +%prison_player_food_saturation% +%prison_pfs% +%prison_player_food_exhaustion% +%prison_pfe% +%prison_player_xp% +%prison_pxp% +%prison_player_xp_to_level% +%prison_pxptl% +%prison_player_level% +%prison_pl% +%prison_player_walk_speed% +%prison_pws% +``` + + +**LADDERS placeholders (32, 16 aliases):** + +Must be used directly with a player, and returns the information related to their active rank on the specified ladder. + +Use the ladder name, all lowercase, in place of ``, and it will return zero or one rank related values. + +``` +%prison_rank_% +%prison_r_% +%prison_rank_number_% +%prison_rn_% +%prison_rank_tag_% +%prison_rt_% +prison_rank_ladder_position_% +%prison_rlp_% +%prison_rankup_cost_% +%prison_rc_% +%prison_rankup_cost_formatted_% +%prison_rcf_% +%prison_rankup_cost_percent_% +%prison_rcp_% +%prison_rankup_cost_bar_% +%prison_rcb_% +%prison_rankup_cost_remaining_% +%prison_rcr_% +%prison_rankup_cost_remaining_formatted_% +%prison_rcrf_% +%prison_rankup_cost_remaining_percent_% +%prison_rcrp_% +%prison_rankup_cost_remaining_bar_% +%prison_rcrb_% +%prison_rankup_rank_% +%prison_rr_% +%prison_rankup_rank_tag_% +%prison_rrt_% +%prison_player_balance_% +%prison_pb_% +prison_player_balance_formatted_% +%prison_pbf_% +``` + + +**RANKS placeholders (22, 11 aliases):** + +RANKS placeholders deal directly with specific rank information. + +Use the rank name in place of ``, and may return zero or one value. + +``` +%prison_rank__name_% +%prison_r_n_% +%prison_rank__tag_% +%prison_r_t_% +%prison_rank__ladder_% +%prison_r_l_% +%prison_rank__ladder_position_% +%prison_r_lp_% +%prison_rank__cost_% +%prison_r_c_% +%prison_rank__cost_formatted_% +%prison_r_cf_% +%prison_rank__cost_multiplier_% +%prison_r_cm_% +%prison_rank__currency_% +%prison_r_cu_% +%prison_rank__id_% +%prison_r_id_% +%prison_rank__player_count_% +%prison_r_pc_% +%prison_rank__linked_mines_% +%prison_r_lm_% +``` + + +**RANKPLAYERS placeholders (12, 6 aliases):** + +RANKPLAYERS placeholders are used with players and shows what their adjusted costs are for the specified rank. These placeholders are ideal for showing a player how much each rank will cost using their personal rank cost multipliers. + +Use the rank name in place of ``, and may return zero or one value. + +``` +%prison_rank__player_cost_% +%prison_r_pcst_% +%prison_rank__player_cost_formatted_% +%prison_r_pcf_% +%prison_rank__player_cost_remaining_% +%prison_r_pcf_% +%prison_rank__player_cost_remaining_formatted_% +%prison_r_pcf_% +%prison_rank__player_cost_percent_% +%prison_r_pcp_% +%prison_rank__player_cost_bar_% +%prison_r_pcb_% +``` + +**MINES placeholders (34, 17 aliases):** + +MINES placeholder provides stats for the given mine. + +Use the mine name in place of ``, and may return zero or one value. + +``` +%prison_mines_name_% +%prison_mn_% +%prison_mines_tag_% +%prison_mt_% +%prison_mines_interval_% +%prison_mi_% +%prison_mines_interval_formatted_% +%prison_mif_% +%prison_mines_timeleft_% +%prison_mtl_% +%prison_mines_timeleft_bar_% +%prison_mtlb_% +%prison_mines_timeleft_formatted_% +%prison_mtlf_% +%prison_mines_size_% +%prison_ms_% +%prison_mines_remaining_% +%prison_mr_% +%prison_mines_remaining_bar_% +%prison_mrb_% +%prison_mines_percent_% +%prison_mp_% +%prison_mines_player_count_% +%prison_mpc_% +%prison_mines_blocks_mined_% +%prison_mbm_% +%prison_mines_reset_count_% +%prison_mrc_% +%prison_player_blocks_total_% +%prison_pbtm + +%prison_top_mine_block_line_header_% +%prison_tmbl_header_% +%prison_top_mine_block_line_totals_% +%prison_tmbl_totals_% +``` + +Note: The placeholders `%prison_top_mine_block_line_header_%` and `%prison_top_mine_block_line_totals_%` are used with the STATSMINES placeholders and provide the headers and total details for the given mines. + + +**MINEPLAYERS placeholders (28, 14 aliases):** + +MINEPLAYERS placeholders are tied to a player and dynamically shows the details of the mine the player is in, or blanks when not in a mine. These are ideal for use in scoreboards or chat prefixes. + +Must be used with a player. + +``` +%prison_mines_name_playermines% +%prison_mn_pm% +%prison_mines_tag_playermines% +%prison_mt_pm% +%prison_mines_interval_playermines% +%prison_mi_pm% +%prison_mines_interval_formatted_playermines% +%prison_mif_pm% +%prison_mines_timeleft_playermines% +%prison_mtl_pm% +%prison_mines_timeleft_bar_playermines% +%prison_mtlb_pm% +%prison_mines_timeleft_formatted_playermines% +%prison_mtlf_pm% +%prison_mines_size_playermines% +%prison_ms_pm% +%prison_mines_remaining_playermines% +%prison_mr_pm% +%prison_mines_remaining_bar_playermines% +%prison_mrb_pm% +%prison_mines_percent_playermines% +%prison_mp_pm% +%prison_mines_player_count_playermines% +%prison_mpc_pm% +%prison_mines_blocks_mined_playermines% +%prison_mbm_pm% +%prison_mines_reset_count_playermines% +%prison_mrc_pm% +``` + + +**STATSMINES placeholders (14, 7 aliases):** + +The STATSMINES placeholders represents the blocks that in the specified mine. The value `nnn` should be replaced with a number starting with a `1`, or `001` and refers to one block. The "_line_ placeholder is composed of the other placeholders and can simplify the use of these placeholders. See the headers and footer totals within the MINES placeholders. + +Use the mine name in place of ``, and may return zero or one value. Invalid values for `_nnn_` will return blanks. + +``` +%prison_top_mine_block_line_nnn_% +%prison_tmbl_nnn_% +%prison_top_mine_block_name_nnn_% +%prison_tmbn_nnn_% +%prison_top_mine_block_chance_nnn_% +%prison_tmbc_nnn_% +%prison_top_mine_block_placed_nnn_% +%prison_tmbpl_nnn_% +%prison_top_mine_block_remaing_nnn_% +%prison_tmbr_nnn_% +%prison_top_mine_block_remaing_bar_nnn_% +%prison_tmbrb_nnn_% +%prison_top_mine_block_total_nnn_% +%prison_tmbt_nnn_% +``` + + +**STATSRANKS placeholders (6, 3 aliases)** + +The STATSRANKS placeholders represents the top-n players for a given rank. The value `nnn` should be replaced with a number starting with a `1`, or `001` and refers to a given player. + +Use the mine name in place of ``, and may return zero or one value. Invalid values for `_nnn_` will return blanks. + +``` +%prison_top_rank_balance_name_nnn_% +%prison_trbn_nnn_% +%prison_top_rank_balance_score_nnn_% +%prison_trbs_nnn_% +%prison_top_rank_balance_balance_nnn_% +%prison_trbb_nnn_% +``` + +---- + + From 436b8646dc0f1cf9b7d576f120149ee97e61caaa Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 13:04:20 -0500 Subject: [PATCH 020/297] Update the placeholderAPI docs to correct the formatting of the docs to match what they should be. Had to indent by two spaces. --- docs/changelog_v3.3.x.md | 4 + docs/prison_placeholderapi_wiki_docs.md | 729 ++++++++++++------------ 2 files changed, 368 insertions(+), 365 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a0130e90f..68663e372 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-29 +* **Update the placeholderAPI docs to correct the formatting of the docs to match what they should be.** +Had to indent by two spaces. + + * **Created updated documents for the placeholderAPI wiki.** These are local copies of the content since the prior content was removed/vandelized. diff --git a/docs/prison_placeholderapi_wiki_docs.md b/docs/prison_placeholderapi_wiki_docs.md index bf9d3c823..04e93d56e 100644 --- a/docs/prison_placeholderapi_wiki_docs.md +++ b/docs/prison_placeholderapi_wiki_docs.md @@ -38,375 +38,374 @@ The following are Prison's entries in the file **Placeholders.md**: ## **P** -- **[Prison](#prison)** ---- - ### **[Prison](https://www.spigotmc.org/resources/1223/)** -> NO DOWNLOAD COMMAND - -Each placeholder has a shorter alias, which follows the primary placeholder below. - -Prison uses PlaceholderAPI to support any plugin placeholders within the GUI Ranks Lore and the GUI Mine Lore. - - -**Prison Placeholder Attributes:** - -Prison supports Placeholder Attributes which allows an infinite way to customize most placeholders, such as numeric formatting, hex colors, and reductions. Can customize any bar-graph for character codes, colors, and size. - -Simple examples using placeholder attributes with the results following each example. Colors are not shown. - -``` -%prison_mines_size_mine5::nFormat:#,##0% -654,321 -%prison_mines_size_mine5::nFormat:#,##0.00:1:kmg% -654.32 k -%prison_mines_size_mine5::nFormat:'#af33ff'#,##0.00:1:binary:hex% -638.99 KB -%prison_mines_timeleft_bar_mine5::bar:40:&2:O:&d:x:debug% -OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOxxxxxxxx - -``` - - -**PLAYER placeholders (110, 55 aliases):** - -PLAYER placeholders are used directly with a player, such as with player chat prefixes and scoreboards. - -Rank related placeholders apply to all ranks that a player may have, and may return more than one value. Use the LADDER placeholders to control the order that is displayed. Rank based placeholder can return zero, one, or more rank related values depending upon how many ladders the player is on. - -``` -%prison_rank% -%prison_r% -%prison_rank_number% -%prison_rn% -%prison_rank_tag% -%prison_rt% -%prison_rank_ladder_position% -%prison_rlp% -%prison_rankup_cost% -%prison_rc% -%prison_rankup_cost_formatted% -%prison_rcf% -%prison_rankup_cost_percent% -%prison_rcp% -%prison_rankup_cost_bar% -%prison_rcb% -%prison_rankup_cost_remaining% -%prison_rcr% -%prison_rankup_cost_remaining_formatted% -%prison_rcrf% -%prison_rankup_cost_remaining_percent% -%prison_rcrp -%prison_rankup_cost_remaining_bar% -%prison_rcrb% -%prison_rankup_rank% -%prison_rr% -%prison_rankup_rank_tag% -%prison_rrt% -%prison_player_balance% -%prison_pb% -%prison_player_balance_formatted% -%prison_pbf% -%prison_player_balance_earnings_per_minute% -%prison_pb_epm% -%prison_player_balance_earnings_per_minute_formatted% -%prison_pb_epmf% -%prison_player_token_balance% -%prison_ptb% -%prison_player_token_balance_formatted% -%prison_ptbf% -%prison_player_token_balance_formatted_metric% -%prison_ptbfm% -%prison_player_token_balance_formatted_kmbt% -%prison_ptbfk% -%prison_player_token_balance_earnings_per_minute% -%prison_ptb_epm% -%prison_player_token_balance_earnings_per_minute_formatted% -%prison_ptb_epmf% -%prison_player_sellall_multiplier% -%prison_psm% -%prison_player_blocks_total% -%prison_pbt% -%prison_player_blocks_total_formatted% -%prison_pbtf% -%prison_player_tool_id% -%prison_ptid% -%prison_player_tool_name% -%prison_ptn% -%prison_player_tool_type% -%prison_ptt% -%prison_player_tool_material_type% -%prison_ptmt% -%prison_player_tool_data% -%prison_ptdata% -%prison_player_tool_lore% -%prison_ptlore% -%prison_player_tool_durability_used% -%prison_ptdu% -%prison_player_tool_durability_max% -%prison_ptdm% -%prison_player_tool_durability_remaining% -%prison_ptdr% -%prison_player_tool_durability_percent% -%prison_ptdp% -%prison_player_tool_durability_bar% -%prison_ptdb% -%prison_player_tool_enchantment_fortune% -%prison_ptef% -%prison_player_tool_enchantment_efficency% -%prison_ptee% -%prison_player_tool_enchantment_silktouch% -%prison_ptes% -%prison_player_tool_enchantment_unbreaking% -%prison_pteu% -%prison_player_tool_enchantment_mending% -%prison_ptem% -%prison_player_tool_enchantment_luck% -%prison_ptel% -%prison_player_health% -%prison_ph% -%prison_player_health_max% -%prison_phm% -%prison_player_air_max% -%prison_pam% -%prison_player_air_remaining% -%prison_par% -%prison_player_food_level% -%prison_pfl% -%prison_player_food_saturation% -%prison_pfs% -%prison_player_food_exhaustion% -%prison_pfe% -%prison_player_xp% -%prison_pxp% -%prison_player_xp_to_level% -%prison_pxptl% -%prison_player_level% -%prison_pl% -%prison_player_walk_speed% -%prison_pws% -``` - - -**LADDERS placeholders (32, 16 aliases):** - -Must be used directly with a player, and returns the information related to their active rank on the specified ladder. - -Use the ladder name, all lowercase, in place of ``, and it will return zero or one rank related values. - -``` -%prison_rank_% -%prison_r_% -%prison_rank_number_% -%prison_rn_% -%prison_rank_tag_% -%prison_rt_% -prison_rank_ladder_position_% -%prison_rlp_% -%prison_rankup_cost_% -%prison_rc_% -%prison_rankup_cost_formatted_% -%prison_rcf_% -%prison_rankup_cost_percent_% -%prison_rcp_% -%prison_rankup_cost_bar_% -%prison_rcb_% -%prison_rankup_cost_remaining_% -%prison_rcr_% -%prison_rankup_cost_remaining_formatted_% -%prison_rcrf_% -%prison_rankup_cost_remaining_percent_% -%prison_rcrp_% -%prison_rankup_cost_remaining_bar_% -%prison_rcrb_% -%prison_rankup_rank_% -%prison_rr_% -%prison_rankup_rank_tag_% -%prison_rrt_% -%prison_player_balance_% -%prison_pb_% -prison_player_balance_formatted_% -%prison_pbf_% -``` - - -**RANKS placeholders (22, 11 aliases):** - -RANKS placeholders deal directly with specific rank information. - -Use the rank name in place of ``, and may return zero or one value. - -``` -%prison_rank__name_% -%prison_r_n_% -%prison_rank__tag_% -%prison_r_t_% -%prison_rank__ladder_% -%prison_r_l_% -%prison_rank__ladder_position_% -%prison_r_lp_% -%prison_rank__cost_% -%prison_r_c_% -%prison_rank__cost_formatted_% -%prison_r_cf_% -%prison_rank__cost_multiplier_% -%prison_r_cm_% -%prison_rank__currency_% -%prison_r_cu_% -%prison_rank__id_% -%prison_r_id_% -%prison_rank__player_count_% -%prison_r_pc_% -%prison_rank__linked_mines_% -%prison_r_lm_% -``` - - -**RANKPLAYERS placeholders (12, 6 aliases):** - -RANKPLAYERS placeholders are used with players and shows what their adjusted costs are for the specified rank. These placeholders are ideal for showing a player how much each rank will cost using their personal rank cost multipliers. - -Use the rank name in place of ``, and may return zero or one value. - -``` -%prison_rank__player_cost_% -%prison_r_pcst_% -%prison_rank__player_cost_formatted_% -%prison_r_pcf_% -%prison_rank__player_cost_remaining_% -%prison_r_pcf_% -%prison_rank__player_cost_remaining_formatted_% -%prison_r_pcf_% -%prison_rank__player_cost_percent_% -%prison_r_pcp_% -%prison_rank__player_cost_bar_% -%prison_r_pcb_% -``` - -**MINES placeholders (34, 17 aliases):** - -MINES placeholder provides stats for the given mine. - -Use the mine name in place of ``, and may return zero or one value. - -``` -%prison_mines_name_% -%prison_mn_% -%prison_mines_tag_% -%prison_mt_% -%prison_mines_interval_% -%prison_mi_% -%prison_mines_interval_formatted_% -%prison_mif_% -%prison_mines_timeleft_% -%prison_mtl_% -%prison_mines_timeleft_bar_% -%prison_mtlb_% -%prison_mines_timeleft_formatted_% -%prison_mtlf_% -%prison_mines_size_% -%prison_ms_% -%prison_mines_remaining_% -%prison_mr_% -%prison_mines_remaining_bar_% -%prison_mrb_% -%prison_mines_percent_% -%prison_mp_% -%prison_mines_player_count_% -%prison_mpc_% -%prison_mines_blocks_mined_% -%prison_mbm_% -%prison_mines_reset_count_% -%prison_mrc_% -%prison_player_blocks_total_% -%prison_pbtm - -%prison_top_mine_block_line_header_% -%prison_tmbl_header_% -%prison_top_mine_block_line_totals_% -%prison_tmbl_totals_% -``` - -Note: The placeholders `%prison_top_mine_block_line_header_%` and `%prison_top_mine_block_line_totals_%` are used with the STATSMINES placeholders and provide the headers and total details for the given mines. - - -**MINEPLAYERS placeholders (28, 14 aliases):** - -MINEPLAYERS placeholders are tied to a player and dynamically shows the details of the mine the player is in, or blanks when not in a mine. These are ideal for use in scoreboards or chat prefixes. - -Must be used with a player. - -``` -%prison_mines_name_playermines% -%prison_mn_pm% -%prison_mines_tag_playermines% -%prison_mt_pm% -%prison_mines_interval_playermines% -%prison_mi_pm% -%prison_mines_interval_formatted_playermines% -%prison_mif_pm% -%prison_mines_timeleft_playermines% -%prison_mtl_pm% -%prison_mines_timeleft_bar_playermines% -%prison_mtlb_pm% -%prison_mines_timeleft_formatted_playermines% -%prison_mtlf_pm% -%prison_mines_size_playermines% -%prison_ms_pm% -%prison_mines_remaining_playermines% -%prison_mr_pm% -%prison_mines_remaining_bar_playermines% -%prison_mrb_pm% -%prison_mines_percent_playermines% -%prison_mp_pm% -%prison_mines_player_count_playermines% -%prison_mpc_pm% -%prison_mines_blocks_mined_playermines% -%prison_mbm_pm% -%prison_mines_reset_count_playermines% -%prison_mrc_pm% -``` - - -**STATSMINES placeholders (14, 7 aliases):** - -The STATSMINES placeholders represents the blocks that in the specified mine. The value `nnn` should be replaced with a number starting with a `1`, or `001` and refers to one block. The "_line_ placeholder is composed of the other placeholders and can simplify the use of these placeholders. See the headers and footer totals within the MINES placeholders. - -Use the mine name in place of ``, and may return zero or one value. Invalid values for `_nnn_` will return blanks. - -``` -%prison_top_mine_block_line_nnn_% -%prison_tmbl_nnn_% -%prison_top_mine_block_name_nnn_% -%prison_tmbn_nnn_% -%prison_top_mine_block_chance_nnn_% -%prison_tmbc_nnn_% -%prison_top_mine_block_placed_nnn_% -%prison_tmbpl_nnn_% -%prison_top_mine_block_remaing_nnn_% -%prison_tmbr_nnn_% -%prison_top_mine_block_remaing_bar_nnn_% -%prison_tmbrb_nnn_% -%prison_top_mine_block_total_nnn_% -%prison_tmbt_nnn_% -``` - - -**STATSRANKS placeholders (6, 3 aliases)** - -The STATSRANKS placeholders represents the top-n players for a given rank. The value `nnn` should be replaced with a number starting with a `1`, or `001` and refers to a given player. - -Use the mine name in place of ``, and may return zero or one value. Invalid values for `_nnn_` will return blanks. - -``` -%prison_top_rank_balance_name_nnn_% -%prison_trbn_nnn_% -%prison_top_rank_balance_score_nnn_% -%prison_trbs_nnn_% -%prison_top_rank_balance_balance_nnn_% -%prison_trbb_nnn_% -``` + > NO DOWNLOAD COMMAND + + Each placeholder has a shorter alias, which follows the primary placeholder below. + + Prison uses PlaceholderAPI to support any plugin placeholders within the GUI Ranks Lore and the GUI Mine Lore. + + + **Prison Placeholder Attributes:** + + Prison supports Placeholder Attributes which allows an infinite way to customize most placeholders, such as numeric formatting, hex colors, and reductions. Can customize any bar-graph for character codes, colors, and size. + + Simple examples using placeholder attributes with the results following each example. Colors are not shown. + + ``` + %prison_mines_size_mine5::nFormat:#,##0% + 654,321 + %prison_mines_size_mine5::nFormat:#,##0.00:1:kmg% + 654.32 k + %prison_mines_size_mine5::nFormat:'#af33ff'#,##0.00:1:binary:hex% + 638.99 KB + %prison_mines_timeleft_bar_mine5::bar:40:&2:O:&d:x:debug% + OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOxxxxxxxx + + ``` + + + **PLAYER placeholders (110, 55 aliases):** + + PLAYER placeholders are used directly with a player, such as with player chat prefixes and scoreboards. + + Rank related placeholders apply to all ranks that a player may have, and may return more than one value. Use the LADDER placeholders to control the order that is displayed. Rank based placeholder can return zero, one, or more rank related values depending upon how many ladders the player is on. + + ``` + %prison_rank% + %prison_r% + %prison_rank_number% + %prison_rn% + %prison_rank_tag% + %prison_rt% + %prison_rank_ladder_position% + %prison_rlp% + %prison_rankup_cost% + %prison_rc% + %prison_rankup_cost_formatted% + %prison_rcf% + %prison_rankup_cost_percent% + %prison_rcp% + %prison_rankup_cost_bar% + %prison_rcb% + %prison_rankup_cost_remaining% + %prison_rcr% + %prison_rankup_cost_remaining_formatted% + %prison_rcrf% + %prison_rankup_cost_remaining_percent% + %prison_rcrp + %prison_rankup_cost_remaining_bar% + %prison_rcrb% + %prison_rankup_rank% + %prison_rr% + %prison_rankup_rank_tag% + %prison_rrt% + %prison_player_balance% + %prison_pb% + %prison_player_balance_formatted% + %prison_pbf% + %prison_player_balance_earnings_per_minute% + %prison_pb_epm% + %prison_player_balance_earnings_per_minute_formatted% + %prison_pb_epmf% + %prison_player_token_balance% + %prison_ptb% + %prison_player_token_balance_formatted% + %prison_ptbf% + %prison_player_token_balance_formatted_metric% + %prison_ptbfm% + %prison_player_token_balance_formatted_kmbt% + %prison_ptbfk% + %prison_player_token_balance_earnings_per_minute% + %prison_ptb_epm% + %prison_player_token_balance_earnings_per_minute_formatted% + %prison_ptb_epmf% + %prison_player_sellall_multiplier% + %prison_psm% + %prison_player_blocks_total% + %prison_pbt% + %prison_player_blocks_total_formatted% + %prison_pbtf% + %prison_player_tool_id% + %prison_ptid% + %prison_player_tool_name% + %prison_ptn% + %prison_player_tool_type% + %prison_ptt% + %prison_player_tool_material_type% + %prison_ptmt% + %prison_player_tool_data% + %prison_ptdata% + %prison_player_tool_lore% + %prison_ptlore% + %prison_player_tool_durability_used% + %prison_ptdu% + %prison_player_tool_durability_max% + %prison_ptdm% + %prison_player_tool_durability_remaining% + %prison_ptdr% + %prison_player_tool_durability_percent% + %prison_ptdp% + %prison_player_tool_durability_bar% + %prison_ptdb% + %prison_player_tool_enchantment_fortune% + %prison_ptef% + %prison_player_tool_enchantment_efficency% + %prison_ptee% + %prison_player_tool_enchantment_silktouch% + %prison_ptes% + %prison_player_tool_enchantment_unbreaking% + %prison_pteu% + %prison_player_tool_enchantment_mending% + %prison_ptem% + %prison_player_tool_enchantment_luck% + %prison_ptel% + %prison_player_health% + %prison_ph% + %prison_player_health_max% + %prison_phm% + %prison_player_air_max% + %prison_pam% + %prison_player_air_remaining% + %prison_par% + %prison_player_food_level% + %prison_pfl% + %prison_player_food_saturation% + %prison_pfs% + %prison_player_food_exhaustion% + %prison_pfe% + %prison_player_xp% + %prison_pxp% + %prison_player_xp_to_level% + %prison_pxptl% + %prison_player_level% + %prison_pl% + %prison_player_walk_speed% + %prison_pws% + ``` + + + **LADDERS placeholders (32, 16 aliases):** + + Must be used directly with a player, and returns the information related to their active rank on the specified ladder. + + Use the ladder name, all lowercase, in place of ``, and it will return zero or one rank related values. + + ``` + %prison_rank_% + %prison_r_% + %prison_rank_number_% + %prison_rn_% + %prison_rank_tag_% + %prison_rt_% + %prison_rank_ladder_position_% + %prison_rlp_% + %prison_rankup_cost_% + %prison_rc_% + %prison_rankup_cost_formatted_% + %prison_rcf_% + %prison_rankup_cost_percent_% + %prison_rcp_% + %prison_rankup_cost_bar_% + %prison_rcb_% + %prison_rankup_cost_remaining_% + %prison_rcr_% + %prison_rankup_cost_remaining_formatted_% + %prison_rcrf_% + %prison_rankup_cost_remaining_percent_% + %prison_rcrp_% + %prison_rankup_cost_remaining_bar_% + %prison_rcrb_% + %prison_rankup_rank_% + %prison_rr_% + %prison_rankup_rank_tag_% + %prison_rrt_% + %prison_player_balance_% + %prison_pb_% + %prison_player_balance_formatted_% + %prison_pbf_% + ``` + + + **RANKS placeholders (22, 11 aliases):** + + RANKS placeholders deal directly with specific rank information. + + Use the rank name in place of ``, and may return zero or one value. + + ``` + %prison_rank__name_% + %prison_r_n_% + %prison_rank__tag_% + %prison_r_t_% + %prison_rank__ladder_% + %prison_r_l_% + %prison_rank__ladder_position_% + %prison_r_lp_% + %prison_rank__cost_% + %prison_r_c_% + %prison_rank__cost_formatted_% + %prison_r_cf_% + %prison_rank__cost_multiplier_% + %prison_r_cm_% + %prison_rank__currency_% + %prison_r_cu_% + %prison_rank__id_% + %prison_r_id_% + %prison_rank__player_count_% + %prison_r_pc_% + %prison_rank__linked_mines_% + %prison_r_lm_% + ``` + + + **RANKPLAYERS placeholders (12, 6 aliases):** + + RANKPLAYERS placeholders are used with players and shows what their adjusted costs are for the specified rank. These placeholders are ideal for showing a player how much each rank will cost using their personal rank cost multipliers. + + Use the rank name in place of ``, and may return zero or one value. + + ``` + %prison_rank__player_cost_% + %prison_r_pcst_% + %prison_rank__player_cost_formatted_% + %prison_r_pcf_% + %prison_rank__player_cost_remaining_% + %prison_r_pcf_% + %prison_rank__player_cost_remaining_formatted_% + %prison_r_pcf_% + %prison_rank__player_cost_percent_% + %prison_r_pcp_% + %prison_rank__player_cost_bar_% + %prison_r_pcb_% + ``` + + **MINES placeholders (34, 17 aliases):** + + MINES placeholder provides stats for the given mine. + + Use the mine name in place of ``, and may return zero or one value. + + ``` + %prison_mines_name_% + %prison_mn_% + %prison_mines_tag_% + %prison_mt_% + %prison_mines_interval_% + %prison_mi_% + %prison_mines_interval_formatted_% + %prison_mif_% + %prison_mines_timeleft_% + %prison_mtl_% + %prison_mines_timeleft_bar_% + %prison_mtlb_% + %prison_mines_timeleft_formatted_% + %prison_mtlf_% + %prison_mines_size_% + %prison_ms_% + %prison_mines_remaining_% + %prison_mr_% + %prison_mines_remaining_bar_% + %prison_mrb_% + %prison_mines_percent_% + %prison_mp_% + %prison_mines_player_count_% + %prison_mpc_% + %prison_mines_blocks_mined_% + %prison_mbm_% + %prison_mines_reset_count_% + %prison_mrc_% + %prison_player_blocks_total_% + %prison_pbtm + + %prison_top_mine_block_line_header_% + %prison_tmbl_header_% + %prison_top_mine_block_line_totals_% + %prison_tmbl_totals_% + ``` + + Note: The placeholders `%prison_top_mine_block_line_header_%` and `%prison_top_mine_block_line_totals_%` are used with the STATSMINES placeholders and provide the headers and total details for the given mines. + + + **MINEPLAYERS placeholders (28, 14 aliases):** + + MINEPLAYERS placeholders are tied to a player and dynamically shows the details of the mine the player is in, or blanks when not in a mine. These are ideal for use in scoreboards or chat prefixes. + + Must be used with a player. + + ``` + %prison_mines_name_playermines% + %prison_mn_pm% + %prison_mines_tag_playermines% + %prison_mt_pm% + %prison_mines_interval_playermines% + %prison_mi_pm% + %prison_mines_interval_formatted_playermines% + %prison_mif_pm% + %prison_mines_timeleft_playermines% + %prison_mtl_pm% + %prison_mines_timeleft_bar_playermines% + %prison_mtlb_pm% + %prison_mines_timeleft_formatted_playermines% + %prison_mtlf_pm% + %prison_mines_size_playermines% + %prison_ms_pm% + %prison_mines_remaining_playermines% + %prison_mr_pm% + %prison_mines_remaining_bar_playermines% + %prison_mrb_pm% + %prison_mines_percent_playermines% + %prison_mp_pm% + %prison_mines_player_count_playermines% + %prison_mpc_pm% + %prison_mines_blocks_mined_playermines% + %prison_mbm_pm% + %prison_mines_reset_count_playermines% + %prison_mrc_pm% + ``` + + + **STATSMINES placeholders (14, 7 aliases):** + + The STATSMINES placeholders represents the blocks that in the specified mine. The value `nnn` should be replaced with a number starting with a `1`, or `001` and refers to one block. The "_line_ placeholder is composed of the other placeholders and can simplify the use of these placeholders. See the headers and footer totals within the MINES placeholders. + + Use the mine name in place of ``, and may return zero or one value. Invalid values for `_nnn_` will return blanks. + + ``` + %prison_top_mine_block_line_nnn_% + %prison_tmbl_nnn_% + %prison_top_mine_block_name_nnn_% + %prison_tmbn_nnn_% + %prison_top_mine_block_chance_nnn_% + %prison_tmbc_nnn_% + %prison_top_mine_block_placed_nnn_% + %prison_tmbpl_nnn_% + %prison_top_mine_block_remaing_nnn_% + %prison_tmbr_nnn_% + %prison_top_mine_block_remaing_bar_nnn_% + %prison_tmbrb_nnn_% + %prison_top_mine_block_total_nnn_% + %prison_tmbt_nnn_% + ``` + + + **STATSRANKS placeholders (6, 3 aliases)** + + The STATSRANKS placeholders represents the top-n players for a given rank. The value `nnn` should be replaced with a number starting with a `1`, or `001` and refers to a given player. + + Use the mine name in place of ``, and may return zero or one value. Invalid values for `_nnn_` will return blanks. + + ``` + %prison_top_rank_balance_name_nnn_% + %prison_trbn_nnn_% + %prison_top_rank_balance_score_nnn_% + %prison_trbs_nnn_% + %prison_top_rank_balance_balance_nnn_% + %prison_trbb_nnn_% + ``` ---- From 766460709523af308268737e1f9e243a9bbd5da6 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 13:24:11 -0500 Subject: [PATCH 021/297] Disable all ranks related commands within the GUI menus. GUI was bypassing safeguards that were in place when the ranks module failed to load. --- docs/changelog_v3.3.x.md | 4 ++ .../mcprison/prison/spigot/SpigotPrison.java | 2 + .../commands/PrisonSpigotGUICommands.java | 39 ++++++++++++++++++- .../PrisonSpigotPrestigeCommands.java | 28 ++++++++++++- .../commands/PrisonSpigotRanksCommands.java | 15 +++++++ 5 files changed, 86 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 68663e372..e0fca9afb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-29 +* **Disable all ranks related commands within the GUI menus.** +GUI was bypassing safeguards that were in place when the ranks module failed to load. + + * **Update the placeholderAPI docs to correct the formatting of the docs to match what they should be.** Had to indent by two spaces. 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 0c024899f..633ff0ac0 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 @@ -747,7 +747,9 @@ private void initModulesAndCommands() { Prison.get().getCommandHandler().registerCommands( new PrisonSpigotBackpackCommands() ); } + // This registers the admin's /gui commands + // GUI commands were updated to prevent use of ranks commands when ranks module is not loaded. if (getConfig().getString("prison-gui-enabled").equalsIgnoreCase("true")) { Prison.get().getCommandHandler().registerCommands( new PrisonSpigotGUICommands() ); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUICommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUICommands.java index 78e0529d6..77d6d5512 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUICommands.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUICommands.java @@ -1,10 +1,14 @@ package tech.mcprison.prison.spigot.commands; +import java.util.Optional; + import org.bukkit.entity.Player; +import tech.mcprison.prison.Prison; import tech.mcprison.prison.commands.Arg; import tech.mcprison.prison.commands.Command; import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.modules.Module; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.data.RankLadder; @@ -89,6 +93,13 @@ protected void cmdPrisonManagerPrestiges( CommandSender sender, int page, String return; } } + + Optional ranksModule = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); + if ( !ranksModule.isPresent() || ranksModule.isPresent() && !ranksModule.get().isEnabled() ) { + + Output.get().sendWarn( sender, "The command '/gui prestiges' is disabled because the Ranks module is not active." ); + return; + } Player player = getSpigotPlayer( sender ); @@ -220,6 +231,13 @@ protected void cmdPrisonManagerRanks(CommandSender sender, int page, String cmdP } } + Optional ranksModule = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); + if ( !ranksModule.isPresent() || ranksModule.isPresent() && !ranksModule.get().isEnabled() ) { + + Output.get().sendWarn( sender, "The command '/gui ranks' is disabled because the Ranks module is not active." ); + return; + } + SpigotPlayerRanksGUI gui = new SpigotPlayerRanksGUI( player, "default", page, cmdPage, cmdReturn ); gui.open(); } @@ -253,6 +271,14 @@ protected void cmdPrisonManagerAdminRanks(CommandSender sender, String ladder, } + Optional ranksModule = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); + if ( !ranksModule.isPresent() || ranksModule.isPresent() && !ranksModule.get().isEnabled() ) { + + Output.get().sendWarn( sender, "The command '/gui admin ranks' is disabled because the Ranks module is not active." ); + return; + } + + // ladder RankLadder rLadder = PrisonRanks.getInstance().getLadderManager().getLadder( ladder ); if ( rLadder == null ) { @@ -322,6 +348,14 @@ protected void cmdPrisonManagerLadders(CommandSender sender, int page, String cm } } + Optional ranksModule = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); + if ( !ranksModule.isPresent() || ranksModule.isPresent() && !ranksModule.get().isEnabled() ) { + + Output.get().sendWarn( sender, "The command '/gui ladders' is disabled because the Ranks module is not active." ); + return; + } + + SpigotLaddersGUI gui = new SpigotLaddersGUI( player, page, cmdPage, cmdReturn ); gui.open(); } @@ -335,11 +369,14 @@ protected void cmdPrisonManagerLadders(CommandSender sender, int page, String cm // Backpack GUI commands got moved to the Backpacks class so they won't be loaded if backpacks are disabled. - @Command(identifier = "gui reload", description = "Reload GUIs", permissions = "prison.admin",onlyPlayers = false) + @Command(identifier = "gui reload", description = "Reload GUIs and sellall", + permissions = "prison.admin",onlyPlayers = false, + aliases = {"prison reload gui", "prison reload sellall"}) public void reloadGUICommand(CommandSender sender){ SpigotGUIComponents.updateMessages(); SpigotGUIComponents.updateSellAllConfig(); SpigotGUIComponents.updateGUIConfig(); Output.get().sendInfo(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_gui_reload_success))); } + } 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 3e6048ffe..8d14087bf 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 @@ -1,7 +1,8 @@ package tech.mcprison.prison.spigot.commands; +import java.util.Optional; + import org.bukkit.Bukkit; -import org.bukkit.configuration.Configuration; import org.bukkit.entity.Player; import tech.mcprison.prison.Prison; @@ -33,6 +34,13 @@ public void prestigesGUICommand(CommandSender sender) { Output.get().sendInfo(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_prestiges_disabled))); return; } + + Optional ranksModule = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); + if ( !ranksModule.isPresent() || ranksModule.isPresent() && !ranksModule.get().isEnabled() ) { + + Output.get().sendWarn( sender, "The command '/prestiges' is disabled because the Ranks module is not active." ); + return; + } if ( isConfig( "Options.Prestiges.GUI_Enabled") ) { sender.dispatchCommand( "gui prestiges"); @@ -45,6 +53,16 @@ public void prestigesGUICommand(CommandSender sender) { public void prestigesPrestigeCommand(CommandSender sender) { if ( isPrisonConfig( "prestiges" ) || isPrisonConfig( "prestige.enabled" ) ) { + + + Optional ranksModule = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); + if ( !ranksModule.isPresent() || ranksModule.isPresent() && !ranksModule.get().isEnabled() ) { + + Output.get().sendWarn( sender, "The command '/prestige' is disabled because the Ranks module is not active." ); + return; + } + + prisonManagerPrestige(sender); } } @@ -55,6 +73,14 @@ public void prisonManagerPrestige(CommandSender sender ) { if ( isPrisonConfig( "prestige.enabled" ) ) { + + Optional ranksModule = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); + if ( !ranksModule.isPresent() || ranksModule.isPresent() && !ranksModule.get().isEnabled() ) { + + Output.get().sendWarn( sender, "The command '/gui prestiges' is disabled because the Ranks module is not active." ); + return; + } + if ( PrisonRanks.getInstance().getLadderManager().getLadder("prestiges") == null ) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ranks ladder create prestiges"); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotRanksCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotRanksCommands.java index 81d668dc4..9514be5c8 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotRanksCommands.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotRanksCommands.java @@ -1,9 +1,14 @@ package tech.mcprison.prison.spigot.commands; +import java.util.Optional; + import tech.mcprison.prison.Prison; import tech.mcprison.prison.commands.Arg; import tech.mcprison.prison.commands.Command; import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.modules.Module; +import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.ranks.PrisonRanks; /** * @author RoyalBlueRanger @@ -23,6 +28,16 @@ public void ranksGUICommand(CommandSender sender, "be shown on multiple pages. The page parameter starts with " + "page 1.", def = "1" ) int page ) { + + // NOTE: This command will NOT be registered if ranks module fails to load, so this is just a fallback + // safety measure: + Optional ranksModule = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); + if ( !ranksModule.isPresent() || ranksModule.isPresent() && !ranksModule.get().isEnabled() ) { + + Output.get().sendWarn( sender, "The command '/ranks' is disabled because the Ranks module is not active." ); + return; + } + if (!sender.hasPermission("ranks.admin")) { try { From b4dc64df7e0aea775a1fa97257ffd2faae0e0744 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 14:04:06 -0500 Subject: [PATCH 022/297] Added nano-second timing autosell to confirm if there is a performance issue. My initial testings are showing that sellall has significant chance of performance problems in that selling items takes way too long. Will address in the future. --- docs/changelog_v3.3.x.md | 4 ++++ .../autofeatures/AutoManagerFeatures.java | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e0fca9afb..0bf8a6d18 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-29 +* **Added nano-second timing autosell to confirm if there is a performance issue.** +My initial testings are showing that sellall has significant chance of performance problems in that selling items takes way too long. Will address in the future. + + * **Disable all ranks related commands within the GUI menus.** GUI was bypassing safeguards that were in place when the ranks module failed to load. 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 4470d37b0..0e13bf2b7 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 @@ -1,5 +1,6 @@ package tech.mcprison.prison.spigot.autofeatures; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -494,6 +495,8 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, double autosellTotal = 0; double autosellUnsellableCount = 0; + long nanoTime = 0L; + for ( SpigotItemStack itemStack : drops ) { count += itemStack.getAmount(); @@ -503,7 +506,11 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, if ( SellAllUtil.get() != null && (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || pmEvent.isForceAutoSell()) ) { + final long nanoStart = System.nanoTime(); double amount = SellAllUtil.get().sellAllSell( player, itemStack, false, false, true ); + final long nanoStop = System.nanoTime(); + nanoTime += nanoStop - nanoStart; + autosellTotal += amount; PlayerCache.getInstance().addPlayerEarnings( pmEvent.getSpigotPlayer(), @@ -571,10 +578,20 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, if ( count > 0 || autosellTotal > 0 ) { debugInfo.append( "[autoPickupDrops total: qty: " + count + " value: " + autosellTotal + - " unsellableCount: " + autosellUnsellableCount + " ] "); + " unsellableCount: " + autosellUnsellableCount ); + + if ( nanoTime > 0 ) { + DecimalFormat fFmt = new DecimalFormat("#,##0.0000"); + final double autoSellTimeMs = ( nanoTime / 1000000.0d ); + debugInfo.append( " autosellTiming: " ) + .append( fFmt.format( autoSellTimeMs ) ) + .append( " ms" ); + } + debugInfo.append( " ] " ); } + // if ( !isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) && // !pmEvent.isForceAutoSell() ) { // From b6e70e3bcfc059ee9c120bc7b94c20a9eb31b823 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 14:12:04 -0500 Subject: [PATCH 023/297] Release v3.3.0-beta.1 !! Hooray!! --- docs/changelog_v3.3.x.md | 3 ++ docs/knownissues_v3.3.x.md | 63 ++++++++++++++++++++++++++++++++++++++ gradle.properties | 5 ++- 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0bf8a6d18..9a701ef40 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-29 +* **Release v3.3.0-beta.1 !! Hooray!!** 2022-01-29 2:11 PM EST + + * **Added nano-second timing autosell to confirm if there is a performance issue.** My initial testings are showing that sellall has significant chance of performance problems in that selling items takes way too long. Will address in the future. diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index 082006343..caa270413 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -3,6 +3,69 @@ # Prison Known Issues and To Do's for v3.3.x + + +# TODO Items for v3.3.0-alpha.7 + + +- update CMI delayed loading docs... they are "backwards" + + +- Upon startup the first time, broadcast to everyone that they should use /ranks autoConfigure. + + +- SELLALL has huge performance issues! It takes 2.3 ms to autosell, and full auto features block handling is 4.2 ms!! Serious performance issue with sellall, and autosell is bypassing the command handler too! + - added 'autosellTiming:' stats to auto features autosell to track actual sell time using nano-seconds... initial tests show there maybe significant performance issues. + - autosell in auto features causing lag? Flaco21 + - Issue with autosell causing lag? + + +- DONE: admin gui - allows them to bypass No Economy safeguards. + + + +* DONE: Add commands to list shop prices in console. Currently sellall is 100% gui so cannot be used offline. + + +* Problems with blocks: + - Sand or any other block that falls is no longer in original location so cannot break it. + - Might have to tag the blocks with NMS? + - Just fixed an issue with a block that was in a mine with gravel, sand, and dirt. MIght have been sand causing the error. NOTE: prevent error, not fixed the actual problem. + - DONE: lapis lazuli is not auto selling + + +- Problem with actionBar - messages are not goign through. + - sellall updates every second - different messages - but never show first one - PlayerMessages + + + + - DONE: No economy error mssage not showing + - works on delayed startup + - Fails when not delayed - gui ranks was registering on top of ranks warning + + + - block stats based upon drops instead of breakage?? + + +-> DONE: Hook in to quests + + +-> Suport for eco enchants: + - Need to add an event listener and then have a new function in EnchantmentUtils handle the event, with passing continuing to call the normal rehandleBreaking. Maybe name it rehandleBreakingEvent? +https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java +https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java + + +- DONE: You cannot afford the rankup is using a NBSP for the thousand separator. Using Prison v3.2.11, Java 16, and spigot 1.16.5. Cannot reproduce. Was a server hosting config issue, but not sure why it only impacted that one message. + + +* calculate mine worth? + + +* ShiftAndRightClickSellAll is not working + + + # TODO Items for v3.2.11-alpha.13 diff --git a/gradle.properties b/gradle.properties index 63996a0da..3c47c730c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,8 @@ ## # 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.7 -#version=3.2.8.2 -#version=3.3.0-alpha.6 +version=3.3.0-beta.1 +#version=3.3.0-alpha.7 From a44e73d304fb5767f541e42df48438c983d39166 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 15:44:02 -0500 Subject: [PATCH 024/297] Broadcast the failed ranks loading to all online players. Its important that they know ranks failed to load. --- docs/changelog_v3.3.x.md | 6 ++++++ .../ranks/commands/FailedRankCommands.java | 20 ++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9a701ef40..4bffabdc5 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,12 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-29 + + +* **Broadcast the failed ranks loading to all online players.** +Its important that they know ranks failed to load. + + * **Release v3.3.0-beta.1 !! Hooray!!** 2022-01-29 2:11 PM EST diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/FailedRankCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/FailedRankCommands.java index d03775907..5c03dbe8b 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/FailedRankCommands.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/FailedRankCommands.java @@ -1,8 +1,12 @@ package tech.mcprison.prison.ranks.commands; +import java.util.List; + +import tech.mcprison.prison.Prison; import tech.mcprison.prison.commands.BaseCommands; import tech.mcprison.prison.commands.Command; import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.output.ChatDisplay; public class FailedRankCommands @@ -45,12 +49,18 @@ public void failedRanks( CommandSender sender ) { display.sendtoOutputLogInfo(); + // Broadcast to all online players: - if ( sender.isPlayer() ) { - display.send( sender ); - } - - + List onlinePlayers = Prison.get().getPlatform().getOnlinePlayers(); + + for ( Player player : onlinePlayers ) { + + display.send( player ); + } + +// if ( sender.isPlayer() ) { +// display.send( sender ); +// } } From 50c18e88267ab5ec9225ee7e011656c67531ba00 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 16:02:53 -0500 Subject: [PATCH 025/297] Broadcast the prison welcome message to all online players when prison is loaded with no mines or ranks defined. The messag is loggd to console 8 sconds after prison loads. The broadcast messags are sent 16 seconds after logging the welcome message. The intention is to help bring awareness to new mods/admins that there is an easy way to get started with prison. --- docs/changelog_v3.3.x.md | 3 ++ .../tasks/PrisonInitialStartupTask.java | 34 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 4bffabdc5..ba1220a9e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-29 +* **Broadcast the prison welcome message to all online players when prison is loaded with no mines or ranks defined.** +The messag is loggd to console 8 sconds after prison loads. The broadcast messags are sent 16 seconds after logging the welcome message. +The intention is to help bring awareness to new mods/admins that there is an easy way to get started with prison. * **Broadcast the failed ranks loading to all online players.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/PrisonInitialStartupTask.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/PrisonInitialStartupTask.java index 947ff0c9e..a817a6335 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/PrisonInitialStartupTask.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/PrisonInitialStartupTask.java @@ -1,5 +1,9 @@ package tech.mcprison.prison.spigot.tasks; +import java.util.List; + +import tech.mcprison.prison.Prison; +import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.api.PrisonSpigotAPI; @@ -8,9 +12,10 @@ public class PrisonInitialStartupTask implements PrisonRunnable { - public static final long INITIAL_SUBMISSION_DELALY = 20 * 5; // 5 seconds + public static final long INITIAL_SUBMISSION_DELALY = 20 * 8; // 8 seconds private SpigotPrison prison; + private boolean firstPass = true; public PrisonInitialStartupTask( SpigotPrison prison ) { super(); @@ -32,6 +37,11 @@ public void submit() { prison.getScheduler().runTaskLater( this, INITIAL_SUBMISSION_DELALY ); } + private void resubmit() { + + prison.getScheduler().runTaskLater( this, INITIAL_SUBMISSION_DELALY * 2 ); + } + @Override public void run() { @@ -65,8 +75,26 @@ public void run() { display.addText(""); display.addText(""); - - display.sendtoOutputLogInfo(); + if ( firstPass ) { + + display.sendtoOutputLogInfo(); + + firstPass = false; + + resubmit(); + } + else { + + display.addText("Please see the prison startup messages within the console."); + + List onlinePlayers = Prison.get().getPlatform().getOnlinePlayers(); + + for ( Player player : onlinePlayers ) { + + display.send( player ); + } + } + } From 6821adf895a517a3a8a73d4f8397a0a5cfcf22da Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 18:07:17 -0500 Subject: [PATCH 026/297] Update some documentation related to CMI Economy. --- docs/changelog_v3.3.x.md | 3 + docs/prison_docs_000_toc.md | 4 + docs/prison_docs_016_setting_up_Vault.md | 17 ++- .../prison_docs_028_setting_up_CMI_economy.md | 102 ++++++++++++++++++ docs/prison_docs_810_faq_other_plugins.md | 64 +---------- 5 files changed, 126 insertions(+), 64 deletions(-) create mode 100644 docs/prison_docs_028_setting_up_CMI_economy.md diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ba1220a9e..89bfb02ca 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-29 +* **Update some documentation related to CMI Economy.** + + * **Broadcast the prison welcome message to all online players when prison is loaded with no mines or ranks defined.** The messag is loggd to console 8 sconds after prison loads. The broadcast messags are sent 16 seconds after logging the welcome message. The intention is to help bring awareness to new mods/admins that there is an easy way to get started with prison. diff --git a/docs/prison_docs_000_toc.md b/docs/prison_docs_000_toc.md index 82607d3f1..8a43fe31b 100644 --- a/docs/prison_docs_000_toc.md +++ b/docs/prison_docs_000_toc.md @@ -268,6 +268,10 @@ Auto configure can get you up and running with as little as two commands. The f Installing the plugins +* [Setting up CMI Economy](prison_docs_028_setting_up_CMI_economy.md) + Enabling Prison's Delayed Startup so CMI Economy will work. If CMI Economy fails to start before Prison starts, then the Prison Ranks will fail to load. + + * [Prison's PlaceholderAPI wiki page content](prison_placeholderapi_wiki_docs.md) This document contains the Prison's content that is published on PlaceholderAPI's wiki. diff --git a/docs/prison_docs_016_setting_up_Vault.md b/docs/prison_docs_016_setting_up_Vault.md index 1fb8d8a65..ff4f1cc1f 100644 --- a/docs/prison_docs_016_setting_up_Vault.md +++ b/docs/prison_docs_016_setting_up_Vault.md @@ -8,14 +8,27 @@ This document provides a quick overview on how to install Vault. Vault may be optional, but it is a very important plugin. It provides easy integration with economies and permissions. This is useful because its a standard way for prison to hook in and use any plugin that supports Vault. +Prison uses Vault to connect to Economies and Permissions. + + +*Documented updated: 2022-01-29* + +
+ +# Note about CMI Economy and Vault + +CMI Economy has special requirements and needs special configuration settings to enable Prison to work properly. + +Please see the following documentation on how to configure Vault, CMI Economy, and Prison: +[Setting up CMI Economy](prison_docs_028_setting_up_CMI_economy.md)
# Optional Dependencies -There aren't any required dependencies to using Vault, but Vault will be useless if there were no other plugins to hook in to it. +Vault doesn't have any "required" dependencies, but Vault will be useless if there were no other plugins to hook in to it. -The two most useful plugins to use would be EssentialsX and LuckPerms. EssentialsX is useful for its economy, and LP for the permissions. +Two kinds of plugins to use with Vault are economy and permission plugins. If you don't have your own preference for these, then it is strongly suggested that EssentialsX and LuckPerms are used.
diff --git a/docs/prison_docs_028_setting_up_CMI_economy.md b/docs/prison_docs_028_setting_up_CMI_economy.md new file mode 100644 index 000000000..b189f859f --- /dev/null +++ b/docs/prison_docs_028_setting_up_CMI_economy.md @@ -0,0 +1,102 @@ + +### Prison Documentation +[Prison Documents - Table of Contents](prison_docs_000_toc.md) + + +## Setting up CMI Economy + +CMI Economy, CMIE, is a feature rich economy plugin, but it requires special configuration settings within Prison to get it to work perfectly. + +*Documented updated: 2022-01-29* + +
+ + +# The Challenge of CMI Economy + +CMI "tries" to load last, thus it can ensure all of it's dependencies and hooks are in place before it starts up. That's understandable, and Prison also has similar requirements and expectations. Unfortunately, this also causes a conflict with Prison, since Prison must perform validation on startup, and if there is no economy, then Prison could fail to start. + +To get CMIE to work correctly with prison, there are a couple of things that you must do. + + +
+ + +# Using the 'Correct' version of Vault + +You cannot just use the vanilla version of Vault, since CMI must hook in to Vault. Most plugins are added to the public release of Vault, but CMI has chosen not to add a public interface directly to Vault. + + +Therefore, you must use a customized version of Vault that will work with CMI Economy. + + +CMI offers a prebuilt version of Vault that includes their hooks, but in all the past attempts to use it, it has never worked, so we do not recommend using that version. + + +It is recommended to use their Vault Injector with the normal version of Vault, since that has always worked well. + + +Download the normal version of [Vault from SpigotMC.org](https://www.spigotmc.org/resources/34315/). + + +To download the CMI Economy Vault Injector, visit [CMI's page on SpigotMC.org](https://www.spigotmc.org/resources/3742/), then look under Economy's second option for the injector. + + +Then update the CMI config settings to enable the CMI Economy. + + +
+ + +# Enabling Prison's Delayed Startup for CMI Economy + +The CMI Economy **has** to be fully loaded and active *before* prison loads the Ranks. Otherwise, prison will refuse to load the ranks and prison will not work. + + +CMI Economy delays it's startup, which causes problems for prison. Because of this delay, Prison is unable to validate the Ranks and fails. The solution, is that Prison has to wait until CMI Economy has fully loaded before it can use it. + + +Prison is able to delay it's startup, to wait for CMI Economy to become active. + + +To enable this, you need to make a configuration change within Prison's `plugins/Prison/config.yml` file. Near the bottom of that config, are a few settings that need to be enabled. The following is an example of what is needed, along with a configuration that will work in most situations. + +``` +delayedPrisonStartup: + enabled: true + cooldown-secs: 5 + max-attempts: 6 + inspect-vault: true + triggers: + vault: true + vault-economy-name: Economy_Essentials +``` + +
+ + +# Additional Changes maybe Needed + +If Prison is not able to startup with the settings above then there are a few things that need to be checked, and maybe changed. + + +Confirm that it's able to successfully inspect the vault economy. If it is not able to find what is set for the `delayedPrisonStartup.triggers.vault-economy-name`, then it needs to be updated. + + +This value may change, if it does, Prison will display what this value is within it's first startup message that notifies that it's going in to a delayed startup mode. If the name shown does not match "Economy_Essentials", then use that new name in these config settings. + + +If it's able to properly lock on the Vault economy, but CMIE is loading after Prison stops waiting, then you can increase either the `delayedPrisonStartup.cooldown-secs` or the `delayedPrisonStartup.max-attempts`. Increasing either, or both, could help. It's probably better to increase the max-attempts. + + +
+ + +# Getting Additional Help + +If Prison's startup delay has been enabled, and you tried to make adjustments to the **delayedPrisonStartup** settings, then please contact Blue on Prison's discord server since there could be another conflict going on. Blue can review your server's startup log to identify the problem and help you fix it. + + + + +
diff --git a/docs/prison_docs_810_faq_other_plugins.md b/docs/prison_docs_810_faq_other_plugins.md index dc2a5c6cb..a5739d903 100644 --- a/docs/prison_docs_810_faq_other_plugins.md +++ b/docs/prison_docs_810_faq_other_plugins.md @@ -9,73 +9,13 @@ This document covers some common issues that pertain to other plugins, but may n
-# CMI - Used for the Economy within Prison -**Symptoms of Issues** +# No FAQs right now -Symptoms of issues with CMI is when it appears like Vault is using CMI has successfully loaded, but yet the Ranks module fails to load. +Please note, the FAQs that were in this document were for versions of prison that were a few years old and do not apply to the current Prison releases. Therefore the FAQs have been removed to reduce confusion and problems. -**Overview of CMI** -CMI Is a premium plugin and costs about 15.00 Euros. It is a very extensive plugin that covers many aspects of what you could possibly do with a server. The developers claim it is a worthy replacement for EssentialsX. The primary aspects CMI with what Prison needs to use is their economy and permissions. -[CMI on spigotmc.org](https://www.spigotmc.org/resources/cmi-270-commands-insane-kits-portals-essentials-economy-mysql-sqlite-much-more.3742) - - -**How to Resolve the Issues** - -In order to use CMI with prison, it is required that you use Vault. Prison does not have any direct integrations to CMI. Since it is a premium plugin, the CMI integration for Vault is not publicly available in the original Vault plugin. Instead CMI offers their own modified version of Vault that has been recompiled with their hooks added, or an injector that will add it to the original Vault plugin. - - -On their spigotmc.org resource page, they identify there are two way to enable a working version of Vault: -1. Install and use their modified version of Vault (recommended) -2. Or use the CMIEInjector to modify an original Vault (not recommended) - - -**Common Problems** - -1. Make sure you are using the CMI modified version of Vault -2. The CMIEInjector has problems, or will cause problems. So don't use it. -3. Do not use both the CMI modified version of Vault and the CMIEInjector. They were never intended to be used together and they will cause problems with prison. - - -
- - -# Prison Won't Load - No Modules Loaded - LuckPerms is the Cause - -**Symptoms of Issues** - -Symptoms of issues is that Prison fails to start up and load properly. The biggest symptom is that there are no active modules and most of the prison commands fail to work. - - -**Cause** - -This is caused by LuckPerms. More specifically, trying to use LuckPerms v5.0.x with Prison v3.2.0 or older. LuckPerms v5.0.x is not supported with older version of Prison. - - -**How to Resolve the Issues** - -There are two major ways to resolve this issue. - -1. Down grade to LuckPerms v4.4.1 for use with Prison v3.2.0 and older. - -2. Upgrade Prison to v3.2.1 (or the pre-release version of v3.2.1) or newer. Prison v3.2.1 supports both the newer LuckPerms v5.0.x and the older LuckPerms v4.4.1 and older. - -**Suggested action:** Upgrade Prison to v3.2.1 or newer and use the latest version of LuckPerms. - - -**Background** - -Basically the fault of this issues lies with LuckPerms in using the same registered -plugin name with the bukkit/Spigot Plugin Manager for v5.0.x. By using the same registered -plugin name and the same class name, but an altogether different package name, that broke -the standard way of using the plugin manager to get an instance of the plugin. This would -have caused any plugin to generate a Class Not Found exception. - -They shouldn't have used the same signatures for v5.0.x as they did with v4.x. -If they would have chosen a new signature, such as LuckPerms5, then there would have been no issues since the plugin manager would not falsely report that the old version of LuckPerms -is available and will not try to cast the new packages in to the old variables.
From 72281b331f681c34164f92327d22f5c9cbe462bd Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 18:29:06 -0500 Subject: [PATCH 027/297] More doc updates related to CMIE. --- docs/prison_docs_000_toc.md | 2 +- ...rison_docs_012_setting_up_prison_basics.md | 24 ++++--------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/docs/prison_docs_000_toc.md b/docs/prison_docs_000_toc.md index 8a43fe31b..05649f0f3 100644 --- a/docs/prison_docs_000_toc.md +++ b/docs/prison_docs_000_toc.md @@ -388,7 +388,7 @@ This section of guides will focus on FAQs; short helps for common problems. * [FAQ - Other Plugins](prison_docs_810_faq_other_plugins.md) - CMI Plugin. Prison fails to load. No modules. + *No FAQs are available at this time* * [FAQ - Miscellaneous Questions](prison_docs_880_faq_misc_01.md) diff --git a/docs/prison_docs_012_setting_up_prison_basics.md b/docs/prison_docs_012_setting_up_prison_basics.md index 1dcf09962..b0fa49a4d 100644 --- a/docs/prison_docs_012_setting_up_prison_basics.md +++ b/docs/prison_docs_012_setting_up_prison_basics.md @@ -76,28 +76,14 @@ Prison requires an active economy in order to active the Ranks plugin. When Pri * **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. -* **CMI Economy** - Optional - Formerly we could not recommend its use, but Prison now has a couple of advanced tools that is able to allow CMI to fully load before Prison needs to use CMI's functions. Therefore if you want to use many of CMI's features, you now can! +* **CMI Economy** - Optional - If using CMIE then you must enable Prison's delayed startup - CMI "tries" to load last, thus it can ensure all of it's dependencies and hooks are in place before it starts up. That's understandable, and Prison also has similar requirements and expectations. Unfortunately, this also causes a conflict with Prison, since Prison must perform validation on startup, and if there is no economy, then Prison could fail to start. - - To get CMIE to work correctly with prison, there are a couple of things that you must do. - - 1) You must use the normal version of Vault and then use the CMI Vault Injector. We've never seen the CMI provided version of Vault work with prison, so therefore recommend not using it. Symptom is that prison reports a 0.00 amount for the online player when using `/ranks player `. The Vault inject has always worked well. - 2) The CMI Economy **has** to be fully loaded and active *before* prison loads the Ranks. Otherwise prison will refuse to load the ranks and prison will not work. You must make a configuration change within Prison's `plugins/Prison/config.yml` file. Near the bottom of that config, are a few settings that need to be enabled. The following is an example of what is needed, along with a configuration that will work in most situations. + See: [Setting up CMI Economy](prison_docs_028_setting_up_CMI_economy.md) for full information on how to get CMIE working with Prison. + + Background: CMI "tries" to load last, so it can ensure all of it's dependencies and hooks are in place before it starts up. That's understandable, but Prison also has similar requirements and expectations. Unfortunately, this also causes a conflict with Prison, since Prison must perform validation on startup, and if there is no economy, then Prison could fail to start the Ranks module. -``` -delayedPrisonStartup: - enabled: true - cooldown-secs: 5 - max-attempts: 6 - inspect-vault: true - triggers: - vault: true - vault-economy-name: Economy_Essentials -``` + The document, [Setting up CMI Economy](prison_docs_028_setting_up_CMI_economy.md), explains in detail how to get everything working perfectly. - If enabled, and you are still having problems, please contact Blue on Prison's discord server. To get CMIE to work may be as simple as increasing the `cooldown-secs` or the `max-attempts` settings, but there could be another conflict going on. Blue can review your server's startup log to identify the problem and help you fix it. - ### Chat Prefix Plugins - Optional From 2d486b09696ade6e231306e815dae5a36e84e323 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 29 Jan 2022 20:08:17 -0500 Subject: [PATCH 028/297] More doc updates for CMIE. --- .../prison_docs_028_setting_up_CMI_economy.md | 53 +++++++++++++++---- prison-spigot/src/main/resources/config.yml | 3 +- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/docs/prison_docs_028_setting_up_CMI_economy.md b/docs/prison_docs_028_setting_up_CMI_economy.md index b189f859f..adf108ca1 100644 --- a/docs/prison_docs_028_setting_up_CMI_economy.md +++ b/docs/prison_docs_028_setting_up_CMI_economy.md @@ -24,19 +24,17 @@ To get CMIE to work correctly with prison, there are a couple of things that you # Using the 'Correct' version of Vault -You cannot just use the vanilla version of Vault, since CMI must hook in to Vault. Most plugins are added to the public release of Vault, but CMI has chosen not to add a public interface directly to Vault. +You need to use and install the normal version of Vault on your server, which is available here: [Vault from SpigotMC.org](https://www.spigotmc.org/resources/34315/). -Therefore, you must use a customized version of Vault that will work with CMI Economy. +CMIE needs to customize Vault to add hooks so the two can communicate with eachother. This is accomplished by using CMIE's Vault Injector. Upon starting the server, the CMIE injector will dynamically add it's hooks to Vault. -CMI offers a prebuilt version of Vault that includes their hooks, but in all the past attempts to use it, it has never worked, so we do not recommend using that version. +Beware though, CMI offers a prebuilt version of Vault that contains the CMIE's hooks. The prebuild version of Vault should never be used due to past attempts to it has always resulted in failure. -It is recommended to use their Vault Injector with the normal version of Vault, since that has always worked well. - -Download the normal version of [Vault from SpigotMC.org](https://www.spigotmc.org/resources/34315/). +Therefore, it is recommended to only use the CMIE Vault injector with the normal version of Vault, which has worked every time. To download the CMI Economy Vault Injector, visit [CMI's page on SpigotMC.org](https://www.spigotmc.org/resources/3742/), then look under Economy's second option for the injector. @@ -65,13 +63,21 @@ To enable this, you need to make a configuration change within Prison's `plugins delayedPrisonStartup: enabled: true cooldown-secs: 5 - max-attempts: 6 + max-attempts: 12 inspect-vault: true triggers: vault: true - vault-economy-name: Economy_Essentials + vault-economy-name: Economy_CMI ``` +Please note that different values for the **vault-economy-name** may be required for different versions of the plugins. Some possible valus may include: + + * **Economy_CMI** + * **Economy_Essentials** (EssentialsX: <= v2.18.x) + * **VaultEconomyProvider** (EssentialsX: >= v2.19.x) + + +
@@ -79,14 +85,39 @@ delayedPrisonStartup: If Prison is not able to startup with the settings above then there are a few things that need to be checked, and maybe changed. +**Setting the value for: vault-economy-name** + +Confirm that Prison is able to successfully inspect the current Vault economy. If it is not able to find what is set for the `delayedPrisonStartup.triggers.vault-economy-name`, then it needs to be updated. + + +This value may change with other economy plugins, and with future economy plugin updates. + + +If this setting needs to be changed, then Prison will try to display what value to use. Ensure the config setting `delayedPrisonStartup.inspect-vault: true` is set to true. This setting will allow the following message to be shown in the console. A value of **Failed** generally indicats that no economy plugin was found. + +``` +Inspect Vault Economy: enabled +Use 'VaultEconomyProvider' with 'delayedPrisonStartup.triggers-vault-economy-name' +NOTICE: Prison Delayed Enablement: Prison startup has been delayed. Waiting for a Vault Economy to be enabled. Attempts: 0 of 12. Submitting task... +``` + +``` + Prison Delayed Enablement: Failed to find an active Vault Economy Named + 'Economy_CMI' after 13 attempts. Cannot start Prison. +``` + +The above value `VaultEconomyProvider` indictes that Vault is trying to use EssentialsX economy instead of CMIE. This is an example of EssentialsX hooking in to Vault before CMIE. If this is the situation you're seeing, thn disable EssentialX's economy within their config file to allow CMIE to load. + + +NOT the correct value to use for CMIE is: **Economy_CMI** -Confirm that it's able to successfully inspect the vault economy. If it is not able to find what is set for the `delayedPrisonStartup.triggers.vault-economy-name`, then it needs to be updated. +If Vault is loading the correct economy, but Prison's config setting is incorrect, then you can find the correct value in the first message whre it says "Use.." then that value provided. Update the config.yml file with the displayed value. -This value may change, if it does, Prison will display what this value is within it's first startup message that notifies that it's going in to a delayed startup mode. If the name shown does not match "Economy_Essentials", then use that new name in these config settings. +**Setting the cooldown seconds and max attempts:** -If it's able to properly lock on the Vault economy, but CMIE is loading after Prison stops waiting, then you can increase either the `delayedPrisonStartup.cooldown-secs` or the `delayedPrisonStartup.max-attempts`. Increasing either, or both, could help. It's probably better to increase the max-attempts. +If Prison is able to properly lock on the Vault economy, but CMIE is loading after Prison stops waiting, then you can increase either the `delayedPrisonStartup.cooldown-secs` or the `delayedPrisonStartup.max-attempts`. Increasing either, or both, could help. It's probably better to increase the max-attempts.
diff --git a/prison-spigot/src/main/resources/config.yml b/prison-spigot/src/main/resources/config.yml index af8d80da3..98363d4df 100644 --- a/prison-spigot/src/main/resources/config.yml +++ b/prison-spigot/src/main/resources/config.yml @@ -211,12 +211,13 @@ prison-mines: delayedPrisonStartup: enabled: false cooldown-secs: 5 - max-attempts: 6 + max-attempts: 12 inspect-vault: true triggers: vault: true vault-economy-name: Economy_CMI +# CMI Economy: vault-economy-name: Economy_CMI # EssentialsX: <= v2.18.x vault-economy-name: Economy_Essentials # EssentialsX: >= v2.19.x vault-economy-name: VaultEconomyProvider From 61d79172da9e33d306fb6adadb07dbd959745c50 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 30 Jan 2022 15:16:07 -0500 Subject: [PATCH 029/297] Ladder rank cost multiplier has 100 percent limits removed. Value can be any positive or negative number now. --- docs/changelog_v3.3.x.md | 6 +++++- .../prison/ranks/commands/LadderCommands.java | 15 ++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 89bfb02ca..4f0ea63b7 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.1 (alpha.7) 2022-01-29 +# 3.3.0-beta.1 (alpha.7) 2022-01-30 + + +* **Ladder rank cost multiplier has 100 percent limits removed.** +Value can be any positive or negative number now. * **Update some documentation related to CMI Economy.** 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 1f16fcd72..f38402a54 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 @@ -296,8 +296,9 @@ public void ladderSetRankCostMultiplier( CommandSender sender, @Arg( name = "rankCostMultiplier", def = "0", description = "Sets the Rank Cost Multiplier for the ladder, which will be " + "applied to each rank, multiplied by the position of the rank. " + - "A value of zero is disabled. The value is expressed in " + - "percentages.") Double rankCostMultiplier ) + "A value of zero is disabled. The value is expressed in " + + "percentages and can be positive or negative, with any " + + "valid double value such as -3.141592653589793 or 475.19.") Double rankCostMultiplier ) { RankLadder ladder = PrisonRanks.getInstance().getLadderManager().getLadder( ladderName ); @@ -319,11 +320,11 @@ public void ladderSetRankCostMultiplier( CommandSender sender, return; } - if ( rankCostMultiplier < -100d || rankCostMultiplier > 100d ) { - - ladderSetRankCostMultiplierOutOfRangeMsg( sender, rankCostMultiplier ); - return; - } +// if ( rankCostMultiplier < -100d || rankCostMultiplier > 100d ) { +// +// ladderSetRankCostMultiplierOutOfRangeMsg( sender, rankCostMultiplier ); +// return; +// } double oldRankCostMultiplier = ladder.getRankCostMultiplierPerRank() * 100; From acc0a39944322d32049be3de497315097eda31b7 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 30 Jan 2022 15:24:49 -0500 Subject: [PATCH 030/297] Add debug logging when calling the external events. Will have to revisit this when hooked up to multi-block events, otherwise it could overwhelm the logging. --- docs/changelog_v3.3.x.md | 4 + .../spigot/block/OnBlockBreakEventCore.java | 3 +- .../block/OnBlockBreakExternalEvents.java | 198 ++++++++++++++---- 3 files changed, 158 insertions(+), 47 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 4f0ea63b7..42a8cb709 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-30 +* **Add debug logging when calling the external events.** +Will have to revisit this when hooked up to multi-block events, otherwise it could overwhelm the logging. + + * **Ladder rank cost multiplier has 100 percent limits removed.** Value can be any positive or negative number now. 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 e663d8a94..34b8e0bbd 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 @@ -391,7 +391,8 @@ else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && } // check all external events such as mcMMO and EZBlocks: - OnBlockBreakExternalEvents.getInstance().checkAllExternalEvents( e ); + debugInfo.append( + OnBlockBreakExternalEvents.getInstance().checkAllExternalEvents( e ) ); List explodedBlocks = new ArrayList<>(); pmEvent.setExplodedBlocks( explodedBlocks ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java index 87d2f576a..95dbcdd8a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java @@ -11,11 +11,13 @@ import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper; +import tech.mcprison.prison.spigot.spiget.BluesSpigetSemVerComparator; public class OnBlockBreakExternalEvents { private static final OnBlockBreakExternalEvents instance = new OnBlockBreakExternalEvents(); - + private boolean isDropItemsSupported = false; + // private boolean isWorldGuardChecked = false; // private RegisteredListener registeredListenerWorldGuard = null; // private Method worldGuardOnBlockBreakMethod; @@ -30,12 +32,19 @@ public class OnBlockBreakExternalEvents { private RegisteredListener registeredListenerQuests = null; + private boolean setup = false; + private AutoFeaturesWrapper autoFeatureWrapper = null; private OnBlockBreakExternalEvents() { super(); + // if mc version is greater than or equal to 1.13.0. + if ( new BluesSpigetSemVerComparator().compareMCVersionTo("1.13.0") >= 0 ) { + this.isDropItemsSupported = true; + } + this.autoFeatureWrapper = AutoFeaturesWrapper.getInstance(); } @@ -54,6 +63,13 @@ public static OnBlockBreakExternalEvents getInstance() { + public boolean isDropItemsSupported() { + return isDropItemsSupported; + } + public void setDropItemsSupported( boolean isDropItemsSupported ) { + this.isDropItemsSupported = isDropItemsSupported; + } + public AutoFeaturesFileConfig getAutoFeaturesConfig() { return autoFeatureWrapper.getAutoFeaturesConfig(); } @@ -77,19 +93,25 @@ protected List getListString( AutoFeatures feature ) { protected void registerAllExternalEvents() { + if ( !setup ) { + setup = true; + + + // If mcMMO was not registered, then it will get registered. If mcMMO is not available + // then it will just bypass the registration. It will only be processed only once. + registerMCMMO(); + + + registerEZBlock(); + + + registerQuests(); -// registerWorldGuard(); - - - // If mcMMO was not registered, then it will get registered. If mcMMO is not available - // then it will just bypass the registration. It will only be processed only once. - registerMCMMO(); - - - registerEZBlock(); - + +// registerWorldGuard(); + + } - registerQuests(); // Removed because there is a directly callable target with /prison debug now: @@ -119,30 +141,52 @@ protected void registerAllExternalEvents() { } - protected void checkAllExternalEvents( BlockBreakEvent e ) { +// private void registerPriorityEvents() { +// +// // First priority plugins: +// List fpPlugins = getListString( AutoFeatures.firstPriorityBlockBreakEventPlugins ); +// +// +// // gather all plugins within the event: +// TreeMap registeredPlugins = new TreeMap<>(); +// +// +// HandlerList handlers = BlockBreakEvent.getHandlerList(); +// +// for ( RegisteredListener handler : handlers.getRegisteredListeners() ) { +// +// Plugin plugin = handler.getPlugin(); +// String pluginName = plugin.getName(); +// +// if ( !registeredPlugins.containsKey( pluginName ) ) { +// +// registeredPlugins.put( pluginName, plugin ); +// } +// } +// +// //handlers.get +// } + + protected StringBuilder checkAllExternalEvents( BlockBreakEvent e ) { // check mcmmo - checkMCMMO( e ); + StringBuilder sb = checkMCMMO( e ); + + sb.append( checkEZBlock( e ) ); - checkEZBlock( e ); + sb.append( checkQuests( e ) ); - checkQuests( e ); + return sb; } - protected void checkAllExternalEvents( Player player, Block block ) { - - // check mcmmo - checkMCMMO( player, block ); - - - checkEZBlock( player, block ); - + protected StringBuilder checkAllExternalEvents( Player player, Block block ) { - checkQuests( player, block ); + BlockBreakEvent bEvent = new BlockBreakEvent( block, player ); + return checkAllExternalEvents( bEvent ); } @@ -282,23 +326,44 @@ private void registerMCMMO() { } } - private void checkMCMMO( Player player, Block block ) { - if ( registeredListenerMCMMO != null ) { - BlockBreakEvent bEvent = new BlockBreakEvent( block, player ); - checkMCMMO( bEvent ); - } - } +// private void checkMCMMO( Player player, Block block ) { +// if ( registeredListenerMCMMO != null ) { +// BlockBreakEvent bEvent = new BlockBreakEvent( block, player ); +// checkMCMMO( bEvent ); +// } +// } - private void checkMCMMO( BlockBreakEvent e ) { + private StringBuilder checkMCMMO( BlockBreakEvent e ) { + StringBuilder sb = new StringBuilder(); + if ( registeredListenerMCMMO != null ) { try { + + boolean isCanceled = e.isCancelled(); + boolean isDropItems = false; + + if ( isDropItemsSupported() ) { + isDropItems = e.isDropItems(); + } + registeredListenerMCMMO.callEvent( e ); + + sb.append( "[Quests" ); + if ( isCanceled != e.isCancelled() ) { + sb.append( ":isCanceled=" ).append( e.isCancelled() ); + } + if ( isDropItemsSupported() && isDropItems != e.isDropItems() ) { + sb.append( ":isDropItems=" ).append( e.isDropItems() ); + } + sb.append( "]" ); } catch ( EventException e1 ) { e1.printStackTrace(); } } + + return sb; } @@ -336,23 +401,43 @@ private void registerEZBlock() { } } - private void checkEZBlock( Player player, Block block ) { - if ( registeredListenerEZBlock != null ) { - BlockBreakEvent bEvent = new BlockBreakEvent( block, player ); - checkEZBlock( bEvent ); - } - } +// private void checkEZBlock( Player player, Block block ) { +// if ( registeredListenerEZBlock != null ) { +// BlockBreakEvent bEvent = new BlockBreakEvent( block, player ); +// checkEZBlock( bEvent ); +// } +// } - private void checkEZBlock( BlockBreakEvent e ) { + private StringBuilder checkEZBlock( BlockBreakEvent e ) { + StringBuilder sb = new StringBuilder(); + if ( registeredListenerEZBlock != null ) { try { + boolean isCanceled = e.isCancelled(); + boolean isDropItems = false; + + if ( isDropItemsSupported() ) { + isDropItems = e.isDropItems(); + } + registeredListenerEZBlock.callEvent( e ); + + sb.append( "[EZBlock" ); + if ( isCanceled != e.isCancelled() ) { + sb.append( ":isCanceled=" ).append( e.isCancelled() ); + } + if ( isDropItemsSupported() && isDropItems != e.isDropItems() ) { + sb.append( ":isDropItems=" ).append( e.isDropItems() ); + } + sb.append( "]" ); } catch ( EventException e1 ) { e1.printStackTrace(); } } + + return sb; } @@ -390,23 +475,44 @@ private void registerQuests() { } } - private void checkQuests( Player player, Block block ) { - if ( registeredListenerQuests != null ) { - BlockBreakEvent bEvent = new BlockBreakEvent( block, player ); - checkEZBlock( bEvent ); - } - } +// private void checkQuests( Player player, Block block ) { +// if ( registeredListenerQuests != null ) { +// BlockBreakEvent bEvent = new BlockBreakEvent( block, player ); +// checkEZBlock( bEvent ); +// } +// } - private void checkQuests( BlockBreakEvent e ) { + private StringBuilder checkQuests( BlockBreakEvent e ) { + StringBuilder sb = new StringBuilder(); + if ( registeredListenerQuests != null ) { try { + + boolean isCanceled = e.isCancelled(); + boolean isDropItems = false; + + if ( isDropItemsSupported() ) { + isDropItems = e.isDropItems(); + } + registeredListenerQuests.callEvent( e ); + + sb.append( "[Quests" ); + if ( isCanceled != e.isCancelled() ) { + sb.append( ":isCanceled=" ).append( e.isCancelled() ); + } + if ( isDropItemsSupported() && isDropItems != e.isDropItems() ) { + sb.append( ":isDropItems=" ).append( e.isDropItems() ); + } + sb.append( "]" ); } catch ( EventException e1 ) { e1.printStackTrace(); } } + + return sb; } From 4a4bc1d72f5cba3a334e2547c68d4bfb37fa44d9 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 30 Jan 2022 18:52:48 -0500 Subject: [PATCH 031/297] sellall multiplier - Able to list all multipliers. It lists them in a 5 column listing. --- docs/changelog_v3.3.x.md | 4 ++ .../commands/PrisonSpigotSellAllCommands.java | 70 ++++++++++++++++++- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 42a8cb709..25ea097f2 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-30 +* **sellall multiplier - Now able to list all multipliers.** +It lists them in a 5 column listing. + + * **Add debug logging when calling the external events.** Will have to revisit this when hooked up to multi-block events, otherwise it could overwhelm the logging. 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 03a0c2f1d..8dcf197e0 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 @@ -2,6 +2,7 @@ import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.HashMap; import java.util.Set; import java.util.TreeMap; @@ -614,7 +615,8 @@ private void sellAllEditCommand(CommandSender sender, } } - @Command(identifier = "sellall multiplier list", description = "SellAll multiplier command list", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall multiplier list", description = "SellAll multiplier command list", + permissions = "prison.admin", onlyPlayers = false) private void sellAllMultiplierCommand(CommandSender sender){ if (!isEnabled()) return; @@ -629,10 +631,72 @@ private void sellAllMultiplierCommand(CommandSender sender){ return; } - String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall multiplier help" ); - sender.dispatchCommand(registeredCmd); + +// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall multiplier help" ); +// sender.dispatchCommand(registeredCmd); + + TreeMap mults = new TreeMap<>( sellAllUtil.getPrestigeMultipliers() ); + +// TreeMap items = new TreeMap<>( sellAllUtil.getSellAllBlocks() ); + DecimalFormat fFmt = new DecimalFormat("#,##0.00"); + + Set keys = mults.keySet(); + + int maxLenKey = 0; + int maxLenVal = 0; + for ( String key : keys ) { + if ( key.length() > maxLenKey ) { + maxLenKey = key.length(); + } + String val = fFmt.format( mults.get( key ) ); + if ( val.length() > maxLenVal ) { + maxLenVal = val.length(); + } + } + + + ChatDisplay chatDisplay = new ChatDisplay("&bSellall Prestige Multipliers list: &3(&b" + keys.size() + "&3)" ); + + int lines = 0; + int columns = 0; + StringBuilder sb = new StringBuilder(); + for ( String key : keys ) { +// boolean first = sb.length() == 0; + + Double cost = mults.get( key ); + + if ( columns++ > 0 ) { + sb.append( " " ); + } + + sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s", + key, fFmt.format( cost ) ) ); +// sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s %-" + maxLenCode + "s", +// key.toString(), fFmt.format( cost ), key.name() ) ); + + if ( columns > 4 ) { + chatDisplay.addText( sb.toString() ); + + if ( ++lines % 10 == 0 && lines > 1 ) { + chatDisplay.addText( " " ); + } + + sb.setLength( 0 ); + columns = 0; + } + } + if ( sb.length() > 0 ) { + chatDisplay.addText( sb.toString() ); + } + + chatDisplay.send( sender ); + + + + } + @Command(identifier = "sellall multiplier add", description = "SellAll add a multiplier. Permission multipliers for player's prison.sellall.multiplier., example prison.sellall.multiplier.2 will add a 2x multiplier," + "There's also another kind of Multiplier called permission multipliers, they're permissions that you can give to players to give them a multiplier, remember that their format is prison.sellall.multiplier.2 (for example), and this example will give you a " + "total of 3x multiplier (1x default + 2x permission = 3x).", From 3cb7eb5634bd70d3b017c479807a96ad823715ee Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 30 Jan 2022 18:55:57 -0500 Subject: [PATCH 032/297] RankLadders - Added a boolean function to check if the ladder is the default ladder or prestiges ladder. --- docs/changelog_v3.3.x.md | 3 +++ .../tech/mcprison/prison/ranks/data/RankLadder.java | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 25ea097f2..0cf3cbaa6 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-01-30 +* **RankLadders - Added a boolean function to check if the ladder is the default ladder or prestiges ladder.** + + * **sellall multiplier - Now able to list all multipliers.** It lists them in a 5 column listing. diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java index 47c899f2a..41c870a3b 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java @@ -79,6 +79,16 @@ public RankLadder( int id, String name ) { this.name = name; } + + public boolean isDefault() { + return getName().equalsIgnoreCase( "default" ); + } + + public boolean isPrestiges() { + return getName().equalsIgnoreCase( "prestiges" ); + } + + // @SuppressWarnings( "unchecked" ) // public RankLadder(Document document, PrisonRanks prisonRanks) { // this(); @@ -549,5 +559,5 @@ public boolean isDirty() { public void setDirty( boolean dirty ) { this.dirty = dirty; } - + } From 61253766ba7819fcf1bbf884a822649f3cecc47c Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 2 Feb 2022 15:46:35 -0500 Subject: [PATCH 033/297] Modified SpigotPlayer to add getRankPlayer() and modified RankPlayer to add getRankLadder, with short cuts for default and prestige so you don't have to always refer to their names (reduce errors). This is to remove the "mess" from other functions that need to get these player objects, of which sometimes they are not going about it the correct way. --- docs/changelog_v3.3.x.md | 6 ++- .../prison/ranks/data/RankPlayer.java | 47 ++++++++++++++++++- .../prison/spigot/game/SpigotPlayer.java | 11 +++++ 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0cf3cbaa6..faa5ef57a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.1 (alpha.7) 2022-01-30 +# 3.3.0-beta.1 (alpha.7) 2022-02-02 + + +* **Modified SpigotPlayer to add getRankPlayer() and modified RankPlayer to add getRankLadder, with short cuts for default and prestige so you don't have to always refer to their names (reduce errors).** +This is to remove the "mess" from other functions that need to get these player objects, of which sometimes they are not going about it the correct way. * **RankLadders - Added a boolean function to check if the ladder is the default ladder or prestiges ladder.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index c3557da95..eaa10229d 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -529,6 +529,35 @@ public TreeMap getLadderRanks() { // public void setLadderRanks( TreeMap ladderRanks ) { // this.ladderRanks = ladderRanks; // } + + private RankLadder getRankLadder( String ladderName ) { + RankLadder results = null; + + for ( RankLadder rLadder : getLadderRanks().keySet() ) { + if ( rLadder.getName().equalsIgnoreCase( ladderName ) ) { + results = rLadder; + } + } + + return results; + } + public PlayerRank getPlayerRank( String ladderName ) { + PlayerRank results = null; + + RankLadder rLadder = getRankLadder( ladderName ); + + if ( rLadder != null ) { + results = getLadderRanks().get( rLadder ); + } + + return results; + } + public PlayerRank getPlayerRankDefault() { + return getPlayerRank( "default" ); + } + public PlayerRank getPlayerRankPrestiges() { + return getPlayerRank( "prestiges" ); + } public HashMap getRanksRefs(){ return ranksRefs ; @@ -708,17 +737,31 @@ public boolean isOp() { */ @Override public boolean isPlayer() { - return false; + Player player = getPlayer(); + return (player != null ? player.isPlayer() : false ); } @Override public void updateInventory() { + Player player = getPlayer(); + if ( player != null ) { + + player.updateInventory(); + } } @Override public Inventory getInventory() { - return null; + Inventory results = null; + + Player player = getPlayer(); + if ( player != null ) { + + results = player.getInventory(); + } + + return results; } // @Override 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 0179fd4c0..1a006699a 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 @@ -38,6 +38,8 @@ import tech.mcprison.prison.internal.scoreboard.Scoreboard; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.ranks.PrisonRanks; +import tech.mcprison.prison.ranks.data.RankPlayer; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; @@ -55,6 +57,8 @@ public class SpigotPlayer extends SpigotCommandSender implements Player { + private RankPlayer rankPlayer; + private org.bukkit.entity.Player bukkitPlayer; public SpigotPlayer(org.bukkit.entity.Player bukkitPlayer) { @@ -625,6 +629,13 @@ public void setActionBar( String actionBar ) { } } + public RankPlayer getRankPlayer() { + if ( rankPlayer == null ) { + rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer( this ); + } + return rankPlayer; + } + @Override public PlayerCache getPlayerCache() { return PlayerCache.getInstance(); From 7d2bc3cb8ed4d87632bec962e615b9c424ae7988 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 2 Feb 2022 15:54:34 -0500 Subject: [PATCH 034/297] sellall multiplier add - Now reports if a multiplier cannot be added. Also now adds the multiplier based upon the actual rank name . of which it was what the user entered with the command, which may not match the actual rank name. --- docs/changelog_v3.3.x.md | 4 + .../prison/spigot/sellall/SellAllUtil.java | 102 +++++++++++------- 2 files changed, 70 insertions(+), 36 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index faa5ef57a..6f37efb6e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -20,6 +20,10 @@ These build logs represent the work that has been going on within prison. This is to remove the "mess" from other functions that need to get these player objects, of which sometimes they are not going about it the correct way. +* **sellall multiplier add - Now reports if a multiplier cannot be added. Also now adds the multiplier based upon the actual rank name**, +of which it was what the user entered with the command, which may not match the actual rank name. + + * **RankLadders - Added a boolean function to check if the ladder is the default ladder or prestiges ladder.** 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 b9f99ebd5..4620ddbe6 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 @@ -277,39 +277,54 @@ public double getPlayerMultiplier(Player p){ return 1; } - // Get Ranks module. - ModuleManager modMan = Prison.get().getModuleManager(); - Module module = modMan == null ? null : modMan.getModule(PrisonRanks.MODULE_NAME).orElse(null); + +// // Get Ranks module. +// ModuleManager modMan = Prison.get().getModuleManager(); +// Module module = modMan == null ? null : modMan.getModule(PrisonRanks.MODULE_NAME).orElse(null); SpigotPlayer sPlayer = new SpigotPlayer(p); double multiplier = defaultMultiplier; - // Get multiplier depending on Player + Prestige. NOTE that prestige multiplier will replace - // the actual default multiplier. - if (module != null) { - PrisonRanks rankPlugin = (PrisonRanks) module; - if (rankPlugin.getPlayerManager().getPlayer(sPlayer) != null) { - String playerRankName; - try { - - RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); - - RankPlayer rankPlayer = rankPlugin.getPlayerManager().getPlayer(sPlayer); - PlayerRank pRank = rankPlayer == null ? null : rankPlayerFactory.getRank( rankPlayer, "prestiges"); - Rank rank = pRank == null ? null : pRank.getRank(); + RankPlayer rPlayer = sPlayer.getRankPlayer(); +// rPlayer.getSellAllMultiplier(); // NOTE: This actually calls this function + PlayerRank pRank = rPlayer.getPlayerRankPrestiges(); + Rank rank = pRank == null ? null : pRank.getRank(); - playerRankName = rank == null ? null : rank.getName(); - } catch (NullPointerException ex) { - playerRankName = null; - } - if (playerRankName != null) { - String multiplierRankString = sellAllConfig.getString("Multiplier." + playerRankName + ".MULTIPLIER"); - if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey(playerRankName)){ - multiplier = sellAllPrestigeMultipliers.get(playerRankName); - } - } - } + if ( pRank != null ) { + String rankName = rank.getName(); + String multiplierRankString = sellAllConfig.getString("Multiplier." + rankName + ".MULTIPLIER"); + if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey( rankName )){ + multiplier = sellAllPrestigeMultipliers.get( rankName ); + } } + + // Get multiplier depending on Player + Prestige. NOTE that prestige multiplier will replace + // the actual default multiplier. +// if (module != null) { +// PrisonRanks rankPlugin = (PrisonRanks) module; +// if (rankPlugin.getPlayerManager().getPlayer(sPlayer) != null) { +// String playerRankName; +// try { +// +// RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); +// +// RankPlayer rankPlayer = rankPlugin.getPlayerManager().getPlayer(sPlayer); +// PlayerRank pRank = rankPlayer == null ? null : rankPlayerFactory.getRank( rankPlayer, "prestiges"); +// Rank rank = pRank == null ? null : pRank.getRank(); +// +// playerRankName = rank == null ? null : rank.getName(); +// } catch (NullPointerException ex) { +// playerRankName = null; +// } +// if (playerRankName != null) { +// String multiplierRankString = sellAllConfig.getString("Multiplier." + playerRankName + ".MULTIPLIER"); +// if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey(playerRankName)){ +// multiplier = sellAllPrestigeMultipliers.get(playerRankName); +// } +// } +// } +// } + // Get Multiplier from multipliers permission's if there's any. List perms = sPlayer.getPermissions("prison.sellall.multiplier."); double multiplierExtraByPerms = 0; @@ -321,6 +336,7 @@ public double getPlayerMultiplier(Player p){ multiplierExtraByPerms = multByPermDouble; } } + multiplier += multiplierExtraByPerms; return multiplier; @@ -350,6 +366,8 @@ public double getSellMoney(Player p, HashMap xMaterialIntege } double multiplier = getPlayerMultiplier(p); + + double earned = 0; for (HashMap.Entry xMaterialIntegerEntry : xMaterialIntegerHashMap.entrySet()){ if (sellAllBlocks.containsKey(xMaterialIntegerEntry.getKey())){ @@ -754,28 +772,40 @@ public boolean addPrestigeMultiplier(String prestigeName, double multiplier){ return false; } - boolean isARank = rankPlugin.getRankManager().getRank(prestigeName) != null; - if (!isARank) { + Rank pRank = rankPlugin.getRankManager().getRank(prestigeName); + + if ( pRank == null ) { + // Invalid rank! return false; } - boolean isInPrestigeLadder = rankPlugin.getLadderManager().getLadder("prestiges").containsRank(rankPlugin.getRankManager().getRank(prestigeName)); - if (!isInPrestigeLadder) { - return false; + if ( !pRank.getLadder().isPrestiges() ) { + // Rank is not in the prestiges ladder: + return false; } + +// boolean isInPrestigeLadder = rankPlugin.getLadderManager().getLadder("prestiges").containsRank(rankPlugin.getRankManager().getRank(prestigeName)); +// if (!isInPrestigeLadder) { +// return false; +// } try { File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml"); FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile); - conf.set("Multiplier." + prestigeName + ".PRESTIGE_NAME", prestigeName); - conf.set("Multiplier." + prestigeName + ".MULTIPLIER", multiplier); + + conf.set("Multiplier." + pRank.getName() + ".PRESTIGE_NAME", pRank.getName()); + conf.set("Multiplier." + pRank.getName() + ".MULTIPLIER", multiplier); + conf.save(sellAllFile); - } catch (IOException e) { + } + catch (IOException e) { e.printStackTrace(); return false; } - sellAllPrestigeMultipliers.put(prestigeName, multiplier); + + sellAllPrestigeMultipliers.put( pRank.getName(), multiplier); updateConfig(); + return true; } From 0fd1dbc6abe81835cf262fc0aabd98ac7ff81402 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 2 Feb 2022 16:06:29 -0500 Subject: [PATCH 035/297] Change notification alerts from runnign every 5 minutes to every hour. Got a few complaints within the last fewa days that the notifications are too frequent. --- docs/changelog_v3.3.x.md | 3 +++ .../main/java/tech/mcprison/prison/Prison.java | 15 ++++++++++----- .../java/tech/mcprison/prison/alerts/Alerts.java | 5 +++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 6f37efb6e..dbc428b28 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -15,6 +15,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-02-02 +* **Change notification alerts from runnign every 5 minutes to every hour.** +Got a few complaints within the last fewa days that the notifications are too frequent. + * **Modified SpigotPlayer to add getRankPlayer() and modified RankPlayer to add getRankLadder, with short cuts for default and prestige so you don't have to always refer to their names (reduce errors).** This is to remove the "mess" from other functions that need to get these player objects, of which sometimes they are not going about it the correct way. diff --git a/prison-core/src/main/java/tech/mcprison/prison/Prison.java b/prison-core/src/main/java/tech/mcprison/prison/Prison.java index 2c47766ff..0683fdb3b 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/Prison.java +++ b/prison-core/src/main/java/tech/mcprison/prison/Prison.java @@ -573,11 +573,16 @@ private void registerInbuiltTroubleshooters() { } private void scheduleAlertNagger() { - // Nag the user with alerts every 5 minutes - PrisonAPI.getScheduler().runTaskTimerAsync(() -> PrisonAPI.getOnlinePlayers().stream() - .filter(player -> player.hasPermission("prison.admin") - && Alerts.getInstance().getAlertsFor(player.getUUID()).size() > 0) - .forEach(Alerts.getInstance()::showAlerts), 60 * 20 * 5, 60 * 20 * 5); + + // Nag the users with the correct perms 5 mins after server starts, and every + // hour thereafter. + Alerts.getInstance().submitShowAlertsTask(); + +// // Nag the user with alerts every 5 minutes +// PrisonAPI.getScheduler().runTaskTimerAsync(() -> PrisonAPI.getOnlinePlayers().stream() +// .filter(player -> player.hasPermission("prison.admin") +// && Alerts.getInstance().getAlertsFor(player.getUUID()).size() > 0) +// .forEach(Alerts.getInstance()::showAlerts), 60 * 20 * 5, 60 * 20 * 5); } // End initialization steps diff --git a/prison-core/src/main/java/tech/mcprison/prison/alerts/Alerts.java b/prison-core/src/main/java/tech/mcprison/prison/alerts/Alerts.java index 8b0036775..0f5b8c17d 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/alerts/Alerts.java +++ b/prison-core/src/main/java/tech/mcprison/prison/alerts/Alerts.java @@ -18,6 +18,11 @@ * @since API 1.0 */ public class Alerts { + + public static final long DURATION_ONE_MINUTE = 20 * 60; + public static final long DURATION_FIVE_MINUTES = DURATION_ONE_MINUTE * 5; + public static final long DURATION_ONE_HOUR = DURATION_ONE_MINUTE * 60; + /* * Variables & Constants From 83a52535c7ffaa88e8e054205c1c873ab76ec5bf Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 2 Feb 2022 16:17:08 -0500 Subject: [PATCH 036/297] Change notification alerts from runnign every 5 minutes to every hour. Got a few complaints within the last fewa days that the notifications are too frequent. --- .../java/tech/mcprison/prison/alerts/Alerts.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/prison-core/src/main/java/tech/mcprison/prison/alerts/Alerts.java b/prison-core/src/main/java/tech/mcprison/prison/alerts/Alerts.java index 0f5b8c17d..223bce9bc 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/alerts/Alerts.java +++ b/prison-core/src/main/java/tech/mcprison/prison/alerts/Alerts.java @@ -2,6 +2,7 @@ import com.google.common.eventbus.Subscribe; import tech.mcprison.prison.Prison; +import tech.mcprison.prison.PrisonAPI; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.events.player.PlayerJoinEvent; import tech.mcprison.prison.output.Output; @@ -52,6 +53,20 @@ public static Alerts getInstance() { } return instance; } + + public void submitShowAlertsTask() { + + long intialDelay = DURATION_FIVE_MINUTES; + long intervalToRepeat = DURATION_ONE_HOUR; + + PrisonAPI.getScheduler().runTaskTimerAsync( + () -> PrisonAPI.getOnlinePlayers().stream() + + .filter(player -> player.hasPermission("prison.admin") + && Alerts.getInstance().getAlertsFor(player.getUUID()).size() > 0) + + .forEach(Alerts.getInstance()::showAlerts), intialDelay, intervalToRepeat ); + } public void sendAlert(String alertMsg, Object... format) { String msg = String.format(alertMsg, format); From 8b9df1a3fe983d1df1478efebf2bfae27def41ef Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Feb 2022 01:33:54 -0500 Subject: [PATCH 037/297] For command /mines set notification added *all* for mine name so all mines can be changed at the same time. --- docs/changelog_v3.3.x.md | 6 +- .../prison/mines/commands/MinesCommands.java | 137 +++++++++++------- 2 files changed, 90 insertions(+), 53 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index dbc428b28..169675d2f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.1 (alpha.7) 2022-02-02 +# 3.3.0-beta.1 (alpha.7) 2022-02-03 + + +* **For command /mines set notification added *all* for mine name so all mines can be changed at the same time.** + * **Change notification alerts from runnign every 5 minutes to every hour.** Got a few complaints within the last fewa days that the notifications are too frequent. 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 2d3b61f29..58796bc96 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 @@ -2023,11 +2023,63 @@ public void setNotificationCommand(CommandSender sender, String radius ) { - - if (performCheckMineExists(sender, mineName)) { + + + MineNotificationMode noteMode = MineNotificationMode.fromString( mode, MineNotificationMode.displayOptions ); + + if ( noteMode == MineNotificationMode.displayOptions ) { + sender.sendMessage( "&7Select a Mode: &bdisabled&7, &bwithin &7the mine, &bradius " + + "&7from center of mine." ); + return; + } + + long noteRadius = 0L; + if ( noteMode == MineNotificationMode.radius ) { + if ( radius == null || radius.trim().length() == 0 ) { + noteRadius = MineData.MINE_RESET__BROADCAST_RADIUS_BLOCKS; + } else { + try { + noteRadius = Long.parseLong( radius ); + + if ( noteRadius < 1 ) { + noteRadius = MineData.MINE_RESET__BROADCAST_RADIUS_BLOCKS; + DecimalFormat dFmt = new DecimalFormat("#,##0"); + Output.get().sendWarn( sender, "&7Invalid radius value. " + + "Must be an positive non-zero integer. Using the default value: &b%s &7[&b%s&7]", + dFmt.format(MineData.MINE_RESET__BROADCAST_RADIUS_BLOCKS), radius ); + return; + } + } + catch ( NumberFormatException e ) { + e.printStackTrace(); + Output.get().sendWarn( sender, "&7Invalid notification radius. " + + "Must be an positive non-zero integer. [&b%s&7]", + radius ); + return; + } + } + } + + PrisonMines pMines = PrisonMines.getInstance(); + + if ( "*all*".equalsIgnoreCase( mineName ) ) { + + int count = 0; + for ( Mine m : pMines.getMines() ) + { + + if ( changeMineNotification( sender, mineName, noteMode, noteRadius, pMines, m, true ) ) { + count++; + } + } + + Output.get().sendInfo( sender, "&7Notification mode was changed for &b%d&7 mines.", + count ); + } + + else if (performCheckMineExists(sender, mineName)) { setLastMineReferenced(mineName); - PrisonMines pMines = PrisonMines.getInstance(); Mine m = pMines.getMine(mineName); // if ( !m.isEnabled() ) { @@ -2035,58 +2087,39 @@ public void setNotificationCommand(CommandSender sender, // return; // } - MineNotificationMode noteMode = MineNotificationMode.fromString( mode, MineNotificationMode.displayOptions ); - - if ( noteMode == MineNotificationMode.displayOptions ) { - sender.sendMessage( "&7Select a Mode: &bdisabled&7, &bwithin &7the mine, &bradius " + - "&7from center of mine." ); - } else { - long noteRadius = 0L; - if ( noteMode == MineNotificationMode.radius ) { - if ( radius == null || radius.trim().length() == 0 ) { - noteRadius = MineData.MINE_RESET__BROADCAST_RADIUS_BLOCKS; - } else { - try { - noteRadius = Long.parseLong( radius ); - - if ( noteRadius < 1 ) { - noteRadius = MineData.MINE_RESET__BROADCAST_RADIUS_BLOCKS; - DecimalFormat dFmt = new DecimalFormat("#,##0"); - Output.get().sendWarn( sender, "&7Invalid radius value for &b%s&7. " + - "Must be an positive non-zero integer. Using the default value: &b%s &7[&b%s&7]", - mineName, dFmt.format(MineData.MINE_RESET__BROADCAST_RADIUS_BLOCKS), radius ); - } - } - catch ( NumberFormatException e ) { - e.printStackTrace(); - Output.get().sendWarn( sender, "&7Invalid notification radius for &b%s&7. " + - "Must be an positive non-zero integer. [&b%s&7]", - mineName, radius ); - } - } - } - - if ( m.getNotificationMode() != noteMode || m.getNotificationRadius() != noteRadius ) { - m.setNotificationMode( noteMode ); - m.setNotificationRadius( noteRadius ); - - pMines.getMineManager().saveMine( m ); - - DecimalFormat dFmt = new DecimalFormat("#,##0"); - // message: notification mode changed - Output.get().sendInfo( sender, "&7Notification mode was changed for &b%s&7: &b%s %s", - mineName, m.getNotificationMode().name(), - (m.getNotificationMode() == MineNotificationMode.radius ? - dFmt.format( m.getNotificationRadius() ) : "" )); - - } else { - // message: notification mode did not change - Output.get().sendInfo( sender, "&7Notification mode was not changed for mine &b%s&7.", mineName ); - } - } + + changeMineNotification( sender, mineName, noteMode, noteRadius, pMines, m, false ); } } + private boolean changeMineNotification( CommandSender sender, String mineName, + MineNotificationMode noteMode, long noteRadius, + PrisonMines pMines, Mine m, boolean suppressMessages ) + { + boolean success = false; + + if ( m.getNotificationMode() != noteMode || m.getNotificationRadius() != noteRadius ) { + m.setNotificationMode( noteMode ); + m.setNotificationRadius( noteRadius ); + + pMines.getMineManager().saveMine( m ); + success = true; + + DecimalFormat dFmt = new DecimalFormat("#,##0"); + // message: notification mode changed + Output.get().sendInfo( sender, "&7Notification mode was changed for &b%s&7: &b%s %s", + mineName, m.getNotificationMode().name(), + (m.getNotificationMode() == MineNotificationMode.radius ? + dFmt.format( m.getNotificationRadius() ) : "" )); + + } else if ( !suppressMessages ) { + // message: notification mode did not change + Output.get().sendInfo( sender, "&7Notification mode was not changed for mine &b%s&7.", mineName ); + } + + return success; + } + @Command(identifier = "mines set notificationPerm", permissions = "mines.notification", description = "Enable or disable a mine's notification permission. If enabled, then players " + From 37ff13fa7e0f0f2a91bf76253bb141ddf746cff4 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Feb 2022 12:58:27 -0500 Subject: [PATCH 038/297] Bug fix: Correct the comparison of a prison ItemStack by using compareTo. The old code was using enums, so the check for equality of enums resulted in comparing pointers, which will never work. Updated a few other parts of the code to use the compareTo function instead of the equals function since that may not work correctly all the time. --- docs/changelog_v3.3.x.md | 5 ++++ .../mcprison/prison/internal/ItemStack.java | 11 ++++++--- .../player/PrisonPlayerInteractEvent.java | 24 +++++++++++++++---- .../prison/selection/SelectionManager.java | 2 +- .../prison/spigot/SpigotListener.java | 21 ++++++++++------ .../spigot/inventory/SpigotInventory.java | 2 +- 6 files changed, 49 insertions(+), 16 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 169675d2f..1bed39387 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-02-03 +* **Bug fix: Correct the comparison of a prison ItemStack by using compareTo.** +The old code was using enums, so the check for equality of enums resulted in comparing pointers, which will never work. +Updated a few other parts of the code to use the compareTo function instead of the equals function since that may not work correctly all the time. + + * **For command /mines set notification added *all* for mine name so all mines can be changed at the same time.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/ItemStack.java b/prison-core/src/main/java/tech/mcprison/prison/internal/ItemStack.java index d250fbe93..880d0cb85 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/ItemStack.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/ItemStack.java @@ -139,9 +139,14 @@ public boolean hasEnchantment(int enchantment) { } ItemStack stack = (ItemStack) o; - - return (displayName != null ? Text.stripColor(displayName).equals(Text.stripColor(Text.stripColor(stack.displayName))) : - stack.displayName == null) && material == stack.material; + + String stackName = Text.stripColor(stack.displayName); + boolean isDisplayNamesEqual = (displayName != null ? + Text.stripColor(displayName).equals(stackName) : + (stack.displayName == null)); + + return isDisplayNamesEqual && + material.compareTo( stack.material ) == 0; } @Override public int hashCode() { diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/events/player/PrisonPlayerInteractEvent.java b/prison-core/src/main/java/tech/mcprison/prison/internal/events/player/PrisonPlayerInteractEvent.java index ab5a328f7..15fe44b74 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/events/player/PrisonPlayerInteractEvent.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/events/player/PrisonPlayerInteractEvent.java @@ -37,6 +37,26 @@ public class PrisonPlayerInteractEvent implements Cancelable { private Location clicked; private boolean canceled = false; + + public enum Action { + LEFT_CLICK_BLOCK, RIGHT_CLICK_BLOCK; + + public static Action fromString( String value ) { + Action results = null; + + if ( value != null ) { + for ( Action action : values() ) + { + if ( action.name().equalsIgnoreCase( value.trim() ) ) { + results = action; + } + } + } + + return results; + } + } + public PrisonPlayerInteractEvent(Player player, ItemStack itemInHand, Action action, Location clicked) { this.player = player; @@ -69,8 +89,4 @@ public Location getClicked() { this.canceled = canceled; } - public enum Action { - LEFT_CLICK_BLOCK, RIGHT_CLICK_BLOCK - } - } diff --git a/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionManager.java b/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionManager.java index 9a07f832b..7d8aea24e 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionManager.java @@ -68,7 +68,7 @@ private int selectionWandCount( Player player) { if ( is != null && // is.getName().toLowerCase().contains( "selection wand" ) && // is.getDisplayName().toLowerCase().contains( "selection wand" ) && - is.getMaterial().equals( PrisonBlock.BLAZE_ROD ) ) { + is.getMaterial().compareTo( PrisonBlock.BLAZE_ROD ) == 0 ) { count += is.getAmount(); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java index 720bad63d..e4a320454 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java @@ -47,6 +47,7 @@ import tech.mcprison.prison.internal.events.player.PlayerPickUpItemEvent; import tech.mcprison.prison.internal.events.player.PlayerSuffocationEvent; import tech.mcprison.prison.internal.events.player.PrisonPlayerInteractEvent; +import tech.mcprison.prison.internal.events.player.PrisonPlayerInteractEvent.Action; import tech.mcprison.prison.internal.events.world.PrisonWorldLoadEvent; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; @@ -214,13 +215,20 @@ public void onPlayerInteract(PlayerInteractEvent e) { // TODO Accept air events (block is null when air is clicked...) // Check to see if we support the Action - PrisonPlayerInteractEvent.Action[] values = PrisonPlayerInteractEvent.Action.values(); +// PrisonPlayerInteractEvent.Action[] values = PrisonPlayerInteractEvent.Action.values(); - boolean has = false; - for ( PrisonPlayerInteractEvent.Action value : values) { - if(value.name().equals(e.getAction().name())) has = true; +// boolean has = false; + + Action action = Action.fromString( e.getAction().name() ); + if ( action == null ) { + // We don't support this action: + return; } - if(!has) return; // we don't support this Action + +// for ( PrisonPlayerInteractEvent.Action value : PrisonPlayerInteractEvent.Action.values() ) { +// if(value.name().equals(e.getAction().name())) has = true; +// } +// if(!has) return; // we don't support this Action // This one's a workaround for the double-interact event glitch. // The wand can only be used in the main hand @@ -234,8 +242,7 @@ public void onPlayerInteract(PlayerInteractEvent e) { new SpigotPlayer(e.getPlayer()), SpigotUtil.bukkitItemStackToPrison( SpigotCompatibility.getInstance().getItemInMainHand(e)), - PrisonPlayerInteractEvent.Action - .valueOf(e.getAction().name()), + action, new Location(new SpigotWorld(block.getWorld()), block.getX(), block.getY(), block.getZ())); Prison.get().getEventBus().post(event); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotInventory.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotInventory.java index ed58a832b..e8c71c822 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotInventory.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotInventory.java @@ -178,7 +178,7 @@ public void setItems(List items) { public HashMap getItems( PrisonBlock type ) { HashMap result = new HashMap<>(); List items = Arrays.asList(getItems()); - items.removeIf(x -> !x.getMaterial().equals( type ) ); + items.removeIf(x -> x.getMaterial().compareTo( type ) != 0 ); items.forEach(y -> result.put(items.indexOf(y), y)); return result; } From 2c469c71a0e94374249369314a716448c1401910 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Feb 2022 13:02:29 -0500 Subject: [PATCH 039/297] Update /ranks autoConfigure to set notifications to a radius of 25 blocks, and enabled skip resets at a limit of 90% with 24 skips. Also moved DARK_PRISMARINE down a few levels since it's not as valuable as the other blocks. --- docs/changelog_v3.3.x.md | 4 ++++ .../tech/mcprison/prison/spigot/SpigotPlatform.java | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 1bed39387..3ec2b864b 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-02-03 +* **Update /ranks autoConfigure to set notifications to a radius of 25 blocks, and enabled skip resets at a limit of 90% with 24 skips.** +Also moved DARK_PRISMARINE down a few levels since it's not as valuable as the other blocks. + + * **Bug fix: Correct the comparison of a prison ItemStack by using compareTo.** The old code was using enums, so the check for equality of enums resulted in comparing pointers, which will never work. Updated a few other parts of the code to use the compareTo function instead of the equals function since that may not work correctly all the time. 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 cd4a6bb5d..4501b7fb8 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 @@ -73,6 +73,7 @@ import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.commands.MinesCommands; import tech.mcprison.prison.mines.data.Mine; +import tech.mcprison.prison.mines.data.MineData.MineNotificationMode; import tech.mcprison.prison.mines.features.MineLinerBuilder.LinerPatterns; import tech.mcprison.prison.mines.managers.MineManager; import tech.mcprison.prison.modules.Module; @@ -1430,6 +1431,15 @@ public void autoCreateConfigureMines() { for ( Mine mine : mines ) { + mine.setNotificationMode( MineNotificationMode.radius ); + mine.setNotificationRadius( 25 ); + + mine.setSkipResetEnabled( true ); + mine.setSkipResetPercent( 90 ); + mine.setSkipResetBypassLimit( 24 ); + + mine.setZeroBlockResetDelaySec( 0 ); + // Setup access by rank: if ( mine.getRank() != null ) { @@ -1735,6 +1745,8 @@ public List buildBlockListXMaterial() { blockList.add( new SellAllBlockData( XMaterial.PRISMARINE, 52, true ) ); + blockList.add( new SellAllBlockData( XMaterial.DARK_PRISMARINE, 54, true ) ); + blockList.add( new SellAllBlockData( XMaterial.LAPIS_BLOCK, 950, true) ); blockList.add( new SellAllBlockData( XMaterial.REDSTONE_BLOCK, 405, true) ); @@ -1742,7 +1754,6 @@ public List buildBlockListXMaterial() { blockList.add( new SellAllBlockData( XMaterial.DIAMOND_BLOCK, 2000, true) ); - blockList.add( new SellAllBlockData( XMaterial.DARK_PRISMARINE, 54, true ) ); blockList.add( new SellAllBlockData( XMaterial.EMERALD_BLOCK, 2250, true) ); From f28935a942f53c8bfe382a55c5b5bbd980d3d5fe Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Feb 2022 13:09:23 -0500 Subject: [PATCH 040/297] New feature: cached adding of earnings for the default currency. This was causing a significant amount of lag/slow down when performing autosell, or spamming of sellall. The lag was in the economy plugin not being able to accept additons of money fast enough. Now this simple cache, will wait 3 seconds before adding the player's earnings to the economy plugin. When it does, it will do so in an async thread so as to not impact any performance in bukkit's main thread. Also prison's getBalance() functions, which includes the use of all prison placeholders, will include the cached amount, which means the player's balances appear as if they are not being cached. Still need to cache the custom currencies. --- docs/changelog_v3.3.x.md | 6 ++ .../prison/ranks/data/RankPlayer.java | 70 ++++++++++++++++--- 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 3ec2b864b..6fe2da9ec 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,12 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-02-03 +* **New feature: cached adding of earnings for the default currency.** +This was causing a significant amount of lag/slow down when performing autosell, or spamming of sellall. The lag was in the economy plugin not being able to accept additions of money fast enough. +Now this simple cache, will wait 3 seconds before adding the player's earnings to the economy plugin. When it does, it will do so in an async thread so as to not impact any performance in bukkit's main thread. Also prison's getBalance() functions, which includes the use of all prison placeholders, will include the cached amount, which means the player's balances appear as if they are not being cached. +Still need to cache the custom currencies. + + * **Update /ranks autoConfigure to set notifications to a radius of 25 blocks, and enabled skip resets at a limit of 90% with 24 skips.** Also moved DARK_PRISMARINE down a few levels since it's not as valuable as the other blocks. diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index eaa10229d..6a61f0903 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -48,6 +48,8 @@ public class RankPlayer implements Player { + public static final long DELAY_THREE_SECONDS = 20 * 3; // 3 seconds in ticks + /* * Fields & Constants */ @@ -71,12 +73,18 @@ public class RankPlayer // For tops processing. Need current balance. private TreeMap playerBalances; - //x + + + + private EconomyIntegration economy = null; + private double unsavedBalance = 0; + private Object unsavedBalanceLock = new Object(); + private int ubTaskId = 0; + + private HashMap economyCustom = new HashMap<>();; + - /* - * Document-related - */ public RankPlayer() { super(); @@ -919,20 +927,49 @@ private RankPlayerBalance getCachedRankPlayerBalance( String currency, boolean u public double getBalance() { double results = 0; - EconomyIntegration economy = PrisonAPI.getIntegrationManager().getEconomy(); + EconomyIntegration economy = getEconomy(); if ( economy != null ) { - results = economy.getBalance( this ); + results = economy.getBalance( this ) + getBalanceUnsaved(); setCachedRankPlayerBalance( null, results ); } return results; } + public double getBalanceUnsaved() { + return unsavedBalance; + } + public void addBalance( double amount ) { - EconomyIntegration economy = PrisonAPI.getIntegrationManager().getEconomy(); - + + synchronized ( unsavedBalanceLock ) + { + unsavedBalance += amount; + + if ( ubTaskId == 0 ) { + + ubTaskId = PrisonAPI.getScheduler().runTaskLaterAsync( + () -> { + double tempBalance = 0; + synchronized ( unsavedBalanceLock ) + { + tempBalance = unsavedBalance; + unsavedBalance = 0; + ubTaskId = 0; + } + addBalanceEconomy( tempBalance ); + }, DELAY_THREE_SECONDS ); + } + } + + + } + + private void addBalanceEconomy( double amount ) { + EconomyIntegration economy = getEconomy(); + if ( economy != null ) { economy.addBalance( this, amount ); addCachedRankPlayerBalance( null, amount ); @@ -940,7 +977,7 @@ public void addBalance( double amount ) { } public void removeBalance( double amount ) { - EconomyIntegration economy = PrisonAPI.getIntegrationManager().getEconomy(); + EconomyIntegration economy = getEconomy(); if ( economy != null ) { economy.removeBalance( this, amount ); @@ -949,7 +986,7 @@ public void removeBalance( double amount ) { } public void setBalance( double amount ) { - EconomyIntegration economy = PrisonAPI.getIntegrationManager().getEconomy(); + EconomyIntegration economy = getEconomy(); if ( economy != null ) { economy.setBalance( this, amount ); @@ -1035,6 +1072,19 @@ public void setBalance( String currency, double amount ) { } } } + + /** + * addBalance: original t3: 2.19 1.34 1.37 1.37 1.24 0.81 1.49 2.05 1.17 0.98 1.0 0.62 + * addBalance: opt Econ-localVar t3: 3.46 1.21 0.88 0.84 1.48 1.3 0.6 1.09 1.62 0.72 0.64 0.67 1.02 0.63 0.97 1.8 + * addBalance: cached t3: 0.0322 0.0011 0.0016 0.0012 0.0111 0.0012 0.0012 0.0018 0.0011 0.0102 0.0010 0.0013 0.0015 0.0011 + * @return + */ + private EconomyIntegration getEconomy() { + if ( economy == null ) { + economy = PrisonAPI.getIntegrationManager().getEconomy(); + } + return economy; + } @Override public List getPermissionsIntegrations( boolean detailed ) { From bfff53b08525b97c6d04ed72aa4bd85be59199f1 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Feb 2022 13:10:45 -0500 Subject: [PATCH 041/297] Added an error message when failed to add a prestige multiplier. --- docs/changelog_v3.3.x.md | 3 +++ .../prison/spigot/commands/PrisonSpigotSellAllCommands.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 6fe2da9ec..59f327d15 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.1 (alpha.7) 2022-02-03 +* **Added an error message when failed to add a prestige multiplier.** + + * **New feature: cached adding of earnings for the default currency.** This was causing a significant amount of lag/slow down when performing autosell, or spamming of sellall. The lag was in the economy plugin not being able to accept additions of money fast enough. Now this simple cache, will wait 3 seconds before adding the player's earnings to the economy plugin. When it does, it will do so in an async thread so as to not impact any performance in bukkit's main thread. Also prison's getBalance() functions, which includes the use of all prison placeholders, will include the cached amount, which means the player's balances appear as if they are not being cached. 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 8dcf197e0..5a0c4557f 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 @@ -720,6 +720,9 @@ private void sellAllAddMultiplierCommand(CommandSender sender, if (sellAllUtil.addPrestigeMultiplier(prestige, multiplier)){ Output.get().sendInfo(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_add_success)); } + else { + Output.get().sendInfo( sender, "Failed to add sellall prestige multiplier." ); + } } @Command(identifier = "sellall multiplier delete", description = "SellAll delete a multiplier.", permissions = "prison.admin", onlyPlayers = false) From f95a84e36b6e93aeaabf2df7dfa0733d6b7988f5 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Feb 2022 14:30:19 -0500 Subject: [PATCH 042/297] Release v3.3.0-beta.2 --- 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 59f327d15..47ef04c4f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.1 (alpha.7) 2022-02-03 +# 3.3.0-beta.2 (alpha.7) 2022-02-03 + + + +* **v3.3.0-beta.2 2022-02-03** * **Added an error message when failed to add a prestige multiplier.** diff --git a/gradle.properties b/gradle.properties index 3c47c730c..f94e8f6cc 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-beta.1 +version=3.3.0-beta.2 #version=3.3.0-alpha.7 From cb2b1f23a6047b0a77cf34b860756b0c4dd16399 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Feb 2022 14:31:40 -0500 Subject: [PATCH 043/297] Update to knownissues doc --- docs/knownissues_v3.3.x.md | 53 +++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index caa270413..f54d1b7f1 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -8,16 +8,47 @@ # TODO Items for v3.3.0-alpha.7 -- update CMI delayed loading docs... they are "backwards" +- when rank tag = none - show "null" for placeholder +- work on getting CustomItems working in mines again +- sellall get player multiplier needs to be rewritten -- Upon startup the first time, broadcast to everyone that they should use /ranks autoConfigure. +- automatic prestiges +- Docs: + - finish luckperms doc + - Placeholders details - Explain each placeholder -- SELLALL has huge performance issues! It takes 2.3 ms to autosell, and full auto features block handling is 4.2 ms!! Serious performance issue with sellall, and autosell is bypassing the command handler too! +- Rankup commands: placeholders for {promote}{demote} + +- Mine reset notifications logging to console - options? + + +- DONE: /ranks autoConfigure - review setup and maybe enable skip resets and tweak some notification settings. + + +- remove this warning message: no longer used. +[18:58:51 INFO]: | Prison | Cannot initialize NMS components - ClassNotFoundException - NMS is not functional - net.minecraft.server.v1_18_R1.EntityPlayer + + +- DONE: update CMI delayed loading docs... they are "backwards" + + + + +- DONE: Upon startup the first time, broadcast to everyone that they should use /ranks autoConfigure. + - Broadcast failed ranks too. + + +- DONE: RankPlayer addBalance cache for default currency +- RankPlayer addBalance cache for custom currency - still needed! + + +- DONE: SELLALL has huge performance issues! It takes 2.3 ms to autosell, and full auto features block handling is 4.2 ms!! Serious performance issue with sellall, and autosell is bypassing the command handler too! - added 'autosellTiming:' stats to auto features autosell to track actual sell time using nano-seconds... initial tests show there maybe significant performance issues. - autosell in auto features causing lag? Flaco21 - Issue with autosell causing lag? + - DONE: see RankPlayer addBalance cache - 1250 times improvement! - DONE: admin gui - allows them to bypass No Economy safeguards. @@ -34,20 +65,20 @@ - DONE: lapis lazuli is not auto selling -- Problem with actionBar - messages are not goign through. +- Problem with actionBar - messages are not going through. - sellall updates every second - different messages - but never show first one - PlayerMessages - - DONE: No economy error mssage not showing + - DONE: No economy error message not showing - works on delayed startup - Fails when not delayed - gui ranks was registering on top of ranks warning - - block stats based upon drops instead of breakage?? + - block stats based upon drops instead of breakage?? (not sure if this has merit?) --> DONE: Hook in to quests +-> DONE: Hook in to quests - Only on block break events -> Suport for eco enchants: @@ -65,6 +96,14 @@ https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main * ShiftAndRightClickSellAll is not working +* Found a problem with mcMMO, Quest, and EZBlock support... only works on BlockBreakEvents. I added logging to identify when they are called, but if an explosion has 20,000 blocks, then it will log 20,000 times! 😂 So I need to figure out something before hooking it up to multi-block breaks. + + +* sellall - ladder based sellall rank multipliers + - so a ladder value of 0.05 would apply p1 = 1.05, p2 = 1.10, p3 = 1.15, etc... + + + # TODO Items for v3.2.11-alpha.13 From ea70211c8b711d9b72230d522ebd28a6400bc819 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 4 Feb 2022 02:31:38 -0500 Subject: [PATCH 044/297] Bug Fix: When mine reset time is disabled, set to -1, and then all mines are reset with '/mines reset *all* details' it would terminate the reset chain on that mine. This change allows the next mine to be reset by not trying to set this mine's next action... which is none because reset time is -1. --- docs/changelog_v3.3.x.md | 5 ++++- .../mcprison/prison/mines/data/MineScheduler.java | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 47ef04c4f..1c1a97035 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,9 +13,12 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.2 (alpha.7) 2022-02-03 +# 3.3.0-beta.2 (alpha.7) 2022-02-04 +* **Bug Fix: When mine reset time is disabled, set to -1, and then all mines are reset with '/mines reset `*all*` details' it would terminate the reset chain on that mine.** +This change allows the next mine to be reset by not trying to set this mine's next action... which is none because reset time is -1. + * **v3.3.0-beta.2 2022-02-03** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java index 99809701a..7910516b5 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java @@ -330,15 +330,15 @@ public void run() // appears like it will never load? //checkWorld(); - if ( getResetTime() <= 0 ) { + boolean forced = getCurrentJob() != null && + getCurrentJob().getResetType() == MineResetScheduleType.FORCED; + + if ( getResetTime() <= 0 && !forced ) { submitNextAction(); return; } - boolean forced = getCurrentJob() != null && - getCurrentJob().getResetType() == MineResetScheduleType.FORCED; - boolean skip = !forced && isSkipResetEnabled() && getPercentRemainingBlockCount() >= getSkipResetPercent() && @@ -419,7 +419,10 @@ public void run() // } // - submitNextAction(); + if ( getResetTime() > 0 ) { + + submitNextAction(); + } } /** From 67fdb3d227815617162930c7695ba0e655d46397 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 4 Feb 2022 03:20:35 -0500 Subject: [PATCH 045/297] If fail on /mines reset, then needed a missing return so the mine reset success message won't follow the error message. --- docs/changelog_v3.3.x.md | 3 +++ .../tech/mcprison/prison/mines/commands/MinesCommands.java | 1 + 2 files changed, 4 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 1c1a97035..0b1cc8ffb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-04 +* **If fail on /mines reset, then needed a missing return so the mine reset success message won't follow the error message.** + + * **Bug Fix: When mine reset time is disabled, set to -1, and then all mines are reset with '/mines reset `*all*` details' it would terminate the reset chain on that mine.** This change allows the next mine to be reset by not trying to set this mine's next action... which is none because reset time is -1. 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 58796bc96..639c0349e 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 @@ -1353,6 +1353,7 @@ public void resetCommand(CommandSender sender, .withReplacements( m.getName() ) .sendTo(sender); Output.get().logError("Couldn't reset mine " + mineName, e); + return; } pMines.getMinesMessages().getLocalizable("mine_reset") From dbecbd1cffefb850c9642f02c199219a73f5467b Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 5 Feb 2022 01:45:44 -0500 Subject: [PATCH 046/297] Clean up the formatting on `/mines block list` so it's easier to read and looks better. --- docs/changelog_v3.3.x.md | 5 +- .../mines/commands/MinesBlockCommands.java | 59 +++++++++++++------ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0b1cc8ffb..645b65048 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.2 (alpha.7) 2022-02-04 +# 3.3.0-beta.2 (alpha.7) 2022-02-05 + + +* **Clean up the formatting on `/mines block list` so it's easier to read and looks better.** * **If fail on /mines reset, then needed a missing return so the mine reset success message won't follow the error message.** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java index 19cc4303c..50d4608a5 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java @@ -164,6 +164,17 @@ protected BulletedListComponent getBlocksList( Mine m, CommandPagedData cmdPageD PrisonBlock totals = new PrisonBlock( "Totals" ); + int maxBlockNameLength = 8; + + // Find the max block length: + for ( PrisonBlock block : m.getPrisonBlocks() ) { + if ( block.getBlockName().length() > maxBlockNameLength ) { + maxBlockNameLength = block.getBlockName().length(); + } + } + + addBlockStatsHeader( maxBlockNameLength, builder); + for ( PrisonBlock block : m.getPrisonBlocks() ) { double chance = Math.round( block.getChance() * 100.0d ) / 100.0d; @@ -174,7 +185,7 @@ protected BulletedListComponent getBlocksList( Mine m, CommandPagedData cmdPageD if ( cmdPageData == null || count++ >= cmdPageData.getPageStart() && count <= cmdPageData.getPageEnd() ) { - addBlockStats( m, block, iFmt, dFmt, builder ); + addBlockStats( m, block, maxBlockNameLength, iFmt, dFmt, builder ); } } @@ -182,18 +193,31 @@ protected BulletedListComponent getBlocksList( Mine m, CommandPagedData cmdPageD if ( totalChance < 100.0d ) { - builder.add( "&e%s - Air", dFmt.format( 100.0d - totalChance ) + "%" ); + builder.add( "&e%6s - Air", dFmt.format( 100.0d - totalChance ) + "%" ); } if ( includeTotals ) { - addBlockStats( m, totals, iFmt, dFmt, builder ); + addBlockStats( m, totals, maxBlockNameLength, iFmt, dFmt, builder ); } return builder.build(); } - private void addBlockStats( Mine mine, PrisonBlockStatusData block, DecimalFormat iFmt, DecimalFormat dFmt, + private void addBlockStatsHeader( int maxBlockNameLength, BulletedListComponent.BulletedListBuilder builder ) { + RowComponent row = new RowComponent(); + + String rawMessage = "&3Percent %-" + maxBlockNameLength + "s Placed Remaining TotalMined"; + String message = String.format( rawMessage, "Blocks" ); + + row.addTextComponent( message ); + + builder.add( row ); + } + + private void addBlockStats( Mine mine, PrisonBlockStatusData block, + int maxBlockNameLength, + DecimalFormat iFmt, DecimalFormat dFmt, BulletedListComponent.BulletedListBuilder builder ) { RowComponent row = new RowComponent(); @@ -202,7 +226,7 @@ private void addBlockStats( Mine mine, PrisonBlockStatusData block, DecimalForma if ( totals ) { - String text = " &dTotals: "; + String text = String.format( "&d%" + maxBlockNameLength + "s Totals: ", " " ); row.addTextComponent( text ); } else @@ -210,34 +234,34 @@ private void addBlockStats( Mine mine, PrisonBlockStatusData block, DecimalForma String percent = dFmt.format( block.getChance() ) + "%"; - String text = String.format( "&7%6s - %-20s ", percent, block.getBlockName() ); + String text = String.format( "&7%6s - %-" + maxBlockNameLength + "s ", percent, block.getBlockName() ); FancyMessage msg = new FancyMessage( text ) .suggest( "/mines block set " + mine.getName() + " " + block.getBlockName() + " %" ) .tooltip( "&7Click to edit the block's chance." ); row.addFancy( msg ); } - String text1 = String.format( (totals ? "&b%-7s " : "&3Pl: &7%-7s "), + String text1 = String.format( (totals ? " &b%9s " : " &7%9s "), iFmt.format( block.getBlockPlacedCount() ) ); - FancyMessage msg1 = new FancyMessage( text1 ).tooltip( "&7Number of blocks of this type &3Pl&7aced in this mine." ); + FancyMessage msg1 = new FancyMessage( text1 ).tooltip( "&7Number of blocks of this type &3Placed &7in this mine." ); row.addFancy( msg1 ); - String text2 = String.format( (totals ? "&b%-7s " : "&3Rm: &7%-7s "), + String text2 = String.format( (totals ? " &b%9s " : " &7%9s "), iFmt.format( block.getBlockPlacedCount() - block.getBlockCountUnsaved() ) ); - FancyMessage msg2 = new FancyMessage( text2 ).tooltip( "&7Number of blocks of this type &3R&7e&3m&7aining." ); + FancyMessage msg2 = new FancyMessage( text2 ).tooltip( "&7Number of blocks of this type &3Remaining&7." ); row.addFancy( msg2 ); - FancyMessage msg3 = new FancyMessage( String.format( (totals ? "&b%-11s " : "&3T: &7%-11s"), + FancyMessage msg3 = new FancyMessage( String.format( (totals ? " &b%11s " : " &7%11s "), PlaceholdersUtil.formattedKmbtSISize( 1.0d * block.getBlockCountTotal(), dFmt, "" ) ) ) .tooltip( "&3T&7otal blocks of this type that have been mined." ); row.addFancy( msg3 ); - FancyMessage msg4 = new FancyMessage( String.format( (totals ? "&b%-9s" : " &3S: &7%-9s"), - PlaceholdersUtil.formattedKmbtSISize( 1.0d * block.getBlockCountTotal(), dFmt, "" ) ) ) - .tooltip( "&7Blocks of this type that have been mined since the server was &3S&7tarted." ); - row.addFancy( msg4 ); +// FancyMessage msg4 = new FancyMessage( String.format( (totals ? "&b%-9s" : " &3S: &7%-9s"), +// PlaceholdersUtil.formattedKmbtSISize( 1.0d * block.getBlockCountTotal(), dFmt, "" ) ) ) +// .tooltip( "&7Blocks of this type that have been mined since the server was &3S&7tarted." ); +// row.addFancy( msg4 ); builder.add( row ); @@ -637,9 +661,10 @@ public void listBlockCommand(CommandSender sender, if ( !m.isVirtual() ) { RowComponent row = new RowComponent(); - row.addTextComponent( "&3Blocks Remaining: &7%s %s%% ", + row.addTextComponent( "&3Blocks Remaining: &7%s %s%% &3out of &7%s", dFmt.format( m.getRemainingBlockCount() ), - fFmt.format( m.getPercentRemainingBlockCount() ) ); + fFmt.format( m.getPercentRemainingBlockCount() ), + dFmt.format( Math.round(m.getBounds().getTotalBlockCount())) ); chatDisplay.addComponent( row ); } From 2f60d966a046f943363684d67ec970ed8434f2f9 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 5 Feb 2022 03:39:54 -0500 Subject: [PATCH 047/297] CustomItems: Hook up on server startup the ability to check for custom blocks when scanning the mines to set the air counts and block counts. --- .../integration/IntegrationManager.java | 55 +++++++++++++++---- .../tech/mcprison/prison/internal/World.java | 2 + .../tech/mcprison/prison/util/Location.java | 4 ++ .../java/tech/mcprison/prison/TestWorld.java | 16 +++++- .../mcprison/prison/mines/data/MineReset.java | 5 +- .../spigot/customblock/CustomItems.java | 6 ++ .../prison/spigot/game/SpigotWorld.java | 42 +++++++++++++- 7 files changed, 113 insertions(+), 17 deletions(-) diff --git a/prison-core/src/main/java/tech/mcprison/prison/integration/IntegrationManager.java b/prison-core/src/main/java/tech/mcprison/prison/integration/IntegrationManager.java index 9f7e2529e..c6d19205c 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/integration/IntegrationManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/integration/IntegrationManager.java @@ -131,27 +131,58 @@ public CustomBlockIntegration getCustomBlockIntegration( PrisonBlockType blockTy { CustomBlockIntegration results = null; - if(integrations.containsKey(IntegrationType.CUSTOMBLOCK)) { - - List cbIntegrations = getAllForType(IntegrationType.CUSTOMBLOCK); + for ( CustomBlockIntegration customBlock : getCustomBlockIntegrations() ) + { + + if ( customBlock.getBlockType() == blockType ) { + results = customBlock; + break; + } + } + +// if(integrations.containsKey(IntegrationType.CUSTOMBLOCK)) { +// +// List cbIntegrations = getAllForType(IntegrationType.CUSTOMBLOCK); +// +// for ( Integration cbIntegration : cbIntegrations ) { +// if ( cbIntegration.hasIntegrated() && cbIntegration instanceof CustomBlockIntegration ) { +// +// CustomBlockIntegration customBlock = (CustomBlockIntegration) cbIntegration; +// +// if ( customBlock.getBlockType() == blockType ) { +// results = customBlock; +// break; +// } +// } +// } +// } + + return results; + + } - for ( Integration cbIntegration : cbIntegrations ) { + public List getCustomBlockIntegrations() + { + List results = new ArrayList<>(); + + if(integrations.containsKey(IntegrationType.CUSTOMBLOCK)) { + + List cbIntegrations = getAllForType(IntegrationType.CUSTOMBLOCK); + + for ( Integration cbIntegration : cbIntegrations ) { if ( cbIntegration.hasIntegrated() && cbIntegration instanceof CustomBlockIntegration ) { CustomBlockIntegration customBlock = (CustomBlockIntegration) cbIntegration; - if ( customBlock.getBlockType() == blockType ) { - results = customBlock; - break; - } + results.add( customBlock ); } } - - } - return results; + + } + return results; } - + public String getIntegrationDetails( IntegrationType integrationType ) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/World.java b/prison-core/src/main/java/tech/mcprison/prison/internal/World.java index 8541c896d..00f70483c 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/World.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/World.java @@ -51,6 +51,7 @@ public interface World { */ public Block getBlockAt(Location location); + public Block getBlockAt( Location location, boolean containsCustomBlocks ); public void setBlock( PrisonBlock block, int x, int y, int z ); @@ -71,4 +72,5 @@ public void setBlocksSynchronously( List tBlocks, MineResetType resetType, PrisonStatsElapsedTimeNanos nanos ); + } diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/Location.java b/prison-core/src/main/java/tech/mcprison/prison/util/Location.java index 0db64010d..07df41a44 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/util/Location.java +++ b/prison-core/src/main/java/tech/mcprison/prison/util/Location.java @@ -138,6 +138,10 @@ public Block getBlockAt() { return world.getBlockAt(this); } + public Block getBlockAt( boolean containsCustomBlocks ) { + return world.getBlockAt( this, containsCustomBlocks ); + } + public void setBlockAsync( PrisonBlock prisonBlock ) { world.setBlockAsync( prisonBlock, this ); } diff --git a/prison-core/src/test/java/tech/mcprison/prison/TestWorld.java b/prison-core/src/test/java/tech/mcprison/prison/TestWorld.java index 72d67a289..873d31269 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/TestWorld.java +++ b/prison-core/src/test/java/tech/mcprison/prison/TestWorld.java @@ -40,17 +40,26 @@ public TestWorld(String name) { this.name = name; } - @Override public String getName() { + @Override + public String getName() { return name; } - @Override public List getPlayers() { + @Override + public List getPlayers() { return null; } - @Override public Block getBlockAt(Location location) { + @Override + public Block getBlockAt(Location location) { return null; } + + @Override + public Block getBlockAt( Location location, boolean containsCustomBlocks ) + { + return null; + } @Override public void setBlock( PrisonBlock block, int x, int y, int z ) { @@ -67,4 +76,5 @@ public void setBlocksSynchronously( List tBlocks, } + } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index 463a13b14..f318ed093 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -16,6 +16,7 @@ import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlockStatusData; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.MineScheduler.MineJob; import tech.mcprison.prison.mines.data.MineScheduler.MineResetActions; @@ -1142,6 +1143,8 @@ else if ( getPrisonBlocks().size() == 1 && World world = worldOptional.get(); + boolean containsCustomBlocks = getPrisonBlockTypes().contains( PrisonBlockType.CustomItems ); + if ( world == null ) { Output.get().logError( String.format( "MineReset: refreshAirCountAsyncTask failure: The world is invalid and " + @@ -1181,7 +1184,7 @@ else if ( getPrisonBlocks().size() == 1 && try { Location targetBlock = new Location(world, x, y, z); - Block tBlock = targetBlock.getBlockAt(); + Block tBlock = targetBlock.getBlockAt( containsCustomBlocks ); boolean xEdge = x == xMin || x == xMax; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java index 06dfe5cad..a4dea5f25 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java @@ -105,6 +105,12 @@ public PrisonBlock getCustomBlock( Block block ) { if ( customBlockId != null ) { results = SpigotPrison.getInstance().getPrisonBlockTypes() .getBlockTypesByName( customBlockId ); + + if ( results != null ) { + + Location loc = new Location( block.getLocation() ); + results.setLocation( loc ); + } } return results; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java index 9689ece74..56160f40a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java @@ -78,7 +78,7 @@ public SpigotWorld(org.bukkit.World bukkitWorld) { * */ @Override - public Block getBlockAt( Location location ) { + public Block getBlockAt( Location location, boolean containsCustomBlocks ) { SpigotBlock sBlock = null; if ( location != null ) { @@ -86,16 +86,56 @@ public Block getBlockAt( Location location ) { org.bukkit.Location bLocation = getBukkitLocation( location ); org.bukkit.block.Block bBlock = bukkitWorld.getBlockAt( bLocation ); + sBlock = SpigotCompatibility.getInstance().getSpigotBlock( bBlock ); if ( sBlock == null ) { sBlock = new SpigotBlock( bBlock, PrisonBlock.AIR.clone() ); } + + + if ( containsCustomBlocks ) { + + List cbIntegrations = + PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); + + for ( CustomBlockIntegration customBlock : cbIntegrations ) + { + PrisonBlock pBlock = customBlock.getCustomBlock( sBlock ); + + if ( pBlock != null ) { + + //if ( Output.get().isDebug() ) +// { +// +// String message = String.format( +// "SpigotWorld.getBlockAt: customBlock: %s " + +// "spigot: %s bukkit: %s", +// pBlock.getBlockName(), sBlock.getBlockName(), +// bBlock.getType().name() ); +// +// Output.get().logInfo( message ); +// } + + sBlock.setBlockName( pBlock.getBlockName() ); + sBlock.setBlockType( customBlock.getBlockType() ); + break; + } + } + } + + } return sBlock; } + + public Block getBlockAt( Location location ) { + return getBlockAt( location, false ); + } + + // public SpigotBlock getSpigotBlockAt(Location location) { // return new SpigotBlock( // bukkitWorld.getBlockAt(SpigotUtil.prisonLocationToBukkit(location))); From e887bcd83b61c4fb75b3a9ac2f4c1c341f320475 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 5 Feb 2022 03:42:43 -0500 Subject: [PATCH 048/297] If cancelAllBlockEventBlockDrops is enabled when it's not valid on the server version, then it will print the error to console, then turn off this features --- docs/changelog_v3.3.x.md | 6 ++++++ .../prison/spigot/block/OnBlockBreakEventCore.java | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 645b65048..21fc7727e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,12 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-05 +* **If cancelAllBlockEventBlockDrops is enabled when it's not valid on the server version, then it will print the error to console, then turn off this features** + + +* **CustomItems: Hook up on server startup the ability to check for custom blocks when scanning the mines to set the air counts and block counts.** + + * **Clean up the formatting on `/mines block list` so it's easier to read and looks better.** 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 34b8e0bbd..c2e03a447 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 @@ -417,10 +417,14 @@ else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && { String message = String.format( "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + - "is not valid for this version of Spigot. Modify the config settings and set " + - "this value to `false`. [%s]", + "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 ); } } From 2bd8308669f28d3658d3fbfa3f064a6645667f9b Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 6 Feb 2022 23:01:49 -0500 Subject: [PATCH 049/297] For CustomBlockIntegrations added getDrops(). This has to be used instead of bukkit's getDrops() since that will return only the base item drops, which are the wrong items. For CustomItems plugin, there currently isn't a getDrops() function in the CustomItems API so instead, the integration's getDrops() returns the block. --- .../integration/CustomBlockIntegration.java | 2 ++ .../spigot/customblock/CustomItems.java | 18 +++++++++++ .../customblock/CustomItemsWrapper.java | 30 +++++++++++++++++++ .../spigot/customblock/HeadsCustomBlocks.java | 16 ++++++++-- 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/prison-core/src/main/java/tech/mcprison/prison/integration/CustomBlockIntegration.java b/prison-core/src/main/java/tech/mcprison/prison/integration/CustomBlockIntegration.java index e9b118296..10d6800a9 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/integration/CustomBlockIntegration.java +++ b/prison-core/src/main/java/tech/mcprison/prison/integration/CustomBlockIntegration.java @@ -2,6 +2,7 @@ import java.util.List; +import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.Block; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; @@ -48,6 +49,7 @@ public CustomBlockIntegration( String keyName, String providerName, public abstract void setCustomBlockIdAsync( PrisonBlock prisonBlock, Location location ); + public abstract List getDrops( PrisonBlock prisonBlock ); public abstract List getCustomBlockList(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java index a4dea5f25..16dde472f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java @@ -6,11 +6,13 @@ import com.jojodmo.customitems.api.CustomItemsAPI; import tech.mcprison.prison.integration.CustomBlockIntegration; +import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.Block; 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.spigot.SpigotPrison; +import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.spigot.spiget.BluesSpigetSemVerComparator; import tech.mcprison.prison.util.Location; @@ -127,6 +129,22 @@ public void setCustomBlockIdAsync( PrisonBlock prisonBlock, Location location ) customItemsWrapper.setCustomBlockIdAsync( prisonBlock, location ); } + @Override + public List getDrops( PrisonBlock prisonBlock ) { + List results = customItemsWrapper.getDrops( prisonBlock ); + + +// PrisonBlock ciPBlock = getCustomBlock( prisonBlock ); +// +// if ( ciPBlock != null ) { +// +// results.add( new ItemStack( 1, ciPBlock ) ); +// +// } + + return results; + } + @Override public List getCustomBlockList() { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java index 9367e3352..970d2d04c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java @@ -1,5 +1,6 @@ package tech.mcprison.prison.spigot.customblock; +import java.util.ArrayList; import java.util.List; import org.bukkit.scheduler.BukkitRunnable; @@ -10,6 +11,7 @@ import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.block.SpigotBlock; +import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.util.Location; public class CustomItemsWrapper { @@ -83,6 +85,34 @@ public void run() { } + /** + *

WARNING: CustomItems does not have a getDrops() function, so there is no way to + * actually get custom drops for CustomItems blocks. All we can do is return the custom + * block. + *

+ * + *

If a getDrops() function is added in the future, then we will be able to hook that up + * with that future version. + *

+ * + * @param prisonBlock + * @return + */ + public List getDrops( PrisonBlock prisonBlock ) { + List results = new ArrayList<>(); + + org.bukkit.inventory.ItemStack bItemStack = CustomItemsAPI.getCustomItem( prisonBlock.getBlockName() ); + + SpigotItemStack sItemStack = new SpigotItemStack( bItemStack ); + + // Fix itemStack's displayName and set to the correct BlockType: + sItemStack.setPrisonBlock( prisonBlock ); + + results.add( sItemStack ); + + return results; + } + public List getCustomBlockList() { return CustomItemsAPI.listBlockCustomItemIDs(); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/HeadsCustomBlocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/HeadsCustomBlocks.java index 0a96df8df..ace0613be 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/HeadsCustomBlocks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/HeadsCustomBlocks.java @@ -1,8 +1,10 @@ package tech.mcprison.prison.spigot.customblock; +import java.util.ArrayList; import java.util.List; import tech.mcprison.prison.integration.CustomBlockIntegration; +import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.Block; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; @@ -55,8 +57,18 @@ public void setCustomBlockIdAsync( PrisonBlock prisonBlock, Location location ) @Override public List getCustomBlockList() { - // TODO Auto-generated method stub - return null; + List results = new ArrayList<>(); + + return results; + } + + + @Override + public List getDrops( PrisonBlock prisonBlock ) + { + List results = new ArrayList<>(); + + return results; } } From 916b13d05b60cd71dd66465735140558c661b4bc Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 6 Feb 2022 23:11:05 -0500 Subject: [PATCH 050/297] Add more support for CustomItems plugin. It appears like this is working really well with auto pickup. It should be noted that the CustomItems' API does not have a getDrops() so it's impossible to get the correctly configured drops for the block, so for now, it will only return the block itself and not any configured drops. Sellall may need to be fixed and there could be some other areas that needs some fine tuning, but so far all is working well. --- docs/changelog_v3.3.x.md | 12 +- .../prison/internal/block/PrisonBlock.java | 2 +- .../internal/block/PrisonBlockStatusData.java | 12 +- .../mcprison/prison/mines/data/BlockOld.java | 5 +- .../autofeatures/AutoManagerFeatures.java | 37 +++-- .../events/PrisonDebugBlockInspector.java | 133 +++++++++++++----- .../spigot/block/OnBlockBreakEventCore.java | 39 ++--- .../spigot/block/OnBlockBreakMines.java | 132 ++++++++++++++--- .../prison/spigot/block/SpigotItemStack.java | 9 ++ .../prison/spigot/game/SpigotWorld.java | 24 +++- 10 files changed, 319 insertions(+), 86 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 21fc7727e..ed785d158 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,17 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.2 (alpha.7) 2022-02-05 +# 3.3.0-beta.2 (alpha.7) 2022-02-06 + + +* **Add more support for CustomItems plugin.** +It appears like this is working really well with auto pickup. It should be noted that the CustomItems' API does not have a getDrops() so it's impossible to get the correctly configured drops for the block, so for now, it will only return the block itself and not any configured drops. +Sellall may need to be fixed and there could be some other areas that needs some fine tuning, but so far all is working well. + + +* **For CustomBlockIntegrations added getDrops().** +This has to be used instead of bukkit's getDrops() since that will return only the base item drops, which are the wrong items. +For CustomItems plugin, there currently isn't a getDrops() function in the CustomItems API so instead, the integration's getDrops() returns the block. * **If cancelAllBlockEventBlockDrops is enabled when it's not valid on the server version, then it will print the error to console, then turn off this features** diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java index d5dbd42af..2e200746f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java @@ -84,7 +84,7 @@ public PrisonBlock( String blockName, boolean block ) { * @param chance */ public PrisonBlock( PrisonBlockType blockType, String blockName, double chance, long blockCountTotal ) { - super( blockName, chance, blockCountTotal ); + super( blockType, blockName, chance, blockCountTotal ); this.blockType = blockType; diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockStatusData.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockStatusData.java index c2ff50d8b..dce71ce66 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockStatusData.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockStatusData.java @@ -3,11 +3,13 @@ import java.text.DecimalFormat; import tech.mcprison.prison.Prison; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.placeholders.PlaceholdersUtil; public abstract class PrisonBlockStatusData { // blockName is more of an internal reference: + private PrisonBlockType blockType; private String blockName; private double chance; @@ -36,9 +38,10 @@ public abstract class PrisonBlockStatusData { private boolean gravity = false; - public PrisonBlockStatusData( String blockName, double chance, long blockCountTotal ) { + public PrisonBlockStatusData( PrisonBlockType blockType, String blockName, double chance, long blockCountTotal ) { super(); + this.blockType = blockType; this.blockName = blockName; this.chance = chance; @@ -396,6 +399,13 @@ public void setBlockName( String blockName ) { this.blockName = blockName; } + public PrisonBlockType getBlockType() { + return blockType; + } + public void setBlockType( PrisonBlockType blockType ) { + this.blockType = blockType; + } + public double getChance() { return chance; } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/BlockOld.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/BlockOld.java index adaeb4fc7..414395046 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/BlockOld.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/BlockOld.java @@ -18,6 +18,7 @@ package tech.mcprison.prison.mines.data; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.internal.block.PrisonBlockStatusData; import tech.mcprison.prison.util.ObsoleteBlockType; @@ -52,14 +53,14 @@ protected BlockOld( ObsoleteBlockType block ) { * Assigns the type and chance */ public BlockOld(ObsoleteBlockType block, double chance, long blockCountTotal) { - super((block == null ? BlockOld.AIR.getBlockName() : block.name()), chance, blockCountTotal); + super( PrisonBlockType.minecraft, (block == null ? BlockOld.AIR.getBlockName() : block.name()), chance, blockCountTotal); this.type = block; // this.chance = chance; } public BlockOld(String blockType, double chance, long blockCountTotal) { - super(blockType, chance, blockCountTotal); + super( PrisonBlockType.minecraft, blockType, chance, blockCountTotal); // this.chance = chance; 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 0e13bf2b7..1b0496823 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 @@ -26,6 +26,7 @@ import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.cache.PlayerCache; import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.output.Output.DebugTarget; @@ -503,8 +504,8 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, // Try to autosell if enabled: - if ( SellAllUtil.get() != null && (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || - pmEvent.isForceAutoSell()) ) { + if ( (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || pmEvent.isForceAutoSell()) && + SellAllUtil.get() != null ) { final long nanoStart = System.nanoTime(); double amount = SellAllUtil.get().sellAllSell( player, itemStack, false, false, true ); @@ -543,7 +544,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, double amount = SellAllUtil.get().sellAllSell( player, itemStack, true, false, false ); autosellTotal += amount; - debugInfo.append( "(keeping: " + itemStack.getName() + " qty: " + itemStack.getAmount() + " value: " + amount + ") "); + debugInfo.append( "(Debug-unsold: " + itemStack.getName() + " qty: " + itemStack.getAmount() + " value: " + amount + ") "); } HashMap extras = SpigotUtil.addItemToPlayerInventory( player, itemStack ); @@ -1595,6 +1596,11 @@ protected void normalDropSmelt( List drops ) { Set xMats = new HashSet<>(); for ( SpigotItemStack sItemStack : drops ) { + if ( sItemStack.getMaterial().getBlockType() == PrisonBlockType.CustomItems ) { + // cannot smelt custom blocks so skip XMaterial: + continue; + } + XMaterial xMat = null; if ( sItemStack.getBukkitStack() != null ) { @@ -1730,10 +1736,19 @@ protected void normalDropBlock( List drops ) { Set xMats = new HashSet<>(); for ( SpigotItemStack sItemStack : drops ) { - XMaterial source = XMaterial.matchXMaterial( sItemStack.getBukkitStack() ); - if ( !xMats.contains( source ) ) { - xMats.add( source ); + if ( sItemStack.getMaterial().getBlockType() == PrisonBlockType.CustomItems ) { + // cannot block custom blocks so skip XMaterial: + continue; + } + + if ( sItemStack.getBukkitStack() != null ) { + + XMaterial source = XMaterial.matchXMaterial( sItemStack.getBukkitStack() ); + + if ( !xMats.contains( source ) ) { + xMats.add( source ); + } } } @@ -1930,10 +1945,10 @@ protected void calculateFortune(SpigotItemStack blocks, int fortuneLevel) { if ( bukkitExtendedFortuneBlockCount > 0 ) { count = bukkitExtendedFortuneBlockCount; + + // The count has the final value so set it as the amount: + blocks.setAmount( count ); } - - // The count has the final value so set it as the amount: - blocks.setAmount( count ); return; } @@ -2407,7 +2422,9 @@ private void calculateDropAdditions(SpigotItemStack itemInHand, List 0 ) { + drops.addAll( adds ); + } } } 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 9719a26a0..36a3df7fb 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 @@ -12,8 +12,12 @@ import com.google.common.eventbus.Subscribe; import tech.mcprison.prison.Prison; +import tech.mcprison.prison.PrisonAPI; +import tech.mcprison.prison.integration.CustomBlockIntegration; import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; +import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.internal.events.player.PrisonPlayerInteractEvent; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.output.Output; @@ -57,9 +61,14 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) { Location location = e.getClicked(); SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); - UUID playerUUID = e.getPlayer().getUUID(); - Mine mine = obbMines.findMine( playerUUID, sBlock, null, null ); +// UUID playerUUID = e.getPlayer().getUUID(); +// Mine mine = obbMines.findMine( playerUUID, sBlock, null, null ); + // Get the mine, and if in a mine, then get the target block: + Mine mine = obbMines.findMine( player.getWrapper(), sBlock, null, null ); + + MineTargetPrisonBlock targetBlock = null; + if ( mine == null ) { player.sendMessage( @@ -69,35 +78,47 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) { } else { + + targetBlock = mine.getTargetPrisonBlock( sBlock ); + + if ( obbMines.isBlockAMatch( targetBlock.getPrisonBlock(), sBlock ) ) { + // Match ... PrisonBlockType and blockName was updated in isBlockAMatch(): + } + +// // Check if it's a custom block, if it is, then change PrisonBlockType and blockName: +// checkForCustomBlock( sBlock, targetBlock ); + + player.sendMessage( String.format( - "&dDebugBlockInfo: &3Mine &7%s. " + - "&5%s &7%s", - mine.getName(), + "&dDebugBlockInfo: &3Mine &7%s &3Rank: &7%s " + + "&5%s &7%s", + mine.getName(), + (mine.getRank() == null ? "---" : mine.getRank().getName()), sBlock.getBlockName(), location.toWorldCoordinates()) ); // Get the mine's targetBlock: - MineTargetPrisonBlock tBlock = mine.getTargetPrisonBlock( sBlock ); +// MineTargetPrisonBlock tBlock = mine.getTargetPrisonBlock( sBlock ); String message = String.format( "&3TargetBlock: &7%s " + "&3Mined: %s%b &3Broke: &7%b", - tBlock.getPrisonBlock().getBlockName(), - (tBlock.isMined() ? "&d" : "&2"), - tBlock.isMined(), - tBlock.isAirBroke() + targetBlock.getPrisonBlock().getBlockName(), + (targetBlock.isMined() ? "&d" : "&2"), + targetBlock.isMined(), + targetBlock.isAirBroke() ); player.sendMessage( message ); String message2 = String.format( " &3Counted: &7%b &3Edge: &7%b " + "&3Exploded: %s%b &3IgnorAllEvents: &7%b", - tBlock.isCounted(), - tBlock.isEdge(), - (tBlock.isExploded() ? "&d" : "&2"), - tBlock.isExploded(), - tBlock.isIgnoreAllBlockEvents() + targetBlock.isCounted(), + targetBlock.isEdge(), + (targetBlock.isExploded() ? "&d" : "&2"), + targetBlock.isExploded(), + targetBlock.isIgnoreAllBlockEvents() ); player.sendMessage( message2 ); @@ -119,14 +140,14 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) { // Debug the block break events: - dumpBlockBreakEvent( player, sBlock ); + dumpBlockBreakEvent( player, sBlock, targetBlock ); + } - } // if (e.getAction() == PrisonPlayerInteractEvent.Action.LEFT_CLICK_BLOCK) { // // Set first position @@ -149,15 +170,32 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) { // } } - public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock ) { + public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTargetPrisonBlock targetBlock ) { List output = new ArrayList<>(); + SpigotBlock checkBlock = sBlock; + +// +// // Get the mine, and if in a mine, then get the target block: +// Mine mine = obbMines.findMine( player.getWrapper(), sBlock, null, null ); +// +// MineTargetPrisonBlock targetBlock = null; +// if ( mine != null ) { +// +// targetBlock = mine.getTargetPrisonBlock( sBlock ); +// } +// +// +// // Check if it's a custom block: +// checkForCustomBlock( checkBlock, targetBlock ); +// + // Save the item held in the player's hand, which should be the prison wand: org.bukkit.inventory.ItemStack heldItem = SpigotCompatibility.getInstance().getItemInMainHand( player.getWrapper() ); BlockBreakEvent bbe = new BlockBreakEvent( sBlock.getWrapper(), player.getWrapper() ); - String blockName = sBlock.getBlockName().toLowerCase(); + String blockName = checkBlock.getBlockName().toLowerCase(); boolean useShovel = blockName.matches( "^clay$|farmland|grass_block|dirt|gravel|mycelium|" + @@ -190,18 +228,24 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock ) { // Temporaily put the tool in the player's hand: SpigotCompatibility.getInstance().setItemInMainHand( player.getWrapper(), tool.getBukkitStack() ); + + //String blockName = sBlk.getBlockName(); + + + output.add( String.format( "&dBlockBreakEvent Dump: &7%s &3%s", - sBlock.getBlockName(), - sBlock.getLocation().toBlockCoordinates() + checkBlock.getBlockName(), + checkBlock.getLocation().toBlockCoordinates() ) ); + output.add( String.format( " &3Tool Used for drops: &2%s", tool.getName() ) ); - printEventStatus( bbe, "-initial-", "", sBlock, tool, output ); + printEventStatus( bbe, "-initial-", "", checkBlock, targetBlock, tool, output ); for ( RegisteredListener listener : bbe.getHandlers().getRegisteredListeners() ) { @@ -218,7 +262,7 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock ) { } printEventStatus( bbe, - listener.getPlugin().getName(), listener.getPriority().name(), sBlock, tool, output ); + listener.getPlugin().getName(), listener.getPriority().name(), checkBlock, targetBlock, tool, output ); } @@ -232,8 +276,34 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock ) { } } + +// private void checkForCustomBlock( SpigotBlock checkBlock, MineTargetPrisonBlock targetBlock ) { +// +// // USE OnBlockBreakMines.isBlockAMatch() instead of this one... +// +// if ( targetBlock != null && targetBlock.getPrisonBlock().getBlockType() == PrisonBlockType.CustomItems ) { +// +// List cbIntegrations = +// PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); +// +// for ( CustomBlockIntegration customBlock : cbIntegrations ) +// { +// PrisonBlock ciPBlock = customBlock.getCustomBlock( checkBlock ); +// +// if ( ciPBlock != null ) { +// +// checkBlock.setBlockType( ciPBlock.getBlockType() ); +// checkBlock.setBlockName( ciPBlock.getBlockName() ); +// +// break; +// } +// } +// } +// } + private void printEventStatus( BlockBreakEvent bbe, - String plugin, String priority, SpigotBlock sBlock, + String plugin, String priority, + SpigotBlock sBlock, MineTargetPrisonBlock targetBlock, SpigotItemStack tool, List output ) { StringBuilder sb = new StringBuilder(); @@ -244,10 +314,9 @@ private void printEventStatus( BlockBreakEvent bbe, // Get a fresh copy of the block to ensure we pickup the latest status: SpigotBlock sBlk = (SpigotBlock) sBlock.getLocation().getBlockAt(); - - + List bukkitDrops = new ArrayList<>(); - obbMines.collectBukkitDrops( bukkitDrops, null, tool, sBlk ); + obbMines.collectBukkitDrops( bukkitDrops, targetBlock, tool, sBlk ); bukkitDrops = obbMines.mergeDrops( bukkitDrops ); sb.append( " &3Plugin: &7" ).append( plugin ).append( " " ) @@ -256,16 +325,16 @@ private void printEventStatus( BlockBreakEvent bbe, sb.append( "&3Canceled: " ).append( isCanceled ? "&c" : "&a" ) .append( isCanceled ? "true " : "false" ); - if ( !sBlock.getBlockName().equalsIgnoreCase( sBlk.getBlockName() )) { - - sb.append( "&a" ).append( sBlk.getBlockName() ).append( " " ); - } +// if ( !sBlock.getBlockName().equalsIgnoreCase( sBlk.getBlockName() )) { +// +// sb.append( " &a" ).append( sBlk.getBlockName() ).append( " " ); +// } if ( !isDropItems ) { - sb.append( "&3No Drops" ); + sb.append( " &3No Drops" ); } output.add( sb.toString() ); 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 c2e03a447..8776cb22d 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 @@ -635,6 +635,8 @@ private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder MineTargetPrisonBlock targetBlock = mine.getTargetPrisonBlock( sBlockHit ); pmEvent.setTargetBlock( targetBlock ); + boolean matchedBlocks = isBlockAMatch( targetBlock.getPrisonBlock(), sBlockHit ); + // If ignore all block events has been set on this target block, then shutdown. // Same if this block was already included in an explosion... prevent it from spawning // more explosions, which could result in a chain reaction. @@ -665,10 +667,10 @@ private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder PrisonBlockStatusData pbTargetBlock = targetBlock.getPrisonBlock(); PrisonBlock pbBlockHit = sBlockHit == null ? null : sBlockHit.getPrisonBlock(); - if ( pbBlockHit != null && pbTargetBlock != null && - pbTargetBlock.equals( pbBlockHit ) && - collectBukkitDrops( pmEvent.getBukkitDrops(), targetBlock, pmEvent.getItemInHand(), sBlockHit )) { + if ( pbBlockHit != null && matchedBlocks ) { + // Confirmed the block is correct... so get the drops... + collectBukkitDrops( pmEvent.getBukkitDrops(), targetBlock, pmEvent.getItemInHand(), sBlockHit ); // If a chain reaction on explosions, this will prevent the same block from // being processed more than once: @@ -764,33 +766,35 @@ private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder for ( Block bukkitBlock : pmEvent.getUnprocessedRawBlocks() ) { - SpigotBlock sBlock = SpigotBlock.getSpigotBlock( bukkitBlock ); + SpigotBlock sBlockMined = SpigotBlock.getSpigotBlock( bukkitBlock ); // Thanks to CrazyEnchant, there is no telling which block was actually hit, so // if using CrazyEnchant one of the unprocessedRawBlocks may be the same as the // pmEvent.getSpigotBlock(), so ignore if both are the same. - if ( !sBlock.equals( sBlockHit ) ) { + if ( !sBlockMined.equals( sBlockHit ) ) { - if ( !mine.isInMineExact( sBlock.getLocation() ) ) { + if ( !mine.isInMineExact( sBlockMined.getLocation() ) ) { outsideOfMine++; } - else if ( BlockUtils.getInstance().isUnbreakable( sBlock ) ) { + else if ( BlockUtils.getInstance().isUnbreakable( sBlockMined ) ) { unbreakable++; } - else if ( sBlock.isEmpty() ) { + else if ( sBlockMined.isEmpty() ) { alreadyMined++; } else { // Get the mine's targetBlock: - MineTargetPrisonBlock targetExplodedBlock = mine.getTargetPrisonBlock( sBlock ); + MineTargetPrisonBlock targetExplodedBlock = mine.getTargetPrisonBlock( sBlockMined ); + + boolean matchedExplodedBlocks = isBlockAMatch( targetExplodedBlock.getPrisonBlock(), sBlockMined ); if ( targetExplodedBlock == null || targetExplodedBlock.getPrisonBlock() == null ) { // No targetBlock so add it anyway: - pmEvent.getExplodedBlocks().add( sBlock ); + pmEvent.getExplodedBlocks().add( sBlockMined ); noTargetBlock++; } @@ -805,27 +809,28 @@ else if ( targetExplodedBlock.isMined() ) { // Check to make sure the block is the same block that was placed there. // If not, then do not process it. - SpigotBlock sBlockMined = SpigotBlock.getSpigotBlock( bukkitBlock ); +// SpigotBlock sBlockMined = SpigotBlock.getSpigotBlock( bukkitBlock ); PrisonBlock pBlockMined = sBlockMined.getPrisonBlock(); PrisonBlockStatusData pbTargetExploded = targetExplodedBlock.getPrisonBlock(); - if ( pBlockMined!= null && pbTargetExploded != null && - pbTargetExploded.equals( pBlockMined ) && - collectBukkitDrops( pmEvent.getBukkitDrops(), targetExplodedBlock, pmEvent.getItemInHand(), sBlockMined ) ) { + if ( pBlockMined!= null && matchedExplodedBlocks ) { + + // Confirmed the block is correct... so get the drops... + collectBukkitDrops( pmEvent.getBukkitDrops(), targetExplodedBlock, pmEvent.getItemInHand(), sBlockMined ); // If a chain reaction on explosions, this will prevent the same block from // being processed more than once: targetExplodedBlock.setMined( true ); - targetExplodedBlock.setMinedBlock( sBlock ); + targetExplodedBlock.setMinedBlock( sBlockMined ); // Mark the block as being part of an explosion, if it was: targetExplodedBlock.setExploded( isExplosionEvent ); - pmEvent.getExplodedBlocks().add( sBlock ); + pmEvent.getExplodedBlocks().add( sBlockMined ); pmEvent.getTargetExplodedBlocks().add( targetExplodedBlock ); @@ -1064,6 +1069,8 @@ else if ( results && pmEvent.isMonitor() && mine != null ) { return results; } + + // private boolean collectBukkitDrops( List bukkitDrops, MineTargetPrisonBlock targetBlock, // SpigotItemStack itemInHand, SpigotBlock sBlockMined ) // { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java index 671f1098a..5719e06bf 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java @@ -10,7 +10,13 @@ import org.bukkit.entity.Player; import tech.mcprison.prison.Prison; +import tech.mcprison.prison.PrisonAPI; +import tech.mcprison.prison.integration.CustomBlockIntegration; +import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; +import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.internal.block.PrisonBlockStatusData; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.modules.Module; @@ -233,47 +239,136 @@ public void checkZeroBlockReset( Mine mine ) { } } + + public boolean isBlockAMatch( PrisonBlockStatusData pbTargetBlock, PrisonBlock pbBlockHit ) + { + boolean results = false; + + if ( pbTargetBlock != null && pbBlockHit != null ) { + if ( pbTargetBlock.getBlockType() == PrisonBlockType.CustomItems ) { + // The pbBlockHit will never match the pbTargetBlock.. must check the actual block: + + List cbIntegrations = + PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); + + for ( CustomBlockIntegration customBlock : cbIntegrations ) + { + String cbId = customBlock.getCustomBlockId( pbBlockHit ); + + if ( cbId != null ) { + + if ( pbTargetBlock.getBlockName().equalsIgnoreCase( cbId ) ) { + + pbBlockHit.setBlockType( customBlock.getBlockType() ); + pbBlockHit.setBlockName( cbId ); + + results = true; + break; + } + } + } + + } + else if ( pbTargetBlock != null && pbBlockHit != null ) { + + results = pbTargetBlock.equals( pbBlockHit ); + } + } + + return results; + } + + /** + *

This function is only called once it has been confirmed that the block is the correct one, that + * it matches the the targetBlock. All validation on if the block is correct, or not, has been + * removed since this is not the place for the checks. + *

+ * + *

The function isBlockAMatch() should be used prior to calling this function. + *

+ * + * @param bukkitDrops + * @param targetBlock + * @param itemInHand + * @param sBlockMined + * @return + */ public boolean collectBukkitDrops( List bukkitDrops, MineTargetPrisonBlock targetBlock, SpigotItemStack itemInHand, SpigotBlock sBlockMined ) { boolean results = false; + if ( targetBlock != null && targetBlock.getPrisonBlock().getBlockType() == PrisonBlockType.CustomItems ) { + + List cbIntegrations = + PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); + + for ( CustomBlockIntegration customBlock : cbIntegrations ) + { + List drops = customBlock.getDrops( sBlockMined ); + + for ( ItemStack drop : drops ) + { + bukkitDrops.add( (SpigotItemStack) drop ); + results = true; + } + } + + } + + + // if ( sBlockMined == null && targetBlock.getMinedBlock() != null ) { // sBlockMined = (SpigotBlock) targetBlock.getMinedBlock(); // } // SpigotBlock sBlock = (SpigotBlock) targetBlock.getMinedBlock(); // If in the mine, then need a targetBlock, otherwise if it's null then get drops anyway: - if ( sBlockMined != null && - ( targetBlock == null || - targetBlock.getPrisonBlock().equals( sBlockMined.getPrisonBlock() ) - ) ) + if ( !results && sBlockMined != null +// && ( targetBlock == null || +// targetBlock.getPrisonBlock().equals( sBlockMined.getPrisonBlock() ) +// ) + ) { + - List drops = SpigotUtil.getDrops( sBlockMined, itemInHand ); - - bukkitDrops.addAll( drops ); - + getSpigotDrops( bukkitDrops, sBlockMined, itemInHand ); + //// This clears the drops for the given block, so if the event is //// not canceled, it will //// not result in duplicate drops. // if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { // sBlock.clearDrops(); // } - + results = true; } - else if ( sBlockMined != null ) - { - Output.get().logWarn( "collectBukkitDrops: block was changed and not what was expected. " + "Block: " + - sBlockMined.getBlockName() + " expecting: " + - (targetBlock == null ? "(nothing)" : targetBlock.getPrisonBlock().getBlockName()) ); - } +// else if ( !results && sBlockMined != null ) +// { +// Output.get().logWarn( "collectBukkitDrops: block was changed and not what was expected. " + "Block: " + +// sBlockMined.getBlockName() + " expecting: " + +// (targetBlock == null ? "(nothing)" : targetBlock.getPrisonBlock().getBlockName()) ); +// } return results; } + + /** + *

This gets the bukkit drops... + *

+ * + * @param bukkitDrops + * @param sBlockMined + * @param itemInHand + */ + private void getSpigotDrops( List bukkitDrops, SpigotBlock sBlockMined, SpigotItemStack itemInHand ) + { + List drops = SpigotUtil.getDrops( sBlockMined, itemInHand ); + + bukkitDrops.addAll( drops ); + } public void clearBukkitDrops( List bukkitDrops, MineTargetPrisonBlock targetBlock ) @@ -297,8 +392,12 @@ public void clearBukkitDrops( List bukkitDrops, MineTargetPriso */ public List mergeDrops( List drops ) { + if ( drops.size() <= 1 ) { + return drops; + } TreeMap results = new TreeMap<>(); + boolean changed = false; for ( SpigotItemStack drop : drops ) { String key = drop.getName(); if ( !results.containsKey( key ) ) { @@ -308,10 +407,11 @@ public List mergeDrops( List drops ) SpigotItemStack sItemStack = results.get( key ); sItemStack.setAmount( sItemStack.getAmount() + drop.getAmount() ); + changed = true; } } - return new ArrayList<>( results.values() ); + return changed ? new ArrayList<>( results.values() ) : drops; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java index f7a76494b..efe5ab084 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java @@ -91,6 +91,15 @@ public SpigotItemStack(int amount, PrisonBlock material, String... lore) { super( amount, material, lore ); } + + public void setPrisonBlock( PrisonBlock pBlock ) { + + String displayName = pBlock.getBlockName(); + + setDisplayName( displayName ); + + setMaterial( pBlock ); + } /** *

This function overrides the Prison's ItemStack class's setAmount() to perform the diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java index 56160f40a..9f13040c7 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java @@ -240,14 +240,24 @@ public void run() { } } catch ( Exception e ) { - String blkName = current.getPrisonBlock().getBlockName(); - PrisonBlock pBlock = current.getPrisonBlock( resetType ); - String resetTypeBlockName = pBlock == null ? "null" : pBlock.getBlockName(); - Output.get().logError( - String.format( "SpigotWorld.setBlocksSynchronously: %s resetType: %s %s", - blkName, resetType.name(), resetTypeBlockName ), e ); -// e.printStackTrace(); + if ( current != null ) { + + String blkName = current.getPrisonBlock().getBlockName(); + PrisonBlock pBlock = current.getPrisonBlock( resetType ); + String resetTypeBlockName = pBlock == null ? "null" : pBlock.getBlockName(); + + Output.get().logError( + String.format( "SpigotWorld.setBlocksSynchronously: %s resetType: %s %s", + blkName, resetType.name(), resetTypeBlockName ), e ); + } + else { + + Output.get().logError( + String.format( "SpigotWorld.setBlocksSynchronously: --noBlock-- resetType: %s " + + "[unable to set 'current']", + resetType.name() ), e ); + } } long elapsedNanos = System.nanoTime() - start; From 128679cc681b416fb54c36b00920489f06311e6a Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 7 Feb 2022 01:12:55 -0500 Subject: [PATCH 051/297] Update CustomItems api from v3.7.17 to v4.1.3. This newer version of the API still does not have a getDrops() function. --- docs/changelog_v3.3.x.md | 6 +++++- prison-spigot/lib/CustomItems_v3.7.17_api.jar | Bin 3234 -> 0 bytes prison-spigot/lib/CustomItems_v4.1.3_api.jar | Bin 0 -> 14678 bytes 3 files changed, 5 insertions(+), 1 deletion(-) delete mode 100644 prison-spigot/lib/CustomItems_v3.7.17_api.jar create mode 100644 prison-spigot/lib/CustomItems_v4.1.3_api.jar diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ed785d158..ed7c50a3f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.2 (alpha.7) 2022-02-06 +# 3.3.0-beta.2 (alpha.7) 2022-02-07 + + +* **Update CustomItems api from v3.7.17 to v4.1.3.** +This newer version of the API still does not have a getDrops() function. * **Add more support for CustomItems plugin.** diff --git a/prison-spigot/lib/CustomItems_v3.7.17_api.jar b/prison-spigot/lib/CustomItems_v3.7.17_api.jar deleted file mode 100644 index 7ee7c654a2af84483a92391a81e6db6fb4e49903..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3234 zcmai$cTf}98pRQa0wTTlB1#D;B@`PSj3^}ZCJ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J)jA-JDR@t#GT~mPT^hqv%C!6&Yy}?WsXeA%6}rK|CWuVareB5V)HWZje@MVZ z-W9*1W!|{j7_V@QS|2`mzi?sBN{pfdkd%8?x+SQadonDMY=37wg{%of+`r%7dzy0U zuyeNjwva#Lvp9DqsN%(~2#CQkY6hy`W9$(P{!M>E?e7ymvG$k5j>eyfUy%Fz*$lcsO05bg0IOtDVPU?5kBx6rn-tZw81E_w|StWJ``>Q2L~AtAl%7IFTh$G ztPJ*am$$YE^fxkhHUoQ~mvb@kM!M^``CbpOchXeT)v~s9^7DkCtW=>8b8mg5srxm* Mprcx(vWwM!06utnm;e9( diff --git a/prison-spigot/lib/CustomItems_v4.1.3_api.jar b/prison-spigot/lib/CustomItems_v4.1.3_api.jar new file mode 100644 index 0000000000000000000000000000000000000000..3dcddf750d603207369aca8fdaefae1835a8afcf GIT binary patch literal 14678 zcmb7rWpEr@lcgL-%*@QpEQ_tRcjk-l&5NBkvsr(# zt2$5LuDB6-@@5`+DNr!fPf$=$pA4}?lt2B&z<&Eib~f~&pX8+=q5eDo`Ol~F|7{H1 zf5uqaS=t%f*!_RSV*V}G$i>Oo&c?#o#K!3#aZLZVZrp#sF|fDz|H5MUAFzZ}B*aW? zO&l$ZBz~`x&dA!p$thXQN(tu(%~w}PT>~8i)`(Es#)yQprbfvqs&+2`J{~kpeH-0e zYQPeHOhmCTH~`3&T4XWn1#BvvYXhci@+~K#V=_-b@)%9sQ`|$|6WmKtC_Q?(E$tct zmixv}H|mdgukJGLGU~^^ez;wce9G?C0~55g5NPb0j~*QxdRb zTmK{F-bhqbPB#6gkjHsb*6Kch0vy*392>IkHayjTy;JJpoveq8ujJ*qAm*d( zbAjd2YsLk4)e7$<74c4|BF-3cyv~(_sR5-&F2bI&WTZ`BfcJ^dbCEvje>qRzIi5+m zujtvCzK51}lci42?`h^)9*vKEZ0Ss3rde%Q<9=lbN+lbz0#SJ$AZTP_q|ves;@G<@ z4JI`U4s%3sD|PzW4<{#GaHN!o63t#kC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sVog=f-Il;-n^*O=LTs>K*)twY4h@n%a=u8 zIJ)u;H=hD6I(r4GRuv~b(^WUNZp>4o5wv1eq1v*#h3495v23)D()OebeuvmMz%6`P z{QdEoZ)r6>JbTy7*f*)`%e9lK{L%4qgHNQUT-FR{3zKT1}uBAbMb$*j;H`Qmlw&PL} zXgcee7oBiD<&(NV2yqU|FM|*5fKj6L_-5-Dy>+bM0!47PO9%~-F{_fgXi@%5|0fx? ziGUTIiT~TcKL0b)|4VcB zcl5vZ?EWjdAoTx${{NUs|2z6$%kMvZzkeIu@0apVZ{hda|JDWkJN946)1LzV-_}F< zzrz0S%K5+l&|f#^A1?N9)BD}%{9pWu|6peFQsBRL_oq+Lzpwe^|&!_(b)Hj#Z literal 0 HcmV?d00001 From 697c1221c097ad9bffd629299a62cd09a3879f88 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 7 Feb 2022 01:25:53 -0500 Subject: [PATCH 052/297] Changed around the logging of messages related to the use of autofeatures autosell. Added permissions to enable autosell on a per block. --- docs/changelog_v3.3.x.md | 4 ++++ .../autofeatures/AutoFeaturesFileConfig.java | 4 +++- .../spigot/autofeatures/AutoManagerFeatures.java | 15 ++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ed7c50a3f..f813ff252 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-07 +* **Changed around the logging of messages related to the use of autofeatures autosell.** +Added permissions to enable autosell on a per block. + + * **Update CustomItems api from v3.7.17 to v4.1.3.** This newer version of the API still does not have a getDrops() function. 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 d1e440b4f..89c58b32c 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 @@ -123,7 +123,9 @@ public enum AutoFeatures { isAutoSellPerBlockBreakEnabled(inventory, false), -// isAutoSellPerBlockBreakInlinedEnabled(general, false), + permissionAutoSellPerBlockBreakEnabled(inventory, "prison.automanager.autosell"), +// + isAutoSellPerBlockBreakInlinedEnabled(general, false), isAutoSellIfInventoryIsFull(inventory, true), 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 1b0496823..cb38e08c5 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 @@ -492,6 +492,8 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, } + DecimalFormat fFmt = new DecimalFormat("#,##0.0000"); + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); double autosellTotal = 0; double autosellUnsellableCount = 0; @@ -504,7 +506,9 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, // Try to autosell if enabled: - if ( (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || pmEvent.isForceAutoSell()) && + if ( (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || + pmEvent.isForceAutoSell() || + player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) && SellAllUtil.get() != null ) { final long nanoStart = System.nanoTime(); @@ -518,7 +522,8 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, amount, mineName ); if ( amount != 0 ) { - debugInfo.append( "(sold: " + itemStack.getName() + " qty: " + itemStack.getAmount() + " value: " + amount + ") "); + debugInfo.append( "(sold: " + itemStack.getName() + " qty: " + itemStack.getAmount() + + " value: " + dFmt.format( amount ) + ") "); // Set to zero quantity since they have all been sold. itemStack.setAmount( 0 ); @@ -544,7 +549,8 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, double amount = SellAllUtil.get().sellAllSell( player, itemStack, true, false, false ); autosellTotal += amount; - debugInfo.append( "(Debug-unsold: " + itemStack.getName() + " qty: " + itemStack.getAmount() + " value: " + amount + ") "); + debugInfo.append( "(Debug-unsold-value-check: " + itemStack.getName() + + " qty: " + itemStack.getAmount() + " value: " + dFmt.format( amount ) + ") "); } HashMap extras = SpigotUtil.addItemToPlayerInventory( player, itemStack ); @@ -578,11 +584,10 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, if ( count > 0 || autosellTotal > 0 ) { - debugInfo.append( "[autoPickupDrops total: qty: " + count + " value: " + autosellTotal + + debugInfo.append( "[autoPickupDrops total: qty: " + count + " value: " + dFmt.format( autosellTotal ) + " unsellableCount: " + autosellUnsellableCount ); if ( nanoTime > 0 ) { - DecimalFormat fFmt = new DecimalFormat("#,##0.0000"); final double autoSellTimeMs = ( nanoTime / 1000000.0d ); debugInfo.append( " autosellTiming: " ) .append( fFmt.format( autoSellTimeMs ) ) From f31bd9425cc4f1342ab7e582da5586b948e87b39 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 7 Feb 2022 04:18:52 -0500 Subject: [PATCH 053/297] Added a few new placeholders and a new placeholder type of PLAYERBLOCKS. Added raws to the player_block_total per mine. Added player_blocks_total and its raw counts, which is a PLAYERBLOCKS. --- docs/changelog_v3.3.x.md | 8 ++ .../mcprison/prison/cache/PlayerCache.java | 10 +- .../placeholders/PlaceholderManager.java | 14 ++- .../prison/mines/managers/MineManager.java | 99 ++++++++++++++++++- .../api/PrisonMinesBlockBreakEvent.java | 15 ++- .../placeholder/SpigotPlaceholders.java | 4 +- 6 files changed, 141 insertions(+), 9 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index f813ff252..c50d44abb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,14 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-07 +* **Added a few new placeholders and a new placeholder type of PLAYERBLOCKS.** +Added raws to the player_block_total per mine. Added player_blocks_total and its raw counts, which is a PLAYERBLOCKS. + + +* **Added a few new placeholders and a new placeholder type of PLAYERBLOCKS.** +Added raws to the player_block_total per mine. Added player_blocks_total and its raw counts, which is a PLAYERBLOCKS. + + * **Changed around the logging of messages related to the use of autofeatures autosell.** Added permissions to enable autosell on a per block. diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java index 9646746a7..6aee36ca2 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java @@ -9,6 +9,7 @@ import java.util.TreeSet; import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.internal.block.PrisonBlockStatusData; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.tasks.PrisonTaskSubmitter; @@ -371,7 +372,14 @@ public PlayerCacheRunnable submitCacheUpdatePlayerStats() { public void addPlayerBlocks( Player player, String mine, PrisonBlockStatusData block, int quantity ) { - addPlayerBlocks( player, mine, block.getBlockName(), quantity ); + if ( block.getBlockType() == PrisonBlockType.minecraft ) { + addPlayerBlocks( player, mine, block.getBlockName(), quantity ); + } + else { + String blockName = block.getBlockType() + ":" + block.getBlockName(); + addPlayerBlocks( player, mine, blockName, quantity ); + } + } // public void addPlayerBlocks( Player player, String mine, PrisonBlock block, int quantity ) { // addPlayerBlocks( player, mine, block.getBlockName(), quantity ); diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java index 01a9fc0cc..41c4ce01e 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java @@ -15,6 +15,7 @@ public class PlaceholderManager { public static final String PRISON_PLACEHOLDER_MINENAME_SUFFIX = "_minename"; public static final String PRISON_PLACEHOLDER_LADDERNAME_SUFFIX = "_laddername"; public static final String PRISON_PLACEHOLDER_RANKNAME_SUFFIX = "_rankname"; + public static final String PRISON_PLACEHOLDER_PLAYERBLOCK_SUFFIX = "__blockname"; public static final String PRISON_PLACEHOLDER_ATTRIBUTE_FIELD_SEPARATOR = ":"; public static final String PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR = @@ -38,6 +39,7 @@ public enum PlaceholderFlags { MINES, MINEPLAYERS, + PLAYERBLOCKS, STATSMINES( true ), STATSRANKS( true ), @@ -286,8 +288,16 @@ public enum PrisonPlaceHolders { prison_player_blocks_total_formatted(prison_pbtf, PlaceholderFlags.PLAYER), - prison_pbtm(PlaceholderFlags.MINEPLAYERS, PlaceholderFlags.ALIAS), - prison_player_blocks_total_minename(prison_pbtm, PlaceholderFlags.MINEPLAYERS), + prison_pbt_minename(PlaceholderFlags.MINEPLAYERS, PlaceholderFlags.ALIAS), + prison_pbtr_minename(PlaceholderFlags.MINEPLAYERS, PlaceholderFlags.ALIAS), + prison_player_blocks_total_minename(prison_pbt_minename, PlaceholderFlags.MINEPLAYERS), + prison_player_blocks_total_raw_minename(prison_pbtr_minename, PlaceholderFlags.MINEPLAYERS), + + + prison_ptb__blockname(PlaceholderFlags.PLAYERBLOCKS, PlaceholderFlags.ALIAS), + prison_player_total_blocks__blockname(prison_ptb__blockname, PlaceholderFlags.PLAYERBLOCKS), + prison_ptbr__blockname(PlaceholderFlags.PLAYERBLOCKS, PlaceholderFlags.ALIAS), + prison_player_total_blocks_raw__blockname(prison_ptbr__blockname, PlaceholderFlags.PLAYERBLOCKS), diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java index b7234790f..3e79c433b 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java @@ -24,6 +24,7 @@ import java.util.Optional; import java.util.Set; import java.util.TreeMap; +import java.util.TreeSet; import java.util.UUID; import tech.mcprison.prison.Prison; @@ -31,6 +32,7 @@ import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.World; import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.mines.data.MineScheduler.MineResetActions; @@ -798,7 +800,7 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place mine = getMine( placeHolderKey.getData() ); } - if ( mine != null ) { + if ( mine != null || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS )) { DecimalFormat dFmt = new DecimalFormat("#,##0.00"); DecimalFormat iFmt = new DecimalFormat("#,##0"); // DecimalFormat fFmt = new DecimalFormat("#,##0.00"); @@ -1254,14 +1256,20 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place // break; // - case prison_pbtm: + case prison_pbt_minename: case prison_player_blocks_total_minename: + case prison_pbtr_minename: + case prison_player_blocks_total_raw_minename: if ( !mine.isVirtual() && player != null ) { long blocksTotalByMine = PlayerCache.getInstance() .getPlayerBlocksTotalByMine( player, mine.getName() ); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { + if ( placeHolderKey.getPlaceholder() == PrisonPlaceHolders.prison_pbtr_minename || + placeHolderKey.getPlaceholder() == PrisonPlaceHolders.prison_player_blocks_total_raw_minename ) { + results = Long.toString( blocksTotalByMine ); + } + else if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { PlaceholderAttributeNumberFormat attributeNF = (PlaceholderAttributeNumberFormat) attribute; results = attributeNF.format( blocksTotalByMine ); @@ -1275,6 +1283,32 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place break; + case prison_ptb__blockname: + case prison_player_total_blocks__blockname: + case prison_ptbr__blockname: + case prison_player_total_blocks_raw__blockname: + { + String blockName = placeHolderKey.getData().replace( "-", ":" ); + + long blockCount = player.getPlayerCache().getPlayerBlocksTotalByBlockType( player, blockName ); + + if ( placeHolderKey.getPlaceholder() == PrisonPlaceHolders.prison_ptbr__blockname || + placeHolderKey.getPlaceholder() == PrisonPlaceHolders.prison_player_total_blocks_raw__blockname ) { + results = Long.toString( blockCount ); + } + else if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { + PlaceholderAttributeNumberFormat attributeNF = + (PlaceholderAttributeNumberFormat) attribute; + results = attributeNF.format( blockCount ); + } + else { + + results = iFmt.format( blockCount ); + } + + } + break; + default: break; } @@ -1542,6 +1576,8 @@ public List getTranslatedPlaceHolderKeys() { if ( translatedPlaceHolderKeys == null ) { translatedPlaceHolderKeys = new ArrayList<>(); + TreeSet blockNames = new TreeSet<>(); + List placeHolders = PrisonPlaceHolders.getTypes( PlaceholderFlags.MINES ); @@ -1571,6 +1607,17 @@ public List getTranslatedPlaceHolderKeys() { // PlaceHolderKey placeholder2 = new PlaceHolderKey(key2, ph, mine.getName(), false ); // translatedPlaceHolderKeys.add( placeholder2 ); + // capture all of the possible blocks used within the mines: + for ( PrisonBlock block : mine.getPrisonBlocks() ) { + + String blockName = block.getBlockType() == PrisonBlockType.minecraft ? + block.getBlockName().toLowerCase() : + block.getBlockNameFormal().replace( ":", "-" ).toLowerCase(); + + if ( !blockNames.contains( blockName ) ) { + blockNames.add( blockName ); + } + } } } @@ -1618,6 +1665,52 @@ public List getTranslatedPlaceHolderKeys() { translatedPlaceHolderKeys.add( placeholder ); } } + + + + // Next we need to register all the PLAYERMINES. The mines are dynamic, based upon which one + // the player is in. So this is just a simple registration. + List placeHoldersBN = + PrisonPlaceHolders.getTypes( PlaceholderFlags.PLAYERBLOCKS ); + + for ( PrisonPlaceHolders bn : placeHoldersBN ) { + String key = bn.name().toLowerCase(); + + // There is a special condition when a MINEPLAYERS placeholder may have a suffix of + // _minename so they need to be expanded the same as a MINES placeholder. + if ( key.endsWith( PlaceholderManager.PRISON_PLACEHOLDER_PLAYERBLOCK_SUFFIX ) ) { + + for ( String blockName : blockNames ) { + String mineKey = bn.name().replace( + PlaceholderManager.PRISON_PLACEHOLDER_PLAYERBLOCK_SUFFIX, "_" + blockName ). + toLowerCase(); + + PlaceHolderKey placeholder = new PlaceHolderKey(mineKey, bn, blockName ); + if ( bn.getAlias() != null ) { + String aliasName = bn.getAlias().name().replace( + PlaceholderManager.PRISON_PLACEHOLDER_PLAYERBLOCK_SUFFIX, "_" + blockName ). + toLowerCase(); + placeholder.setAliasName( aliasName ); + } + translatedPlaceHolderKeys.add( placeholder ); + } +// PlaceHolderKey placeholder = new PlaceHolderKey(key, ph ); +// if ( ph.getAlias() != null ) { +// String aliasName = ph.getAlias().name().toLowerCase(); +// placeholder.setAliasName( aliasName ); +// } +// translatedPlaceHolderKeys.add( placeholder ); + } + else { + + PlaceHolderKey placeholder = new PlaceHolderKey(key, bn ); + if ( bn.getAlias() != null ) { + String aliasName = bn.getAlias().name().toLowerCase(); + placeholder.setAliasName( aliasName ); + } + translatedPlaceHolderKeys.add( placeholder ); + } + } } return translatedPlaceHolderKeys; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java index 69ae4f74d..1d0124fcb 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java @@ -10,6 +10,7 @@ import org.bukkit.event.block.BlockBreakEvent; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; +import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType; import tech.mcprison.prison.spigot.block.SpigotBlock; @@ -223,12 +224,22 @@ public TreeMap getTargetBlockCounts() { TreeMap results = new TreeMap<>(); if ( getTargetBlock() != null ) { - results.put( getTargetBlock().getPrisonBlock().getBlockName(), 1 ); + results.put( + getTargetBlock().getPrisonBlock().getBlockType() == PrisonBlockType.minecraft ? + getTargetBlock().getPrisonBlock().getBlockName() : + getTargetBlock().getPrisonBlock().getBlockType() + ":" + getTargetBlock().getPrisonBlock().getBlockName() + , 1 ); } for ( MineTargetPrisonBlock targetBlock : getTargetExplodedBlocks() ) { - String blockName = targetBlock.getPrisonBlock().getBlockName(); + String blockName = + targetBlock.getPrisonBlock().getBlockType() == PrisonBlockType.minecraft ? + targetBlock.getPrisonBlock().getBlockName() : + targetBlock.getPrisonBlock().getBlockType() + ":" + targetBlock.getPrisonBlock().getBlockName(); + + // targetBlock.getPrisonBlock().getBlockName(); + int count = 1 + ( results.containsKey( blockName ) ? results.get( blockName ) : 0) ; results.put( blockName, count ); } 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 a10274ecd..18fb1597c 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 @@ -432,7 +432,9 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin PlaceholderAttribute attribute = null; value = mm.getTranslateMinesPlaceHolder( placeHolderKey, attribute, -1 ); } - if ( mm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ))) { + if ( mm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) + )) { PlaceholderAttribute attribute = null; value = mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, placeHolderKey, attribute, -1 ); From b6a6253c62ba7c92f3e18ebda9c20e08f9e622a3 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 7 Feb 2022 13:45:08 -0500 Subject: [PATCH 054/297] Upgrade gradle from v7.0.2 to v7.1. --- docs/changelog_v3.3.x.md | 3 +++ gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 59536 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c50d44abb..947d0073e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-07 +* **Upgrade gradle from v7.0.2 to v7.1.** + + * **Added a few new placeholders and a new placeholder type of PLAYERBLOCKS.** Added raws to the player_block_total per mine. Added player_blocks_total and its raw counts, which is a PLAYERBLOCKS. diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c023ec8b20f512888fe07c5bd3ff77bb8f..7454180f2ae8848c63b8b4dea2cb829da983f2fa 100644 GIT binary patch delta 18435 zcmY&<19zBR)MXm8v2EM7ZQHi-#I|kQZfv7Tn#Q)%81v4zX3d)U4d4 zYYc!v@NU%|U;_sM`2z(4BAilWijmR>4U^KdN)D8%@2KLcqkTDW%^3U(Wg>{qkAF z&RcYr;D1I5aD(N-PnqoEeBN~JyXiT(+@b`4Pv`;KmkBXYN48@0;iXuq6!ytn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..1acc777d7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0c8..744e882ed 100644 --- a/gradlew +++ b/gradlew @@ -72,7 +72,7 @@ case "`uname`" in Darwin* ) darwin=true ;; - MINGW* ) + MSYS* | MINGW* ) msys=true ;; NONSTOP* ) From fe3ce55ac89f6a7e685f8c559fbd71f524acb2a1 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 7 Feb 2022 13:56:07 -0500 Subject: [PATCH 055/297] Upgrade gradle from v7.1 to v7.1.1 to v7.2. --- docs/changelog_v3.3.x.md | 3 +++ gradle/wrapper/gradle-wrapper.properties | 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 947d0073e..7007d13ba 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-07 +* **Upgrade gradle from v7.1 to v7.1.1 to v7.2.** + + * **Upgrade gradle from v7.0.2 to v7.1.** diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1acc777d7..a0f7639f7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From ac3c77275049628821614b28119e0267eff29121 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 7 Feb 2022 14:01:52 -0500 Subject: [PATCH 056/297] Upgrade gradle from v7.2 to v7.3 --- docs/changelog_v3.3.x.md | 5 + gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 257 ++++++++++++++--------- 3 files changed, 159 insertions(+), 105 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7007d13ba..261109600 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,10 +16,15 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-07 +* **Upgrade gradle from v7.2 to v7.3** + - Changes to provide better security when runnign gradle to prevent injection attacks. + + * **Upgrade gradle from v7.1 to v7.1.1 to v7.2.** * **Upgrade gradle from v7.0.2 to v7.1.** +NOTE: There are a number of updates to apply for gradle. Will commit on the minor versions and final version. * **Added a few new placeholders and a new placeholder type of PLAYERBLOCKS.** diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a0f7639f7..fbce071a3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 744e882ed..c53aefaa5 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MSYS* | MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" From a9580954a1db4bdd7f714f47d81be50318dd47df Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 7 Feb 2022 14:13:51 -0500 Subject: [PATCH 057/297] Upgrade gradle from v7.3 to v7.3.1 to v7.3.2 to v7.3.3 This is at the latest release. --- docs/changelog_v3.3.x.md | 4 ++++ gradle/wrapper/gradle-wrapper.properties | 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 261109600..3b6e43a61 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-07 +* **Upgrade gradle from v7.3 to v7.3.1 to v7.3.2 to v7.3.3** +This is at the latest release. + + * **Upgrade gradle from v7.2 to v7.3** - Changes to provide better security when runnign gradle to prevent injection attacks. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fbce071a3..669386b87 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From c2a99fa19f1be27c466fa932f2451a1cb96f8710 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Feb 2022 00:03:26 -0500 Subject: [PATCH 058/297] Fixed the generation of the player mined block count placeholders. Was missing one _ after generating the specific block related placeholder. --- docs/changelog_v3.3.x.md | 6 +++++- .../tech/mcprison/prison/mines/managers/MineManager.java | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 3b6e43a61..b00d49b4f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.2 (alpha.7) 2022-02-07 +# 3.3.0-beta.2 (alpha.7) 2022-02-08 + + +* **Fixed the generation of the player mined block count placeholders.** +Was missing one _ after generating the specific block related placeholder. * **Upgrade gradle from v7.3 to v7.3.1 to v7.3.2 to v7.3.3** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java index 3e79c433b..acec1c970 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java @@ -1682,13 +1682,13 @@ public List getTranslatedPlaceHolderKeys() { for ( String blockName : blockNames ) { String mineKey = bn.name().replace( - PlaceholderManager.PRISON_PLACEHOLDER_PLAYERBLOCK_SUFFIX, "_" + blockName ). + PlaceholderManager.PRISON_PLACEHOLDER_PLAYERBLOCK_SUFFIX, "__" + blockName ). toLowerCase(); PlaceHolderKey placeholder = new PlaceHolderKey(mineKey, bn, blockName ); if ( bn.getAlias() != null ) { String aliasName = bn.getAlias().name().replace( - PlaceholderManager.PRISON_PLACEHOLDER_PLAYERBLOCK_SUFFIX, "_" + blockName ). + PlaceholderManager.PRISON_PLACEHOLDER_PLAYERBLOCK_SUFFIX, "__" + blockName ). toLowerCase(); placeholder.setAliasName( aliasName ); } From 1345d185d77f8b8b98fe5551d25f3dfa8eaadf99 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Feb 2022 00:58:48 -0500 Subject: [PATCH 059/297] On the command /ranks set tag, added the note that if a tag is removed from a rank, then the rank name will be used instead. Fixed the placeholder for rank tags so if it is null, it no longer show a null, but now it show the rank's name. --- docs/changelog_v3.3.x.md | 4 ++++ .../tech/mcprison/prison/ranks/commands/RanksCommands.java | 5 +++-- .../tech/mcprison/prison/ranks/managers/PlayerManager.java | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index b00d49b4f..692e9a639 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-08 +* **On the command /ranks set tag, added the note that if a tag is removed from a rank, then the rank name will be used instead.** +Fixed the placeholder for rank tags so if it is null, it no longer show a null, but now it show the rank's name. + + * **Fixed the generation of the player mined block count placeholders.** Was missing one _ after generating the specific block related placeholder. 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 729f6969d..4c14db41d 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 @@ -1334,7 +1334,8 @@ else if ( "none".equalsIgnoreCase( currency ) ) { } - @Command(identifier = "ranks set tag", description = "Modifies a ranks tag", + @Command(identifier = "ranks set tag", description = "Modifies a ranks tag. If a rank does not have a " + + "tag set, then the rank name will be used. You can use color codes to stylize your rank tag.", onlyPlayers = false, permissions = "ranks.set") public void setTag(CommandSender sender, @Arg(name = "rankName") String rankName, @@ -1513,7 +1514,7 @@ public void rankPlayer(CommandSender sender, } - RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); +// RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); Map rankLadders = rankPlayer.getLadderRanks(); diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index 9b9ad9b11..21ff052a9 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -486,7 +486,9 @@ public String getPlayerRankTag( RankPlayer rankPlayer, String ladderName ) { // if ( sb.length() > 0 ) { // sb.append(" "); // } - sb.append(entry.getValue().getRank().getTag()); + Rank rank = entry.getValue().getRank(); + String tag = rank.getTag(); + sb.append( tag == null ? rank.getName() : tag ); } } } From a4ad8f459476ad0d14ab773a67e44756e3691c7d Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:11:26 -0500 Subject: [PATCH 060/297] Removed the backpack's object from the player's cache. Backpacks are too massive for the player's cache and needs thier own cache system. --- docs/changelog_v3.3.x.md | 4 + .../prison/cache/PlayerCachePlayerData.java | 22 +- .../spigot/backpacks/NewBackpacksUtil.java | 1315 ++++++++--------- .../gui/backpacks/BackpacksPlayerGUI.java | 15 +- 4 files changed, 667 insertions(+), 689 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 692e9a639..e17503d7f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-08 +* **Removed the backpack's object from the player's cache.** + Backpacks are too massive for the player's cache and needs thier own cache system. + + * **On the command /ranks set tag, added the note that if a tag is removed from a rank, then the rank name will be used instead.** Fixed the placeholder for rank tags so if it is null, it no longer show a null, but now it show the rank's name. diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCachePlayerData.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCachePlayerData.java index 1ae833cfc..676fb8674 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCachePlayerData.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCachePlayerData.java @@ -2,9 +2,7 @@ import java.io.File; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; -import java.util.List; import java.util.TreeMap; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; @@ -12,7 +10,6 @@ import tech.mcprison.prison.autofeatures.PlayerMessaging; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.block.PrisonBlock; -import tech.mcprison.prison.internal.inventory.Inventory; import tech.mcprison.prison.placeholders.PlaceholdersUtil; /** @@ -57,7 +54,7 @@ public class PlayerCachePlayerData { // lastSeenDate tries to track when the player was last on the server. // This is important to know for refreshing player stats. private long lastSeenDate; - private double lastSeenBalance; +// private double lastSeenBalance; private long onlineTimeTotal = 0L; @@ -111,7 +108,7 @@ public class PlayerCachePlayerData { private transient PlayerMessaging playerMessaging; - private List backpacks; +// private List backpacks; private transient boolean dirty = false; @@ -149,7 +146,7 @@ public PlayerCachePlayerData() { this.playerMessaging = new PlayerMessaging(); - this.backpacks = new ArrayList<>(); +// this.backpacks = new ArrayList<>(); } @@ -375,6 +372,7 @@ public void addBlock( String mine, String blockName, int quantity ) private void addBlockByType( String blockName, int quantity ) { int qty = quantity; + blockName = blockName.toLowerCase(); if ( getBlocksByType().containsKey( blockName ) ) { qty += getBlocksByType().get( blockName ); } @@ -894,12 +892,12 @@ public void setPlayerMessaging( PlayerMessaging playerMessaging ) { this.playerMessaging = playerMessaging; } - public List getBackpacks() { - return backpacks; - } - public void setBackpacks( List backpacks ) { - this.backpacks = backpacks; - } +// public List getBackpacks() { +// return backpacks; +// } +// public void setBackpacks( List backpacks ) { +// this.backpacks = backpacks; +// } public boolean isDirty() { return dirty; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/NewBackpacksUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/NewBackpacksUtil.java index cd9617ba9..c31340a21 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/NewBackpacksUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/NewBackpacksUtil.java @@ -1,679 +1,652 @@ package tech.mcprison.prison.spigot.backpacks; -import com.cryptomorin.xseries.XMaterial; -import com.cryptomorin.xseries.XSound; -import org.bukkit.Bukkit; -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.meta.ItemMeta; -import tech.mcprison.prison.cache.PlayerCache; -import tech.mcprison.prison.cache.PlayerCachePlayerData; -import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; -import tech.mcprison.prison.spigot.configs.MessagesConfig; -import tech.mcprison.prison.spigot.game.SpigotPlayer; -import tech.mcprison.prison.spigot.gui.backpacks.BackpacksPlayerGUI; -import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; -import tech.mcprison.prison.spigot.inventory.SpigotInventory; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - /** * @author AnonymousGCA (GABRYCA) */ public class NewBackpacksUtil { - private static NewBackpacksUtil instance; - private MessagesConfig messages; - private Configuration backpacksConfig; - private Configuration backpacksData; - private boolean isFoundDeprecatedData; - private boolean isBackpackUsePermissionEnabled; - private boolean isBackpackAutoPickupEnabled; - private boolean isBackpackOpenItemEnabled; - private boolean isBackpackOpenItemGivenOnJoin; - private boolean isBackpackEnabledIfLimitZero; - private boolean isBackpackLostOnDeath; - private boolean isBackpackOpenSoundEnabled; - private boolean isBackpackCloseSoundEnabled; - private boolean isMultipleBackpacksEnabled; - private String backpackUsePermission; - private String backpackOpenItemTitle; - private XSound backpackOpenSound = XSound.BLOCK_CHEST_OPEN; - private XSound backpackCloseSound = XSound.BLOCK_CHEST_CLOSE; - private int defaultBackpackSize; - private int defaultBackpackLimitForPlayer; - private XMaterial backpackOpenItem = XMaterial.CHEST; - - - /** - * Get an instance of Backpacks to get full access to the API. - * - * If Backpacks are disabled, this will return null. - * - * @return BackpacksUtil - */ - public static NewBackpacksUtil get() { - - if (!getBoolean(SpigotPrison.getInstance().getConfig().getString("backpacks"))) { - return null; - } - - if (instance == null) { - instance = new NewBackpacksUtil(); - instance.initCachedData(); - } - - return instance; - } - - /** - * Check if Backpack AutoPickup is enabled. - * - * @return boolean. - */ - public boolean isBackpackAutoPickupEnabled() { - return this.isBackpackAutoPickupEnabled; - } - - /** - * Check if the Backpack Open Item is enabled. - * - * @return boolean. - */ - public boolean isBackpackOpenItemEnabled() { - return this.isBackpackOpenItemEnabled; - } - - /** - * Check if the Backpack Open Item is given on join. - * - * @return boolean. - */ - public boolean isBackpackOpenItemGivenOnJoin() { - return this.isBackpackOpenItemGivenOnJoin; - } - - /** - * Check if Backpack can be used and Backpack item too - * if the Player's limit is set to 0. - * - * @return boolean. - */ - public boolean isBackpackEnabledIfLimitZero() { - return this.isBackpackEnabledIfLimitZero; - } - - /** - * Check if Backpack is deleted/reset on death. - * - * @return boolean. - */ - public boolean isBackpackLostOnDeath() { - return this.isBackpackLostOnDeath; - } - - /** - * Check if Backpack open sound is enabled. - * - * @return boolean. - * */ - public boolean isBackpackOpenSoundEnabled(){ - return this.isBackpackOpenSoundEnabled; - } - - /** - * Check if Backpack close sound is enabled. - * - * @return boolean. - * */ - public boolean isBackpackCloseSoundEnabled(){ - return this.isBackpackCloseSoundEnabled; - } - - /** - * Get Backpack Open Item Title. - * - * @return String. - * */ - public String getBackpackOpenItemTitle(){ - return this.backpackOpenItemTitle; - } - - /** - * Get Backpack Open Permission. - * - * @return String. - * */ - public String getBackpackUsePermission(){ - return this.backpackUsePermission; - } - - /** - * Get Backpack Open Sound. - * - * @return Sound. - * */ - public Sound getBackpackOpenSound(){ - return this.backpackOpenSound.parseSound(); - } - - /** - * Get Backpack Close Sound. - * - * @return Sound. - * */ - public Sound getBackpackCloseSound(){ - return this.backpackCloseSound.parseSound(); - } - - /** - * Get Backpack Open Item. - * - * @return ItemStack. - * */ - public ItemStack getBackpackOpenItem(){ - - ItemStack backPackOpenItemStack = new ItemStack(backpackOpenItem.parseMaterial(), 1); - ItemMeta meta = backPackOpenItemStack.getItemMeta(); - meta.setDisplayName(SpigotPrison.format(SpigotPrison.format(backpackOpenItemTitle))); - ButtonLore lore = new ButtonLore(); - lore.setLoreAction("Click to open Backpack!"); - meta.setLore(lore.getLore()); - backPackOpenItemStack.setItemMeta(meta); - - return backPackOpenItemStack; - } - - /** - * Return boolean value from String. - * - * @param string - Boolean string. - * @return boolean. - */ - public static boolean getBoolean(String string) { - return string != null && string.equalsIgnoreCase("true"); - } - - /** - * Init options that will be cached. - */ - private void initCachedData() { - messages = SpigotPrison.getInstance().getMessagesConfig(); - backpacksConfig = SpigotPrison.getInstance().getBackpacksConfig(); - if (new File(SpigotPrison.getInstance().getDataFolder() + "/backpacks/backpacksData.yml").exists()) { - backpacksData = YamlConfiguration.loadConfiguration(new File(SpigotPrison.getInstance().getDataFolder() + "/backpacks/backpacksData.yml")); - isFoundDeprecatedData = true; - } else { - isFoundDeprecatedData = false; - } - isBackpackUsePermissionEnabled = getBoolean(backpacksConfig.getString("Options.BackPack_Use_Permission_Enabled")); - isBackpackAutoPickupEnabled = getBoolean(backpacksConfig.getString("Options.BackPack_AutoPickup_Usable")); - isBackpackOpenItemEnabled = getBoolean(backpacksConfig.getString("Options.Back_Pack_GUI_Opener_Item")); - isBackpackOpenItemGivenOnJoin = getBoolean(backpacksConfig.getString("Options.BackPack_Item_OnJoin")); - isBackpackEnabledIfLimitZero = getBoolean(backpacksConfig.getString("Options.BackPack_Access_And_Item_If_Limit_Is_0")); - isBackpackLostOnDeath = getBoolean(backpacksConfig.getString("Options.BackPack_Lose_Items_On_Death")); - isBackpackOpenSoundEnabled = getBoolean(backpacksConfig.getString("Options.BackPack_Open_Sound_Enabled")); - isBackpackCloseSoundEnabled = getBoolean(backpacksConfig.getString("Options.BackPack_Close_Sound_Enabled")); - isMultipleBackpacksEnabled = getBoolean(backpacksConfig.getString("Options.Multiple-BackPacks-For-Player-Enabled")); - if (XSound.matchXSound(backpacksConfig.getString("Options.BackPack_Open_Sound")).isPresent()) { - backpackOpenSound = XSound.matchXSound(backpacksConfig.getString("Options.BackPack_Open_Sound")).get(); - } - if (XSound.matchXSound(backpacksConfig.getString("Options.BackPack_Close_Sound")).isPresent()) { - backpackCloseSound = XSound.matchXSound(backpacksConfig.getString("Options.BackPack_Close_Sound")).get(); - } - if (XMaterial.matchXMaterial(backpacksConfig.getString("Options.BackPack_Item")).isPresent()) { - backpackOpenItem = XMaterial.matchXMaterial(backpacksConfig.getString("Options.BackPack_Item")).get(); - } - backpackUsePermission = backpacksConfig.getString("Options.BackPack_Use_Permission"); - backpackOpenItemTitle = backpacksConfig.getString("Options.BackPack_Item_Title"); - defaultBackpackSize = Integer.parseInt(backpacksConfig.getString("Options.BackPack_Default_Size")); - defaultBackpackLimitForPlayer = Integer.parseInt(backpacksConfig.getString("Options.Multiple-BackPacks-For-Player")); - } - - /** - * Save a Player's Backpack. - * This method will return true if ran with success, false if Player is missing permission (if enabled) - * or some conditions aren't met, or even errors. - * Essentially, return true if success, false if fail. - * - * @param p - Player. - * @param inv - Backpack. - * @return boolean. - */ - public boolean setBackpack(Player p, Inventory inv, int id) { - - if (!canOwnBackpacks(p)) { - return false; - } - - PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); - - if (pData == null) { - Output.get().sendInfo(new SpigotPlayer(p), "Sorry, unable to find cached data about you, this may be a bug! Please report it."); - return false; - } - - List inventories = prisonInventoryToNormalConverter(pData.getBackpacks()); - - if (inventories.get(id) != null) { - // No need to check more conditions here, Player already owns a backpack here. - inventories.set(id, inv); - - pData.setBackpacks(normalInventoryToPrisonConverter(inventories)); - pData.isDirty(); - } else { - - return addBackpack(p, inv); - } - return true; - } - - /** - * Add a Backpack to a Player. - *

- * Return true if success, false if fail. - * - * @param p - Player. - * @param inv - Inventory. - * @return boolean. - */ - public boolean addBackpack(Player p, Inventory inv) { - - if (!canOwnBackpacks(p)) { - return false; - } - - if (inv.getSize() <= getBackpackPermSize(p)) { - Output.get().sendWarn(new SpigotPlayer(p), "Sorry but you can't own a Backpack of this size."); - return false; - } - - PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); - - if (pData == null) { - Output.get().sendInfo(new SpigotPlayer(p), "Sorry, unable to find cached data on you, this may be a bug! Please report it."); - return false; - } - - List inventories = prisonInventoryToNormalConverter(pData.getBackpacks()); - - if (reachedBackpacksLimit(p)) { - Output.get().sendWarn(new SpigotPlayer(p), "Sorry, you can't own more Backpacks!"); - return false; - } - - inventories.add(inv); - pData.setBackpacks(normalInventoryToPrisonConverter(inventories)); - pData.isDirty(); - return true; - } - - /** - * Check if player reached limit of own backpacks. - * - * @return boolean - True if reached, false if not. - */ - public boolean reachedBackpacksLimit(Player p) { - return isMultipleBackpacksEnabled && (getBackpacksLimit(p) <= getNumberOwnedBackpacks(p)); - } - - /** - * Get number of Backpacks own by Player. - * - * @param p - Player. - */ - public int getNumberOwnedBackpacks(Player p) { - PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); - - if (pData == null) { - return 0; - } - - return pData.getBackpacks().size(); - } - - // TODO - // Not sure if this data is cached yet. - private int getBackpacksLimit(Player p) { - return defaultBackpackLimitForPlayer; - } - - /** - * Check if Player can own Backpacks. - * Return true if can, False otherwise. - * - * @param p - Player. - * @return boolean. - */ - public boolean canOwnBackpacks(Player p) { - return !isBackpackUsePermissionEnabled || p.hasPermission(backpackUsePermission); - } - - /** - * Get a Player's Backpack, there may be multiple ones. - * - * @param p - Player. - * @param id - int. - * @return Inventory - Backpack. - */ - public Inventory getBackpack(Player p, int id) { - - PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); - - if (pData == null) { - return null; - } - - oldBackpacksConverter(p); - - if (pData.getBackpacks() == null || pData.getBackpacks().get(id) == null) { - return null; - } - SpigotInventory sInv = (SpigotInventory) pData.getBackpacks().get(id); - - return sInv.getWrapper(); - } - - /** - * Get Backpacks of a Player in a List of Inventories. - * - * @param p - Player. - * @return Inventory - List. - */ - public List getBackpacks(Player p) { - - PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); - - if (pData == null) { - return null; - } - - oldBackpacksConverter(p); - - if (pData.getBackpacks() == null) { - return null; - } - - return prisonInventoryToNormalConverter(pData.getBackpacks()); - } - - /** - * Open Player's Backpack. - * - * Return true if open with success, false if fail or error. - * - * @param p - Player. - * @param id - Int. - * - * return boolean. - * */ - public boolean openBackpack(Player p, int id){ - - // Check if Player owns a Backpack with this ID. - if (getBackpack(p, id) == null){ - - Output.get().sendWarn(new SpigotPlayer(p), "Backpack not found!"); - return false; - } - - BackpacksPlayerGUI gui = new BackpacksPlayerGUI(p, id); - gui.open(); - return true; - } - - /** - * Converts a Prison's Inventory List to the spigot standard one. - * - * @param pInv - PrisonInventory List. - * @return List - Inventory. - */ - private List prisonInventoryToNormalConverter(List pInv) { - List inventories = new ArrayList<>(); - for (tech.mcprison.prison.internal.inventory.Inventory pInvRead : pInv) { - SpigotInventory sInv = (SpigotInventory) pInvRead; - inventories.add(sInv.getWrapper()); - } - - return inventories; - } - - /** - * Converts a Spigot's normal Inventory List to the Prison one. - * - * @param inventories - Inventories. - * @return List - Prison Inventories. - */ - private List normalInventoryToPrisonConverter(List inventories) { - List pInv = new ArrayList<>(); - for (Inventory readInv : inventories) { - pInv.add(SpigotInventory.fromWrapper(readInv)); - } - return pInv; - } - - /** - * Converts old Backpacks storage to the new one, deleting the deprecated one for this player. - * - * @param p - Player. - */ - private void oldBackpacksConverter(Player p) { - if (isFoundDeprecatedData) { - if (backpacksData.getString("Inventories." + p.getUniqueId() + ".PlayerName") != null) { - - PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); - - List prisonBackpacks = pData.getBackpacks(); - List readBackpacks = new ArrayList<>(); - - Output.get().sendWarn(new SpigotPlayer(p), "The Backpack data got updated, conversion started..."); - File backpacksFile = new File(SpigotPrison.getInstance().getDataFolder() + "/backpacks/backpacksData.yml"); - FileConfiguration backpacksFileData = YamlConfiguration.loadConfiguration(backpacksFile); - - // Check if multiple backpacks is enabled and get the backpacks. - if (isMultipleBackpacksEnabled) { - for (String backpackIds : getBackpacksIDsList(p)) { - readBackpacks.add(getOldBackpackOwn(p, backpackIds)); - } - } else { - readBackpacks.add(getOldBackpackOwn(p)); - } - - // Set to null this data and save it in the old config. - backpacksFileData.set("Inventories." + p.getUniqueId(), null); - try { - backpacksFileData.save(backpacksFile); - } catch (IOException e) { - e.printStackTrace(); - } - - int numberConverted = 0; - for (Inventory inv : readBackpacks) { - numberConverted++; - prisonBackpacks.add(SpigotInventory.fromWrapper(inv)); - } - - pData.setBackpacks(prisonBackpacks); - pData.isDirty(); - Output.get().sendInfo(new SpigotPlayer(p), numberConverted + " Backpacks converted with success, will open soon..."); - } - } - } - - /** - * Get backpack size of a Player Backpack with the permission for a custom one. - */ - private int getBackpackPermSize(Player p, int backPackSize) { - SpigotPlayer sPlayer = new SpigotPlayer(p); - List perms = sPlayer.getPermissions("prison.backpack.size."); - int value = 0; - for (String permNumber : perms) { - int newValue = Integer.parseInt(permNumber.substring(21)); - if (newValue > value) { - value = (int) Math.ceil((float) newValue / 9) * 9; - } - } - - if (value != 0) { - return value; - } - return backPackSize; - } - - /** - * Get backpack size from permissions of a Player and/or defaults. - * - * @param p - Player. - * @return int - size. - */ - public int getBackpackPermSize(Player p) { - int backPackSize = defaultBackpackSize; - - if (backPackSize % 9 != 0) { - backPackSize = (int) Math.ceil((float) backPackSize / 9) * 9; - } - - if (backPackSize == 0) backPackSize = 9; - - return getBackpackPermSize(p, backPackSize); - } - - /** - * This method exists only for the conversion of the old deprecated one. - */ - @Deprecated - private Inventory getOldBackpackOwn(Player p) { - - int size = getOldSize(p); - Inventory inv = Bukkit.createInventory(p, size, SpigotPrison.format("&3" + p.getName() + " -> Backpack")); - - // Get the Items config section. - Set slots; - try { - slots = backpacksData.getConfigurationSection("Inventories." + p.getUniqueId() + ".Items").getKeys(false); - } catch (NullPointerException ex) { - return inv; - } - if (slots.size() != 0) { - for (String slot : slots) { - ItemStack finalItem = backpacksData.getItemStack("Inventories." + p.getUniqueId() + ".Items." + slot + ".ITEMSTACK"); - if (finalItem != null) { - int slotNumber = Integer.parseInt(slot); - if (size > slotNumber) { - inv.setItem(slotNumber, finalItem); - } - } - } - } - - return inv; - } - - /** - * This method exists only for the conversion of the old deprecated one. - */ - @Deprecated - private Inventory getOldBackpackOwn(Player p, String id) { - - int size = getOldSize(p, id); - Inventory inv = Bukkit.createInventory(p, size, SpigotPrison.format("&3" + p.getName() + " -> Backpack-" + id)); - - // Get the Items config section - Set slots; - try { - slots = backpacksData.getConfigurationSection("Inventories." + p.getUniqueId() + ".Items-" + id).getKeys(false); - } catch (NullPointerException ex) { - return inv; - } - if (slots.size() != 0) { - for (String slot : slots) { - ItemStack finalItem = backpacksData.getItemStack("Inventories." + p.getUniqueId() + ".Items-" + id + "." + slot + ".ITEMSTACK"); - if (finalItem != null) { - int slotNumber = Integer.parseInt(slot); - if (size > slotNumber) { - inv.setItem(slotNumber, finalItem); - } - } - } - } - - return inv; - } - - /** - * Don't use this method. - */ - @Deprecated - private int getOldSize(Player p) { - - int backPackSize = defaultBackpackSize; - - try { - backPackSize = Integer.parseInt(backpacksData.getString("Inventories." + p.getUniqueId() + ".Items.Size")); - } catch (NumberFormatException ignored) { - } - - if (backPackSize % 9 != 0) { - backPackSize = (int) Math.ceil((float) backPackSize / 9) * 9; - } - - if (backPackSize == 0) backPackSize = 9; - - return getBackpackPermSize(p, backPackSize); - } - - /** - * Don't use this method. - */ - @Deprecated - private int getOldSize(Player p, String id) { - int backPackSize = defaultBackpackSize; - - try { - backPackSize = Integer.parseInt(backpacksData.getString("Inventories." + p.getUniqueId() + ".Items-" + id + ".Size")); - } catch (NumberFormatException ignored) { - } - - if (backPackSize % 9 != 0) { - backPackSize = (int) Math.ceil((float) backPackSize / 9) * 9; - } - - if (backPackSize == 0) backPackSize = 9; - - return getBackpackPermSize(p, backPackSize); - } - - /** - * This method exists only for the conversion of the old deprecated one. - */ - @Deprecated - private List getBackpacksIDsList(Player p) { - List backpacksIDs = new ArrayList<>(); - - // Items can be -> Items- or just Items in the config, the default and old backpacks will have Items only, newer will be like - // Items-1 or anyway an ID, I'm just getting the ID with this which's what I need. - try { - for (String key : backpacksData.getConfigurationSection("Inventories." + p.getUniqueId()).getKeys(false)) { - if (!key.equalsIgnoreCase("Items") && !key.equalsIgnoreCase("Limit") && !key.equalsIgnoreCase("PlayerName") && !key.equalsIgnoreCase("UniqueID")) { - backpacksIDs.add(key.substring(6)); - } else { - if (!backpacksIDs.contains(null) && !key.equalsIgnoreCase("PlayerName") && !key.equalsIgnoreCase("UniqueID") && !key.equalsIgnoreCase("Limit")) { - backpacksIDs.add(null); - } - } - } - } catch (NullPointerException ignored) { - } - - return backpacksIDs; - } +// private static NewBackpacksUtil instance; +// private MessagesConfig messages; +// private Configuration backpacksConfig; +// private Configuration backpacksData; +// private boolean isFoundDeprecatedData; +// private boolean isBackpackUsePermissionEnabled; +// private boolean isBackpackAutoPickupEnabled; +// private boolean isBackpackOpenItemEnabled; +// private boolean isBackpackOpenItemGivenOnJoin; +// private boolean isBackpackEnabledIfLimitZero; +// private boolean isBackpackLostOnDeath; +// private boolean isBackpackOpenSoundEnabled; +// private boolean isBackpackCloseSoundEnabled; +// private boolean isMultipleBackpacksEnabled; +// private String backpackUsePermission; +// private String backpackOpenItemTitle; +// private XSound backpackOpenSound = XSound.BLOCK_CHEST_OPEN; +// private XSound backpackCloseSound = XSound.BLOCK_CHEST_CLOSE; +// private int defaultBackpackSize; +// private int defaultBackpackLimitForPlayer; +// private XMaterial backpackOpenItem = XMaterial.CHEST; + + +// /** +// * Get an instance of Backpacks to get full access to the API. +// * +// * If Backpacks are disabled, this will return null. +// * +// * @return BackpacksUtil +// */ +// public static NewBackpacksUtil get() { +// +// if (!getBoolean(SpigotPrison.getInstance().getConfig().getString("backpacks"))) { +// return null; +// } +// +// if (instance == null) { +// instance = new NewBackpacksUtil(); +// instance.initCachedData(); +// } +// +// return instance; +// } +// +// /** +// * Check if Backpack AutoPickup is enabled. +// * +// * @return boolean. +// */ +// public boolean isBackpackAutoPickupEnabled() { +// return this.isBackpackAutoPickupEnabled; +// } +// +// /** +// * Check if the Backpack Open Item is enabled. +// * +// * @return boolean. +// */ +// public boolean isBackpackOpenItemEnabled() { +// return this.isBackpackOpenItemEnabled; +// } +// +// /** +// * Check if the Backpack Open Item is given on join. +// * +// * @return boolean. +// */ +// public boolean isBackpackOpenItemGivenOnJoin() { +// return this.isBackpackOpenItemGivenOnJoin; +// } +// +// /** +// * Check if Backpack can be used and Backpack item too +// * if the Player's limit is set to 0. +// * +// * @return boolean. +// */ +// public boolean isBackpackEnabledIfLimitZero() { +// return this.isBackpackEnabledIfLimitZero; +// } +// +// /** +// * Check if Backpack is deleted/reset on death. +// * +// * @return boolean. +// */ +// public boolean isBackpackLostOnDeath() { +// return this.isBackpackLostOnDeath; +// } +// +// /** +// * Check if Backpack open sound is enabled. +// * +// * @return boolean. +// * */ +// public boolean isBackpackOpenSoundEnabled(){ +// return this.isBackpackOpenSoundEnabled; +// } +// +// /** +// * Check if Backpack close sound is enabled. +// * +// * @return boolean. +// * */ +// public boolean isBackpackCloseSoundEnabled(){ +// return this.isBackpackCloseSoundEnabled; +// } +// +// /** +// * Get Backpack Open Item Title. +// * +// * @return String. +// * */ +// public String getBackpackOpenItemTitle(){ +// return this.backpackOpenItemTitle; +// } +// +// /** +// * Get Backpack Open Permission. +// * +// * @return String. +// * */ +// public String getBackpackUsePermission(){ +// return this.backpackUsePermission; +// } +// +// /** +// * Get Backpack Open Sound. +// * +// * @return Sound. +// * */ +// public Sound getBackpackOpenSound(){ +// return this.backpackOpenSound.parseSound(); +// } +// +// /** +// * Get Backpack Close Sound. +// * +// * @return Sound. +// * */ +// public Sound getBackpackCloseSound(){ +// return this.backpackCloseSound.parseSound(); +// } +// +// /** +// * Get Backpack Open Item. +// * +// * @return ItemStack. +// * */ +// public ItemStack getBackpackOpenItem(){ +// +// ItemStack backPackOpenItemStack = new ItemStack(backpackOpenItem.parseMaterial(), 1); +// ItemMeta meta = backPackOpenItemStack.getItemMeta(); +// meta.setDisplayName(SpigotPrison.format(SpigotPrison.format(backpackOpenItemTitle))); +// ButtonLore lore = new ButtonLore(); +// lore.setLoreAction("Click to open Backpack!"); +// meta.setLore(lore.getLore()); +// backPackOpenItemStack.setItemMeta(meta); +// +// return backPackOpenItemStack; +// } +// +// /** +// * Return boolean value from String. +// * +// * @param string - Boolean string. +// * @return boolean. +// */ +// public static boolean getBoolean(String string) { +// return string != null && string.equalsIgnoreCase("true"); +// } +// +// /** +// * Init options that will be cached. +// */ +// private void initCachedData() { +// messages = SpigotPrison.getInstance().getMessagesConfig(); +// backpacksConfig = SpigotPrison.getInstance().getBackpacksConfig(); +// if (new File(SpigotPrison.getInstance().getDataFolder() + "/backpacks/backpacksData.yml").exists()) { +// backpacksData = YamlConfiguration.loadConfiguration(new File(SpigotPrison.getInstance().getDataFolder() + "/backpacks/backpacksData.yml")); +// isFoundDeprecatedData = true; +// } else { +// isFoundDeprecatedData = false; +// } +// isBackpackUsePermissionEnabled = getBoolean(backpacksConfig.getString("Options.BackPack_Use_Permission_Enabled")); +// isBackpackAutoPickupEnabled = getBoolean(backpacksConfig.getString("Options.BackPack_AutoPickup_Usable")); +// isBackpackOpenItemEnabled = getBoolean(backpacksConfig.getString("Options.Back_Pack_GUI_Opener_Item")); +// isBackpackOpenItemGivenOnJoin = getBoolean(backpacksConfig.getString("Options.BackPack_Item_OnJoin")); +// isBackpackEnabledIfLimitZero = getBoolean(backpacksConfig.getString("Options.BackPack_Access_And_Item_If_Limit_Is_0")); +// isBackpackLostOnDeath = getBoolean(backpacksConfig.getString("Options.BackPack_Lose_Items_On_Death")); +// isBackpackOpenSoundEnabled = getBoolean(backpacksConfig.getString("Options.BackPack_Open_Sound_Enabled")); +// isBackpackCloseSoundEnabled = getBoolean(backpacksConfig.getString("Options.BackPack_Close_Sound_Enabled")); +// isMultipleBackpacksEnabled = getBoolean(backpacksConfig.getString("Options.Multiple-BackPacks-For-Player-Enabled")); +// if (XSound.matchXSound(backpacksConfig.getString("Options.BackPack_Open_Sound")).isPresent()) { +// backpackOpenSound = XSound.matchXSound(backpacksConfig.getString("Options.BackPack_Open_Sound")).get(); +// } +// if (XSound.matchXSound(backpacksConfig.getString("Options.BackPack_Close_Sound")).isPresent()) { +// backpackCloseSound = XSound.matchXSound(backpacksConfig.getString("Options.BackPack_Close_Sound")).get(); +// } +// if (XMaterial.matchXMaterial(backpacksConfig.getString("Options.BackPack_Item")).isPresent()) { +// backpackOpenItem = XMaterial.matchXMaterial(backpacksConfig.getString("Options.BackPack_Item")).get(); +// } +// backpackUsePermission = backpacksConfig.getString("Options.BackPack_Use_Permission"); +// backpackOpenItemTitle = backpacksConfig.getString("Options.BackPack_Item_Title"); +// defaultBackpackSize = Integer.parseInt(backpacksConfig.getString("Options.BackPack_Default_Size")); +// defaultBackpackLimitForPlayer = Integer.parseInt(backpacksConfig.getString("Options.Multiple-BackPacks-For-Player")); +// } + +// /** +// * Save a Player's Backpack. +// * This method will return true if ran with success, false if Player is missing permission (if enabled) +// * or some conditions aren't met, or even errors. +// * Essentially, return true if success, false if fail. +// * +// * @param p - Player. +// * @param inv - Backpack. +// * @return boolean. +// */ +// public boolean setBackpack(Player p, Inventory inv, int id) { +// +// if (!canOwnBackpacks(p)) { +// return false; +// } +// +// PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); +// +// if (pData == null) { +// Output.get().sendInfo(new SpigotPlayer(p), "Sorry, unable to find cached data about you, this may be a bug! Please report it."); +// return false; +// } +// +// List inventories = prisonInventoryToNormalConverter(pData.getBackpacks()); +// +// if (inventories.get(id) != null) { +// // No need to check more conditions here, Player already owns a backpack here. +// inventories.set(id, inv); +// +// pData.setBackpacks(normalInventoryToPrisonConverter(inventories)); +// pData.isDirty(); +// } else { +// +// return addBackpack(p, inv); +// } +// return true; +// } +// +// /** +// * Add a Backpack to a Player. +// *

+// * Return true if success, false if fail. +// * +// * @param p - Player. +// * @param inv - Inventory. +// * @return boolean. +// */ +// public boolean addBackpack(Player p, Inventory inv) { +// +// if (!canOwnBackpacks(p)) { +// return false; +// } +// +// if (inv.getSize() <= getBackpackPermSize(p)) { +// Output.get().sendWarn(new SpigotPlayer(p), "Sorry but you can't own a Backpack of this size."); +// return false; +// } +// +// PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); +// +// if (pData == null) { +// Output.get().sendInfo(new SpigotPlayer(p), "Sorry, unable to find cached data on you, this may be a bug! Please report it."); +// return false; +// } +// +// List inventories = prisonInventoryToNormalConverter(pData.getBackpacks()); +// +// if (reachedBackpacksLimit(p)) { +// Output.get().sendWarn(new SpigotPlayer(p), "Sorry, you can't own more Backpacks!"); +// return false; +// } +// +// inventories.add(inv); +// pData.setBackpacks(normalInventoryToPrisonConverter(inventories)); +// pData.isDirty(); +// return true; +// } +// +// /** +// * Check if player reached limit of own backpacks. +// * +// * @return boolean - True if reached, false if not. +// */ +// public boolean reachedBackpacksLimit(Player p) { +// return isMultipleBackpacksEnabled && (getBackpacksLimit(p) <= getNumberOwnedBackpacks(p)); +// } +// +// /** +// * Get number of Backpacks own by Player. +// * +// * @param p - Player. +// */ +// public int getNumberOwnedBackpacks(Player p) { +// PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); +// +// if (pData == null) { +// return 0; +// } +// +// return pData.getBackpacks().size(); +// } +// +// // TODO +// // Not sure if this data is cached yet. +// private int getBackpacksLimit(Player p) { +// return defaultBackpackLimitForPlayer; +// } +// +// /** +// * Check if Player can own Backpacks. +// * Return true if can, False otherwise. +// * +// * @param p - Player. +// * @return boolean. +// */ +// public boolean canOwnBackpacks(Player p) { +// return !isBackpackUsePermissionEnabled || p.hasPermission(backpackUsePermission); +// } +// +// /** +// * Get a Player's Backpack, there may be multiple ones. +// * +// * @param p - Player. +// * @param id - int. +// * @return Inventory - Backpack. +// */ +// public Inventory getBackpack(Player p, int id) { +// +// PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); +// +// if (pData == null) { +// return null; +// } +// +// oldBackpacksConverter(p); +// +// if (pData.getBackpacks() == null || pData.getBackpacks().get(id) == null) { +// return null; +// } +// SpigotInventory sInv = (SpigotInventory) pData.getBackpacks().get(id); +// +// return sInv.getWrapper(); +// } +// +// /** +// * Get Backpacks of a Player in a List of Inventories. +// * +// * @param p - Player. +// * @return Inventory - List. +// */ +// public List getBackpacks(Player p) { +// +// PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); +// +// if (pData == null) { +// return null; +// } +// +// oldBackpacksConverter(p); +// +// if (pData.getBackpacks() == null) { +// return null; +// } +// +// return prisonInventoryToNormalConverter(pData.getBackpacks()); +// } +// +// /** +// * Open Player's Backpack. +// * +// * Return true if open with success, false if fail or error. +// * +// * @param p - Player. +// * @param id - Int. +// * +// * return boolean. +// * */ +// public boolean openBackpack(Player p, int id){ +// +// // Check if Player owns a Backpack with this ID. +// if (getBackpack(p, id) == null){ +// +// Output.get().sendWarn(new SpigotPlayer(p), "Backpack not found!"); +// return false; +// } +// +// BackpacksPlayerGUI gui = new BackpacksPlayerGUI(p, id); +// gui.open(); +// return true; +// } +// +// /** +// * Converts a Prison's Inventory List to the spigot standard one. +// * +// * @param pInv - PrisonInventory List. +// * @return List - Inventory. +// */ +// private List prisonInventoryToNormalConverter(List pInv) { +// List inventories = new ArrayList<>(); +// for (tech.mcprison.prison.internal.inventory.Inventory pInvRead : pInv) { +// SpigotInventory sInv = (SpigotInventory) pInvRead; +// inventories.add(sInv.getWrapper()); +// } +// +// return inventories; +// } +// +// /** +// * Converts a Spigot's normal Inventory List to the Prison one. +// * +// * @param inventories - Inventories. +// * @return List - Prison Inventories. +// */ +// private List normalInventoryToPrisonConverter(List inventories) { +// List pInv = new ArrayList<>(); +// for (Inventory readInv : inventories) { +// pInv.add(SpigotInventory.fromWrapper(readInv)); +// } +// return pInv; +// } +// +// /** +// * Converts old Backpacks storage to the new one, deleting the deprecated one for this player. +// * +// * @param p - Player. +// */ +// private void oldBackpacksConverter(Player p) { +// if (isFoundDeprecatedData) { +// if (backpacksData.getString("Inventories." + p.getUniqueId() + ".PlayerName") != null) { +// +// PlayerCachePlayerData pData = PlayerCache.getInstance().getOnlinePlayer(new SpigotPlayer(p)); +// +// List prisonBackpacks = pData.getBackpacks(); +// List readBackpacks = new ArrayList<>(); +// +// Output.get().sendWarn(new SpigotPlayer(p), "The Backpack data got updated, conversion started..."); +// File backpacksFile = new File(SpigotPrison.getInstance().getDataFolder() + "/backpacks/backpacksData.yml"); +// FileConfiguration backpacksFileData = YamlConfiguration.loadConfiguration(backpacksFile); +// +// // Check if multiple backpacks is enabled and get the backpacks. +// if (isMultipleBackpacksEnabled) { +// for (String backpackIds : getBackpacksIDsList(p)) { +// readBackpacks.add(getOldBackpackOwn(p, backpackIds)); +// } +// } else { +// readBackpacks.add(getOldBackpackOwn(p)); +// } +// +// // Set to null this data and save it in the old config. +// backpacksFileData.set("Inventories." + p.getUniqueId(), null); +// try { +// backpacksFileData.save(backpacksFile); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// +// int numberConverted = 0; +// for (Inventory inv : readBackpacks) { +// numberConverted++; +// prisonBackpacks.add(SpigotInventory.fromWrapper(inv)); +// } +// +// pData.setBackpacks(prisonBackpacks); +// pData.isDirty(); +// Output.get().sendInfo(new SpigotPlayer(p), numberConverted + " Backpacks converted with success, will open soon..."); +// } +// } +// } +// +// /** +// * Get backpack size of a Player Backpack with the permission for a custom one. +// */ +// private int getBackpackPermSize(Player p, int backPackSize) { +// SpigotPlayer sPlayer = new SpigotPlayer(p); +// List perms = sPlayer.getPermissions("prison.backpack.size."); +// int value = 0; +// for (String permNumber : perms) { +// int newValue = Integer.parseInt(permNumber.substring(21)); +// if (newValue > value) { +// value = (int) Math.ceil((float) newValue / 9) * 9; +// } +// } +// +// if (value != 0) { +// return value; +// } +// return backPackSize; +// } +// +// /** +// * Get backpack size from permissions of a Player and/or defaults. +// * +// * @param p - Player. +// * @return int - size. +// */ +// public int getBackpackPermSize(Player p) { +// int backPackSize = defaultBackpackSize; +// +// if (backPackSize % 9 != 0) { +// backPackSize = (int) Math.ceil((float) backPackSize / 9) * 9; +// } +// +// if (backPackSize == 0) backPackSize = 9; +// +// return getBackpackPermSize(p, backPackSize); +// } +// +// /** +// * This method exists only for the conversion of the old deprecated one. +// */ +// @Deprecated +// private Inventory getOldBackpackOwn(Player p) { +// +// int size = getOldSize(p); +// Inventory inv = Bukkit.createInventory(p, size, SpigotPrison.format("&3" + p.getName() + " -> Backpack")); +// +// // Get the Items config section. +// Set slots; +// try { +// slots = backpacksData.getConfigurationSection("Inventories." + p.getUniqueId() + ".Items").getKeys(false); +// } catch (NullPointerException ex) { +// return inv; +// } +// if (slots.size() != 0) { +// for (String slot : slots) { +// ItemStack finalItem = backpacksData.getItemStack("Inventories." + p.getUniqueId() + ".Items." + slot + ".ITEMSTACK"); +// if (finalItem != null) { +// int slotNumber = Integer.parseInt(slot); +// if (size > slotNumber) { +// inv.setItem(slotNumber, finalItem); +// } +// } +// } +// } +// +// return inv; +// } +// +// /** +// * This method exists only for the conversion of the old deprecated one. +// */ +// @Deprecated +// private Inventory getOldBackpackOwn(Player p, String id) { +// +// int size = getOldSize(p, id); +// Inventory inv = Bukkit.createInventory(p, size, SpigotPrison.format("&3" + p.getName() + " -> Backpack-" + id)); +// +// // Get the Items config section +// Set slots; +// try { +// slots = backpacksData.getConfigurationSection("Inventories." + p.getUniqueId() + ".Items-" + id).getKeys(false); +// } catch (NullPointerException ex) { +// return inv; +// } +// if (slots.size() != 0) { +// for (String slot : slots) { +// ItemStack finalItem = backpacksData.getItemStack("Inventories." + p.getUniqueId() + ".Items-" + id + "." + slot + ".ITEMSTACK"); +// if (finalItem != null) { +// int slotNumber = Integer.parseInt(slot); +// if (size > slotNumber) { +// inv.setItem(slotNumber, finalItem); +// } +// } +// } +// } +// +// return inv; +// } +// +// /** +// * Don't use this method. +// */ +// @Deprecated +// private int getOldSize(Player p) { +// +// int backPackSize = defaultBackpackSize; +// +// try { +// backPackSize = Integer.parseInt(backpacksData.getString("Inventories." + p.getUniqueId() + ".Items.Size")); +// } catch (NumberFormatException ignored) { +// } +// +// if (backPackSize % 9 != 0) { +// backPackSize = (int) Math.ceil((float) backPackSize / 9) * 9; +// } +// +// if (backPackSize == 0) backPackSize = 9; +// +// return getBackpackPermSize(p, backPackSize); +// } +// +// /** +// * Don't use this method. +// */ +// @Deprecated +// private int getOldSize(Player p, String id) { +// int backPackSize = defaultBackpackSize; +// +// try { +// backPackSize = Integer.parseInt(backpacksData.getString("Inventories." + p.getUniqueId() + ".Items-" + id + ".Size")); +// } catch (NumberFormatException ignored) { +// } +// +// if (backPackSize % 9 != 0) { +// backPackSize = (int) Math.ceil((float) backPackSize / 9) * 9; +// } +// +// if (backPackSize == 0) backPackSize = 9; +// +// return getBackpackPermSize(p, backPackSize); +// } +// +// /** +// * This method exists only for the conversion of the old deprecated one. +// */ +// @Deprecated +// private List getBackpacksIDsList(Player p) { +// List backpacksIDs = new ArrayList<>(); +// +// // Items can be -> Items- or just Items in the config, the default and old backpacks will have Items only, newer will be like +// // Items-1 or anyway an ID, I'm just getting the ID with this which's what I need. +// try { +// for (String key : backpacksData.getConfigurationSection("Inventories." + p.getUniqueId()).getKeys(false)) { +// if (!key.equalsIgnoreCase("Items") && !key.equalsIgnoreCase("Limit") && !key.equalsIgnoreCase("PlayerName") && !key.equalsIgnoreCase("UniqueID")) { +// backpacksIDs.add(key.substring(6)); +// } else { +// if (!backpacksIDs.contains(null) && !key.equalsIgnoreCase("PlayerName") && !key.equalsIgnoreCase("UniqueID") && !key.equalsIgnoreCase("Limit")) { +// backpacksIDs.add(null); +// } +// } +// } +// } catch (NullPointerException ignored) { +// } +// +// return backpacksIDs; +// } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksPlayerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksPlayerGUI.java index 843100d1f..29054d546 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksPlayerGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksPlayerGUI.java @@ -2,8 +2,9 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; + import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.backpacks.NewBackpacksUtil; +import tech.mcprison.prison.spigot.backpacks.BackpacksUtil; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; import tech.mcprison.prison.spigot.gui.guiutility.SpigotGUIComponents; @@ -26,7 +27,8 @@ public BackpacksPlayerGUI(Player p, int id){ public void open(){ - NewBackpacksUtil backpacksUtil = NewBackpacksUtil.get(); + BackpacksUtil backpacksUtil = BackpacksUtil.get(); +// NewBackpacksUtil backpacksUtil = NewBackpacksUtil.get(); if (backpacksUtil == null){ return; @@ -34,16 +36,17 @@ public void open(){ SpigotPlayer sPlayer = new SpigotPlayer(p); - Inventory inv = backpacksUtil.getBackpack(p, id); + Inventory inv = backpacksUtil.getBackpack(p, Integer.toString( id )); +// Inventory inv = backpacksUtil.getBackpack(p, id); if (inv != null){ PrisonGUI gui = new PrisonGUI(p, inv.getSize(), "&3" + p.getName() + " -> Backpack-" + id); Output.get().sendInfo(sPlayer, "Backpack" + id + " open with success!"); - if (backpacksUtil.isBackpackOpenSoundEnabled()){ - p.playSound(p.getLocation(), backpacksUtil.getBackpackOpenSound(),3,1); - } +// if (backpacksUtil.isBackpackOpenSoundEnabled()){ +// p.playSound(p.getLocation(), backpacksUtil.getBackpackOpenSound(),3,1); +// } gui.open(); } From db7ee5af2a273524e86e35f71b9bdba239596cf3 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:13:27 -0500 Subject: [PATCH 061/297] Some minor changes to /prison debug to give it an alias of /prison support debug. Format a few of the messages to make it easier to understand. --- docs/changelog_v3.3.x.md | 4 ++++ .../src/main/java/tech/mcprison/prison/PrisonCommand.java | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e17503d7f..16ddec8ef 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-08 +* **Some minor changes to /prison debug to give it an alias of /prison support debug.** +Format a few of the messages to make it easier to understand. + + * **Removed the backpack's object from the player's cache.** Backpacks are too massive for the player's cache and needs thier own cache system. 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 8100b54c4..39c4ae157 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -1005,7 +1005,8 @@ public void autoFeaturesInformation(CommandSender sender) { @Command(identifier = "prison debug", description = "Enables debugging and trouble shooting information. " + "For internal use only. Do not use unless instructed.", - onlyPlayers = false, permissions = "prison.debug" ) + onlyPlayers = false, permissions = "prison.debug", + aliases = {"prison support debug"} ) public void toggleDebug(CommandSender sender, @Wildcard(join=true) @Arg(name = "targets", def = " ", @@ -1047,13 +1048,13 @@ public void toggleDebug(CommandSender sender, // Applies normal and selective targets: Output.get().applyDebugTargets( targets ); - String message = "Global Debug Logging is " + (Output.get().isDebug() ? "enabled" : "disabled"); + String message = "&7Global Debug Logging is " + (Output.get().isDebug() ? "&3enabled" : "&cdisabled"); sender.sendMessage( message ); Set activeDebugTargets = Output.get().getActiveDebugTargets(); if ( activeDebugTargets.size() > 0 ) { - message = ". Active Debug Targets:"; + message = ". Note: Active Debug Targets:"; sender.sendMessage( message ); for ( DebugTarget target : activeDebugTargets ) From 91dc8c1b98aefcdb417971cde4df84608dc04a9f Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:26:07 -0500 Subject: [PATCH 062/297] For the /prison support commands, the output is now sent to the player instead of just the console. --- docs/changelog_v3.3.x.md | 3 + .../tech/mcprison/prison/PrisonCommand.java | 58 +++++++++---------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 16ddec8ef..45ee3576e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-08 +* **For the /prison support commands, the output is now sent to the player instead of just the console.** + + * **Some minor changes to /prison debug to give it an alias of /prison support debug.** Format a few of the messages to make it easier to understand. 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 39c4ae157..4a9a88e79 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -1116,14 +1116,14 @@ public void supportSetName(CommandSender sender, ) { if ( supportName == null || supportName.trim().isEmpty() ) { - Output.get().logInfo( "A value for supportName is required." ); + sender.sendMessage( "A value for supportName is required." ); return; } setSupportName( supportName ); - Output.get().logInfo( "The support name has been set to: %s", getSupportName() ); - Output.get().logInfo( "You can now use the support submit options." ); + sender.sendMessage( String.format( "The support name has been set to: %s", getSupportName() ) ); + sender.sendMessage( "You can now use the support submit options." ); } @@ -1138,8 +1138,8 @@ public void supportSubmitVersion(CommandSender sender if ( getSupportName() == null || getSupportName().trim().isEmpty() ) { - Output.get().logInfo( "The support name needs to be set prior to using this command." ); - Output.get().logInfo( "Use &7/prison support setSupportName help" ); + sender.sendMessage( "The support name needs to be set prior to using this command." ); + sender.sendMessage( "Use &7/prison support setSupportName help" ); return; } @@ -1156,12 +1156,12 @@ public void supportSubmitVersion(CommandSender sender if ( helpURL != null ) { - Output.get().logInfo( "Prison's support information has been pasted. Copy and " + + sender.sendMessage( "Prison's support information has been pasted. Copy and " + "paste this URL in to Prison's Discord server." ); - Output.get().logInfo( "Paste this URL: %s", helpURL ); + sender.sendMessage( String.format( "Paste this URL: %s", helpURL )); } else { - Output.get().logInfo( "There was an error trying to generate the paste.helpch.at URL." ); + sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." ); } @@ -1179,8 +1179,8 @@ public void supportSubmitConfigs(CommandSender sender if ( getSupportName() == null || getSupportName().trim().isEmpty() ) { - Output.get().logInfo( "The support name needs to be set prior to using this command." ); - Output.get().logInfo( "Use &7/prison support setSupportName help" ); + sender.sendMessage( "The support name needs to be set prior to using this command." ); + sender.sendMessage( "Use &7/prison support setSupportName help" ); return; } @@ -1212,12 +1212,12 @@ public void supportSubmitConfigs(CommandSender sender if ( helpURL != null ) { - Output.get().logInfo( "Prison's support information has been pasted. Copy and " + + sender.sendMessage( "Prison's support information has been pasted. Copy and " + "paste this URL in to Prison's Discord server." ); - Output.get().logInfo( "Paste this URL: %s", helpURL ); + sender.sendMessage( String.format( "Paste this URL: %s", helpURL )); } else { - Output.get().logInfo( "There was an error trying to generate the paste.helpch.at URL." ); + sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." ); } @@ -1233,8 +1233,8 @@ public void supportSubmitRanks(CommandSender sender if ( getSupportName() == null || getSupportName().trim().isEmpty() ) { - Output.get().logInfo( "The support name needs to be set prior to using this command." ); - Output.get().logInfo( "Use &7/prison support setSupportName help" ); + sender.sendMessage( "The support name needs to be set prior to using this command." ); + sender.sendMessage( "Use &7/prison support setSupportName help" ); return; } @@ -1266,12 +1266,12 @@ public void supportSubmitRanks(CommandSender sender if ( helpURL != null ) { - Output.get().logInfo( "Prison's support information has been pasted. Copy and " + + sender.sendMessage( "Prison's support information has been pasted. Copy and " + "paste this URL in to Prison's Discord server." ); - Output.get().logInfo( "Paste this URL: %s", helpURL ); + sender.sendMessage( String.format( "Paste this URL: %s", helpURL )); } else { - Output.get().logInfo( "There was an error trying to generate the paste.helpch.at URL." ); + sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." ); } @@ -1288,8 +1288,8 @@ public void supportSubmitMines(CommandSender sender if ( getSupportName() == null || getSupportName().trim().isEmpty() ) { - Output.get().logInfo( "The support name needs to be set prior to using this command." ); - Output.get().logInfo( "Use &7/prison support setSupportName help" ); + sender.sendMessage( "The support name needs to be set prior to using this command." ); + sender.sendMessage( "Use &7/prison support setSupportName help" ); return; } @@ -1328,12 +1328,12 @@ public void supportSubmitMines(CommandSender sender if ( helpURL != null ) { - Output.get().logInfo( "Prison's support information has been pasted. Copy and " + + sender.sendMessage( "Prison's support information has been pasted. Copy and " + "paste this URL in to Prison's Discord server." ); - Output.get().logInfo( "Paste this URL: %s", helpURL ); + sender.sendMessage( String.format( "Paste this URL: %s", helpURL )); } else { - Output.get().logInfo( "There was an error trying to generate the paste.helpch.at URL." ); + sender.sendMessage( "There was an error trying to generate the paste.helpch.at URL." ); } @@ -1425,8 +1425,8 @@ public void supportSubmitLatestLog(CommandSender sender if ( getSupportName() == null || getSupportName().trim().isEmpty() ) { - Output.get().logInfo( "The support name needs to be set prior to using this command." ); - Output.get().logInfo( "Use &7/prison support setSupportName help" ); + sender.sendMessage( "The support name needs to be set prior to using this command." ); + sender.sendMessage( "Use &7/prison support setSupportName help" ); return; } @@ -1435,7 +1435,7 @@ public void supportSubmitLatestLog(CommandSender sender File latestLogFile = new File( Prison.get().getDataFolder().getParentFile().getParentFile(), "logs/latest.log"); - Output.get().logInfo( "### log path: " + latestLogFile.getAbsolutePath() ); + sender.sendMessage( "### log path: " + latestLogFile.getAbsolutePath() ); StringBuilder logText = new StringBuilder(); @@ -1454,9 +1454,9 @@ public void supportSubmitLatestLog(CommandSender sender if ( helpURL != null ) { - Output.get().logInfo( "Prison's support information has been pasted. Copy and " + + sender.sendMessage( "Prison's support information has been pasted. Copy and " + "paste this URL in to Prison's Discord server." ); - Output.get().logInfo( "Paste this URL: %s", helpURL ); + sender.sendMessage( String.format( "Paste this URL: %s", helpURL )); } else { // Do nothing since if helpURL is null, then it has probably @@ -1466,7 +1466,7 @@ public void supportSubmitLatestLog(CommandSender sender } } - Output.get().logInfo( "Unable to send log file. Unknown reason why." ); + sender.sendMessage( "Unable to send log file. Unknown reason why." ); } private void readFileToStringBulider( File textFile, StringBuilder text ) From 8d841a20e0a3139ac1b9d25acefa553c22247cb5 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:50:50 -0500 Subject: [PATCH 063/297] Disable the player's nms attempts to get their locale... spigot 1.17 and higher no longer can get that value. Just use the server's default value. --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/spigot/game/SpigotPlayer.java | 24 +++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 45ee3576e..d89d5e7d3 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-beta.2 (alpha.7) 2022-02-08 +* **Disable the player's nms attempts to get their locale... spigot 1.17 and higher no longer can get that value.** +Just use the server's default value. + + * **For the /prison support commands, the output is now sent to the player instead of just the console.** 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 1a006699a..3f9051cd0 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 @@ -112,18 +112,18 @@ public UUID getUUID() { public Optional getLocale() { Optional results = Optional.empty(); - if ( SpigotNMSPlayer.getInstance().hasSupport() ) { - try { - results = Optional.ofNullable( - SpigotNMSPlayer.getInstance().getLocale( getWrapper() ) - ); - } - catch ( Exception ex ) { - Output.get().logInfo( - "Failed to initialize NMS components -- " + - "NMS is not functional - " + ex.getMessage() ); - } - } +// if ( SpigotNMSPlayer.getInstance().hasSupport() ) { +// try { +// results = Optional.ofNullable( +// SpigotNMSPlayer.getInstance().getLocale( getWrapper() ) +// ); +// } +// catch ( Exception ex ) { +// Output.get().logInfo( +// "Failed to initialize NMS components -- " + +// "NMS is not functional - " + ex.getMessage() ); +// } +// } return results; } From 497fd7440c31c3d6a986393a49e7c115924e839e Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 9 Feb 2022 16:51:28 -0500 Subject: [PATCH 064/297] v3.3.0-alpha.7 2022-02-09 Set this back on an alpha release schedule. The betas appear to have been pretty stable. --- docs/changelog_v3.3.x.md | 6 ++- docs/knownissues_v3.3.x.md | 100 +++++++++++++++++++++++-------------- gradle.properties | 2 +- 3 files changed, 69 insertions(+), 39 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d89d5e7d3..e3a5ad57e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-beta.2 (alpha.7) 2022-02-08 +# 3.3.0-alpha.7 2022-02-09 + + +* **v3.3.0-alpha.7 2022-02-09** +Set this back on an alpha release schedule. The betas appear to have been pretty stable. * **Disable the player's nms attempts to get their locale... spigot 1.17 and higher no longer can get that value.** diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index f54d1b7f1..6ed8d329a 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -8,87 +8,76 @@ # TODO Items for v3.3.0-alpha.7 -- when rank tag = none - show "null" for placeholder +- custom blocks not working with sellall. Sellall is not honoring the custom block's names. -- work on getting CustomItems working in mines again -- sellall get player multiplier needs to be rewritten -- automatic prestiges +- DONE: placeholder for player blocks mined. artic1409 + - maybe use **prison_player_total_blocks__blockname** + +- DONE: update placeholderAPI with prison's updated placeholders -- Docs: - - finish luckperms doc - - Placeholders details - Explain each placeholder +- Auto smelt is missing some blocks? Symadude23 -- Rankup commands: placeholders for {promote}{demote} +- placeholder attributes: Add overrides for "units". kstance requested it for time, such as h,m,s... -- Mine reset notifications logging to console - options? +- DONE: prison support submit are only sending to console, not the user if they are in game -- DONE: /ranks autoConfigure - review setup and maybe enable skip resets and tweak some notification settings. +- DONE: When a mine reset time is disabled... it cancels/stops a /mines reset *all* -- remove this warning message: no longer used. -[18:58:51 INFO]: | Prison | Cannot initialize NMS components - ClassNotFoundException - NMS is not functional - net.minecraft.server.v1_18_R1.EntityPlayer +- DONE: when rank tag = none - was showing "null" for placeholder +- DONE: work on getting CustomItems working in mines again -- DONE: update CMI delayed loading docs... they are "backwards" +- Need to get CustomItems working with sellall +- sellall get player multiplier needs to be rewritten - cached? Currently goes through all perms +- automatic prestiges +- Docs: + - finish luckperms doc + - Placeholders details - Explain each placeholder -- DONE: Upon startup the first time, broadcast to everyone that they should use /ranks autoConfigure. - - Broadcast failed ranks too. - +- Rankup commands: placeholders for {promote}{demote} -- DONE: RankPlayer addBalance cache for default currency -- RankPlayer addBalance cache for custom currency - still needed! +- Mine reset notifications logging to console - options? -- DONE: SELLALL has huge performance issues! It takes 2.3 ms to autosell, and full auto features block handling is 4.2 ms!! Serious performance issue with sellall, and autosell is bypassing the command handler too! - - added 'autosellTiming:' stats to auto features autosell to track actual sell time using nano-seconds... initial tests show there maybe significant performance issues. - - autosell in auto features causing lag? Flaco21 - - Issue with autosell causing lag? - - DONE: see RankPlayer addBalance cache - 1250 times improvement! +- DONE: remove this warning message: no longer used. +[18:58:51 INFO]: | Prison | Cannot initialize NMS components - ClassNotFoundException - NMS is not functional - net.minecraft.server.v1_18_R1.EntityPlayer -- DONE: admin gui - allows them to bypass No Economy safeguards. +- DONE: RankPlayer addBalance cache for default currency +- RankPlayer addBalance cache for custom currency - still needed! -* DONE: Add commands to list shop prices in console. Currently sellall is 100% gui so cannot be used offline. * Problems with blocks: - Sand or any other block that falls is no longer in original location so cannot break it. - Might have to tag the blocks with NMS? - Just fixed an issue with a block that was in a mine with gravel, sand, and dirt. MIght have been sand causing the error. NOTE: prevent error, not fixed the actual problem. - - DONE: lapis lazuli is not auto selling - + - Problem with actionBar - messages are not going through. - sellall updates every second - different messages - but never show first one - PlayerMessages - - - DONE: No economy error message not showing - - works on delayed startup - - Fails when not delayed - gui ranks was registering on top of ranks warning - + - block stats based upon drops instead of breakage?? (not sure if this has merit?) --> DONE: Hook in to quests - Only on block break events - --> Suport for eco enchants: +-> Support for eco enchants: - Need to add an event listener and then have a new function in EnchantmentUtils handle the event, with passing continuing to call the normal rehandleBreaking. Maybe name it rehandleBreakingEvent? https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java -- DONE: You cannot afford the rankup is using a NBSP for the thousand separator. Using Prison v3.2.11, Java 16, and spigot 1.16.5. Cannot reproduce. Was a server hosting config issue, but not sure why it only impacted that one message. - * calculate mine worth? @@ -102,8 +91,45 @@ https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main * sellall - ladder based sellall rank multipliers - so a ladder value of 0.05 would apply p1 = 1.05, p2 = 1.10, p3 = 1.15, etc... + +-> DONE: Hook in to quests - Only on block break events so may not work as expected? + + + - DONE: You cannot afford the rankup is using a NBSP for the thousand separator. Using Prison v3.2.11, Java 16, and spigot 1.16.5. Cannot reproduce. Was a server hosting config issue, but not sure why it only impacted that one message. + + + - DONE: SELLALL has huge performance issues! It takes 2.3 ms to autosell, and full auto features block handling is 4.2 ms!! Serious performance issue with sellall, and autosell is bypassing the command handler too! + - added 'autosellTiming:' stats to auto features autosell to track actual sell time using nano-seconds... initial tests show there maybe significant performance issues. + - autosell in auto features causing lag? Flaco21 + - Issue with autosell causing lag? + - DONE: see RankPlayer addBalance cache - 1250 times improvement! + + +- DONE: admin gui - allows them to bypass No Economy safeguards. + + +* DONE: Add commands to list shop prices in console. Currently sellall is 100% gui so cannot be used offline. + + +- DONE: lapis lazuli is not auto selling + + +- DONE: Upon startup the first time, broadcast to everyone that they should use /ranks autoConfigure. + - Broadcast failed ranks too. + +- DONE: update CMI delayed loading docs... they are "backwards" + + + - DONE: No economy error message not showing + - works on delayed startup + - Fails when not delayed - gui ranks was registering on top of ranks warning + +- DONE: /ranks autoConfigure - review setup and maybe enable skip resets and tweak some notification settings. + + + # TODO Items for v3.2.11-alpha.13 diff --git a/gradle.properties b/gradle.properties index f94e8f6cc..697e8db41 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-beta.2 +version=3.3.0-alpha.7 #version=3.3.0-alpha.7 From 37d34221166d3ee66e2be72aea086e20a96eb948 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 10 Feb 2022 02:08:27 -0500 Subject: [PATCH 065/297] Provide information on locale settings within the `/prison version` command. Falls back to the en_US properties file if the selected language file does not exist. If the non en_US properties files are found to be missing a property, then the english property is used as a fallback. These fallbacks are not written back to the save files. --- .../java/tech/mcprison/prison/Prison.java | 8 ++ .../tech/mcprison/prison/PrisonCommand.java | 9 ++ .../prison/commands/CommandHandler.java | 2 +- .../prison/commands/RegisteredCommand.java | 6 +- .../prison/localization/LocaleManager.java | 100 +++++++++++++++--- .../prison/spigot/configs/MessagesConfig.java | 54 +++++++++- 6 files changed, 160 insertions(+), 19 deletions(-) diff --git a/prison-core/src/main/java/tech/mcprison/prison/Prison.java b/prison-core/src/main/java/tech/mcprison/prison/Prison.java index 0683fdb3b..0d0456986 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/Prison.java +++ b/prison-core/src/main/java/tech/mcprison/prison/Prison.java @@ -105,10 +105,14 @@ public class Prison private PrisonTPS prisonTPS; + private List localeLoadInfo; + private Prison() { super(); this.serverStartupTime = System.currentTimeMillis(); + + this.localeLoadInfo = new ArrayList<>(); } /** @@ -768,5 +772,9 @@ public String getServerRuntimeFormatted() { public PrisonTPS getPrisonTPS() { return prisonTPS; } + + public List getLocaleLoadInfo() { + return localeLoadInfo; + } } 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 4a9a88e79..522ec88d9 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -340,6 +340,15 @@ else if ( !isBasic ) { display.addComponent( component ); } + + display.addText(""); + display.addText("&7Locale Settings:"); + + for ( String localeInfo : Prison.get().getLocaleLoadInfo() ) { + display.addText( ". . " + localeInfo ); + } + + Prison.get().getPlatform().identifyRegisteredPlugins(); // NOTE: This list of plugins is good enough and the detailed does not have all the info. diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/CommandHandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/CommandHandler.java index 6ab541761..130d1f65c 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/CommandHandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/CommandHandler.java @@ -754,7 +754,7 @@ public boolean onCommand(CommandSender sender, PluginCommand command, String lab return false; } - if (rootCommand.onlyPlayers() && !(sender instanceof Player)) { + if (rootCommand.isOnlyPlayers() && !(sender instanceof Player)) { Prison.get().getLocaleManager().getLocalizable("cantAsConsole") .sendTo(sender, LogLevel.ERROR); return true; diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/RegisteredCommand.java b/prison-core/src/main/java/tech/mcprison/prison/commands/RegisteredCommand.java index d2eaf3cc7..4e36bceee 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/RegisteredCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/RegisteredCommand.java @@ -381,9 +381,9 @@ public boolean isSet() { return set; } - public boolean onlyPlayers() { - return onlyPlayers; - } +// public boolean onlyPlayers() { +// return onlyPlayers; +// } public void sendHelpMessage(CommandSender sender) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java b/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java index 4ec090789..af418e629 100755 --- a/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java @@ -54,6 +54,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.TimeZone; import java.util.TreeMap; import java.util.zip.ZipEntry; @@ -81,6 +82,9 @@ public class LocaleManager { static final HashMap> ALTERNATIVES = new HashMap<>(); private static final String DEFAULT_LOCALE = "en_US"; private static final String LOCALE_FOLDER = "lang"; + + public static final String LOCALE_ERROR__CONFIG_LANG_NOT_FOUND = "local.error.configNotFound"; + public static final String LOCALE_ERROR__FALLBACK_COUNT = "local.error.fallbackcount"; static { // English dialects @@ -91,24 +95,24 @@ public class LocaleManager { ALTERNATIVES.put("en_US", Arrays.asList("en_CA", "en_GB", "en_AU")); // Spanish dialects (not sure how accurate this is, mostly guesswork) - ALTERNATIVES.put("es_AR", Arrays.asList("es_UY", "es_VE", "es_MX", "es_ES")); - ALTERNATIVES.put("es_ES", Arrays.asList("es_MX", "es_AR", "es_UY", "es_VE")); - ALTERNATIVES.put("es_MX", Arrays.asList("es_ES", "es_AR", "es_UY", "es_VE")); - ALTERNATIVES.put("es_UY", Arrays.asList("es_AR", "es_VE", "es_MX", "es_ES")); - ALTERNATIVES.put("es_VE", Arrays.asList("es_AR", "es_UY", "es_MX", "es_ES")); + ALTERNATIVES.put("es_AR", Arrays.asList("es_UY", "es_VE", "es_MX", "es_ES", "en_US")); + ALTERNATIVES.put("es_ES", Arrays.asList("es_MX", "es_AR", "es_UY", "es_VE", "en_US")); + ALTERNATIVES.put("es_MX", Arrays.asList("es_ES", "es_AR", "es_UY", "es_VE", "en_US")); + ALTERNATIVES.put("es_UY", Arrays.asList("es_AR", "es_VE", "es_MX", "es_ES", "en_US")); + ALTERNATIVES.put("es_VE", Arrays.asList("es_AR", "es_UY", "es_MX", "es_ES", "en_US")); // French dialects - ALTERNATIVES.put("fr_CA", Arrays.asList("fr_FR")); - ALTERNATIVES.put("fr_FR", Arrays.asList("fr_CA")); + ALTERNATIVES.put("fr_CA", Arrays.asList("fr_FR", "en_US")); + ALTERNATIVES.put("fr_FR", Arrays.asList("fr_CA", "en_US")); // Norwegian dialects (not sure how accurate this is) - ALTERNATIVES.put("nb_NO", Arrays.asList("no_NO", "nn_NO")); - ALTERNATIVES.put("nn_NO", Arrays.asList("no_NO", "nb_NO")); - ALTERNATIVES.put("no_NO", Arrays.asList("nb_NO", "nn_NO")); + ALTERNATIVES.put("nb_NO", Arrays.asList("no_NO", "nn_NO", "en_US")); + ALTERNATIVES.put("nn_NO", Arrays.asList("no_NO", "nb_NO", "en_US")); + ALTERNATIVES.put("no_NO", Arrays.asList("nb_NO", "nn_NO", "en_US")); // Portugese dialects - ALTERNATIVES.put("pt_BR", Arrays.asList("pt_PT")); - ALTERNATIVES.put("pt_PT", Arrays.asList("pt_BR")); + ALTERNATIVES.put("pt_BR", Arrays.asList("pt_PT", "en_US")); + ALTERNATIVES.put("pt_PT", Arrays.asList("pt_BR", "en_US")); } private final PluginEntity module; @@ -473,6 +477,76 @@ private void loadCustomLocales() { " - not loading"); } } + + + // Get the English properties, and use that to ensure entries exist for all of the other + // languages... if not, then copy over the english value. + Properties enUS = configs.get( DEFAULT_LOCALE ); + if ( enUS != null ) { + boolean forceDefault = false; + + // If the config.yml default lang does not exist in this module, copy enUS to + // be used in it's place: + if ( !configs.containsKey( defaultLocale ) ) { + configs.put( defaultLocale, enUS ); + + // log it + Prison.get().getLocaleLoadInfo().add( String.format( + "&3Module: &7%s &3Locale: &7%s &3Warning: Locale specific file does not exist for this " + + "module so defaulting to &7%s.properties&3.", + module.getName(), defaultLocale, DEFAULT_LOCALE ) ); + forceDefault = true; + } + + Set keys = configs.keySet(); + for ( String key : keys ) + { + if ( !key.equalsIgnoreCase( DEFAULT_LOCALE ) ) { + Properties otherLang = configs.get( key ); + if ( otherLang != null ) { + + int fallbackCount = 0; + + + + for ( String enUSKey : enUS.stringPropertyNames() ) + { + String propValueOther = otherLang.getProperty( enUSKey ); + + if ( propValueOther == null || propValueOther.trim().length() == 0 + ) { + + // Add the english value since it is missing: + otherLang.put( enUSKey, enUS.getProperty( enUSKey ) ); + fallbackCount++; + + } + } + + if ( defaultLocale.equalsIgnoreCase( key ) && !forceDefault ) { + + if ( fallbackCount > 0 ) { + // log it + Prison.get().getLocaleLoadInfo().add( String.format( + "&3Module: &7%s &3Locale: &7%s &3Warning: Locale had &7%d &3missing entries " + + "and will fallback to settings from &7%s.properties&3.", + module.getName(), defaultLocale, fallbackCount, DEFAULT_LOCALE ) ); + + } + else { + Prison.get().getLocaleLoadInfo().add( String.format( + "&3Module: &7%s &3Locale language file: &7%s.properties", + module.getName(), defaultLocale ) ); + + + } + } + + } + } + } + + } } } @@ -607,8 +681,8 @@ private void loadLocale(String name, InputStream is, boolean printStackTrace) { try { - Properties temp = new Properties(); + // temp.load(is); // The InputStream is part of a zipEntry so it cannot be closed, or it will close the zip stream diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java index 4306127ac..bacb4caa1 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java @@ -1,8 +1,10 @@ package tech.mcprison.prison.spigot.configs; +import tech.mcprison.prison.Prison; import tech.mcprison.prison.spigot.SpigotPrison; import java.io.*; +import java.nio.charset.Charset; import java.util.Properties; /** @@ -39,10 +41,58 @@ public static MessagesConfig get(){ * */ @Deprecated private void initConfig(){ - try(FileInputStream data = new FileInputStream(SpigotPrison.getInstance().getDataFolder() + path + defaultLanguage + ".properties")){ + + String pathStr = SpigotPrison.getInstance().getDataFolder() + path; + File path = new File( pathStr ); + + String enUSFileName = "en_US" + ".properties"; + File enUSFile = new File( path, enUSFileName ); + + String targetFileName = defaultLanguage + ".properties"; + File targetFile = new File( path, targetFileName ); + + if ( enUSFile.exists() && !targetFile.exists() ) { + targetFile = enUSFile; + + Prison.get().getLocaleLoadInfo().add( String.format( + "&3pseudo-Module: &7GUI-sellall &3Locale: &7%s &3Warning: Locale file does not exist; using " + + " &7%s.properties&3. path: %s", + targetFileName, enUSFileName, pathStr ) ); + } + else { + Prison.get().getLocaleLoadInfo().add( String.format( + "&3pseudo-Module: &7GUI-sellall &3Locale: &7%s Using this language file with no validation. path: %s", + targetFileName, enUSFileName, pathStr ) ); + + } + + + try ( + FileInputStream is = new FileInputStream( targetFile ) + ) { Properties temp = new Properties(); - temp.load(new InputStreamReader(data)); + + // NOTE: This code is from tech.mcprison.prison.localization.LocaleManager.loadLocale(String, InputStream, boolean) + + + // The InputStream is part of a zipEntry so it cannot be closed, or it will close the zip stream + BufferedReader br = new BufferedReader( new InputStreamReader( is, Charset.forName("UTF-8") )); + String line = br.readLine(); + + while ( line != null ) { + if ( !line.startsWith( "#" ) && line.contains( "=" ) ) { + + String[] keyValue = line.split( "\\=" ); + String value = (keyValue.length > 1 ? keyValue[1] : ""); // StringEscapeUtils.escapeJava( keyValue[1] ); + temp.put( keyValue[0], value ); + } + + line = br.readLine(); + } + + // WARNING: cannot use the properties.load() function since it is NOT utf-8 capable. +// temp.load(new InputStreamReader(data)); properties = temp; } catch (IOException ex){ From f83bc2aabc753c2359131ca1ea0d8c1bb5e60c7a Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 10 Feb 2022 02:09:27 -0500 Subject: [PATCH 066/297] Provide information on locale settings within the `/prison version` command. Falls back to the en_US properties file if the selected language file does not exist. If the non en_US properties files are found to be missing a property, then the english property is used as a fallback. These fallbacks are not written back to the save files. --- docs/changelog_v3.3.x.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e3a5ad57e..d830861bf 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,12 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.7 2022-02-09 +# 3.3.0-alpha.7 2022-02-10 + + +* **Provide information on locale settings within the `/prison version` command.** +Falls back to the en_US properties file if the selected language file does not exist. +If the non en_US properties files are found to be missing a property, then the english property is used as a fallback. These fallbacks are not written back to the save files. * **v3.3.0-alpha.7 2022-02-09** From 91039957b299aff90b8201e65fc4d4090f2b65ba Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Feb 2022 15:51:33 -0500 Subject: [PATCH 067/297] Bug fix: cleaned up the way PlayerCache files are managed. Eliminated a lot of old code and simplifed the logic to ensure the liklihood of preventing corruption of the player caches. There has been some reports that the files were not being properly tracked and stats were being replaced with new entries. This also fixes some performance issues by caching the files in the directories. So once loaded, the loaders no longer need to read the file listings, which could take a while with a lot of files. --- docs/changelog_v3.3.x.md | 6 +- .../mcprison/prison/cache/PlayerCache.java | 56 +++--- .../prison/cache/PlayerCacheFiles.java | 188 +++++++++++++----- 3 files changed, 175 insertions(+), 75 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d830861bf..26a7fb476 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.7 2022-02-10 +# 3.3.0-alpha.7 2022-02-12 + + +* **Bug fix: cleaned up the way PlayerCache files are managed.** +Eliminated a lot of old code and simplifed the logic to ensure the liklihood of preventing corruption of the player caches. There has been some reports that the files were not being properly tracked and stats were being replaced with new entries. This also fixes some performance issues by caching the files in the directories. So once loaded, the loaders no longer need to read the file listings, which could take a while with a lot of files. * **Provide information on locale settings within the `/prison version` command.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java index 6aee36ca2..3e4e4ee2f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java @@ -248,42 +248,43 @@ public PlayerCachePlayerData getOnlinePlayer( Player player ) { */ private PlayerCachePlayerData getPlayer( Player player ) { PlayerCachePlayerData playerData = null; - getStats().incrementGetPlayers(); - String playerUuid = player == null || player.getUUID() == null ? null : - player.getUUID().toString(); - if ( !getPlayers().containsKey( playerUuid ) ) { + if ( player != null && player.getUUID() != null ) { - // Load the player's existing balance: - playerData = getCacheFiles().fromJson( player ); - - // NOTE: playerData.isOnline() is dynamic and tied back to the Player object. - // So if they are offline, an OfflinePlayer, then it will automatically - // track that. Also if the PlayerData object does not have a reference - /// to Player, then it's automatically considered offline. + String playerUuid = player.getUUID().toString(); - // Save it to the cache: - addPlayerData( playerData ); + if ( !getPlayers().containsKey( playerUuid ) ) { + + // Load the player's existing balance: + playerData = getCacheFiles().fromJson( player ); + + // NOTE: playerData.isOnline() is dynamic and tied back to the Player object. + // So if they are offline, an OfflinePlayer, then it will automatically + // track that. Also if the PlayerData object does not have a reference + /// to Player, then it's automatically considered offline. + + // Save it to the cache: + addPlayerData( playerData ); // runLoadPlayerNow( player ); // submitAsyncLoadPlayer( player ); - } - else { - - // Note: if the player has not been loaded yet, this will return a null: - playerData = getPlayers().get( playerUuid ); - } - - if ( playerData != null ) { - - if ( playerData.getPlayer() == null || !playerData.getPlayer().equals( player ) ) { + } + else { - playerData.setPlayer( player ); + // Note: if the player has not been loaded yet, this will return a null: + playerData = getPlayers().get( playerUuid ); } - playerData.updateLastSeen(); + if ( playerData != null ) { + + if ( playerData.getPlayer() == null || !playerData.getPlayer().equals( player ) ) { + + playerData.setPlayer( player ); + } + + playerData.updateLastSeen(); + } } - return playerData; } @@ -363,7 +364,8 @@ public PlayerCacheRunnable submitCacheUpdatePlayerStats() { PlayerCacheCheckTimersTask task = new PlayerCacheCheckTimersTask(); // Submit Timer Task to start running in 30 seconds (600 ticks) and then - // refresh stats every 10 seconds (200 ticks): + // refresh stats every 10 seconds (200 ticks). + // This does not update any files or interacts with bukkit/spigot. int taskId = PrisonTaskSubmitter.runTaskTimerAsync( task, 600, 200 ); task.setTaskId( taskId ); diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java index 8c5d4d15e..bcb972831 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java @@ -6,7 +6,12 @@ import java.io.FileWriter; import java.io.IOException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; +import java.util.List; +import java.util.NavigableMap; +import java.util.Set; +import java.util.TreeMap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -35,10 +40,22 @@ */ public class PlayerCacheFiles { + public static final String FILE_SUFFIX_JSON = ".json"; + public static final String FILE_PREFIX_BACKUP = ".backup_"; + public static final String FILE_SUFFIX_BACKUP = ".bu"; + public static final String FILE_SUFFIX_TEMP = ".temp"; + public static final String FILE_TIMESTAMP_FORMAT = "_yyyy-MM-dd_HH-mm-ss"; + public static final String FILE_PLAYERCACHE_PATH = "data_storage/playerCache"; + + private Gson gson = null; private File playerCacheDirectory = null; + + private TreeMap playerFiles; + + public PlayerCacheFiles() { super(); @@ -94,6 +111,11 @@ public void toJsonFile( PlayerCachePlayerData player) { File playerFile = player.getPlayerFile(); File outTemp = createTempFile( playerFile ); + + if ( !getPlayerFiles().containsKey( playerFile.getName() )) { + getPlayerFiles().put( playerFile.getName(), playerFile ); + } + boolean success = false; try ( @@ -142,7 +164,8 @@ public void toJsonFile( PlayerCachePlayerData player) { private void renamePlayerFileToBU( File playerFile ) { - String buFileName = ".backup_" + playerFile.getName().replace( ".temp", ".bu" ); + String buFileName = FILE_PREFIX_BACKUP + + playerFile.getName().replace( FILE_SUFFIX_TEMP, FILE_SUFFIX_BACKUP ); File backupFile = new File( playerFile.getParent(), buFileName ); @@ -151,8 +174,8 @@ private void renamePlayerFileToBU( File playerFile ) } private File createTempFile( File file ) { - SimpleDateFormat sdf = new SimpleDateFormat("_yyyy-MM-dd_HH-mm-ss"); - String name = file.getName() + sdf.format( new Date() ) + ".temp"; + SimpleDateFormat sdf = new SimpleDateFormat( FILE_TIMESTAMP_FORMAT ); + String name = file.getName() + sdf.format( new Date() ) + FILE_SUFFIX_TEMP; return new File( file.getParentFile(), name); } @@ -161,8 +184,13 @@ private File createTempFile( File file ) { *

This loads the PlayerCachePlayerData object from a saved json file. *

* + *

Since this deals with the actual file name, the "knowledge" on how to + * properly generate that file name is contained within this class and should + * never be exposed since it may not be correct and can lead to errors. + *

+ * */ - public PlayerCachePlayerData fromJsonFile( File inputFile ) { + private PlayerCachePlayerData fromJsonFile( File inputFile ) { PlayerCachePlayerData results = null; try ( FileReader fr = new FileReader( inputFile ); @@ -170,6 +198,8 @@ public PlayerCachePlayerData fromJsonFile( File inputFile ) { results = getGson().fromJson( fr, PlayerCachePlayerData.class ); + + results.setPlayerFile( inputFile ); } catch ( IOException e ) { @@ -206,23 +236,23 @@ public PlayerCachePlayerData fromJsonFile( File inputFile ) { * @return */ private String getPlayerFileName( Player player ) { - String uuidHex = player.getUUID().toString(); - String uuidFragment = getFileNamePrefix( uuidHex ); + String UUIDString = player.getUUID().toString(); + String uuidFragment = getFileNamePrefix( UUIDString ); - return uuidFragment + "_" + player.getName() + ".json"; + return uuidFragment + "_" + player.getName() + FILE_SUFFIX_JSON; } /** *

This function returns the first 13 characters of the supplied - * file name, or UUID String. 13 characters only because the 14th character - * is a hyphen. + * file name, or UUID String. The hyphen is around the 12 or 13th position, + * so it may or may not include it. *

* * @param playerFileName * @return */ - private String getFileNamePrefix( String fileName ) { - return fileName.substring( 0, 14 ); + private String getFileNamePrefix( String UUIDString ) { + return UUIDString.substring( 0, 14 ); } @@ -236,7 +266,7 @@ private String getFileNamePrefix( String fileName ) { public File getPlayerFilePath() { if ( playerCacheDirectory == null ) { - playerCacheDirectory = new File( Prison.get().getDataFolder(), "data_storage/playerCache" ); + playerCacheDirectory = new File( Prison.get().getDataFolder(), FILE_PLAYERCACHE_PATH ); playerCacheDirectory.mkdirs(); } @@ -291,37 +321,16 @@ private File getPlayerFile( String playerFileName ) { public PlayerCachePlayerData fromJson( Player player ) { PlayerCachePlayerData results = null; +// // This is the "target" file name for the player, based upon their +// // current name. The saved cache file may not be named exactly the same, +// // and if it's not, then their existing cache file will be renamed +// // within the function getCachedFileMatch() String playerFileName = getPlayerFileName( player ); - String fileNamePrefix = getFileNamePrefix( playerFileName ); - - // This is the "target" file name for the player, based upon their - // current name. The saved cache file may not be named exactly the same, - // and if it's not, then their existing cache file needs to be - // renamed. - File playerFile = getPlayerFile( playerFileName ); - - - FileFilter fileFilter = file -> !file.isDirectory() && - file.getName().startsWith(fileNamePrefix) && - file.getName().endsWith(".json"); - File[] files = playerFile.getParentFile().listFiles( fileFilter ); - - if ( files != null && files.length > 0 ) { - - for ( File file : files ) - { - PlayerCachePlayerData temp = fromJsonFile( file ); - if ( temp != null && temp.getPlayerUuid().equalsIgnoreCase( - player.getUUID().toString() ) ) { - - results = temp; - results.setPlayerFile( file ); - break; - } - } - } + File playerFile = getCachedFileMatch( playerFileName ); + results = fromJsonFile( playerFile ); + // New player and file does not exist so create it. if ( results == null ) { results = new PlayerCachePlayerData( player, playerFile ); @@ -330,17 +339,102 @@ public PlayerCachePlayerData fromJson( Player player ) { toJsonFile( results ); } - // Check to see if the player's name has changed, which means the generated - // file name does not match. If that is the situation, then need to rename - // the file to match the current player's name. - if ( results != null ) { - if ( results.getPlayerFile().equals( playerFile ) ) { + return results; + } + + + + private TreeMap getPlayerFiles() { + // load the player's files: + if ( playerFiles == null ) { + + playerFiles = new TreeMap<>(); + + FileFilter fileFilter = (file) -> { + + String fname = file.getName(); + boolean isTemp = fname.startsWith( FILE_PREFIX_BACKUP ) || + fname.endsWith( FILE_SUFFIX_BACKUP ) || + fname.endsWith( FILE_SUFFIX_TEMP ); - results.getPlayerFile().renameTo( playerFile ); - results.setPlayerFile( playerFile ); + return !file.isDirectory() && !isTemp && + fname.endsWith( FILE_SUFFIX_JSON ); + }; + + + File[] files = getPlayerFilePath().listFiles( fileFilter ); + for ( File f : files ) + { + String fileNamePrefix = getFileNamePrefix( f.getName() ); + getPlayerFiles().put( fileNamePrefix, f ); + } + + } + + return playerFiles; + } + + /** + *

Potentially there could be more than one result, but considering if a player + * changes their name, then it should only return only one entry. The reason for + * this, is that the file name should be based upon the player's UUID, which is the + * first 13 characters of the file, and the name itself, which follows, should + * never be part of the "key". + *

+ * + * @param playerFile + * @param playerFileName + * @return + */ + private File getCachedFileMatch( String playerFileName ) + { + File results = null; + + String fileNamePrefix = getFileNamePrefix( playerFileName ); + + results = getPlayerFiles().get( fileNamePrefix ); + + if ( results == null ) { + + // This is the "target" file name for the player, based upon their + // current name. The saved cache file may not be named exactly the same, + // and if it's not, then their existing cache file needs to be + // renamed. + File playerFile = getPlayerFile( playerFileName ); + + // NOTE: because the file was NOT found in the directory, then we can assume + // this is a new player therefore we won't have an issue with the player's + // name changing. + getPlayerFiles().put( fileNamePrefix, playerFile ); + } + else if ( !playerFileName.equalsIgnoreCase( results.getName() )) { + + // File name changed!!! Need to rename the file in the file system, and + // update what is in the playerFiles map!! + + File newFile = getPlayerFile( playerFileName ); + + if ( results.exists() ) { + // rename what's on the file system: + results.renameTo( newFile ); } + + // Replace what's in the map: + getPlayerFiles().put( fileNamePrefix, newFile ); + + results = newFile; } +// NavigableMap files = getPlayerFiles().tailMap( fileNamePrefix, true ); +// Set keys = files.keySet(); +// for ( String key : keys ) { +// if ( !key.startsWith( fileNamePrefix ) ) { +// break; +// } +// +// results.add( files.get( key ) ); +// } + return results; } From 99fa63a53cf68447aab9fad3b3cf5c9701ac22fe Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Feb 2022 20:46:10 -0500 Subject: [PATCH 068/297] Redesigned the initial mine air-counts which not only identifies which blocks are within a mine upon startup, but it also establishes the number of air blocks in a mine to help ensure it's able to properly reset when the mine is empty. --- docs/changelog_v3.3.x.md | 3 + .../tech/mcprison/prison/util/Location.java | 11 +- .../data/MineCountAirBlocksAsyncTask.java | 25 -- .../mcprison/prison/mines/data/MineReset.java | 285 ++++++++++++------ .../mcprison/prison/mines/data/MineTasks.java | 8 +- ...tartupRefreshBlockBreakCountAsyncTask.java | 21 -- ...StartupRefreshBlockBreakCountSyncTask.java | 173 +++++++++++ 7 files changed, 386 insertions(+), 140 deletions(-) delete mode 100644 prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineCountAirBlocksAsyncTask.java delete mode 100644 prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountAsyncTask.java create mode 100644 prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountSyncTask.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 26a7fb476..37b2bd283 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.7 2022-02-12 +* **Redesigned the initial mine air-counts which not only identifies which blocks are within a mine upon startup, but it also establishes the number of air blocks in a mine to help ensure it's able to properly reset when the mine is empty.** + + * **Bug fix: cleaned up the way PlayerCache files are managed.** Eliminated a lot of old code and simplifed the logic to ensure the liklihood of preventing corruption of the player caches. There has been some reports that the files were not being properly tracked and stats were being replaced with new entries. This also fixes some performance issues by caching the files in the directories. So once loaded, the loaders no longer need to read the file listings, which could take a while with a lot of files. diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/Location.java b/prison-core/src/main/java/tech/mcprison/prison/util/Location.java index 07df41a44..19ffde5c3 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/util/Location.java +++ b/prison-core/src/main/java/tech/mcprison/prison/util/Location.java @@ -36,6 +36,8 @@ public class Location { private float pitch, yaw; private Vector direction; + + private boolean isEdge; public Location(World world, double x, double y, double z, float pitch, float yaw, Vector direction) { this.world = world; @@ -146,7 +148,14 @@ public void setBlockAsync( PrisonBlock prisonBlock ) { world.setBlockAsync( prisonBlock, this ); } - @Override public boolean equals(Object o) { + public boolean isEdge() { + return isEdge; + } + public void setEdge( boolean isEdge ) { + this.isEdge = isEdge; + } + + @Override public boolean equals(Object o) { if (this == o) { return true; } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineCountAirBlocksAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineCountAirBlocksAsyncTask.java deleted file mode 100644 index c33831f4d..000000000 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineCountAirBlocksAsyncTask.java +++ /dev/null @@ -1,25 +0,0 @@ -package tech.mcprison.prison.mines.data; - -import tech.mcprison.prison.tasks.PrisonRunnable; - -public class MineCountAirBlocksAsyncTask - implements PrisonRunnable { - - private MineReset mine; - private PrisonRunnable callbackAsync; - - public MineCountAirBlocksAsyncTask(MineReset mine, PrisonRunnable callbackAsync) { - this.mine = mine; - this.callbackAsync = callbackAsync; - } - - @Override - public void run() { - this.mine.refreshAirCountAsyncTask(); - - if ( this.callbackAsync != null ) { - this.mine.submitAsyncTask( callbackAsync ); - } - } - -} diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index f318ed093..293417ba8 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -15,8 +15,8 @@ import tech.mcprison.prison.internal.block.MineTargetBlockKey; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock; -import tech.mcprison.prison.internal.block.PrisonBlockStatusData; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; +import tech.mcprison.prison.internal.block.PrisonBlockStatusData; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.MineScheduler.MineJob; import tech.mcprison.prison.mines.data.MineScheduler.MineResetActions; @@ -443,9 +443,9 @@ public void saveIfUnsavedBlockCounts() { * * @param callbackAsync */ - public abstract void submitAsyncTask( PrisonRunnable callbackAsync ); + public abstract int submitAsyncTask( PrisonRunnable callbackAsync ); - public abstract void submitSyncTask( PrisonRunnable callbackSync ); + public abstract int submitSyncTask( PrisonRunnable callbackSync ); @@ -535,7 +535,8 @@ public void generateBlockListAsync() { // // setup the monitoring of the blocks that have constraints: // List constrainedBlocks = null; - + Optional worldOptional = getWorld(); + World world = worldOptional.get(); int airCount = 0; int currentLevel = 0; @@ -574,7 +575,9 @@ public void generateBlockListAsync() { boolean isEdge = xEdge && yEdge || xEdge && zEdge || yEdge && zEdge; - + Location targetBlock = new Location(world, x, y, z); + targetBlock.setEdge( isEdge ); + // MineTargetBlock mtb = null; // track the constraints: (obsolete) @@ -587,7 +590,7 @@ public void generateBlockListAsync() { // Increment the mine's block count. This block is one of the control blocks: incrementResetBlockCount( prisonBlock ); - addMineTargetPrisonBlock( prisonBlock, x, y, z, isEdge ); + addMineTargetPrisonBlock( prisonBlock, targetBlock ); // mtb = new MineTargetPrisonBlock( prisonBlock, x, y, z); if ( prisonBlock.equals( PrisonBlock.AIR ) ) { @@ -1090,11 +1093,13 @@ public void refreshBlockBreakCountUponStartup() { // bounds and therefore do not run the task. if ( getBounds() != null ) { - OnStartupRefreshBlockBreakCountAsyncTask cabAsyncTask = new OnStartupRefreshBlockBreakCountAsyncTask(this); + OnStartupRefreshBlockBreakCountSyncTask.submit( this ); - // Must run synchronously!! - submitSyncTask( cabAsyncTask ); - //submitAsyncTask( cabAsyncTask ); +// OnStartupRefreshBlockBreakCountAsyncTask cabAsyncTask = new OnStartupRefreshBlockBreakCountAsyncTask(this); +// +// // Must run synchronously!! +// submitSyncTask( cabAsyncTask ); +// //submitAsyncTask( cabAsyncTask ); } } @@ -1115,8 +1120,9 @@ public void refreshBlockBreakCountUponStartup() { *

* */ - protected void refreshAirCountAsyncTask() + protected boolean refreshAirCountSyncTaskCheckBeforeSubmit() { + boolean results = false; if ( isVirtual() ) { // ignore: @@ -1138,13 +1144,9 @@ else if ( getPrisonBlocks().size() == 1 && setAirCount( 0 ); } else { - long start = System.currentTimeMillis(); Optional worldOptional = getWorld(); World world = worldOptional.get(); - - boolean containsCustomBlocks = getPrisonBlockTypes().contains( PrisonBlockType.CustomItems ); - if ( world == null ) { Output.get().logError( String.format( "MineReset: refreshAirCountAsyncTask failure: The world is invalid and " + @@ -1152,16 +1154,47 @@ else if ( getPrisonBlocks().size() == 1 && getName(), getWorldName() )); - return; } + else { + + // This means we can actually go ahead and perform the air-counts and so the + // actual job can be submitted: + return true; + } + + } + + return results; + } + + + /** + *

This can be ran Asynchronously because it's just creating the Locations that will be used + * to generate the target blocks. This does not update anything in the world so can be + * async. + *

+ * + * @return + */ + public List refreshAirCountSyncTaskBuildLocations() { + List locations = new ArrayList<>(); + +// long start = System.currentTimeMillis(); + Optional worldOptional = getWorld(); + World world = worldOptional.get(); + + + { +// boolean containsCustomBlocks = getPrisonBlockTypes().contains( PrisonBlockType.CustomItems ); + // Reset the target block lists: clearMineTargetPrisonBlocks(); - int airCount = 0; - int errorCount = 0; +// int airCount = 0; +// int errorCount = 0; @@ -1176,87 +1209,151 @@ else if ( getPrisonBlocks().size() == 1 && - StringBuilder sb = new StringBuilder(); +// StringBuilder sb = new StringBuilder(); for (int y = yMax; y >= yMin; y--) { for (int x = xMin; x <= xMax; x++) { for (int z = zMin; z <= zMax; z++) { - try { - Location targetBlock = new Location(world, x, y, z); - Block tBlock = targetBlock.getBlockAt( containsCustomBlocks ); - - - boolean xEdge = x == xMin || x == xMax; - boolean yEdge = y == yMin || y == yMax; - boolean zEdge = z == zMin || z == zMax; - - boolean isEdge = xEdge && yEdge || xEdge && zEdge || - yEdge && zEdge; - - - - PrisonBlock pBlock = tBlock.getPrisonBlock(); - - if ( pBlock != null ) { - - // Increment the mine's block count. This block is one of the control blocks: - addMineTargetPrisonBlock( incrementResetBlockCount( pBlock ), x, y, z, isEdge ); - - } - - if ( pBlock == null || pBlock.isAir() ) { - airCount++; - } - } - catch ( Exception e ) { - // Updates to the "world" should never be ran async. Upon review of the above - // that gets the location and block, causes the chunk to load, if it is not loaded, - // and if there is an entity in that loaded chunk it will throw an exception: - // java.lang.IllegalStateException: Asynchronous entity world add! - // If there are no entities, it will be fine, but they could cause issues with async - // access of unloaded chunks. - String coords = String.format( "%d.%d.%d ", x, y, z ); - if ( errorCount ++ == 0 ) { - String message = String.format( - "MineReset.refreshAirCountAsyncTask: Error counting air blocks: " + - "Mine=%s coords=%s Error: %s ", getName(), coords, e.getMessage() ); - if ( e.getMessage() != null && e.getMessage().contains( "Asynchronous entity world add" )) { - Output.get().logWarn( message, e ); - } else { - Output.get().logWarn( message, e ); - } - - } - else if ( errorCount <= 20 ) { - sb.append( coords ); - } - } + boolean xEdge = x == xMin || x == xMax; + boolean yEdge = y == yMin || y == yMax; + boolean zEdge = z == zMin || z == zMax; + + boolean isEdge = xEdge && yEdge || xEdge && zEdge || + yEdge && zEdge; + + Location targetBlock = new Location(world, x, y, z); + targetBlock.setEdge( isEdge ); + + locations.add( targetBlock ); + + + +// try { +// +// Block tBlock = targetBlock.getBlockAt( containsCustomBlocks ); +// +// +// +// +// PrisonBlock pBlock = tBlock.getPrisonBlock(); +// +// if ( pBlock != null ) { +// +// // Increment the mine's block count. This block is one of the control blocks: +// addMineTargetPrisonBlock( incrementResetBlockCount( pBlock ), targetBlock ); +// +// } +// +// if ( pBlock == null || pBlock.isAir() ) { +// airCount++; +// } +// } +// catch ( Exception e ) { +// // Updates to the "world" should never be ran async. Upon review of the above +// // that gets the location and block, causes the chunk to load, if it is not loaded, +// // and if there is an entity in that loaded chunk it will throw an exception: +// // java.lang.IllegalStateException: Asynchronous entity world add! +// // If there are no entities, it will be fine, but they could cause issues with async +// // access of unloaded chunks. +// String coords = String.format( "%d.%d.%d ", x, y, z ); +// if ( errorCount ++ == 0 ) { +// String message = String.format( +// "MineReset.refreshAirCountAsyncTask: Error counting air blocks: " + +// "Mine=%s coords=%s Error: %s ", getName(), coords, e.getMessage() ); +// if ( e.getMessage() != null && e.getMessage().contains( "Asynchronous entity world add" )) { +// Output.get().logWarn( message, e ); +// } else { +// Output.get().logWarn( message, e ); +// } +// +// } +// else if ( errorCount <= 20 ) { +// sb.append( coords ); +// } +// } } } } - if ( errorCount > 0 ) { - String message = String.format( - "MineReset.refreshAirCountAsyncTask: Error counting air blocks: Mine=%s: " + - "errorCount=%d blocks%s : %s", getName(), errorCount, - (errorCount > 20 ? "(first 20)" : ""), - sb.toString() ); - Output.get().logWarn( message ); - } +// if ( errorCount > 0 ) { +// String message = String.format( +// "MineReset.refreshAirCountAsyncTask: Error counting air blocks: Mine=%s: " + +// "errorCount=%d blocks%s : %s", getName(), errorCount, +// (errorCount > 20 ? "(first 20)" : ""), +// sb.toString() ); +// Output.get().logWarn( message ); +// } +// +// +// setAirCount( airCount ); + +// long stop = System.currentTimeMillis(); +// long elapsed = stop - start; +// setAirCountElapsedTimeMs( elapsed ); +// setAirCountTimestamp( stop ); + } + + return locations; + } + + + public void refreshAirCountSyncTaskSetLocation( Location targetBlock, + OnStartupRefreshBlockBreakCountSyncTask stats ) { + + try { +// Location targetBlock = new Location(world, x, y, z); + boolean containsCustomBlocks = getPrisonBlockTypes().contains( PrisonBlockType.CustomItems ); + + Block tBlock = targetBlock.getBlockAt( containsCustomBlocks ); - setAirCount( airCount ); - long stop = System.currentTimeMillis(); - long elapsed = stop - start; - setAirCountElapsedTimeMs( elapsed ); - setAirCountTimestamp( stop ); + + PrisonBlock pBlock = tBlock.getPrisonBlock(); + + if ( pBlock != null ) { + + // Increment the mine's block count. This block is one of the control blocks: + addMineTargetPrisonBlock( incrementResetBlockCount( pBlock ), targetBlock ); + + } + + if ( pBlock == null || pBlock.isAir() ) { + stats.incrementAirCount(); + } + } + catch ( Exception e ) { + stats.incrementErrorCount(); + + // Updates to the "world" should never be ran async. Upon review of the above + // that gets the location and block, causes the chunk to load, if it is not loaded, + // and if there is an entity in that loaded chunk it will throw an exception: + // java.lang.IllegalStateException: Asynchronous entity world add! + // If there are no entities, it will be fine, but they could cause issues with async + // access of unloaded chunks. + String coords = String.format( "%d.%d.%d ", + targetBlock.getBlockX(), targetBlock.getBlockY(), targetBlock.getBlockZ() ); + + if ( stats.getErrorCount() == 0 ) { + String message = String.format( + "MineReset.refreshAirCountAsyncTask: Error counting air blocks: " + + "Mine=%s coords=%s Error: %s ", getName(), coords, e.getMessage() ); + + if ( e.getMessage() != null && e.getMessage().contains( "Asynchronous entity world add" )) { + Output.get().logWarn( message, e ); + } else { + Output.get().logWarn( message, e ); + } + + } + else if ( stats.getErrorCount() <= 10 ) { + stats.getSbErrors().append( coords ); + } } } - /** *

This function should ONLY be used if an enchantment plugin is being used that cannot * provide a working explosion event to monitor, and the plugin is breaking more blocks than what @@ -1734,14 +1831,24 @@ public void setCurrentJob( MineJob currentJob ) } - - private void addMineTargetPrisonBlock( PrisonBlockStatusData block, int x, int y, int z, boolean isEdge ) { - - MineTargetPrisonBlock mtpb = new MineTargetPrisonBlock( block, getWorld().get(), x, y, z, isEdge ); - + + private void addMineTargetPrisonBlock( PrisonBlockStatusData block, Location targetBlock ) { + + MineTargetPrisonBlock mtpb = new MineTargetPrisonBlock( block, getWorld().get(), + targetBlock.getBlockX(), targetBlock.getBlockY(), targetBlock.getBlockZ(), + targetBlock.isEdge() ); + getMineTargetPrisonBlocks().add( mtpb ); getMineTargetPrisonBlocksMap().put( mtpb.getBlockKey(), mtpb ); - } + } + +// private void addMineTargetPrisonBlock( PrisonBlockStatusData block, int x, int y, int z, boolean isEdge ) { +// +// MineTargetPrisonBlock mtpb = new MineTargetPrisonBlock( block, getWorld().get(), x, y, z, isEdge ); +// +// getMineTargetPrisonBlocks().add( mtpb ); +// getMineTargetPrisonBlocksMap().put( mtpb.getBlockKey(), mtpb ); +// } private void clearMineTargetPrisonBlocks() { getMineTargetPrisonBlocks().clear(); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java index 59e9b8cc4..d63461fa1 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java @@ -52,14 +52,14 @@ protected void initialize() { * @param callbackAsync */ @Override - public void submitAsyncTask( PrisonRunnable callbackAsync ) { - Prison.get().getPlatform().getScheduler().runTaskLaterAsync( callbackAsync, + public int submitAsyncTask( PrisonRunnable callbackAsync ) { + return Prison.get().getPlatform().getScheduler().runTaskLaterAsync( callbackAsync, getResetPagePageSubmitDelayTicks() ); } @Override - public void submitSyncTask( PrisonRunnable callbackSync ) { - Prison.get().getPlatform().getScheduler().runTaskLater( callbackSync, + public int submitSyncTask( PrisonRunnable callbackSync ) { + return Prison.get().getPlatform().getScheduler().runTaskLater( callbackSync, getResetPagePageSubmitDelayTicks() ); } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountAsyncTask.java deleted file mode 100644 index 5da659e99..000000000 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountAsyncTask.java +++ /dev/null @@ -1,21 +0,0 @@ -package tech.mcprison.prison.mines.data; - -import tech.mcprison.prison.tasks.PrisonRunnable; - -public class OnStartupRefreshBlockBreakCountAsyncTask - implements PrisonRunnable { - - private MineReset mine; - - public OnStartupRefreshBlockBreakCountAsyncTask(MineReset mine) { - this.mine = mine; - } - - @Override - public void run() { - this.mine.refreshAirCountAsyncTask(); - - int airBlocks = mine.getAirCount(); - mine.setBlockBreakCount( mine.getBlockBreakCount() + airBlocks ); - } -} diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountSyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountSyncTask.java new file mode 100644 index 000000000..2dec70ff4 --- /dev/null +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountSyncTask.java @@ -0,0 +1,173 @@ +package tech.mcprison.prison.mines.data; + +import java.text.DecimalFormat; +import java.util.List; + +import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.tasks.PrisonRunnable; +import tech.mcprison.prison.util.Location; + +public class OnStartupRefreshBlockBreakCountSyncTask + implements PrisonRunnable { + + private MineReset mine; + private int jobId = 0; + + private List locations = null; + private int position = 0; + private int pages = 0; + + private int airCount = 0; + private long elapsedNanos = 0; + private int errorCount = 0; + private StringBuilder sbErrors = new StringBuilder(); + + + public OnStartupRefreshBlockBreakCountSyncTask(MineReset mine) { + this.mine = mine; + } + + public static void submit( MineReset mine ) { + + OnStartupRefreshBlockBreakCountSyncTask syncTask = + new OnStartupRefreshBlockBreakCountSyncTask( mine ); + + // Check to see if we can even submit the job: + if ( mine.refreshAirCountSyncTaskCheckBeforeSubmit() ) { + + // The first phase generates a List of Locations which + // can be ran async... + syncTask.setJobId( mine.submitAsyncTask( syncTask ) ); + } + + } + + private void resubmit() { + + // Must run synchronously!! + setJobId( mine.submitSyncTask( this ) ); + } + + @Override + public void run() { + + if ( locations == null ) { + + long nanoStart = System.nanoTime(); + locations = this.mine.refreshAirCountSyncTaskBuildLocations(); + long nanoEnd = System.nanoTime(); + long elpased = (nanoEnd - nanoStart ); + this.elapsedNanos += elpased; + + resubmit(); + } + else { + + long nanoStart = System.nanoTime(); + + int start = position; + for (int i = start; i < locations.size(); i++ ) { + + Location targetBlock = locations.get( i ); + + mine.refreshAirCountSyncTaskSetLocation( targetBlock, this ); + position++; + + if ( (i - start) % 500 == 0 ) { + + long nanoEnd = System.nanoTime(); + long elpased = (nanoEnd - nanoStart ); + long elapsedMs = elpased / 1000000; + if ( elapsedMs > 20 ) { + + // Check every 500 blocks and if been running longer than 20 ms then yield to prevent lag + + this.elapsedNanos += elpased; + pages++; + + // Need to yield and resubmit + resubmit(); + return; + } + } + + } + + // It will only hit this point when done processing all of the locations: + + pages++; + + mine.setAirCount( getAirCount() ); + mine.setBlockBreakCount( mine.getBlockBreakCount() + getAirCount() ); + + long nanoEnd = System.nanoTime(); + long elpased = (nanoEnd - nanoStart ); + this.elapsedNanos += elpased; + + double elapsedMs = ((double) elapsedNanos) / 1000000d; + + mine.setAirCountElapsedTimeMs( (long) elapsedMs ); + mine.setAirCountTimestamp( System.currentTimeMillis() ); + + if ( Output.get().isDebug() ) { + DecimalFormat dFmt = new DecimalFormat("#,##0.000"); + DecimalFormat iFmt = new DecimalFormat("#,##0"); + String message = String.format( + "MineReset startup air-count: Mine: %-6s " + + " blocks: %10s pages: %s elapsed %s ms", + mine.getName(), + iFmt.format( locations.size() ), + iFmt.format( pages ), + dFmt.format(elapsedMs) ); + + Output.get().logInfo( message ); + + } + + if ( getErrorCount() > 0 ) { + String message = String.format( + "MineReset.refreshAirCountAsyncTask: Error counting air blocks: Mine=%s: " + + "errorCount=%d blocks: %s : %s", mine.getName(), getErrorCount(), + (getErrorCount() > 20 ? "(first 20)" : ""), + getSbErrors().toString() ); + + Output.get().logWarn( message ); + } + } + + } + + public int getJobId() { + return jobId; + } + public void setJobId( int jobId ) { + this.jobId = jobId; + } + + public void incrementAirCount() { + airCount++; + } + public int getAirCount() { + return airCount; + } + public void setAirCount( int airCount ) { + this.airCount = airCount; + } + + public void incrementErrorCount() { + errorCount++; + } + public int getErrorCount() { + return errorCount; + } + public void setErrorCount( int errorCount ) { + this.errorCount = errorCount; + } + + public StringBuilder getSbErrors() { + return sbErrors; + } + public void setSbErrors( StringBuilder sbErrors ) { + this.sbErrors = sbErrors; + } +} From 941bba81ad50bf721039daa4fcf4b736232f35ed Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Feb 2022 20:48:58 -0500 Subject: [PATCH 069/297] Enable debug mode from within the config.yml file. It was not hooked up before. This is useful for initial logging of the mine air-counts. --- docs/changelog_v3.3.x.md | 4 ++++ .../tech/mcprison/prison/spigot/SpigotPrison.java | 12 ++++++++++-- prison-spigot/src/main/resources/config.yml | 12 +++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 37b2bd283..eb3bb768d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.7 2022-02-12 +* **Enable debug mode from within the config.yml file.** +It was not hooked up before. This is useful for initial logging of the mine air-counts. + + * **Redesigned the initial mine air-counts which not only identifies which blocks are within a mine upon startup, but it also establishes the number of air blocks in a mine to help ensure it's able to properly reset when the mine is empty.** 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 633ff0ac0..ff2aad6a2 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 @@ -190,6 +190,7 @@ public void onEnable() { this.saveDefaultConfig(); this.debug = getConfig().getBoolean("debug", false); + // Create the core directory structure if it is missing: initDataDir(); @@ -201,15 +202,22 @@ public void onEnable() { // prior to starting up: initCommandMap(); this.scheduler = new SpigotScheduler(this); + + SpigotPlatform platform = new SpigotPlatform(this); + // Show Prison's splash screen and setup the core components: Prison.get() - .init(new SpigotPlatform(this), Bukkit.getVersion()); - + .init(platform, Bukkit.getVersion()); // Enable the spigot locale manager: getLocaleManager(); + if ( debug ) { + Output.get().setDebug( debug ); + } + + this.compatibility = SpigotCompatibility.getInstance(); // initCompatibility(); Obsolete... diff --git a/prison-spigot/src/main/resources/config.yml b/prison-spigot/src/main/resources/config.yml index 98363d4df..2958e60f8 100644 --- a/prison-spigot/src/main/resources/config.yml +++ b/prison-spigot/src/main/resources/config.yml @@ -13,9 +13,15 @@ # # -# Note: This actually doesn't do anything. -# May have done something with v3.1.1 or earlier. -#debug: false + + +# Enables Prison's debug mode as soon as prison starts. +# Do not enable unless instructed to do so, since it will increase the amount of +# information sent to the console. To turn on/off debug mode, the following +# command will toggle it on and off: +# /prison debug +debug: false + # Upon server startup prison will check to see if a newer version has been released. check-updates: true From 00faf821d027bdd97446e73c47c7f4469f40ff57 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Feb 2022 02:21:46 -0500 Subject: [PATCH 070/297] v3.3.0-alpha.8 released. --- docs/changelog_v3.3.x.md | 7 ++++++- gradle.properties | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index eb3bb768d..0e969fa9f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,12 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.7 2022-02-12 +# 3.3.0-alpha.8s 2022-02-12 + + + + +***3.3.0-alpha.8 2022-02-12** * **Enable debug mode from within the config.yml file.** diff --git a/gradle.properties b/gradle.properties index 697e8db41..0fb5fff22 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.7 +version=3.3.0-alpha.8 #version=3.3.0-alpha.7 From b09ba99dd5150a2deb8c027c1c2a3629672488cf Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Feb 2022 02:22:14 -0500 Subject: [PATCH 071/297] Added various token funtions to the prison spigot API class. --- docs/changelog_v3.3.x.md | 1 + .../prison/spigot/api/PrisonSpigotAPI.java | 155 ++++++++++++++++++ 2 files changed, 156 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0e969fa9f..59ea35fc7 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,7 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8s 2022-02-12 +* **Added various token funtions to the prison spigot API class.** ***3.3.0-alpha.8 2022-02-12** 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 47e5df6c1..cccccd0b7 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 @@ -469,4 +469,159 @@ public Double getSellAllMoneyWithMultiplier(Player player){ return null; } + + /** + *

Gets a player's current token balance. + *

+ * + * @param player + * @return + */ + public long getTokens( Player player ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + return sPlayer.getPlayerCachePlayerData().getTokens(); + } + + /** + *

Gets a player's total amount of tokens that they have earned. + *

+ * + * @param player + * @return + */ + public long getTokensTotal( Player player ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + return sPlayer.getPlayerCachePlayerData().getTokensTotal(); + } + + /** + *

Gets a player's total amount of tokens given to them by admins. + *

+ * + * @param player + * @return + */ + public long getTokensTotalAdminAdded( Player player ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + return sPlayer.getPlayerCachePlayerData().getTokensTotalAdminAdded(); + } + + /** + *

Gets a player's total amount of tokens removed from them by admins. + *

+ * + * @param player + * @return + */ + public long getTokensTotalAdminRemoved( Player player ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + return sPlayer.getPlayerCachePlayerData().getTokensTotalAdminRemoved(); + } + + /** + *

Returns a Map of a player's total tokens earned by mine. + *

+ * + * @param player + * @return + */ + public TreeMap getTokensTotalByMine( Player player ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + return sPlayer.getPlayerCachePlayerData().getTokensByMine(); + } + + /** + *

Adds tokens to a player's current balance. The tokens + * will be counted as being earned under normal conditions. + *

+ * + * @param player + * @param amount + */ + public void addTokens( Player player, long amount ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + sPlayer.getPlayerCachePlayerData().addTokens( amount ); + } + + /** + *

Adds tokens to a player's balance, but will be recorded as + * an adjustment made by an admin, which means the player did not + * "earn" the tokens under normal conditions. + *

+ * + * @param player + * @param amount + */ + public void addTokensAdmin( Player player, long amount ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + sPlayer.getPlayerCachePlayerData().addTokensAdmin( amount ); + } + + /** + *

Removes tokens from a player's current balance. The tokens + * will be counted as being spent under normal conditions. + *

+ * + * @param player + * @param amount + */ + public void removeTokens( Player player, long amount ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + sPlayer.getPlayerCachePlayerData().removeTokens( amount ); + } + + /** + *

Removes tokens from a player's balance, but will be recorded as + * an adjustment made by an admin, which means the player did not + * "spend" the tokens under normal conditions. + *

+ * + * @param player + * @param amount + */ + public void removeTokensAdmin( Player player, long amount ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + sPlayer.getPlayerCachePlayerData().removeTokensAdmin( amount ); + } + + /** + *

Sets a player's current token balance. The tokens + * will be counted as being earned, or spent, under normal conditions, + * based upon the change in the original amounts. + *

+ * + * @param player + * @param amount + */ + public void setTokens( Player player, long amount ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + sPlayer.getPlayerCachePlayerData().setTokens( amount ); + } + + /** + *

Sets a player's current balance, but will be recorded as + * an adjustment made by an admin, which means the player did not + * "earn" or "spend" the tokens under normal conditions. + *

+ * + * @param player + * @param amount + */ + public void setTokensAdmin( Player player, long amount ) { + SpigotPlayer sPlayer = new SpigotPlayer( player ); + + sPlayer.getPlayerCachePlayerData().setTokensAdmin( amount ); + } + + } From 1399c3b00880b3ca2721de14dbfa56e8e8027fa9 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Feb 2022 10:56:15 -0500 Subject: [PATCH 072/297] Fix issue with mine bombs not dropping blocks. The underlying block changed and therefore so did the behavior of the equals() function. --- docs/changelog_v3.3.x.md | 8 ++++++-- .../prison/spigot/block/OnBlockBreakEventCore.java | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 59ea35fc7..c56480b9f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,10 +13,14 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8s 2022-02-12 +# 3.3.0-alpha.8 2022-02-13 -* **Added various token funtions to the prison spigot API class.** +* **Fix issue with mine bombs not dropping blocks.** +The underlying block changed and therefore so did the behavior of the equals() function. + + +* **Added various token functions to the prison spigot API class.** ***3.3.0-alpha.8 2022-02-12** 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 8776cb22d..2d076cac0 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 @@ -771,7 +771,8 @@ private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder // Thanks to CrazyEnchant, there is no telling which block was actually hit, so // if using CrazyEnchant one of the unprocessedRawBlocks may be the same as the // pmEvent.getSpigotBlock(), so ignore if both are the same. - if ( !sBlockMined.equals( sBlockHit ) ) { + // Compare the locations... + if ( !sBlockHit.getLocation().equals( sBlockMined.getLocation() ) ) { if ( !mine.isInMineExact( sBlockMined.getLocation() ) ) { outsideOfMine++; From ce5be06e978a2eec9bcc690291cb43fe53dd1220 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Feb 2022 11:37:29 -0500 Subject: [PATCH 073/297] Mine Bombs: Add ability to set the Y offset. It defaults to a value of -1. This allows fine tuning of bombs to better position them to sink deeper in the mine to increase the number of blocks that are included. --- docs/changelog_v3.3.x.md | 4 +++ .../mcprison/prison/bombs/MineBombData.java | 26 +++++++++++++++++++ .../spigot/utils/PrisonUtilsMineBombs.java | 4 ++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c56480b9f..43a629609 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-13 +* **Mine Bombs: Add ability to set the Y offset.** +It defaults to a value of -1. This allows fine tuning of bombs to better position them to sink deeper in the mine to increase the number of blocks that are included. + + * **Fix issue with mine bombs not dropping blocks.** The underlying block changed and therefore so did the behavior of the equals() function. 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 ba9a8aad6..758555346 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 @@ -80,6 +80,23 @@ public class MineBombData { */ private int height = 0; + + /** + *

This adjusts the placement of the bomb along the y axis. By + * default, the y adjustment is -1 to drop the bomb deeper in to the + * mine to pickup more blocks. The larger a bomb is in radius, then + * the deeper you may want to make this value to maximize the number + * of blocks that are included for the player. + *

+ * + *

You can easily move the bomb to be sub-surface where it does not break + * any top layered blocks. That may not be so clear to the player that + * the bomb went off. It's also a risk that the bomb could be moved outside + * of the mine too. + *

+ */ + private int placementAdjustmentY = -1; + /** *

The chance of complete removal. So if the explosion includes * 100 blocks, but the chance is only 50%, each block will be given @@ -222,6 +239,8 @@ public MineBombData clone() { cloned.setRadiusInner( getRadiusInner() ); cloned.setHeight( getHeight() ); + cloned.setPlacementAdjustmentY( getPlacementAdjustmentY() ); + cloned.setRemovalChance( getRemovalChance() ); cloned.setFuseDelayTicks( getFuseDelayTicks() ); cloned.setCooldownTicks( getCooldownTicks() ); @@ -325,6 +344,13 @@ public void setHeight( int height ) { this.height = height; } + public int getPlacementAdjustmentY() { + return placementAdjustmentY; + } + public void setPlacementAdjustmentY( int placementAdjustmentY ){ + this.placementAdjustmentY = placementAdjustmentY; + } + public double getRemovalChance() { return removalChance; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index 0d9ec588e..fb6daff7d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -780,7 +780,9 @@ else if ( bomb != null ) { boolean isAir = bombBlock.isEmpty(); while ( (count++ <= ( isAir ? 1 : 0 ) || bombBlock.isEmpty()) && bombBlock.getLocation().getBlockY() > 1 ) { - Block tempBlock = bombBlock.getLocation().getBlockAtDelta( 0, -1, 0 ); + int adjustY = bomb.getPlacementAdjustmentY(); + + Block tempBlock = bombBlock.getLocation().getBlockAtDelta( 0, adjustY, 0 ); if ( tempBlock != null && tempBlock instanceof SpigotBlock ) { bombBlock = (SpigotBlock) tempBlock; } From f080e5e955a9b2cca03301ded123533dcd5feb12 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Feb 2022 11:41:13 -0500 Subject: [PATCH 074/297] Mine Bombs: The mine bomb give command now is case insensitive. --- docs/changelog_v3.3.x.md | 3 +++ .../prison/spigot/utils/PrisonUtilsMineBombs.java | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 43a629609..f3a9654bb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-13 +* **Mine Bombs: The mine bomb give command now is case insensitive.** + + * **Mine Bombs: Add ability to set the Y offset.** It defaults to a value of -1. This allows fine tuning of bombs to better position them to sink deeper in the mine to increase the number of blocks that are included. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index fb6daff7d..b7c7e263d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -459,7 +459,16 @@ public void utilsMineBombsGive( CommandSender sender, MineBombs mBombs = MineBombs.getInstance(); - MineBombData bomb = mBombs.getConfigData().getBombs().get( bombName ); + MineBombData bomb = null; + + Set keys = mBombs.getConfigData().getBombs().keySet(); + for ( String key : keys ) { + MineBombData mbd = mBombs.getConfigData().getBombs().get( key ); + if ( mbd.getName().equalsIgnoreCase( bombName ) ) { + bomb = mbd; + break; + } + } if ( bomb != null ) { From 7a1386ee22da2256bacc5d3bef527ea2a2c5e56b Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Feb 2022 13:30:15 -0500 Subject: [PATCH 075/297] If using a mine bomb, then do not allow durability calculations to be used, since if the pseudo tool breaks, then what ever the player is holding will be removed, which is usually an item stack of mine bombs. --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/spigot/block/OnBlockBreakEventCore.java | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index f3a9654bb..e62f78295 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-13 +* **If using a mine bomb, then do not allow durability calculations to be used**, +since if the pseudo tool breaks, then what ever the player is holding will be removed, which is usually an item stack of mine bombs. + + * **Mine Bombs: The mine bomb give command now is case insensitive.** 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 2d076cac0..55617d6ab 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 @@ -1713,6 +1713,16 @@ protected void genericExplosiveEvent( ExplosiveBlockBreakEvent e, boolean monito // in their hand. if ( e.getToolInHand() != null ) { pmEvent.setItemInHand( (SpigotItemStack) e.getToolInHand() ); + + } + + // Note: If the mineBomb is set, then the bomb itself uses a pseudo + // tool in hand, so need to disable durability calculations since + // if the pseudo tool breaks, it will clear the player's in-hand + // inventory stack, which will be more mine bombs if they had more + // than one. + if ( e.getMineBomb() != null ) { + pmEvent.setCalculateDurability( false ); } if ( !validateEvent( pmEvent, debugInfo ) ) { From 056c8f267228eabfd6e58ae7b6ccdf107bac1b25 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Feb 2022 13:34:51 -0500 Subject: [PATCH 076/297] Mine bombs: Added durability and digspeed enchantments to the mine bomb data. This will allow for greater flexibility in how the tool in hand behaves. --- docs/changelog_v3.3.x.md | 3 +++ .../mcprison/prison/bombs/MineBombData.java | 22 ++++++++++++++++ .../spigot/utils/PrisonUtilsMineBombs.java | 17 +++++++++--- .../utils/PrisonUtilsMineBombsTasks.java | 26 ++++++++++++++----- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e62f78295..7519909b7 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -15,6 +15,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-13 +* **Mine bombs: Added durability and digspeed enchantments to the mine bomb data.** +This will allow for greater flexibility in how the tool in hand behaves. + * **If using a mine bomb, then do not allow durability calculations to be used**, since if the pseudo tool breaks, then what ever the player is holding will be removed, which is usually an item stack of mine bombs. 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 758555346..e3a0c3ba6 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 @@ -113,6 +113,10 @@ public class MineBombData { private int toolInHandFortuneLevel = 0; + private int toolInHandDurabilityLevel = 0; + + private int toolInHandDigSpeedLevel = 0; + private int fuseDelayTicks = 5 * 20; // 5 seconds @@ -208,6 +212,8 @@ public MineBombData( String name, String itemType, String explosionShape, this.toolInHandName = null; this.toolInHandFortuneLevel = 0; + this.toolInHandDurabilityLevel = 0; + this.toolInHandDigSpeedLevel = 0; this.removalChance = 100.0d; @@ -235,6 +241,8 @@ public MineBombData clone() { cloned.setToolInHandName( getToolInHandName() ); cloned.setToolInHandFortuneLevel( getToolInHandFortuneLevel() ); + cloned.setToolInHandDurabilityLevel( getToolInHandDurabilityLevel() ); + cloned.setToolInHandDigSpeedLevel( getToolInHandDigSpeedLevel() ); cloned.setRadiusInner( getRadiusInner() ); cloned.setHeight( getHeight() ); @@ -379,6 +387,20 @@ public void setToolInHandFortuneLevel( int toolInHandFortuneLevel ) { this.toolInHandFortuneLevel = toolInHandFortuneLevel; } + public int getToolInHandDurabilityLevel() { + return toolInHandDurabilityLevel; + } + public void setToolInHandDurabilityLevel( int toolInHandDurabilityLevel ) { + this.toolInHandDurabilityLevel = toolInHandDurabilityLevel; + } + + public int getToolInHandDigSpeedLevel() { + return toolInHandDigSpeedLevel; + } + public void setToolInHandDigSpeedLevel( int toolInHandDigSpeedLevel ) { + this.toolInHandDigSpeedLevel = toolInHandDigSpeedLevel; + } + public int getFuseDelayTicks() { return fuseDelayTicks; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index b7c7e263d..fdb8ae0cf 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -479,6 +479,7 @@ public void utilsMineBombsGive( CommandSender sender, bombs.setAmount( count ); player.getInventory().addItem( bombs ); + player.updateInventory(); } else { @@ -824,21 +825,29 @@ else if ( bomb != null ) { bomb.setActivated( true ); + SpigotItemStack itemInHand = SpigotCompatibility.getInstance().getPrisonItemInMainHand( player ); // Remove from inventory: - itemInHand.setAmount( itemInHand.getAmount() - 1 ); - - if ( itemInHand.getAmount() == 0 ) { + int inHandBombCount = itemInHand.getAmount() - 1; + if ( inHandBombCount == 0 ) { SpigotCompatibility.getInstance() - .setItemInMainHand( player, null ); + .setItemInMainHand( player, null ); + } + else { + + itemInHand.setAmount( inHandBombCount ); } // Apply updates to the player's inventory: player.updateInventory(); + + + + @SuppressWarnings( "unused" ) PlacedMineBombItemTask submitPlacedMineBombItem = submitPlacedMineBombItemTask( bomb, bombBlock, bombs ); // placeMineBombItem( bomb, bombBlock, bombs ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java index bb97fdbec..21164aa57 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java @@ -55,11 +55,9 @@ protected Boolean initialize() } - protected void setFortune( SpigotItemStack itemInHand, int fortuneLevel ) - { + protected void setFortune( SpigotItemStack itemInHand, int fortuneLevel ) { - if ( itemInHand != null && itemInHand.getBukkitStack() != null && itemInHand.getBukkitStack().hasItemMeta() ) - { + if ( itemInHand != null && itemInHand.getBukkitStack() != null && itemInHand.getBukkitStack().hasItemMeta() ) { itemInHand.getBukkitStack().addUnsafeEnchantment( Enchantment.LOOT_BONUS_BLOCKS, fortuneLevel ); @@ -67,9 +65,23 @@ protected void setFortune( SpigotItemStack itemInHand, int fortuneLevel ) // meta.addEnchant( Enchantment.LOOT_BONUS_BLOCKS, fortuneLevel, // true ); // itemInHand.getBukkitStack().setItemMeta( meta ); - } - + } + + protected void setUnbreaking( SpigotItemStack itemInHand, int durabilityLevel ) { + + if ( itemInHand != null && itemInHand.getBukkitStack() != null && itemInHand.getBukkitStack().hasItemMeta() ) { + + itemInHand.getBukkitStack().addUnsafeEnchantment( Enchantment.DURABILITY, durabilityLevel ); + } + } + + protected void setDigSpeed( SpigotItemStack itemInHand, int digSpeedLevel ) { + + if ( itemInHand != null && itemInHand.getBukkitStack() != null && itemInHand.getBukkitStack().hasItemMeta() ) { + + itemInHand.getBukkitStack().addUnsafeEnchantment( Enchantment.DIG_SPEED, digSpeedLevel ); + } } // public static boolean addPlayerCooldown( String playerUUID ) { @@ -271,6 +283,8 @@ public void run() { SpigotItemStack toolInHand = new SpigotItemStack( xMatTool.parseItem() ); setFortune( toolInHand, bomb.getToolInHandFortuneLevel() ); + setUnbreaking( toolInHand, bomb.getToolInHandDurabilityLevel() ); + setDigSpeed( toolInHand, bomb.getToolInHandDigSpeedLevel() ); explodeEvent.setToolInHand( toolInHand ); From 14f2bb865d309d066cdec1100aee675cd716125f Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Feb 2022 13:58:39 -0500 Subject: [PATCH 077/297] Mine bombs: Enable the use of color codes on the armor stands when setting off the bombs... --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/spigot/utils/PrisonUtilsMineBombsTasks.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7519909b7..30479e968 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -15,6 +15,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-13 + +* **Mine bombs: Enable the use of color codes on the armor stands when setting off the bombs...** + + * **Mine bombs: Added durability and digspeed enchantments to the mine bomb data.** This will allow for greater flexibility in how the tool in hand behaves. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java index 21164aa57..0d9072da6 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java @@ -34,6 +34,7 @@ import tech.mcprison.prison.spigot.game.SpigotWorld; import tech.mcprison.prison.spigot.spiget.BluesSpigetSemVerComparator; import tech.mcprison.prison.util.Location; +import tech.mcprison.prison.util.Text; public class PrisonUtilsMineBombsTasks extends PrisonUtils @@ -538,6 +539,7 @@ private void initializeArmorStand() { if ( tagName.contains( "{name}" ) ) { tagName = tagName.replace( "{name}", bomb.getName() ); } + tagName = Text.convertToAmpColorCodes( tagName ); armorStand.setCustomName( tagName ); armorStand.setCustomNameVisible(true); } From f69b685836482b04d6c5fa9886ed5276c2fc6b03 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Feb 2022 11:28:14 -0500 Subject: [PATCH 078/297] Fixed an issue with the GUI, such that if the player does not have a rank on the ladder, that it will now force the creation of a PlayerRank object so it does not cause a NPE. --- docs/changelog_v3.3.x.md | 4 +++ .../prison/ranks/data/RankPlayerFactory.java | 28 +++++++++++++++++++ .../spigot/gui/rank/SpigotPlayerRanksGUI.java | 5 ++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 30479e968..ec4ad347a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-13 +* **Fixed an issue with the GUI, such that if the player does not have a rank on the ladder**, +that it will now force the creation of a PlayerRank object so it does not cause a NPE. + + * **Mine bombs: Enable the use of color codes on the armor stands when setting off the bombs...** diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/RankPlayerFactory.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/RankPlayerFactory.java index 5e425c58f..4e5316303 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/RankPlayerFactory.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/RankPlayerFactory.java @@ -158,6 +158,34 @@ public boolean removeLadder( RankPlayer rankPlayer, String ladderName ) { return results; } + + + /** + *

If the player does not have a rank on the ladder, and force is enabled, + * then return the first rank on the ladder. + *

+ * + * @param rankPlayer + * @param ladder + * @param force + * @return + */ + public PlayerRank getRank( RankPlayer rankPlayer, RankLadder ladder, boolean force ) { + PlayerRank results = getRank( rankPlayer, ladder ); + + if ( force && results == null ) { + Rank tempRank = ladder.getLowestRank().get(); + + if ( tempRank != null ) { + results = new PlayerRank( tempRank ); + + // force cost calculations with a zero multiplier: + results.applyMultiplier( 0 ); + } + } + + return results; + } /** * Retrieves the rank that this player has in a certain ladder, if any. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java index 32b303361..cdda892ff 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java @@ -175,9 +175,10 @@ public void open() { // Decimal Rank cost format. DecimalFormat formatDecimal = new DecimalFormat("###,##0.00"); + DecimalFormat mFmt = new DecimalFormat("###,##0.0000"); boolean showNumber = getBoolean(guiConfig.getString("Options.Ranks.Number_of_Rank_Player_GUI")); - PlayerRank pRank = rankPlayerFactory.getRank( getRankPlayer(), ladder ); + PlayerRank pRank = rankPlayerFactory.getRank( getRankPlayer(), ladder, true ); for ( Rank rank : ranksDisplay ) { @@ -208,7 +209,7 @@ public void open() { ); stringValue = stringValue.replace("{rankName}", rank.getName()); stringValue = stringValue.replace("{rankTag}", SpigotPrison.format(rank.getTag())); - stringValue = stringValue.replace("{rankMultiplier}", Double.toString( rankMultiplier )); + stringValue = stringValue.replace("{rankMultiplier}", mFmt.format( rankMultiplier )); stringValue = stringValue.replace("{ladderName}", rank.getLadder().getName()); StringBuilder sbMines = new StringBuilder(); From dcb6dc144ad1f1219d80c522308800bb94b44713 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Feb 2022 11:30:41 -0500 Subject: [PATCH 079/297] Bug fix: If a player cache file does not exist, it now prevents it from loading. --- docs/changelog_v3.3.x.md | 5 ++++- .../tech/mcprison/prison/cache/PlayerCacheFiles.java | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ec4ad347a..23bb0748b 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8 2022-02-13 +# 3.3.0-alpha.8 2022-02-14 + + +* **Bug fix: If a player cache file does not exist, it now prevents it from loading.** * **Fixed an issue with the GUI, such that if the player does not have a rank on the ladder**, diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java index bcb972831..d4702ecd1 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java @@ -6,11 +6,7 @@ import java.io.FileWriter; import java.io.IOException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; -import java.util.List; -import java.util.NavigableMap; -import java.util.Set; import java.util.TreeMap; import com.google.gson.Gson; @@ -328,8 +324,13 @@ public PlayerCachePlayerData fromJson( Player player ) { String playerFileName = getPlayerFileName( player ); File playerFile = getCachedFileMatch( playerFileName ); + + + if ( playerFile.exists() ) { + + results = fromJsonFile( playerFile ); + } - results = fromJsonFile( playerFile ); // New player and file does not exist so create it. if ( results == null ) { From dfd097a7794299afa8a112f8d1b42eca452e728e Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Feb 2022 13:26:42 -0500 Subject: [PATCH 080/297] Fixed a problem before releasing... was not using the correct variable so the generated File object was not getting used. --- docs/changelog_v3.3.x.md | 3 +++ .../java/tech/mcprison/prison/cache/PlayerCacheFiles.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 23bb0748b..30ca13974 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-14 +* **Fixed a problem before releasing... was not using the correct variable so the generated File object was not getting used.** + + * **Bug fix: If a player cache file does not exist, it now prevents it from loading.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java index d4702ecd1..d179c749f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java @@ -401,12 +401,12 @@ private File getCachedFileMatch( String playerFileName ) // current name. The saved cache file may not be named exactly the same, // and if it's not, then their existing cache file needs to be // renamed. - File playerFile = getPlayerFile( playerFileName ); + results = getPlayerFile( playerFileName ); // NOTE: because the file was NOT found in the directory, then we can assume // this is a new player therefore we won't have an issue with the player's // name changing. - getPlayerFiles().put( fileNamePrefix, playerFile ); + getPlayerFiles().put( fileNamePrefix, results ); } else if ( !playerFileName.equalsIgnoreCase( results.getName() )) { From 62f282af4fa1b32e9630d5897f3ec2ce411b79cc Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Feb 2022 13:38:03 -0500 Subject: [PATCH 081/297] Rework how rankup commands are ran: in progress. This new way of dealing with rankup commands is to collect all commands that need to be ran, from all rankups, then run them in one group when the player is done being ranked up. For most changes in rank, this will have zero effect on anything (mostly), but it has a huge impact with the **rankupmax** command. When hooked up (which is is not), this will take all commands and run them in a sync task. So "every" command will run in a sync task. But each command will be monitored for run time, and if the runtime for one command exceeds a threshold, then the sync task will resubmit itself to run again after on tick. This will slow down the process of running all of the commands, but it will help prevent them from causing lag. With tracking run times on each command, if prison is in debug-mode, then it will generate console logs identify how long it take to run each command. So if any given command is causing lag, then it would be possible to identify what the offending command is. --- docs/changelog_v3.3.x.md | 7 ++ .../prison/tasks/PrisonCommandTask.java | 96 ++++++++++++++++++- .../mines/commands/MinesBlockCommands.java | 2 + .../mcprison/prison/mines/data/MineReset.java | 16 ++-- .../prison/mines/data/MineScheduler.java | 6 +- .../tech/mcprison/prison/ranks/RankUtil.java | 53 ++++++---- .../ranks/commands/RankupCommandTastk.java | 47 +++++++++ .../utils/tasks/PrisonUtilsTaskTypes.java | 4 +- 8 files changed, 200 insertions(+), 31 deletions(-) create mode 100644 prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankupCommandTastk.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 30ca13974..283b108d0 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,13 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-14 +* **Rework how rankup commands are ran: in progress.** +This new way of dealing with rankup commands is to collect all commands that need to be ran, from all rankups, then run them in one group when the player is done being ranked up. +For most changes in rank, this will have zero effect on anything (mostly), but it has a huge impact with the **rankupmax** command. +When hooked up (which is is not), this will take all commands and run them in a sync task. So "every" command will run in a sync task. But each command will be monitored for run time, and if the runtime for one command exceeds a threshold, then the sync task will resubmit itself to run again after on tick. This will slow down the process of running all of the commands, but it will help prevent them from causing lag. +With tracking run times on each command, if prison is in debug-mode, then it will generate console logs identify how long it take to run each command. So if any given command is causing lag, then it would be possible to identify what the offending command is. + + * **Fixed a problem before releasing... was not using the correct variable so the generated File object was not getting used.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java index ab454d52c..602acea30 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java @@ -5,9 +5,20 @@ import java.util.List; import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.ranks.data.PlayerRank; +import tech.mcprison.prison.ranks.data.RankLadder; public class PrisonCommandTask { + private RankLadder ladder; + private PlayerRank rankTarget; + private PlayerRank rankOriginal; + + private int commandRow = 0; + private String cmd; + + private TaskMode taskMode; + private String errorMessagePrefix; private int taskId; @@ -210,7 +221,48 @@ public void submitCommandTask( Player player, String command, command = command.replace( "{syncPlayer}", "" ); } - String commandTranslated = translateCommand( player, command ); + this.cmd = command; + this.taskMode = taskMode; + + } + + public void submitCommandTask() { + submitCommandTask( null ); + } + +// public void submitCommandTask( String command ) { +// submitCommandTask( null, command, TaskMode.sync ); +// } + +// public void submitCommandTask( Player player ) { +// submitCommandTask( player, getCmd(), TaskMode.sync ); +// } + + public void submitCommandTask( Player player +// , String command, TaskMode taskMode + ) { + +// if ( command.contains( "{inline}" ) ) { +// taskMode = TaskMode.inline; +// command = command.replace( "{inline}", "" ); +// } +// +// if ( command.contains( "{inlinePlayer}" ) ) { +// taskMode = TaskMode.inlinePlayer; +// command = command.replace( "{inlinePlayer}", "" ); +// } +// +// if ( command.contains( "{sync}" ) ) { +// taskMode = TaskMode.sync; +// command = command.replace( "{sync}", "" ); +// } +// +// if ( command.contains( "{syncPlayer}" ) ) { +// taskMode = TaskMode.syncPlayer; +// command = command.replace( "{syncPlayer}", "" ); +// } +// + String commandTranslated = translateCommand( player, getCmd() ); // Split multiple commands in to a List of individual tasks: List tasks = new ArrayList<>( @@ -292,6 +344,48 @@ public void addCustomPlaceholder( CustomPlaceholders placeholder, String value ) getCustomPlaceholders().add( cph ); } + public RankLadder getLadder() { + return ladder; + } + public void setLadder( RankLadder ladder ) { + this.ladder = ladder; + } + + public PlayerRank getRankTarget() { + return rankTarget; + } + public void setRankTarget( PlayerRank rankTarget ) { + this.rankTarget = rankTarget; + } + + public PlayerRank getRankOriginal() { + return rankOriginal; + } + public void setRankOriginal( PlayerRank rankOriginal ) { + this.rankOriginal = rankOriginal; + } + + public String getCmd() { + return cmd; + } + public void setCmd( String cmd ) { + this.cmd = cmd; + } + + public int getCommandRow() { + return commandRow; + } + public void setCommandRow( int commandRow ) { + this.commandRow = commandRow; + } + + public TaskMode getTaskMode() { + return taskMode; + } + public void setTaskMode( TaskMode taskMode ) { + this.taskMode = taskMode; + } + public String getErrorMessagePrefix() { return errorMessagePrefix; } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java index 50d4608a5..0a60f75fd 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java @@ -379,6 +379,8 @@ private BlockPercentTotal calculatePercentage( double chance, PrisonBlock prison results.addChance( chance ); for ( PrisonBlock block : m.getPrisonBlocks() ) { + + // Only check the block's name: if ( block.equals( prisonBlock ) ) { // do not replace the block's chance since this may fail results.setPrisonBlock( block ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index 293417ba8..95c5b8991 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -252,8 +252,8 @@ private void resetSynchonouslyInternal() { if ( command.startsWith( "before: " )) { String cmd = command.replace( "before: ", "" ); - PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: Before:" ); - cmdTask.submitCommandTask( cmd ); + PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: Before:", cmd ); + cmdTask.submitCommandTask(); //PrisonAPI.dispatchCommand(cmd); } @@ -289,8 +289,8 @@ private void resetSynchonouslyInternal() { if ( command.startsWith( "after: " )) { String cmd = command.replace( "after: ", "" ); - PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: After:" ); - cmdTask.submitCommandTask( cmd ); + PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: After:", cmd ); + cmdTask.submitCommandTask(); //PrisonAPI.dispatchCommand(cmd); } @@ -848,8 +848,8 @@ public void asynchronouslyResetSetup() { if ( command.startsWith( "before: " )) { String cmd = command.replace( "before: ", "" ); - PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: Before:" ); - cmdTask.submitCommandTask( cmd ); + PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: Before:", cmd ); + cmdTask.submitCommandTask(); // PrisonAPI.dispatchCommand(cmd); } @@ -886,8 +886,8 @@ public void asynchronouslyResetFinalize( List jobResetActions if ( command.startsWith( "after: " )) { String cmd = command.replace( "after: ", "" ); - PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: After:" ); - cmdTask.submitCommandTask( cmd ); + PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: After:", cmd ); + cmdTask.submitCommandTask(); // PrisonAPI.dispatchCommand(cmd); } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java index 7910516b5..1e21562b3 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java @@ -605,7 +605,9 @@ private void processBlockEventDetails( Player player, PrisonBlock prisonBlock, PrisonBlockStatusData originalBlock = targetBlock.getPrisonBlock(); - PrisonCommandTask cmdTask = new PrisonCommandTask( "BlockEvent" ); + PrisonCommandTask cmdTask = new PrisonCommandTask( "BlockEvent", blockEvent.getCommand() ); + cmdTask.setTaskMode( blockEvent.getTaskMode() ); + cmdTask.addCustomPlaceholder( CustomPlaceholders.blockName, originalBlock.getBlockName() ); cmdTask.addCustomPlaceholder( CustomPlaceholders.mineName, getName() ); @@ -654,7 +656,7 @@ private void processBlockEventDetails( Player player, PrisonBlock prisonBlock, - cmdTask.submitCommandTask( player, blockEvent.getCommand(), blockEvent.getTaskMode() ); +// cmdTask.submitCommandTask( player, blockEvent.getCommand(), blockEvent.getTaskMode() ); // { // diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java index e2bdaf188..189084a80 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java @@ -190,31 +190,38 @@ public RankUtil() { - public RankupResults rankupPlayer(Player player, RankPlayer rankPlayer, String ladderName, String playerName) { + public RankupResults rankupPlayer(Player player, RankPlayer rankPlayer, String ladderName, String playerName, + List cmdTasks ) { + return rankupPlayer(RankupCommands.rankup, player, rankPlayer, ladderName, null, - playerName, null, PromoteForceCharge.charge_player ); + playerName, null, PromoteForceCharge.charge_player, cmdTasks ); } public RankupResults promotePlayer(Player player, RankPlayer rankPlayer, String ladderName, - String playerName, String executorName, PromoteForceCharge pForceCharge) { + String playerName, String executorName, PromoteForceCharge pForceCharge, + List cmdTasks ) { + return rankupPlayer(RankupCommands.promote, player, rankPlayer, ladderName, null, - playerName, executorName, pForceCharge); + playerName, executorName, pForceCharge, cmdTasks ); } public RankupResults demotePlayer(Player player, RankPlayer rankPlayer, String ladderName, - String playerName, String executorName, PromoteForceCharge pForceCharge) { + String playerName, String executorName, PromoteForceCharge pForceCharge, + List cmdTasks ) { + return rankupPlayer(RankupCommands.demote, player, rankPlayer, ladderName, null, - playerName, executorName, pForceCharge); + playerName, executorName, pForceCharge, cmdTasks ); } public RankupResults setRank(Player player, RankPlayer rankPlayer, String ladderName, String rankName, - String playerName, String executorName) { + String playerName, String executorName, + List cmdTasks ) { RankupCommands rankupCmd = "FirstJoinEvent".equalsIgnoreCase( executorName ) ? RankupCommands.firstJoin : RankupCommands.setrank; return rankupPlayer( rankupCmd, player, rankPlayer, ladderName, rankName, - playerName, executorName, PromoteForceCharge.no_charge ); + playerName, executorName, PromoteForceCharge.no_charge, cmdTasks ); } /** @@ -234,7 +241,7 @@ public RankupResults setRank(Player player, RankPlayer rankPlayer, String ladder */ private RankupResults rankupPlayer(RankupCommands command, Player player, RankPlayer rankPlayer, String ladderName, String rankName, String playerName, String executorName, - PromoteForceCharge pForceCharge ) { + PromoteForceCharge pForceCharge, List cmdTasks ) { RankupResults results = new RankupResults(command, rankPlayer, executorName, ladderName, rankName); @@ -295,12 +302,12 @@ private RankupResults rankupPlayer(RankupCommands command, Player player, RankPl if ( ladderName == null ) { ladderName = "default"; results.addTransaction(RankupTransactions.assigned_default_ladder); - } + } try { rankupPlayerInternal(results, command, player, rankPlayer, ladderName, - rankName, pForceCharge ); + rankName, pForceCharge, cmdTasks ); } catch (Exception e ) { results.addTransaction( RankupTransactions.failure_exception_caught_check_server_logs ); @@ -324,7 +331,7 @@ private RankupResults rankupPlayer(RankupCommands command, Player player, RankPl private void rankupPlayerInternal(RankupResults results, RankupCommands command, Player prisonPlayer, RankPlayer rankPlayer, String ladderName, String rankName, - PromoteForceCharge pForceCharge) { + PromoteForceCharge pForceCharge, List cmdTasks ) { Output.get().logDebug( DebugTarget.rankup, "Rankup: rankupPlayerInternal: "); @@ -534,7 +541,9 @@ private void rankupPlayerInternal(RankupResults results, rankupCommands.addAll( ladder.getRankUpCommands() ); rankupCommands.addAll( targetRank.getRankUpCommands() ); - for (String cmd : rankupCommands ) { + for ( int row = 0; row < rankupCommands.size(); row++ ) { + + String cmd = rankupCommands.get( row ); if ( cmd != null && ( !cmd.contains( "{firstJoin}" ) || cmd.contains( "{firstJoin}" ) && command == RankupCommands.firstJoin ) ) { @@ -545,7 +554,16 @@ private void rankupPlayerInternal(RankupResults results, Rank oRank = results.getOriginalRank(); Rank tRank = results.getTargetRank(); - PrisonCommandTask cmdTask = new PrisonCommandTask( command.name() ); + if ( command == RankupCommands.firstJoin && cmd.contains( "{firstJoin}" ) ) { + cmd = cmd.replace( "{firstJoin}", "" ); + } + + PrisonCommandTask cmdTask = new PrisonCommandTask( command.name(), cmd, row ); + + cmdTask.setLadder( ladder ); + cmdTask.setRankTarget( tpRank ); + cmdTask.setRankOriginal( opRank ); + cmdTask.addCustomPlaceholder( CustomPlaceholders.balanceInitial, Double.toString( results.getBalanceInitial()) ); cmdTask.addCustomPlaceholder( CustomPlaceholders.balanceFinal, Double.toString( results.getBalanceFinal()) ); @@ -568,12 +586,11 @@ private void rankupPlayerInternal(RankupResults results, cmdTask.addCustomPlaceholder( CustomPlaceholders.targetRankTag, (tRank == null ? "none" : tRank.getTag()) ); - if ( command == RankupCommands.firstJoin && cmd.contains( "{firstJoin}" ) ) { - cmd = cmd.replace( "{firstJoin}", "" ); - } + cmdTasks.add( cmdTask ); - cmdTask.submitCommandTask( prisonPlayer, cmd ); + // Comment this out to stack the rank commands: + cmdTask.submitCommandTask( prisonPlayer ); // String formatted = cmd.replace("{player}", prisonPlayer.getName()) diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankupCommandTastk.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankupCommandTastk.java new file mode 100644 index 000000000..79029982c --- /dev/null +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankupCommandTastk.java @@ -0,0 +1,47 @@ +package tech.mcprison.prison.ranks.commands; + +import java.util.List; + +import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.tasks.PrisonCommandTask; +import tech.mcprison.prison.tasks.PrisonRunnable; + +public class RankupCommandTastk + implements PrisonRunnable +{ + + private Player player; + private List cmdTasks; + + private int cmTasksPosition = 0; + + public static void submitTasks( Player player, List cmdTasks ) { + + RankupCommandTastk rcTask = new RankupCommandTastk(); + rcTask.setPlayer( player ); + rcTask.setCmdTasks( cmdTasks ); + + + } + + @Override + public void run() { + + } + + + public Player getPlayer() { + return player; + } + public void setPlayer( Player player ) { + this.player = player; + } + + public List getCmdTasks() { + return cmdTasks; + } + public void setCmdTasks( List cmdTasks ) { + this.cmdTasks = cmdTasks; + } + +} diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java index 7e7028d1e..5472093a2 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java @@ -131,9 +131,9 @@ public UtilTaskType getTaskType() { @Override public void run() { - PrisonCommandTask pCmd = new PrisonCommandTask( "PrisonUtilsTaskTypRunCommand" ); + PrisonCommandTask pCmd = new PrisonCommandTask( "PrisonUtilsTaskTypRunCommand", getCommand() ); - pCmd.submitCommandTask( getPlayer(), getCommand() ); + pCmd.submitCommandTask( getPlayer() ); } @Override From f64194235b539bdd9bfbaf5e78b3d41e7ef18f9e Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Feb 2022 13:40:44 -0500 Subject: [PATCH 082/297] Rework how rankup commands are ran: in progress. This new way of dealing with rankup commands is to collect all commands that need to be ran, from all rankups, then run them in one group when the player is done being ranked up. For most changes in rank, this will have zero effect on anything (mostly), but it has a huge impact with the **rankupmax** command. When hooked up (which is is not), this will take all commands and run them in a sync task. So "every" command will run in a sync task. But each command will be monitored for run time, and if the runtime for one command exceeds a threshold, then the sync task will resubmit itself to run again after on tick. This will slow down the process of running all of the commands, but it will help prevent them from causing lag. With tracking run times on each command, if prison is in debug-mode, then it will generate console logs identify how long it take to run each command. So if any given command is causing lag, then it would be possible to identify what the offending command is. --- .../prison/ranks/commands/RankUpCommand.java | 72 +++++++++++++++---- 1 file changed, 59 insertions(+), 13 deletions(-) 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 4161dff44..ac7e680b0 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 @@ -17,6 +17,8 @@ package tech.mcprison.prison.ranks.commands; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import tech.mcprison.prison.Prison; @@ -40,6 +42,7 @@ import tech.mcprison.prison.ranks.data.RankPlayerFactory; import tech.mcprison.prison.ranks.managers.LadderManager; import tech.mcprison.prison.ranks.managers.PlayerManager; +import tech.mcprison.prison.tasks.PrisonCommandTask; /** * The commands for this module. @@ -76,7 +79,14 @@ public void rankUpMax(CommandSender sender, Output.get().logDebug( DebugTarget.rankup, "Rankup: cmd '/rankupmax %s' Passed perm check: ranks.rankupmax.%s", ladder, ladder ); - rankUpPrivate(sender, ladder, RankupModes.MAX_RANKS, "ranks.rankupmax."); + + List cmdTasks = new ArrayList<>(); + + rankUpPrivate(sender, ladder, RankupModes.MAX_RANKS, "ranks.rankupmax.", cmdTasks ); + + // submit cmdTasks + submitCmdTasks( cmdTasks ); + } else { Output.get().logDebug( DebugTarget.rankup, @@ -85,8 +95,9 @@ public void rankUpMax(CommandSender sender, rankupMaxNoPermissionMsg( sender, "ranks.rankupmax." + ladder ); } } - - @Command(identifier = "rankup", description = "Ranks up to the next rank.", + + + @Command(identifier = "rankup", description = "Ranks up to the next rank.", permissions = "ranks.user", altPermissions = "ranks.rankup.[ladderName]", onlyPlayers = false) public void rankUp(CommandSender sender, @Arg(name = "ladder", description = "The ladder to rank up on.", def = "default") String ladder @@ -100,10 +111,17 @@ public void rankUp(CommandSender sender, "Rankup: cmd '/rankup %s' Processing ranks.rankup.%s", ladder, ladder ); - rankUpPrivate(sender, ladder, RankupModes.ONE_RANK, "ranks.rankup." ); + List cmdTasks = new ArrayList<>(); + + rankUpPrivate(sender, ladder, RankupModes.ONE_RANK, "ranks.rankup.", cmdTasks ); + + // submit cmdTasks + submitCmdTasks( cmdTasks ); + } - private void rankUpPrivate(CommandSender sender, String ladder, RankupModes mode, String permission ) { + private void rankUpPrivate(CommandSender sender, String ladder, RankupModes mode, + String permission, List cmdTasks ) { // RETRIEVE THE LADDER @@ -234,14 +252,15 @@ private void rankUpPrivate(CommandSender sender, String ladder, RankupModes mode if (rankPlayer != null ) { // Performs the actual rankup here: - RankupResults results = new RankUtil().rankupPlayer(player, rankPlayer, ladder, sender.getName()); + RankupResults results = new RankUtil().rankupPlayer(player, rankPlayer, ladder, + sender.getName(), cmdTasks ); processResults( sender, player.getName(), results, null, ladder, currency ); // If the last rankup attempt was successful and they are trying to rankup as many times as possible: if (results.getStatus() == RankupStatus.RANKUP_SUCCESS && mode == RankupModes.MAX_RANKS && !ladder.equals("prestiges")) { - rankUpPrivate( sender, ladder, mode, permission ); + rankUpPrivate( sender, ladder, mode, permission, cmdTasks ); } if (results.getStatus() == RankupStatus.RANKUP_SUCCESS){ rankupWithSuccess = true; @@ -397,11 +416,15 @@ public void promotePlayer(CommandSender sender, // Get currency if it exists, otherwise it will be null if the Rank has no currency: String currency = rankPlayer == null || pRank == null ? null : pRank.getCurrency(); - - if ( ladder != null && rankPlayer != null ) { + + List cmdTasks = new ArrayList<>(); + RankupResults results = new RankUtil().promotePlayer(player, rankPlayer, ladder, - player.getName(), sender.getName(), pForceCharge); + player.getName(), sender.getName(), pForceCharge, cmdTasks ); + + // submit cmdTasks... + submitCmdTasks( cmdTasks ); processResults( sender, player.getName(), results, null, ladder, currency ); } @@ -455,8 +478,14 @@ public void demotePlayer(CommandSender sender, String currency = rankPlayer == null || pRank == null ? null : pRank.getCurrency(); if ( ladder != null && rankPlayer != null ) { + + List cmdTasks = new ArrayList<>(); + RankupResults results = new RankUtil().demotePlayer(player, rankPlayer, ladder, - player.getName(), sender.getName(), pForceCharge); + player.getName(), sender.getName(), pForceCharge, cmdTasks ); + + // submit cmdTasks + submitCmdTasks( cmdTasks ); processResults( sender, player.getName(), results, null, ladder, currency ); } @@ -534,10 +563,17 @@ public void removeRank(CommandSender sender, public void setPlayerRank( RankPlayer rankPlayer, Rank pRank ) { if ( rankPlayer != null ) { + + List cmdTasks = new ArrayList<>(); + RankupResults results = new RankUtil().setRank(rankPlayer, rankPlayer, pRank.getLadder().getName(), pRank.getName(), - rankPlayer.getName(), rankPlayer.getName()); + rankPlayer.getName(), rankPlayer.getName(), + cmdTasks ); + + // submit cmdTasks + submitCmdTasks( cmdTasks ); processResults( rankPlayer, rankPlayer.getName(), results, pRank.getName(), pRank.getLadder().getName(), @@ -564,8 +600,13 @@ private void setPlayerRank( Player player, String rank, String ladderName, Comma // Get currency if it exists, otherwise it will be null if the Rank has no currency: String currency = rankPlayer == null || pRank == null ? null : pRank.getCurrency(); + List cmdTasks = new ArrayList<>(); + RankupResults results = new RankUtil().setRank(player, rankPlayer, ladderName, rank, - player.getName(), sender.getName()); + player.getName(), sender.getName(), cmdTasks ); + + // submit cmdTasks + submitCmdTasks( cmdTasks ); processResults( sender, player.getName(), results, rank, ladderName, currency ); } @@ -685,5 +726,10 @@ public void processResults( CommandSender sender, String playerName, } } + + private void submitCmdTasks( List cmdTasks ) + { + + } } From 07bb816605dc8e344545d5091c16c73b9e8236a4 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Feb 2022 14:34:03 -0500 Subject: [PATCH 083/297] Rework how rankup commands are ran: in progress. This new way of dealing with rankup commands is to collect all commands that need to be ran, from all rankups, then run them in one group when the player is done being ranked up. For most changes in rank, this will have zero effect on anything (mostly), but it has a huge impact with the **rankupmax** command. When hooked up (which is is not), this will take all commands and run them in a sync task. So "every" command will run in a sync task. But each command will be monitored for run time, and if the runtime for one command exceeds a threshold, then the sync task will resubmit itself to run again after on tick. This will slow down the process of running all of the commands, but it will help prevent them from causing lag. With tracking run times on each command, if prison is in debug-mode, then it will generate console logs identify how long it take to run each command. So if any given command is causing lag, then it would be possible to identify what the offending command is. --- .../prison/tasks/PrisonCommandTask.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java index 602acea30..9883d8781 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java @@ -179,27 +179,22 @@ public CommandEnvironment getEnvironment() { } - public PrisonCommandTask( String errorMessagePrefix ) { + public PrisonCommandTask( String errorMessagePrefix, + String command ) { + this( errorMessagePrefix, command, 0 ); + } + public PrisonCommandTask( String errorMessagePrefix, + String command, int commandRow ) { super(); + this.commandRow = commandRow; + this.errorMessagePrefix = errorMessagePrefix; this.taskId = 0; this.customPlaceholders = new ArrayList<>(); - } - - - - public void submitCommandTask( String command ) { - submitCommandTask( null, command, TaskMode.sync ); - } - - public void submitCommandTask( Player player, String command ) { - submitCommandTask( player, command, TaskMode.sync ); - } - - public void submitCommandTask( Player player, String command, - TaskMode taskMode ) { + + TaskMode taskMode = TaskMode.sync; if ( command.contains( "{inline}" ) ) { taskMode = TaskMode.inline; From 4984da375a5836889cf745ca5846ca7b063acb31 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 01:14:14 -0500 Subject: [PATCH 084/297] Setup the time durations on reporting of mine resets to use external settings. Enables the use of singular and plural unit nams. --- docs/changelog_v3.3.x.md | 6 +- .../java/tech/mcprison/prison/util/Text.java | 77 +++++++++++++++---- .../main/resources/lang/core/de_DE.properties | 10 ++- .../main/resources/lang/core/en_GB.properties | 10 ++- .../main/resources/lang/core/en_US.properties | 11 ++- .../main/resources/lang/core/es_ES.properties | 10 ++- .../main/resources/lang/core/hu_HU.properties | 10 ++- .../main/resources/lang/core/it_IT.properties | 10 ++- .../main/resources/lang/core/nl_BE.properties | 10 ++- .../main/resources/lang/core/nl_NL.properties | 10 ++- .../main/resources/lang/core/zh_TW.properties | 27 ++++++- .../mcprison/prison/spigot/SpigotPrison.java | 4 + 12 files changed, 172 insertions(+), 23 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 283b108d0..c498d5445 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8 2022-02-14 +# 3.3.0-alpha.8 2022-02-15 + + +* **Setup the time durations on reporting of mine resets to use external settings.** +Enables the use of singular and plural unit names. * **Rework how rankup commands are ran: in progress.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/Text.java b/prison-core/src/main/java/tech/mcprison/prison/util/Text.java index b1df3cc29..61d4fcdd4 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/util/Text.java +++ b/prison-core/src/main/java/tech/mcprison/prison/util/Text.java @@ -22,6 +22,7 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -39,7 +40,8 @@ * @author Faizaan A. Datoo * @since API 1.0 */ -public class Text { +public class Text + extends TextMessage { private static final long millisPerSecond = 1000; private static final long millisPerMinute = 60 * millisPerSecond; @@ -48,10 +50,24 @@ public class Text { private static final long millisPerWeek = 7 * millisPerDay; private static final long millisPerMonth = 31 * millisPerDay; private static final long millisPerYear = 365 * millisPerDay; - private static final Map unitMillis = CollectionUtil - .map("years", millisPerYear, "months", millisPerMonth, "weeks", millisPerWeek, "days", - millisPerDay, "hours", millisPerHour, "minutes", millisPerMinute, "seconds", - millisPerSecond); + + private static Map unitMillis = CollectionUtil + .map( + "year:years", millisPerYear, + "month:months", millisPerMonth, + "week:weeks", millisPerWeek, + "day:days", millisPerDay, + "hour:hours", millisPerHour, + "minute:minutes", millisPerMinute, + "second:seconds", millisPerSecond); + + private static String unit_time_text_prefix = "&3"; + private static String unit_time_text_just_now = "just now"; + private static String unit_time_text_ago = "ago"; + private static String unit_time_text_from_now = "from now"; + private static String unit_time_text_and = "and"; + + private static String headingLine = repeat("-", 52); public static final char COLOR_CHAR = '\u00A7'; @@ -80,6 +96,34 @@ protected Text() { super(); } + + public static void initialize() { + + unit_time_text_prefix = coreOutputTextJustPrefixMsg(); + unit_time_text_just_now = coreOutputTextJustNowMsg(); + unit_time_text_ago = coreOutputTextAgoMsg(); + unit_time_text_from_now = coreOutputTextFromNowMsg(); + unit_time_text_and = coreOutputTextAndMsg(); + + String timeUnitsSingular = coreOutputTextTimeUnitsSingularMsg(); + String timeUnitsPlural = coreOutputTextTimeUnitsPluralMsg(); + + String[] tuS = timeUnitsSingular.split( "," ); + String[] tuP = timeUnitsPlural.split( "," ); + + if ( tuS.length == 7 && tuP.length == 7 ) { + unitMillis = new LinkedHashMap<>(); + + int i = 0; + unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerYear ); + unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerMonth ); + unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerWeek ); + unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerDay ); + unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerHour ); + unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerMinute ); + unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerSecond ); + } + } /** * Splits a string at a delimiter. The delimiter may include regular expressions to assist in @@ -204,11 +248,13 @@ public static String implodeCommaAnd(final Collection objects, final String c } public static String implodeCommaAndDot(final Collection objects, final String color) { - return implodeCommaAndDot(objects, color + ", ", color + " and ", color + "."); + return implodeCommaAndDot(objects, color + ", ", + color + " " + unit_time_text_and + " ", color + "."); } public static String implodeCommaAnd(final Collection objects, final String color) { - return implodeCommaAndDot(objects, color + ", ", color + " and ", ""); + return implodeCommaAndDot(objects, color + ", ", + color + " " + unit_time_text_and + " ", ""); } public static String implodeCommaAndDot(final Collection objects) { @@ -499,7 +545,7 @@ public static String tab(String text) { * @return The human-readable string. */ public static String getTimeUntilString(long millis) { - String ret = ""; + String ret = unit_time_text_prefix; double millisLeft = (double) Math.abs(millis); @@ -508,26 +554,31 @@ public static String getTimeUntilString(long millis) { if (unitCountParts.size() == 3) { break; } - String unitName = entry.getKey(); + String[] unitNames = entry.getKey().split( ":" ); + String unitNameSingular = unitNames[0]; + String unitNamePlural = unitNames.length > 1 ? unitNames[1] : unitNames[0]; + long unitSize = entry.getValue(); long unitCount = (long) Math.floor(millisLeft / unitSize); if (unitCount < 1) { continue; } millisLeft -= unitSize * unitCount; - unitCountParts.add(unitCount + " " + unitName); + + unitCountParts.add(unitCount + " " + + ( unitCount == 1 ? unitNameSingular : unitNamePlural) ); } if (unitCountParts.size() == 0) { - return "just now"; + return ret + unit_time_text_just_now; } ret += implodeCommaAnd(unitCountParts); ret += " "; if (millis <= 0) { - ret += "ago"; + ret += unit_time_text_ago; } else { - ret += "from now"; + ret += unit_time_text_from_now; } return ret; diff --git a/prison-core/src/main/resources/lang/core/de_DE.properties b/prison-core/src/main/resources/lang/core/de_DE.properties index 4f1064e60..82d7391cf 100644 --- a/prison-core/src/main/resources/lang/core/de_DE.properties +++ b/prison-core/src/main/resources/lang/core/de_DE.properties @@ -70,7 +70,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=1 +messages__version=2 messages__auto_refresh=true @@ -90,6 +90,14 @@ core_output__error_startup_failure=Prison: (Sending to System.err due to Output. core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + # The following are the original messages and they will eventually be replaced. diff --git a/prison-core/src/main/resources/lang/core/en_GB.properties b/prison-core/src/main/resources/lang/core/en_GB.properties index c3223f96a..0ea0a99ab 100644 --- a/prison-core/src/main/resources/lang/core/en_GB.properties +++ b/prison-core/src/main/resources/lang/core/en_GB.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=1 +messages__version=2 messages__auto_refresh=true @@ -87,6 +87,14 @@ core_output__error_startup_failure=Prison: (Sending to System.err due to Output. core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + # The following are the original messages and they will eventually be replaced. diff --git a/prison-core/src/main/resources/lang/core/en_US.properties b/prison-core/src/main/resources/lang/core/en_US.properties index 3371cf072..d0ce2ebf2 100644 --- a/prison-core/src/main/resources/lang/core/en_US.properties +++ b/prison-core/src/main/resources/lang/core/en_US.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -87,6 +87,15 @@ core_output__error_startup_failure=Prison: (Sending to System.err due to Output. core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + + core_prison_utf8_test=Привет! Давай поÑмотрим, работает ли? Test 01 diff --git a/prison-core/src/main/resources/lang/core/es_ES.properties b/prison-core/src/main/resources/lang/core/es_ES.properties index 2e5bbb6cd..b10152c9c 100644 --- a/prison-core/src/main/resources/lang/core/es_ES.properties +++ b/prison-core/src/main/resources/lang/core/es_ES.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=1 +messages__version=2 messages__auto_refresh=true @@ -87,6 +87,14 @@ core_output__error_startup_failure=Prison: (Sending to System.err due to Output. core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + # The following are the original messages and they will eventually be replaced. diff --git a/prison-core/src/main/resources/lang/core/hu_HU.properties b/prison-core/src/main/resources/lang/core/hu_HU.properties index 3527eb069..c7cef480b 100644 --- a/prison-core/src/main/resources/lang/core/hu_HU.properties +++ b/prison-core/src/main/resources/lang/core/hu_HU.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=1 +messages__version=2 messages__auto_refresh=true @@ -87,6 +87,14 @@ core_output__error_startup_failure=Prison: (Sending to System.err due to Output. core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + # The following are the original messages and they will eventually be replaced. diff --git a/prison-core/src/main/resources/lang/core/it_IT.properties b/prison-core/src/main/resources/lang/core/it_IT.properties index 4fca5a899..c19dfab68 100644 --- a/prison-core/src/main/resources/lang/core/it_IT.properties +++ b/prison-core/src/main/resources/lang/core/it_IT.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=1 +messages__version=2 messages__auto_refresh=true @@ -87,6 +87,14 @@ core_output__error_startup_failure=Prison: (Sending to System.err due to Output. core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + # The following are the original messages and they will eventually be replaced. diff --git a/prison-core/src/main/resources/lang/core/nl_BE.properties b/prison-core/src/main/resources/lang/core/nl_BE.properties index db095934e..da203160d 100644 --- a/prison-core/src/main/resources/lang/core/nl_BE.properties +++ b/prison-core/src/main/resources/lang/core/nl_BE.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=1 +messages__version=2 messages__auto_refresh=true @@ -87,6 +87,14 @@ core_output__error_startup_failure=Prison: (Sending to System.err due to Output. core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + # The following are the original messages and they will eventually be replaced. diff --git a/prison-core/src/main/resources/lang/core/nl_NL.properties b/prison-core/src/main/resources/lang/core/nl_NL.properties index db095934e..da203160d 100644 --- a/prison-core/src/main/resources/lang/core/nl_NL.properties +++ b/prison-core/src/main/resources/lang/core/nl_NL.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=1 +messages__version=2 messages__auto_refresh=true @@ -87,6 +87,14 @@ core_output__error_startup_failure=Prison: (Sending to System.err due to Output. core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + # The following are the original messages and they will eventually be replaced. diff --git a/prison-core/src/main/resources/lang/core/zh_TW.properties b/prison-core/src/main/resources/lang/core/zh_TW.properties index 4256a8016..4b8b68c51 100644 --- a/prison-core/src/main/resources/lang/core/zh_TW.properties +++ b/prison-core/src/main/resources/lang/core/zh_TW.properties @@ -67,10 +67,35 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=1 +messages__version=2 messages__auto_refresh=true +core_output__prefix_template=| %1 | &7 +core_output__prefix_template_prison=Prison +core_output__prefix_template_info=Info +core_output__prefix_template_warning=Warning +core_output__prefix_template_error=Error +core_output__prefix_template_debug=Debug + +core_output__color_code_info=&3 +core_output__color_code_warning=&c +core_output__color_code_error=&c +core_output__color_code_debug=&9 + +core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure): +core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 + + +core_text__prefix=&3 +core_text__just_now=just now +core_text__ago=ago +core_text__from_now=from now +core_text__and=and +core_text__time_units_singular=year,month,week,day,hour,minute,second +core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + + includeError=[%1] 有一個無效值 excludeError=[%1] 有一個無效值 cantAsConsole=您ä¸èƒ½ä½œç‚ºæŽ§åˆ¶å°åŸ·è¡Œæ­¤æ“作 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 ff2aad6a2..dfcb423d5 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 @@ -96,6 +96,7 @@ import tech.mcprison.prison.spigot.tasks.PrisonInitialStartupTask; import tech.mcprison.prison.spigot.tasks.SpigotPrisonDelayedStartupTask; import tech.mcprison.prison.spigot.utils.PrisonUtilsModule; +import tech.mcprison.prison.util.Text; /** * The plugin class for the Spigot implementation. @@ -217,6 +218,9 @@ public void onEnable() { Output.get().setDebug( debug ); } + // Load the Text's language configs: + Text.initialize(); + this.compatibility = SpigotCompatibility.getInstance(); // initCompatibility(); Obsolete... From 50a4c8fd7fcc8f4a7ab985f6958e13ef2c6b34e3 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 01:18:09 -0500 Subject: [PATCH 085/297] Prevent the autosell happening just because someone is op. To make this work, and to prevent odd behaviors where OPs suddenly are not able to mine correctly, OP can no longer use the autosell based upon perms. --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/spigot/autofeatures/AutoManagerFeatures.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 c498d5445..5efb6d08b 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-15 +* **Prevent the autosell happening just because someone is op.** +To make this work, and to prevent odd behaviors where OPs suddenly are not able to mine correctly, OP can no longer use the autosell based upon perms. + + * **Setup the time durations on reporting of mine resets to use external settings.** Enables the use of singular and plural unit names. 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 cb38e08c5..032610ce8 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 @@ -508,7 +508,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, // Try to autosell if enabled: if ( (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || pmEvent.isForceAutoSell() || - player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) && + !player.isOp() && player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) && SellAllUtil.get() != null ) { final long nanoStart = System.nanoTime(); From 7022741ea21247aad1493924829deeff33de8c02 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 19:18:41 -0500 Subject: [PATCH 086/297] Prison commands: reorganize some of the structures used for the prison commands. Hook up some of the logging to track run times for each command. --- docs/changelog_v3.3.x.md | 4 + ...ndTask.java => PrisonCommandTaskData.java} | 188 ++++++++++++++---- .../PrisonCommandTaskPlaceholderData.java | 2 +- .../prison/tasks/PrisonCommandTasks.java | 112 +++++++++++ .../tasks/PrisonDispatchCommandTask.java | 15 +- .../prison/mines/commands/MinesCommands.java | 20 +- .../mcprison/prison/mines/data/MineReset.java | 64 ++++-- .../prison/mines/data/MineScheduler.java | 23 ++- .../prison/mines/features/MineBlockEvent.java | 2 +- .../tech/mcprison/prison/ranks/RankUtil.java | 20 +- .../ranks/commands/CommandCommands.java | 18 +- .../prison/ranks/commands/RankUpCommand.java | 36 ++-- .../ranks/commands/RankupCommandTastk.java | 47 ----- .../block/OnBlockBreakPlayerManualCore.java | 70 +++---- .../spigot/utils/PrisonUtilsMining.java | 13 +- .../utils/tasks/PrisonUtilsTaskTypes.java | 8 +- 16 files changed, 451 insertions(+), 191 deletions(-) rename prison-core/src/main/java/tech/mcprison/prison/tasks/{PrisonCommandTask.java => PrisonCommandTaskData.java} (70%) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java delete mode 100644 prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankupCommandTastk.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5efb6d08b..b8b4d0ed4 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-15 +* **Prison commands: reorganize some of the structures used for the prison commands.** +Hook up some of the logging to track run times for each command. + + * **Prevent the autosell happening just because someone is op.** To make this work, and to prevent odd behaviors where OPs suddenly are not able to mine correctly, OP can no longer use the autosell based upon perms. diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java similarity index 70% rename from prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java rename to prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java index 9883d8781..6a29dee6c 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTask.java +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java @@ -1,14 +1,17 @@ package tech.mcprison.prison.tasks; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import tech.mcprison.prison.PrisonAPI; import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.data.PlayerRank; import tech.mcprison.prison.ranks.data.RankLadder; -public class PrisonCommandTask { +public class PrisonCommandTaskData { private RankLadder ladder; private PlayerRank rankTarget; @@ -25,6 +28,14 @@ public class PrisonCommandTask { private List customPlaceholders; + + private List tasks; + private List elapsedTimes; + + private String errorMessage; + + + public enum TaskMode { inline, inlinePlayer(true), @@ -179,11 +190,11 @@ public CommandEnvironment getEnvironment() { } - public PrisonCommandTask( String errorMessagePrefix, + public PrisonCommandTaskData( String errorMessagePrefix, String command ) { this( errorMessagePrefix, command, 0 ); } - public PrisonCommandTask( String errorMessagePrefix, + public PrisonCommandTaskData( String errorMessagePrefix, String command, int commandRow ) { super(); @@ -193,6 +204,7 @@ public PrisonCommandTask( String errorMessagePrefix, this.taskId = 0; this.customPlaceholders = new ArrayList<>(); + this.elapsedTimes = new ArrayList<>(); TaskMode taskMode = TaskMode.sync; @@ -221,21 +233,59 @@ public PrisonCommandTask( String errorMessagePrefix, } - public void submitCommandTask() { - submitCommandTask( null ); + public String getDebugDetails() { + StringBuilder sb = new StringBuilder(); + + long nanoTotal = 0; + + DecimalFormat dFmt = new DecimalFormat( "#,000.0000" ); + + for ( Long elapsedNano : elapsedTimes ) + { + if ( sb.length() > 0 ) { + sb.append( ", " ); + } + nanoTotal += elapsedNano; + + double elapsedMs = 1000000.0d / elapsedNano; + sb.append( dFmt.format( elapsedMs ) ); + } + + sb.insert( 0, "[" ); + sb.append( "]" ); + + double totalNano = 1000000.0 / nanoTotal; + + String message = null; + + if ( ladder != null && rankTarget != null ) { + + message = String.format( + " Cmd Debug: %s Ladder: %s %s row: %d tasks: %d elapsedTime: %s %s", + errorMessagePrefix, ladder.getName(), rankTarget.getRank().getName(), + commandRow, tasks.size(), + dFmt.format( totalNano ), + sb.toString() + ); + } + else { + message = String.format( + " Cmd Debug: %s row: %d tasks: %d elapsedTime: %s %s", + errorMessagePrefix, + commandRow, tasks.size(), + dFmt.format( totalNano ), + sb.toString() + ); + } + + return message; } -// public void submitCommandTask( String command ) { -// submitCommandTask( null, command, TaskMode.sync ); -// } - -// public void submitCommandTask( Player player ) { -// submitCommandTask( player, getCmd(), TaskMode.sync ); -// } + public void runCommandTask() { + runCommandTask( null ); + } - public void submitCommandTask( Player player -// , String command, TaskMode taskMode - ) { + public void runCommandTask( Player player ) { // if ( command.contains( "{inline}" ) ) { // taskMode = TaskMode.inline; @@ -265,40 +315,102 @@ public void submitCommandTask( Player player if ( tasks.size() > 0 ) { - String errorMessage = errorMessagePrefix + ": " + + this.errorMessage = errorMessagePrefix + ": " + (player == null ? "" : "Player: " + player.getName() + " "); - PrisonDispatchCommandTask task = - new PrisonDispatchCommandTask( tasks, errorMessage, - player, taskMode.isPlayerTask() ); + this.tasks = tasks; + runTask( player ); + +// PrisonDispatchCommandTask task = +// new PrisonDispatchCommandTask( tasks, errorMessage, +// player, taskMode.isPlayerTask() ); + + + // Ignore taskMode since it's already running in a new sync task: +// task.run(); - switch ( taskMode ) - { - case inline: - case inlinePlayer: - // Don't submit, but run it here within this thread: - task.run(); - break; - - case sync: - case syncPlayer: - //case "async": // async will cause failures so run as sync: - - // submit task: - setTaskId( PrisonTaskSubmitter.runTaskLater(task, 0) ); - break; - - default: - break; - } + + // NOTE: taskMode is no longer used, since all tasks are being ran + // within a sync task that has already been submitted. +// switch ( taskMode ) +// { +// case inline: +// case inlinePlayer: +// // Don't submit, but run it here within this thread: +// task.run(); +// break; +// +// case sync: +// case syncPlayer: +// //case "async": // async will cause failures so run as sync: +// +// // submit task: +// setTaskId( PrisonTaskSubmitter.runTaskLater(task, 0) ); +// break; +// +// default: +// break; +// } } } + public void runTask( Player player ) { + if ( tasks != null && tasks.size() > 0 ) { + + for ( String task : tasks ) { + + long start = System.nanoTime(); + + // Apply the custom placeholders: + for ( PrisonCommandTaskPlaceholderData cPlaceholder : getCustomPlaceholders() ) { + if ( cPlaceholder.contains( task ) ) { + task = cPlaceholder.replace( task ); + } + } + + try { + if ( taskMode.isPlayerTask() && player != null ) { +// double start = System.currentTimeMillis(); + + PrisonAPI.dispatchCommand( player, task ); + +// double stop = System.currentTimeMillis(); +// Output.get().logDebug( "PrisonDispatchCommandTask.run: (player) " + +// (stop - start) + " ms player= " + player.getName() + +// " task: " + task ); + } + else { +// double start = System.currentTimeMillis(); + + PrisonAPI.dispatchCommand( task ); + +// double stop = System.currentTimeMillis(); +// Output.get().logDebug( "PrisonDispatchCommandTask.run: (console) " + +// (stop - start) + " ms" + +// " task: " + task ); + } + } + catch ( Exception e ) { + + Output.get().logError( "PrisonDispatchCommand: Error trying to run task: " + errorMessage + + " Task: [" + task + "] " + e.getMessage() ); + } + + long stop = System.nanoTime(); + long elapsed = stop - start; + + elapsedTimes.add( Long.valueOf( elapsed ) ); + + } + + } + } + private String translateCommand( Player player, String command ) { String formatted = command diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskPlaceholderData.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskPlaceholderData.java index f01b1b3df..407441a20 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskPlaceholderData.java +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskPlaceholderData.java @@ -1,6 +1,6 @@ package tech.mcprison.prison.tasks; -import tech.mcprison.prison.tasks.PrisonCommandTask.CustomPlaceholders; +import tech.mcprison.prison.tasks.PrisonCommandTaskData.CustomPlaceholders; public class PrisonCommandTaskPlaceholderData { diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java new file mode 100644 index 000000000..0854780ca --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java @@ -0,0 +1,112 @@ +package tech.mcprison.prison.tasks; + +import java.util.ArrayList; +import java.util.List; + +import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.output.Output; + +public class PrisonCommandTasks + implements PrisonRunnable +{ + + private Player player; + private List cmdTasks; + + private int cmTasksPosition = 0; + + private int taskId = 0; + + private PrisonCommandTasks() { + super(); + } + + public static void submitTasks( PrisonCommandTaskData cmdTask ) { + submitTasks( null, cmdTask ); + } + + public static void submitTasks( Player player, PrisonCommandTaskData cmdTask ) { + + List cmdTasks = new ArrayList<>(); + cmdTasks.add( cmdTask ); + + submitTasks( player, cmdTasks ); + + } + + public static void submitTasks( List cmdTasks ) { + submitTasks( null, cmdTasks ); + } + + public static void submitTasks( Player player, List cmdTasks ) { + + if ( cmdTasks.size() > 0 ) { + + PrisonCommandTasks rcTask = new PrisonCommandTasks(); + rcTask.setPlayer( player ); + rcTask.setCmdTasks( cmdTasks ); + + rcTask.setTaskId( PrisonTaskSubmitter.runTaskLater(rcTask, 1) ); + } + } + + private void resubmitTask() { + + taskId = PrisonTaskSubmitter.runTaskLater(this, 1); + } + + @Override + public void run() { + + if ( cmdTasks.size() > cmTasksPosition ) { + + PrisonCommandTaskData task = cmdTasks.get( cmTasksPosition++ ); + + task.runCommandTask( getPlayer() ); + + resubmitTask(); + } + else if ( Output.get().isDebug() && cmTasksPosition > 0 ) { + // Done running all tasks. If debug is enabled, print: + + String message = String.format( "Prison Command Debug Details: %d", cmTasksPosition ); + Output.get().logInfo( message ); + + for ( PrisonCommandTaskData cmdTask : cmdTasks ) { + + Output.get().logInfo( cmdTask.getDebugDetails() ); + } + + } + } + + + public Player getPlayer() { + return player; + } + public void setPlayer( Player player ) { + this.player = player; + } + + public List getCmdTasks() { + return cmdTasks; + } + public void setCmdTasks( List cmdTasks ) { + this.cmdTasks = cmdTasks; + } + + public int getCmTasksPosition() { + return cmTasksPosition; + } + public void setCmTasksPosition( int cmTasksPosition ) { + this.cmTasksPosition = cmTasksPosition; + } + + public int getTaskId() { + return taskId; + } + public void setTaskId( int taskId ) { + this.taskId = taskId; + } + +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonDispatchCommandTask.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonDispatchCommandTask.java index 16ad2ba65..f041c6c12 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonDispatchCommandTask.java +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonDispatchCommandTask.java @@ -11,17 +11,22 @@ public class PrisonDispatchCommandTask implements PrisonRunnable { private List tasks; + private List elapsedTimes; + private String errorMessage; + private List customPlaceholders; + private Player player; private boolean playerTask = false; - private List customPlaceholders; public PrisonDispatchCommandTask( List tasks, String errorMessage, Player player, boolean playerTask ) { this.tasks = tasks; + this.elapsedTimes = new ArrayList<>(); + this.errorMessage = errorMessage; this.player = player; @@ -37,6 +42,8 @@ public void run() { for ( String task : tasks ) { + long start = System.nanoTime(); + // Apply the custom placeholders: for ( PrisonCommandTaskPlaceholderData cPlaceholder : getCustomPlaceholders() ) { if ( cPlaceholder.contains( task ) ) { @@ -71,6 +78,12 @@ public void run() { Output.get().logError( "PrisonDispatchCommand: Error trying to run task: " + errorMessage + " Task: [" + task + "] " + e.getMessage() ); } + + long stop = System.nanoTime(); + long elapsed = stop - start; + + elapsedTimes.add( Long.valueOf( elapsed ) ); + } } 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 639c0349e..300ce900b 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 @@ -63,8 +63,8 @@ import tech.mcprison.prison.output.RowComponent; import tech.mcprison.prison.placeholders.PlaceholdersUtil; import tech.mcprison.prison.selection.Selection; -import tech.mcprison.prison.tasks.PrisonCommandTask; -import tech.mcprison.prison.tasks.PrisonCommandTask.TaskMode; +import tech.mcprison.prison.tasks.PrisonCommandTaskData; +import tech.mcprison.prison.tasks.PrisonCommandTaskData.TaskMode; import tech.mcprison.prison.tasks.PrisonTaskSubmitter; import tech.mcprison.prison.util.Bounds; import tech.mcprison.prison.util.Bounds.Edges; @@ -3480,11 +3480,11 @@ public void blockEventAdd(CommandSender sender, String placeholders = - PrisonCommandTask.CustomPlaceholders.listPlaceholders( - PrisonCommandTask.CommandEnvironment.all_commands ) + " " + + PrisonCommandTaskData.CustomPlaceholders.listPlaceholders( + PrisonCommandTaskData.CommandEnvironment.all_commands ) + " " + - PrisonCommandTask.CustomPlaceholders.listPlaceholders( - PrisonCommandTask.CommandEnvironment.blockevent_commands ); + PrisonCommandTaskData.CustomPlaceholders.listPlaceholders( + PrisonCommandTaskData.CommandEnvironment.blockevent_commands ); String message = String.format( "Valid Placeholders that can be used with blockEvents: [%s]", placeholders ); @@ -4507,11 +4507,11 @@ public void commandAdd(CommandSender sender, String placeholders = - PrisonCommandTask.CustomPlaceholders.listPlaceholders( - PrisonCommandTask.CommandEnvironment.all_commands ) + " " + + PrisonCommandTaskData.CustomPlaceholders.listPlaceholders( + PrisonCommandTaskData.CommandEnvironment.all_commands ) + " " + - PrisonCommandTask.CustomPlaceholders.listPlaceholders( - PrisonCommandTask.CommandEnvironment.mine_commands ); + PrisonCommandTaskData.CustomPlaceholders.listPlaceholders( + PrisonCommandTaskData.CommandEnvironment.mine_commands ); String message = String.format( "Valid Placeholders that can be used with mine commands: [%s]", placeholders ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index 95c5b8991..d8b96bb43 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -28,9 +28,10 @@ import tech.mcprison.prison.mines.tasks.MinePagedResetAsyncTask; import tech.mcprison.prison.mines.tasks.MineTeleportTask; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.tasks.PrisonCommandTask; +import tech.mcprison.prison.tasks.PrisonCommandTaskData; import tech.mcprison.prison.tasks.PrisonRunnable; import tech.mcprison.prison.tasks.PrisonTaskSubmitter; +import tech.mcprison.prison.tasks.PrisonCommandTasks; import tech.mcprison.prison.util.Bounds; import tech.mcprison.prison.util.Bounds.Edges; import tech.mcprison.prison.util.Location; @@ -246,18 +247,27 @@ private void resetSynchonouslyInternal() { // Before reset commands: if ( getResetCommands() != null && getResetCommands().size() > 0 ) { + List cmdTasks = new ArrayList<>(); + + int row = 0; for (String command : getResetCommands() ) { + row++; // String formatted = cmd.replace("{player}", prisonPlayer.getName()) // .replace("{player_uid}", player.uid.toString()); if ( command.startsWith( "before: " )) { String cmd = command.replace( "before: ", "" ); - PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: Before:", cmd ); - cmdTask.submitCommandTask(); - + PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( + "MineReset sync: " + getName() + " Before:", cmd ); + cmdTask.setCommandRow( row ); + + cmdTasks.add( cmdTask ); +// PrisonCommandTasks.submitTasks( cmdTask ); //PrisonAPI.dispatchCommand(cmd); } } + + PrisonCommandTasks.submitTasks( cmdTasks ); } } @@ -283,18 +293,26 @@ private void resetSynchonouslyInternal() { // After reset commands: if ( getResetCommands() != null && getResetCommands().size() > 0 ) { + List cmdTasks = new ArrayList<>(); + + int row = 0; for (String command : getResetCommands() ) { + row++; // String formatted = cmd.replace("{player}", prisonPlayer.getName()) // .replace("{player_uid}", player.uid.toString()); if ( command.startsWith( "after: " )) { String cmd = command.replace( "after: ", "" ); - PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: After:", cmd ); - cmdTask.submitCommandTask(); - - //PrisonAPI.dispatchCommand(cmd); + + PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( + "MineReset sync: " + getName() + " After:", cmd ); + cmdTask.setCommandRow( row ); + + cmdTasks.add( cmdTask ); } } + + PrisonCommandTasks.submitTasks( cmdTasks ); } } @@ -842,18 +860,27 @@ public void asynchronouslyResetSetup() { // Before reset commands: if ( getResetCommands() != null && getResetCommands().size() > 0 ) { + List cmdTasks = new ArrayList<>(); + + int row = 0; for (String command : getResetCommands() ) { + row++; // String formatted = cmd.replace("{player}", prisonPlayer.getName()) // .replace("{player_uid}", player.uid.toString()); if ( command.startsWith( "before: " )) { String cmd = command.replace( "before: ", "" ); - PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: Before:", cmd ); - cmdTask.submitCommandTask(); - + PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( + "MineReset: " + getName() + " Before:", cmd ); + cmdTask.setCommandRow( row ); + + cmdTasks.add( cmdTask ); +// PrisonCommandTasks.submitTasks( cmdTask ); // PrisonAPI.dispatchCommand(cmd); } } + + PrisonCommandTasks.submitTasks( cmdTasks ); } } } @@ -880,18 +907,27 @@ public void asynchronouslyResetFinalize( List jobResetActions // After reset commands: if ( getResetCommands() != null && getResetCommands().size() > 0 ) { + + List cmdTasks = new ArrayList<>(); + + + int row = 0; for (String command : getResetCommands() ) { + row++; // String formatted = cmd.replace("{player}", prisonPlayer.getName()) // .replace("{player_uid}", player.uid.toString()); if ( command.startsWith( "after: " )) { String cmd = command.replace( "after: ", "" ); - PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: After:", cmd ); - cmdTask.submitCommandTask(); + PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( + "MineReset: " + getName() + " After:", cmd ); + cmdTask.setCommandRow( row ); - // PrisonAPI.dispatchCommand(cmd); + cmdTasks.add( cmdTask ); } } + + PrisonCommandTasks.submitTasks( cmdTasks ); } } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java index 1e21562b3..ed742d400 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java @@ -20,10 +20,11 @@ import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType; import tech.mcprison.prison.mines.tasks.MinePagedResetAsyncTask; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.tasks.PrisonCommandTask; -import tech.mcprison.prison.tasks.PrisonCommandTask.CustomPlaceholders; +import tech.mcprison.prison.tasks.PrisonCommandTaskData; +import tech.mcprison.prison.tasks.PrisonCommandTaskData.CustomPlaceholders; import tech.mcprison.prison.tasks.PrisonRunnable; import tech.mcprison.prison.tasks.PrisonTaskSubmitter; +import tech.mcprison.prison.tasks.PrisonCommandTasks; import tech.mcprison.prison.util.Location; public abstract class MineScheduler @@ -542,14 +543,22 @@ public void processBlockBreakEventCommands( PrisonBlock prisonBlock, // Only one block is processed here: if ( getBlockEvents().size() > 0 ) { + + List cmdTasks = new ArrayList<>(); + Random random = new Random(); + int row = 0; for ( MineBlockEvent blockEvent : getBlockEvents() ) { double chance = random.nextDouble() * 100; processBlockEventDetails( player, prisonBlock, - targetBlock, eventType, chance, blockEvent, triggered ); + targetBlock, eventType, chance, blockEvent, triggered, + cmdTasks, ++row ); } + + + PrisonCommandTasks.submitTasks( player, cmdTasks ); } } @@ -585,7 +594,8 @@ public void processBlockBreakEventCommands( PrisonBlock prisonBlock, private void processBlockEventDetails( Player player, PrisonBlock prisonBlock, MineTargetPrisonBlock targetBlock, BlockEventType eventType, double chance, - MineBlockEvent blockEvent, String triggered ) + MineBlockEvent blockEvent, String triggered, + List cmdTasks, int row ) { boolean fireEvent = blockEvent.isFireEvent( chance, eventType, @@ -605,8 +615,9 @@ private void processBlockEventDetails( Player player, PrisonBlock prisonBlock, PrisonBlockStatusData originalBlock = targetBlock.getPrisonBlock(); - PrisonCommandTask cmdTask = new PrisonCommandTask( "BlockEvent", blockEvent.getCommand() ); + PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( "BlockEvent", blockEvent.getCommand() ); cmdTask.setTaskMode( blockEvent.getTaskMode() ); + cmdTask.setCommandRow( row ); cmdTask.addCustomPlaceholder( CustomPlaceholders.blockName, originalBlock.getBlockName() ); @@ -655,6 +666,8 @@ private void processBlockEventDetails( Player player, PrisonBlock prisonBlock, cmdTask.addCustomPlaceholder( CustomPlaceholders.eventTriggered, triggered ); + cmdTasks.add( cmdTask ); + // cmdTask.submitCommandTask( player, blockEvent.getCommand(), blockEvent.getTaskMode() ); 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 b2664751b..899e87fce 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 @@ -12,7 +12,7 @@ import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlockTypes; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.tasks.PrisonCommandTask.TaskMode; +import tech.mcprison.prison.tasks.PrisonCommandTaskData.TaskMode; public class MineBlockEvent { diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java index 189084a80..570e7abee 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java @@ -34,8 +34,8 @@ import tech.mcprison.prison.ranks.data.RankPlayer; import tech.mcprison.prison.ranks.data.RankPlayerFactory; import tech.mcprison.prison.ranks.events.RankUpEvent; -import tech.mcprison.prison.tasks.PrisonCommandTask; -import tech.mcprison.prison.tasks.PrisonCommandTask.CustomPlaceholders; +import tech.mcprison.prison.tasks.PrisonCommandTaskData; +import tech.mcprison.prison.tasks.PrisonCommandTaskData.CustomPlaceholders; /** * Utilities for changing the ranks of players. @@ -191,7 +191,7 @@ public RankUtil() { public RankupResults rankupPlayer(Player player, RankPlayer rankPlayer, String ladderName, String playerName, - List cmdTasks ) { + List cmdTasks ) { return rankupPlayer(RankupCommands.rankup, player, rankPlayer, ladderName, null, playerName, null, PromoteForceCharge.charge_player, cmdTasks ); @@ -199,7 +199,7 @@ public RankupResults rankupPlayer(Player player, RankPlayer rankPlayer, String l public RankupResults promotePlayer(Player player, RankPlayer rankPlayer, String ladderName, String playerName, String executorName, PromoteForceCharge pForceCharge, - List cmdTasks ) { + List cmdTasks ) { return rankupPlayer(RankupCommands.promote, player, rankPlayer, ladderName, null, playerName, executorName, pForceCharge, cmdTasks ); @@ -207,7 +207,7 @@ public RankupResults promotePlayer(Player player, RankPlayer rankPlayer, String public RankupResults demotePlayer(Player player, RankPlayer rankPlayer, String ladderName, String playerName, String executorName, PromoteForceCharge pForceCharge, - List cmdTasks ) { + List cmdTasks ) { return rankupPlayer(RankupCommands.demote, player, rankPlayer, ladderName, null, playerName, executorName, pForceCharge, cmdTasks ); @@ -215,7 +215,7 @@ public RankupResults demotePlayer(Player player, RankPlayer rankPlayer, String l public RankupResults setRank(Player player, RankPlayer rankPlayer, String ladderName, String rankName, String playerName, String executorName, - List cmdTasks ) { + List cmdTasks ) { RankupCommands rankupCmd = "FirstJoinEvent".equalsIgnoreCase( executorName ) ? RankupCommands.firstJoin : RankupCommands.setrank; @@ -241,7 +241,7 @@ public RankupResults setRank(Player player, RankPlayer rankPlayer, String ladder */ private RankupResults rankupPlayer(RankupCommands command, Player player, RankPlayer rankPlayer, String ladderName, String rankName, String playerName, String executorName, - PromoteForceCharge pForceCharge, List cmdTasks ) { + PromoteForceCharge pForceCharge, List cmdTasks ) { RankupResults results = new RankupResults(command, rankPlayer, executorName, ladderName, rankName); @@ -331,7 +331,7 @@ private RankupResults rankupPlayer(RankupCommands command, Player player, RankPl private void rankupPlayerInternal(RankupResults results, RankupCommands command, Player prisonPlayer, RankPlayer rankPlayer, String ladderName, String rankName, - PromoteForceCharge pForceCharge, List cmdTasks ) { + PromoteForceCharge pForceCharge, List cmdTasks ) { Output.get().logDebug( DebugTarget.rankup, "Rankup: rankupPlayerInternal: "); @@ -558,7 +558,7 @@ private void rankupPlayerInternal(RankupResults results, cmd = cmd.replace( "{firstJoin}", "" ); } - PrisonCommandTask cmdTask = new PrisonCommandTask( command.name(), cmd, row ); + PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( command.name(), cmd, row ); cmdTask.setLadder( ladder ); cmdTask.setRankTarget( tpRank ); @@ -590,7 +590,7 @@ private void rankupPlayerInternal(RankupResults results, cmdTasks.add( cmdTask ); // Comment this out to stack the rank commands: - cmdTask.submitCommandTask( prisonPlayer ); + // cmdTask.submitCommandTask( prisonPlayer ); // String formatted = cmd.replace("{player}", prisonPlayer.getName()) diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java index 5b3be3dc7..7e9051abb 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java @@ -15,7 +15,7 @@ import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.data.Rank; import tech.mcprison.prison.ranks.data.RankLadder; -import tech.mcprison.prison.tasks.PrisonCommandTask; +import tech.mcprison.prison.tasks.PrisonCommandTaskData; /** * @author Faizaan A. Datoo @@ -58,11 +58,11 @@ public void commandAdd(CommandSender sender, String placeholders = - PrisonCommandTask.CustomPlaceholders.listPlaceholders( - PrisonCommandTask.CommandEnvironment.all_commands ) + " " + + PrisonCommandTaskData.CustomPlaceholders.listPlaceholders( + PrisonCommandTaskData.CommandEnvironment.all_commands ) + " " + - PrisonCommandTask.CustomPlaceholders.listPlaceholders( - PrisonCommandTask.CommandEnvironment.rank_commands ); + PrisonCommandTaskData.CustomPlaceholders.listPlaceholders( + PrisonCommandTaskData.CommandEnvironment.rank_commands ); String message = ranksCommandAddPlaceholdersMsg( placeholders ); @@ -235,11 +235,11 @@ public void commandLadderAdd(CommandSender sender, if ( ladderName != null && "placeholders".equalsIgnoreCase( ladderName ) ) { - String placeholders = PrisonCommandTask.CustomPlaceholders.listPlaceholders( - PrisonCommandTask.CommandEnvironment.all_commands ) + " " + + String placeholders = PrisonCommandTaskData.CustomPlaceholders.listPlaceholders( + PrisonCommandTaskData.CommandEnvironment.all_commands ) + " " + - PrisonCommandTask.CustomPlaceholders.listPlaceholders( - PrisonCommandTask.CommandEnvironment.rank_commands ); + PrisonCommandTaskData.CustomPlaceholders.listPlaceholders( + PrisonCommandTaskData.CommandEnvironment.rank_commands ); String message = ladderCommandAddPlaceholdersMsg( placeholders ); 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 ac7e680b0..f0f21b8fc 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 @@ -42,7 +42,8 @@ import tech.mcprison.prison.ranks.data.RankPlayerFactory; import tech.mcprison.prison.ranks.managers.LadderManager; import tech.mcprison.prison.ranks.managers.PlayerManager; -import tech.mcprison.prison.tasks.PrisonCommandTask; +import tech.mcprison.prison.tasks.PrisonCommandTaskData; +import tech.mcprison.prison.tasks.PrisonCommandTasks; /** * The commands for this module. @@ -80,12 +81,13 @@ public void rankUpMax(CommandSender sender, "Rankup: cmd '/rankupmax %s' Passed perm check: ranks.rankupmax.%s", ladder, ladder ); - List cmdTasks = new ArrayList<>(); + List cmdTasks = new ArrayList<>(); rankUpPrivate(sender, ladder, RankupModes.MAX_RANKS, "ranks.rankupmax.", cmdTasks ); // submit cmdTasks - submitCmdTasks( cmdTasks ); + Player player = getPlayer( sender, null ); + submitCmdTasks( player, cmdTasks ); } else { @@ -111,17 +113,18 @@ public void rankUp(CommandSender sender, "Rankup: cmd '/rankup %s' Processing ranks.rankup.%s", ladder, ladder ); - List cmdTasks = new ArrayList<>(); + List cmdTasks = new ArrayList<>(); rankUpPrivate(sender, ladder, RankupModes.ONE_RANK, "ranks.rankup.", cmdTasks ); // submit cmdTasks - submitCmdTasks( cmdTasks ); + Player player = getPlayer( sender, null ); + submitCmdTasks( player, cmdTasks ); } private void rankUpPrivate(CommandSender sender, String ladder, RankupModes mode, - String permission, List cmdTasks ) { + String permission, List cmdTasks ) { // RETRIEVE THE LADDER @@ -418,13 +421,13 @@ public void promotePlayer(CommandSender sender, if ( ladder != null && rankPlayer != null ) { - List cmdTasks = new ArrayList<>(); + List cmdTasks = new ArrayList<>(); RankupResults results = new RankUtil().promotePlayer(player, rankPlayer, ladder, player.getName(), sender.getName(), pForceCharge, cmdTasks ); // submit cmdTasks... - submitCmdTasks( cmdTasks ); + submitCmdTasks( player, cmdTasks ); processResults( sender, player.getName(), results, null, ladder, currency ); } @@ -479,13 +482,13 @@ public void demotePlayer(CommandSender sender, if ( ladder != null && rankPlayer != null ) { - List cmdTasks = new ArrayList<>(); + List cmdTasks = new ArrayList<>(); RankupResults results = new RankUtil().demotePlayer(player, rankPlayer, ladder, player.getName(), sender.getName(), pForceCharge, cmdTasks ); // submit cmdTasks - submitCmdTasks( cmdTasks ); + submitCmdTasks( player, cmdTasks ); processResults( sender, player.getName(), results, null, ladder, currency ); } @@ -564,7 +567,7 @@ public void setPlayerRank( RankPlayer rankPlayer, Rank pRank ) { if ( rankPlayer != null ) { - List cmdTasks = new ArrayList<>(); + List cmdTasks = new ArrayList<>(); RankupResults results = new RankUtil().setRank(rankPlayer, rankPlayer, @@ -573,7 +576,8 @@ public void setPlayerRank( RankPlayer rankPlayer, Rank pRank ) { cmdTasks ); // submit cmdTasks - submitCmdTasks( cmdTasks ); + Player player = getPlayer( null, rankPlayer.getName() ); + submitCmdTasks( player, cmdTasks ); processResults( rankPlayer, rankPlayer.getName(), results, pRank.getName(), pRank.getLadder().getName(), @@ -600,13 +604,13 @@ private void setPlayerRank( Player player, String rank, String ladderName, Comma // Get currency if it exists, otherwise it will be null if the Rank has no currency: String currency = rankPlayer == null || pRank == null ? null : pRank.getCurrency(); - List cmdTasks = new ArrayList<>(); + List cmdTasks = new ArrayList<>(); RankupResults results = new RankUtil().setRank(player, rankPlayer, ladderName, rank, player.getName(), sender.getName(), cmdTasks ); // submit cmdTasks - submitCmdTasks( cmdTasks ); + submitCmdTasks( player, cmdTasks ); processResults( sender, player.getName(), results, rank, ladderName, currency ); } @@ -727,8 +731,10 @@ public void processResults( CommandSender sender, String playerName, } - private void submitCmdTasks( List cmdTasks ) + private void submitCmdTasks( Player player, List cmdTasks ) { + + PrisonCommandTasks.submitTasks( player, cmdTasks ); } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankupCommandTastk.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankupCommandTastk.java deleted file mode 100644 index 79029982c..000000000 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankupCommandTastk.java +++ /dev/null @@ -1,47 +0,0 @@ -package tech.mcprison.prison.ranks.commands; - -import java.util.List; - -import tech.mcprison.prison.internal.Player; -import tech.mcprison.prison.tasks.PrisonCommandTask; -import tech.mcprison.prison.tasks.PrisonRunnable; - -public class RankupCommandTastk - implements PrisonRunnable -{ - - private Player player; - private List cmdTasks; - - private int cmTasksPosition = 0; - - public static void submitTasks( Player player, List cmdTasks ) { - - RankupCommandTastk rcTask = new RankupCommandTastk(); - rcTask.setPlayer( player ); - rcTask.setCmdTasks( cmdTasks ); - - - } - - @Override - public void run() { - - } - - - public Player getPlayer() { - return player; - } - public void setPlayer( Player player ) { - this.player = player; - } - - public List getCmdTasks() { - return cmdTasks; - } - public void setCmdTasks( List cmdTasks ) { - this.cmdTasks = cmdTasks; - } - -} diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java index db847e715..2f6eae52a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java @@ -30,7 +30,7 @@ public class OnBlockBreakPlayerManualCore { - public void playerSmelt( SpigotPlayer player ) { + public void playerSmelt( SpigotPlayer player, StringBuilder debugInfo ) { List smelts = new ArrayList<>(); @@ -68,12 +68,12 @@ public void playerSmelt( SpigotPlayer player ) { for ( XMaterial xMat : smelts ) { - autoFeatureSmelt( player.getWrapper(), xMat ); + autoFeatureSmelt( player.getWrapper(), xMat, debugInfo ); } } - public void playerBlock( SpigotPlayer player ) { + public void playerBlock( SpigotPlayer player, StringBuilder debugInfo ) { List blocks = new ArrayList<>(); @@ -91,13 +91,13 @@ public void playerBlock( SpigotPlayer player ) { for ( XMaterial xMat : blocks ) { - autoFeatureBlock( player.getWrapper(), xMat ); + autoFeatureBlock( player.getWrapper(), xMat, debugInfo ); } } - protected XMaterial autoFeatureSmelt( Player p, XMaterial source ) + protected XMaterial autoFeatureSmelt( Player p, XMaterial source, StringBuilder debugInfo ) { XMaterial results = source; @@ -109,7 +109,7 @@ protected XMaterial autoFeatureSmelt( Player p, XMaterial source ) switch ( source ) { case COBBLESTONE: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltCobblestone ), source, XMaterial.STONE, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltCobblestone ), source, XMaterial.STONE, p, debugInfo ); results = XMaterial.STONE; break; @@ -117,54 +117,54 @@ protected XMaterial autoFeatureSmelt( Player p, XMaterial source ) case NETHER_GOLD_ORE: case DEEPSLATE_GOLD_ORE: case RAW_GOLD: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltGoldOre ), source, XMaterial.GOLD_INGOT, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltGoldOre ), source, XMaterial.GOLD_INGOT, p, debugInfo ); results = XMaterial.GOLD_INGOT; break; case IRON_ORE: case DEEPSLATE_IRON_ORE: case RAW_IRON: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltIronOre ), source, XMaterial.IRON_INGOT, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltIronOre ), source, XMaterial.IRON_INGOT, p, debugInfo ); results = XMaterial.IRON_INGOT; break; case COAL_ORE: case DEEPSLATE_COAL_ORE: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltCoalOre ), source, XMaterial.COAL, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltCoalOre ), source, XMaterial.COAL, p, debugInfo ); results = XMaterial.COAL; break; case DIAMOND_ORE: case DEEPSLATE_DIAMOND_ORE: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltDiamondlOre ), source, XMaterial.DIAMOND, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltDiamondlOre ), source, XMaterial.DIAMOND, p, debugInfo ); results = XMaterial.DIAMOND; break; case EMERALD_ORE: case DEEPSLATE_EMERALD_ORE: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltEmeraldOre ), source, XMaterial.EMERALD, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltEmeraldOre ), source, XMaterial.EMERALD, p, debugInfo ); results = XMaterial.EMERALD; break; case LAPIS_ORE: case DEEPSLATE_LAPIS_ORE: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltLapisOre ), source, XMaterial.LAPIS_LAZULI, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltLapisOre ), source, XMaterial.LAPIS_LAZULI, p, debugInfo ); results = XMaterial.LAPIS_LAZULI; break; case REDSTONE_ORE: case DEEPSLATE_REDSTONE_ORE: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltRedstoneOre ), source, XMaterial.REDSTONE, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltRedstoneOre ), source, XMaterial.REDSTONE, p, debugInfo ); results = XMaterial.REDSTONE; break; case NETHER_QUARTZ_ORE: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltNetherQuartzOre ), source, XMaterial.QUARTZ, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltNetherQuartzOre ), source, XMaterial.QUARTZ, p, debugInfo ); results = XMaterial.QUARTZ; break; case ANCIENT_DEBRIS: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltAncientDebris ), source, XMaterial.NETHERITE_SCRAP, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltAncientDebris ), source, XMaterial.NETHERITE_SCRAP, p, debugInfo ); results = XMaterial.NETHERITE_SCRAP; break; @@ -172,7 +172,7 @@ protected XMaterial autoFeatureSmelt( Player p, XMaterial source ) case COPPER_ORE: case DEEPSLATE_COPPER_ORE: case RAW_COPPER: - autoSmelt( isAll || isBoolean( AutoFeatures.smeltCopperOre ), source, XMaterial.COPPER_INGOT, p ); + autoSmelt( isAll || isBoolean( AutoFeatures.smeltCopperOre ), source, XMaterial.COPPER_INGOT, p, debugInfo ); results = XMaterial.COPPER_INGOT; break; @@ -185,7 +185,7 @@ protected XMaterial autoFeatureSmelt( Player p, XMaterial source ) return results; } - protected void autoFeatureBlock( Player p, XMaterial source ) { + protected void autoFeatureBlock( Player p, XMaterial source, StringBuilder debugInfo ) { boolean isAll = isBoolean( AutoFeatures.smeltAllBlocks ); @@ -197,62 +197,62 @@ protected void autoFeatureBlock( Player p, XMaterial source ) { switch ( source ) { case GOLD_INGOT: - autoBlock( isAll || isBoolean( AutoFeatures.blockGoldBlock ), source, XMaterial.GOLD_BLOCK, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockGoldBlock ), source, XMaterial.GOLD_BLOCK, p, debugInfo ); break; case IRON_INGOT: - autoBlock( isAll || isBoolean( AutoFeatures.blockIronBlock ), source, XMaterial.IRON_BLOCK, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockIronBlock ), source, XMaterial.IRON_BLOCK, p, debugInfo ); break; case COAL: - autoBlock( isAll || isBoolean( AutoFeatures.blockCoalBlock ), source, XMaterial.COAL_BLOCK, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockCoalBlock ), source, XMaterial.COAL_BLOCK, p, debugInfo ); break; case DIAMOND: - autoBlock( isAll || isBoolean( AutoFeatures.blockDiamondBlock ), source, XMaterial.DIAMOND_BLOCK, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockDiamondBlock ), source, XMaterial.DIAMOND_BLOCK, p, debugInfo ); break; case REDSTONE: - autoBlock( isAll || isBoolean( AutoFeatures.blockRedstoneBlock ), source,XMaterial.REDSTONE_BLOCK, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockRedstoneBlock ), source,XMaterial.REDSTONE_BLOCK, p, debugInfo ); break; case EMERALD: - autoBlock( isAll || isBoolean( AutoFeatures.blockEmeraldBlock ), source, XMaterial.EMERALD_BLOCK, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockEmeraldBlock ), source, XMaterial.EMERALD_BLOCK, p, debugInfo ); break; case QUARTZ: - autoBlock( isAll || isBoolean( AutoFeatures.blockQuartzBlock ), source, XMaterial.QUARTZ_BLOCK, 4, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockQuartzBlock ), source, XMaterial.QUARTZ_BLOCK, 4, p, debugInfo ); break; case PRISMARINE_SHARD: - autoBlock( isAll || isBoolean( AutoFeatures.blockPrismarineBlock ), source, XMaterial.PRISMARINE, 4, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockPrismarineBlock ), source, XMaterial.PRISMARINE, 4, p, debugInfo ); break; case SNOWBALL: - autoBlock( isAll || isBoolean( AutoFeatures.blockSnowBlock ), source, XMaterial.SNOW_BLOCK, 4, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockSnowBlock ), source, XMaterial.SNOW_BLOCK, 4, p, debugInfo ); break; case GLOWSTONE_DUST: - autoBlock( isAll || isBoolean( AutoFeatures.blockGlowstone ), source, XMaterial.GLOWSTONE, 4, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockGlowstone ), source, XMaterial.GLOWSTONE, 4, p, debugInfo ); break; case LAPIS_LAZULI: - autoBlock( isAll || isBoolean( AutoFeatures.blockLapisBlock ), source, XMaterial.LAPIS_BLOCK, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockLapisBlock ), source, XMaterial.LAPIS_BLOCK, p, debugInfo ); break; case COPPER_INGOT: - autoBlock( isAll || isBoolean( AutoFeatures.blockCopperBlock ), source, XMaterial.COPPER_BLOCK, p ); + autoBlock( isAll || isBoolean( AutoFeatures.blockCopperBlock ), source, XMaterial.COPPER_BLOCK, p, debugInfo ); break; @@ -265,27 +265,27 @@ protected void autoFeatureBlock( Player p, XMaterial source ) { - protected void autoSmelt( boolean autoSmelt, XMaterial source, XMaterial target, Player p ) { + protected void autoSmelt( boolean autoSmelt, XMaterial source, XMaterial target, Player p, StringBuilder debugInfo ) { if ( autoSmelt && source != null && target != null ) { HashMap overflow = SpigotUtil.itemStackReplaceItems( p, source, target, 1 ); - dropExtra( overflow, p ); + dropExtra( overflow, p, debugInfo ); } } - protected void autoBlock( boolean autoBlock, XMaterial source, XMaterial target, Player p ) { - autoBlock(autoBlock, source, target, 9, p ); + protected void autoBlock( boolean autoBlock, XMaterial source, XMaterial target, Player p, StringBuilder debugInfo ) { + autoBlock(autoBlock, source, target, 9, p, debugInfo ); } - protected void autoBlock( boolean autoBlock, XMaterial source, XMaterial target, int ratio, Player p ) { + protected void autoBlock( boolean autoBlock, XMaterial source, XMaterial target, int ratio, Player p, StringBuilder debugInfo ) { if ( autoBlock && source != null && target != null ) { HashMap overflow = SpigotUtil.itemStackReplaceItems( p, source, target, ratio ); - dropExtra( overflow, p ); + dropExtra( overflow, p, debugInfo ); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMining.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMining.java index 139b61bd2..70c880546 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMining.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMining.java @@ -57,9 +57,14 @@ public void utilMiningSmelt(CommandSender sender, // Player cannot be null. If it is null, then there was a failure. if ( player != null && player.isOnline() ) { + StringBuilder debugInfo = new StringBuilder(); + OnBlockBreakPlayerManualCore manualHandler = new OnBlockBreakPlayerManualCore(); - manualHandler.playerSmelt( player ); + manualHandler.playerSmelt( player, debugInfo ); + if ( Output.get().isDebug() ) { + Output.get().logInfo( debugInfo.toString() ); + } // SpigotPrison.getInstance().getAutoFeatures().playerSmelt( player ); } } @@ -86,10 +91,14 @@ public void utilMiningBlock(CommandSender sender, // Player cannot be null. If it is null, then there was a failure. if ( player != null && player.isOnline() ) { + StringBuilder debugInfo = new StringBuilder(); OnBlockBreakPlayerManualCore manualHandler = new OnBlockBreakPlayerManualCore(); - manualHandler.playerBlock( player ); + manualHandler.playerBlock( player, debugInfo ); + if ( Output.get().isDebug() ) { + Output.get().logInfo( debugInfo.toString() ); + } // SpigotPrison.getInstance().getAutoFeatures().playerBlock( player ); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java index 5472093a2..096e1b1f3 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java @@ -7,7 +7,8 @@ import tech.mcprison.prison.internal.block.MineTargetBlockKey; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.spigot.block.SpigotBlock; -import tech.mcprison.prison.tasks.PrisonCommandTask; +import tech.mcprison.prison.tasks.PrisonCommandTaskData; +import tech.mcprison.prison.tasks.PrisonCommandTasks; import tech.mcprison.prison.util.Location; public interface PrisonUtilsTaskTypes @@ -131,9 +132,10 @@ public UtilTaskType getTaskType() { @Override public void run() { - PrisonCommandTask pCmd = new PrisonCommandTask( "PrisonUtilsTaskTypRunCommand", getCommand() ); + PrisonCommandTaskData pCmd = new PrisonCommandTaskData( "PrisonUtilsTaskTypRunCommand", getCommand(), 1 ); - pCmd.submitCommandTask( getPlayer() ); + PrisonCommandTasks.submitTasks( pCmd ); +// pCmd.submitCommandTask( getPlayer() ); } @Override From b8043ebe742e5cb0d2593b625789b9ee88b516a0 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 19:20:12 -0500 Subject: [PATCH 087/297] These are the message files for the changes to Text to externalize the time components. Totally forgot to commit them yesterday! --- docs/changelog_v3.3.x.md | 4 + .../mcprison/prison/util/TextMessage.java | 73 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/util/TextMessage.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index b8b4d0ed4..0a2ca902b 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -20,6 +20,10 @@ These build logs represent the work that has been going on within prison. Hook up some of the logging to track run times for each command. +* **Prison commands: reorganize some of the structures used for the prison commands.** +Hook up some of the logging to track run times for each command. + + * **Prevent the autosell happening just because someone is op.** To make this work, and to prevent odd behaviors where OPs suddenly are not able to mine correctly, OP can no longer use the autosell based upon perms. diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/TextMessage.java b/prison-core/src/main/java/tech/mcprison/prison/util/TextMessage.java new file mode 100644 index 000000000..f96e520cb --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/util/TextMessage.java @@ -0,0 +1,73 @@ +package tech.mcprison.prison.util; + +import tech.mcprison.prison.Prison; + +public class TextMessage +{ + +// core_text__prefix=&3 +// core_text__just_now=just now +// core_text__ago=ago +// core_text__from_now=from now +// core_text__and=and +// core_text__time_units_singular=year,month,week,day,hour,minute,second +// core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds + + + protected static String coreOutputTextJustPrefixMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_text__prefix" ) + .withReplacements( "%s" ) + .setFailSilently() + .localize(); + } + + protected static String coreOutputTextJustNowMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_text__just_now" ) + .withReplacements( "%s" ) + .setFailSilently() + .localize(); + } + + protected static String coreOutputTextAgoMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_text__ago" ) + .withReplacements( "%s" ) + .setFailSilently() + .localize(); + } + + protected static String coreOutputTextFromNowMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_text__from_now" ) + .withReplacements( "%s" ) + .setFailSilently() + .localize(); + } + + protected static String coreOutputTextAndMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_text__and" ) + .withReplacements( "%s" ) + .setFailSilently() + .localize(); + } + + protected static String coreOutputTextTimeUnitsSingularMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_text__time_units_singular" ) + .withReplacements( "%s" ) + .setFailSilently() + .localize(); + } + + protected static String coreOutputTextTimeUnitsPluralMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_text__time_units_plural" ) + .withReplacements( "%s" ) + .setFailSilently() + .localize(); + } + +} From 542e87d62cd26f0705aaf918a71ed63416d46a29 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 19:24:28 -0500 Subject: [PATCH 088/297] Bug fix: The cancellation of the event was not being returned in the correct locations, so it was bypassing all of the before mine reset commands. The before mine commands will now run correctly. --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/mines/tasks/MinePagedResetAsyncTask.java | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0a2ca902b..cf65a197e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-15 +* **Bug fix: The cancellation of the event was not being returned in the correct locations**, +so it was bypassing all of the before mine reset commands. The before mine commands will now run correctly. + + * **Prison commands: reorganize some of the structures used for the prison commands.** Hook up some of the logging to track run times for each command. diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java index 466935390..f3261a5c0 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java @@ -187,6 +187,7 @@ public void run() { * This calls the functions to */ private boolean runSetupCancelReset() { + boolean cancel = false; // Set the MineStateMutex to a state of starting a mine reset: mine.getMineStateMutex().setMineStateResetStart(); @@ -198,12 +199,13 @@ private boolean runSetupCancelReset() { // resetAsynchonouslyInitiate() will confirm if the reset should happened // and will raise Prison's mine reset event. // A return value of true means cancel the reset: - return mine.resetAsynchonouslyInitiate(); + cancel = mine.resetAsynchonouslyInitiate(); } mine.asynchronouslyResetSetup(); - return false; + + return cancel; } private void runShutdown() { From c943320a58528410814ba22815c3aa5a7ba6544d Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 19:28:22 -0500 Subject: [PATCH 089/297] Add prison command descriptions that goes along with the placeholders. They are not yet hooked up, but they will provide more information to the admins on what the placeholders will provide, and also how they can use them since some of thse will include examples of the formats. --- docs/changelog_v3.3.x.md | 4 + .../prison/tasks/PrisonCommandTaskData.java | 140 +++++++++++++----- 2 files changed, 105 insertions(+), 39 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index cf65a197e..44d738fad 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-15 +* **Add prison command descriptions that goes along with the placeholders.** +They are not yet hooked up, but they will provide more information to the admins on what the placeholders will provide, and also how they can use them since some of these will include examples of the formats. + + * **Bug fix: The cancellation of the event was not being returned in the correct locations**, so it was bypassing all of the before mine reset commands. The before mine commands will now run correctly. diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java index 6a29dee6c..2ac5e4295 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java @@ -83,63 +83,114 @@ public enum CommandEnvironment { public enum CustomPlaceholders { - player(CommandEnvironment.all_commands), - player_uid(CommandEnvironment.all_commands), + player(CommandEnvironment.all_commands, + "{player} provides a player's name."), + player_uid(CommandEnvironment.all_commands, + "{player_uid} provides a player's uuid."), - msg(CommandEnvironment.all_commands), - broadcast(CommandEnvironment.all_commands), - title(CommandEnvironment.all_commands ), - actionBar(CommandEnvironment.all_commands ), + msg(CommandEnvironment.all_commands, + "{msg} sends a message to a player's chat."), + broadcast(CommandEnvironment.all_commands, + "{broadcast} sends a message to all players on the server."), + title(CommandEnvironment.all_commands, + "{title} sends a message to the player's title."), + actionBar(CommandEnvironment.all_commands, + "{actionBar} sends a message to the player's actionBar." ), - inline(CommandEnvironment.all_commands), - inlinePlayer(CommandEnvironment.all_commands), - sync(CommandEnvironment.all_commands), - syncPlayer(CommandEnvironment.all_commands), + inline(CommandEnvironment.all_commands, + "{inline} runs the command as console in the same task as this action." ), + inlinePlayer(CommandEnvironment.all_commands, + "{inlinePlayer} runs the command as the player in the same task as this action."), + sync(CommandEnvironment.all_commands, + "{sync} runs the command as console in a new sync task." ), + syncPlayer(CommandEnvironment.all_commands, + "{syncPlayer} runs the command as the payer in a new sync task."), - firstJoin(CommandEnvironment.rank_commands), + firstJoin(CommandEnvironment.rank_commands, + "{firstJoin} runs the command on first join events for new players"), + promote(CommandEnvironment.rank_commands, + "{promote} runs the command only on promotions such as rankup, promote, and setRank."), + demote(CommandEnvironment.rank_commands, + "{demote} runs the command only on demotions such as demote."), + - balanceInitial(CommandEnvironment.rank_commands), - balanceFinal(CommandEnvironment.rank_commands), - currency(CommandEnvironment.rank_commands), + balanceInitial(CommandEnvironment.rank_commands, + "{balanceInitial} a player's initial balance before the promotion/demotion."), + balanceFinal(CommandEnvironment.rank_commands, + "{balanceFinal} a player's final balance after the promotion/demotion."), + currency(CommandEnvironment.rank_commands, + "{currency} if a rank has a custom currency, then this will contain it's name."), originalRankCost(CommandEnvironment.rank_commands), rankupCost(CommandEnvironment.rank_commands), - ladder(CommandEnvironment.rank_commands), - rank(CommandEnvironment.rank_commands), - rankTag(CommandEnvironment.rank_commands), - targetRank(CommandEnvironment.rank_commands), - targetRankTag(CommandEnvironment.rank_commands), + ladder(CommandEnvironment.rank_commands, + "{ladder} the ladder which has the ranks."), + rank(CommandEnvironment.rank_commands, + "{rank} the original rank the player started off with."), + rankTag(CommandEnvironment.rank_commands, + "{rankTag} the original rank's tag."), + targetRank(CommandEnvironment.rank_commands, + "{targetRank} the new rank."), + targetRankTag(CommandEnvironment.rank_commands, + "{targetRankTag} the new rank's tag."), - blockName(CommandEnvironment.blockevent_commands), - mineName(CommandEnvironment.blockevent_commands), - - locationWorld(CommandEnvironment.blockevent_commands), - locationX(CommandEnvironment.blockevent_commands), - locationY(CommandEnvironment.blockevent_commands), - locationZ(CommandEnvironment.blockevent_commands), - - coordinates(CommandEnvironment.blockevent_commands), - worldCoordinates(CommandEnvironment.blockevent_commands), - blockCoordinates(CommandEnvironment.blockevent_commands), + blockName(CommandEnvironment.blockevent_commands, + "{blockName} returns the name of the block. Custom blocks will be " + + "prefixed with their namespace."), + mineName(CommandEnvironment.blockevent_commands, + "{mineName} returns the name of a mine where the block was broke. " + + "Returns an empty String if outside of a mine."), + + locationWorld(CommandEnvironment.blockevent_commands, + "{locationWorld} returns the world name for the coordinates of the block."), + locationX(CommandEnvironment.blockevent_commands, + "{locationX} returns the integer x value for the coordinates of the block."), + locationY(CommandEnvironment.blockevent_commands, + "{locationY} returns the integer y value for the coordinates of the block."), + locationZ(CommandEnvironment.blockevent_commands, + "{locationZ} returns the integer z value for the coordinates of the block."), + + coordinates(CommandEnvironment.blockevent_commands, + "{coordinates} returns the block coordinates in the format of '(x, y, x)' " + + "where x, y, and z are doubles."), + worldCoordinates(CommandEnvironment.blockevent_commands, + "{worldCoordinates} returns the block coordinates in the format of '(world,x,y,x)' " + + "where x, y, and z are integers."), + blockCoordinates(CommandEnvironment.blockevent_commands, + "{blockCoordinates} is similar to worldCoordinates, but prefixed with the " + + "block name 'blockName::(world,x,y,z)'."), - blockChance(CommandEnvironment.blockevent_commands), - blockIsAir(CommandEnvironment.blockevent_commands), - - blocksPlaced(CommandEnvironment.blockevent_commands), - blockRemaining(CommandEnvironment.blockevent_commands), - blocksMinedTotal(CommandEnvironment.blockevent_commands), - mineBlocksRemaining(CommandEnvironment.blockevent_commands), + blockChance(CommandEnvironment.blockevent_commands, + "{blockChance} if the block is in a mine and is one of the placement blocks, then " + + "this will be the block's spawn percent chance."), + blockIsAir(CommandEnvironment.blockevent_commands, + "{blockIsAir} boolean value if the original block is AIR. Technically this can " + + "never happen since you cannot 'break' AIR blocks with tools."), + + blocksPlaced(CommandEnvironment.blockevent_commands, + "{blocksPlaced} the number of blocks that were placed within a mine at the " + + "last mine reset. This may not be the mine size (see {mineBlockSize}) if " + + "some blocks were placed as AIR."), + blockRemaining(CommandEnvironment.blockevent_commands, + "{blocksRemaining} don't use. Unknown value."), + blocksMinedTotal(CommandEnvironment.blockevent_commands, + "{blocksMinedTotal} total blocks mined in the mine."), + mineBlocksRemaining(CommandEnvironment.blockevent_commands, + "{mineBlocksRemaining} the number of blocks remaining in a mine."), mineBlocksRemainingPercent(CommandEnvironment.blockevent_commands), mineBlocksTotalMined(CommandEnvironment.blockevent_commands), mineBlocksSize(CommandEnvironment.blockevent_commands), - blockMinedName(CommandEnvironment.blockevent_commands), - blockMinedNameFormal(CommandEnvironment.blockevent_commands), + blockMinedName(CommandEnvironment.blockevent_commands, + "{blockMinedName} the name of the mined block."), + blockMinedNameFormal(CommandEnvironment.blockevent_commands, + "{blockMinedNameFormal} the formal name of the mined block, which includes " + + "the namespace such as 'namespace:blockName'."), blockMinedBlockType(CommandEnvironment.blockevent_commands), eventType(CommandEnvironment.blockevent_commands), @@ -150,8 +201,15 @@ public enum CustomPlaceholders { ; private final CommandEnvironment environment; + private final String description; + private CustomPlaceholders( CommandEnvironment environment ) { this.environment = environment; + this.description = null; + } + private CustomPlaceholders( CommandEnvironment environment, String description ) { + this.environment = environment; + this.description = description; } public static String listPlaceholders( CommandEnvironment environment ) { @@ -187,6 +245,10 @@ public String getPlaceholder() { public CommandEnvironment getEnvironment() { return environment; } + + public String getDescription() { + return description; + } } From 1e4673b713e3167fdc4428c74b0baee7b22fe5b9 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 19:36:26 -0500 Subject: [PATCH 090/297] Some changes to Sellall to provide more flexibility and to fix some potential bugs The isEnabled now uses the proper boolean settings to indicate if the sellall utility is enabled or not. Before it was trying to treat strings as boolean. --- .../spigot/gui/rank/SpigotPlayerRanksGUI.java | 11 ++-- .../prison/spigot/sellall/SellAllUtil.java | 51 ++++++++++++------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java index cdda892ff..3a4926366 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java @@ -198,15 +198,16 @@ public void open() { for ( String stringValue : rankLore ) { + String currency = (rank.getCurrency() == null || + "default".equalsIgnoreCase( rank.getCurrency()) || + rank.getCurrency().trim().length() == 0 ? + "" : " " + rank.getCurrency() ); stringValue = stringValue.replace("{rankPrice}", PlaceholdersUtil.formattedKmbtSISize( - rankPrice, formatDecimal, "") + - (rank.getCurrency() == null || - "default".equalsIgnoreCase( rank.getCurrency()) || - rank.getCurrency().trim().length() == 0 ? - "" : " " + rank.getCurrency() ) + rankPrice, formatDecimal, "") + currency ); + stringValue = stringValue.replace("{rankName}", rank.getName()); stringValue = stringValue.replace("{rankTag}", SpigotPrison.format(rank.getTag())); stringValue = stringValue.replace("{rankMultiplier}", mFmt.format( rankMultiplier )); 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 4620ddbe6..86daf355e 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 @@ -24,15 +24,11 @@ import tech.mcprison.prison.Prison; import tech.mcprison.prison.PrisonAPI; import tech.mcprison.prison.integration.EconomyCurrencyIntegration; -import tech.mcprison.prison.modules.Module; -import tech.mcprison.prison.modules.ModuleManager; -import tech.mcprison.prison.output.LogLevel; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.data.PlayerRank; import tech.mcprison.prison.ranks.data.Rank; import tech.mcprison.prison.ranks.data.RankPlayer; -import tech.mcprison.prison.ranks.data.RankPlayerFactory; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.backpacks.BackpacksUtil; import tech.mcprison.prison.spigot.block.SpigotItemStack; @@ -49,7 +45,8 @@ public class SellAllUtil { private static SellAllUtil instance; - private static final boolean isEnabled = getBoolean(SpigotPrison.getInstance().getConfig().getString("sellall")); + private static final boolean isEnabled = Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ); +// private static final boolean isEnabled = getBoolean(SpigotPrison.getInstance().getConfig().getString("sellall")); private final Compatibility compat = SpigotPrison.getInstance().getCompatibility(); private final ItemStack lapisLazuli = compat.getLapisItemStack(); public Configuration sellAllConfig; @@ -1513,18 +1510,23 @@ public boolean setDelay(int delay){ } /** - * 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. + *

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.
  • * - * Return True if success, False if error or nothing changed or Player not meeting requirements. + *
* - * Default usage of this method: sellAllSell(p, false, false, true, true, false, true); + *

Default usage of this method: + *

+ *
sellAllSell(p, false, false, true, true, false, true);
* * @param p - Player. * @param isUsingSign - boolean. @@ -1534,9 +1536,15 @@ public boolean setDelay(int delay){ * @param notifyPlayerEarningDelay - boolean. * @param playSoundOnSellAll - boolean. * - * @return boolean. + * @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 ){ if (!isUsingSign && isSellAllSignEnabled && isSellAllBySignOnlyEnabled && !p.hasPermission(permissionBypassSign)){ if (!completelySilent) { Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_sign_only)); @@ -1560,6 +1568,11 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile double money = getSellMoney(p); if (money != 0){ + + if ( amounts != null ) { + + amounts.add( money ); + } SpigotPlayer sPlayer = new SpigotPlayer(p); RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName()); @@ -1630,7 +1643,9 @@ public double sellAllSell(Player p, SpigotItemStack itemStack, SpigotPlayer sPlayer = new SpigotPlayer(p); RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName()); - if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) sellAllCurrency = null; + if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) { + sellAllCurrency = null; + } rankPlayer.addBalance(sellAllCurrency, money); From c2ccb68ddf82622306247c5e7958bbc18c406dfd Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 19:43:01 -0500 Subject: [PATCH 091/297] Commit some SellAllUtil comments that are useful for debugging timing issues. These are now disabled, but can be manually reenabled when needed. --- docs/changelog_v3.3.x.md | 8 +++++ .../prison/spigot/sellall/SellAllUtil.java | 35 ++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 44d738fad..77878a32f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,14 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-15 +* **Commit some SellAllUtil comments that are useful for debugging timing issues.** +These are now disabled, but can be manually reenabled when needed. + + +* **Some changes to Sellall to provide more flexibility and to fix some potential bugs** +The isEnabled now uses the proper boolean settings to indicate if the sellall utility is enabled or not. Before it was trying to treat strings as boolean. + + * **Add prison command descriptions that goes along with the placeholders.** They are not yet hooked up, but they will provide more information to the admins on what the placeholders will provide, and also how they can use them since some of these will include examples of the formats. 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 86daf355e..694fe6e95 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 @@ -274,6 +274,7 @@ public double getPlayerMultiplier(Player p){ return 1; } +// long tPoint1 = System.nanoTime(); // // Get Ranks module. // ModuleManager modMan = Prison.get().getModuleManager(); @@ -294,6 +295,7 @@ public double getPlayerMultiplier(Player p){ } } +// long tPoint2 = System.nanoTime(); // Get multiplier depending on Player + Prestige. NOTE that prestige multiplier will replace // the actual default multiplier. @@ -336,6 +338,13 @@ public double getPlayerMultiplier(Player p){ multiplier += multiplierExtraByPerms; +// long tPoint3 = System.nanoTime(); +// DecimalFormat dFmt = new DecimalFormat( "0.0000" ); +// String debugMsg = "{sellallMult::" + dFmt.format( multiplier ) + ":t1=" + +// dFmt.format( (tPoint2 - tPoint1)/1000000d ) + +// ":t2=" + dFmt.format( (tPoint3 - tPoint2)/1000000 ) + "}"; +// Output.get().logDebug( debugMsg ); + return multiplier; } @@ -1636,18 +1645,29 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile public double sellAllSell(Player p, SpigotItemStack itemStack, boolean completelySilent, boolean notifyPlayerEarned, boolean notifyPlayerEarningDelay){ +// long tPoint1 = System.nanoTime(); +// long tPoint2 = tPoint1; +// long tPoint3 = tPoint1; +// long tPoint4 = tPoint1; +// long tPoint5 = tPoint1; + double money = getSellMoney(p, itemStack); + +// tPoint2 = System.nanoTime(); if (money != 0) { SpigotPlayer sPlayer = new SpigotPlayer(p); RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName()); +// tPoint3 = System.nanoTime(); + if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) { sellAllCurrency = null; } rankPlayer.addBalance(sellAllCurrency, money); +// tPoint4 = System.nanoTime(); if (!completelySilent) { @@ -1672,7 +1692,20 @@ else if (notifyPlayerEarned){ } } - } + +// tPoint5 = System.nanoTime(); + } + + +// DecimalFormat dFmt = new DecimalFormat( "0.0000" ); +// String debugMsg = "{sellAllSell::" + dFmt.format( money ) + +// ":t1=" + dFmt.format( (tPoint2 - tPoint1)/1000000d ) + +// ":t2=" + dFmt.format( (tPoint3 - tPoint2)/1000000d ) + +// ":t3=" + dFmt.format( (tPoint4 - tPoint3)/1000000d ) + +// ":t4=" + dFmt.format( (tPoint5 - tPoint4)/1000000d ) + +// "}"; +// Output.get().logDebug( debugMsg ); + return money; } From 3243bfa9deb400ee6a4157cbc3625394096ae9f6 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 15 Feb 2022 19:52:16 -0500 Subject: [PATCH 092/297] Potential bug fix in better managing if sellall should be enabled by directly checking the configuration parameter that enables it. Better logging of sellall when inventory is full. --- docs/changelog_v3.3.x.md | 4 + .../autofeatures/AutoManagerFeatures.java | 90 +++++++++++++------ 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 77878a32f..2d133e781 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-15 +* **Potential bug fix in better managing if sellall should be enabled by directly checking the configuration parameter that enables it.** +Better logging of sellall when inventory is full. + + * **Commit some SellAllUtil comments that are useful for debugging timing issues.** These are now disabled, but can be manually reenabled when needed. 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 032610ce8..4bbd8fb25 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 @@ -23,6 +23,7 @@ import com.cryptomorin.xseries.XMaterial; +import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.cache.PlayerCache; import tech.mcprison.prison.internal.block.PrisonBlock; @@ -506,7 +507,8 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, // Try to autosell if enabled: - if ( (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || + if ( Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) && + (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || pmEvent.isForceAutoSell() || !player.isOp() && player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) && SellAllUtil.get() != null ) { @@ -543,7 +545,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, // it will have an amount of more than 0. if ( itemStack.getAmount() > 0 ) { - if ( Output.get().isDebug() && SellAllUtil.get() != null ) { + if ( Output.get().isDebug() && Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) ) { // Just get the calculated value for the drops... do not sell: double amount = SellAllUtil.get().sellAllSell( player, itemStack, true, false, false ); @@ -575,7 +577,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, // extras.clear(); // } - dropExtra( extras, player ); + dropExtra( extras, player, debugInfo ); // dropExtra( player.getInventory().addItem(itemStack), player, block ); } @@ -934,28 +936,59 @@ protected boolean checkLore( SpigotItemStack itemInHand, String loreValue ) { * @param player * @param block */ - protected void dropExtra( HashMap extra, Player player ) { + protected void dropExtra( HashMap extra, Player player, StringBuilder debugInfo ) { if ( extra != null && extra.size() > 0 && SpigotPrison.getInstance().isSellAllEnabled()) { - SellAllUtil sellAllUtil = SellAllUtil.get(); - - - // 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 && ( - sellAllUtil.isAutoSellEnabled || - isBoolean(AutoFeatures.isAutoSellIfInventoryIsFull) )) { + if ( Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) ) { - if ( !sellAllUtil.isAutoSellPerUserToggleable || - sellAllUtil.isAutoSellPerUserToggleable && sellAllUtil.isPlayerAutoSellEnabled(player) ) { - - boolean saNote = sellAllUtil.isAutoSellNotificationEnabled; - SellAllUtil.get().sellAllSell(player, false, !saNote, saNote, saNote, false, true); - } - + SellAllUtil sellAllUtil = SellAllUtil.get(); + // 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 && ( + sellAllUtil.isAutoSellEnabled || + isBoolean(AutoFeatures.isAutoSellIfInventoryIsFull) )) { + + + if ( !sellAllUtil.isAutoSellPerUserToggleable || + sellAllUtil.isAutoSellPerUserToggleable && sellAllUtil.isPlayerAutoSellEnabled(player) ) { + + boolean saNote = sellAllUtil.isAutoSellNotificationEnabled; + + List amounts = new ArrayList<>(); + + final long nanoStart = System.nanoTime(); + SellAllUtil.get().sellAllSell(player, false, !saNote, saNote, saNote, false, true, amounts ); + final long nanoStop = System.nanoTime(); + long nanoTime = nanoStop - nanoStart; + + double amount = 0; + for ( Double amt : amounts ) { + amount += amt; + } + + if ( amount > 0d ) { + + DecimalFormat fFmt = new DecimalFormat("#,##0.0000"); + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); + + debugInfo.append( "[dropExtra sellall: value: " + dFmt.format( amount ) ); + + if ( nanoTime > 0 ) { + final double autoSellTimeMs = ( nanoTime / 1000000.0d ); + debugInfo.append( " sellallTiming: " ) + .append( fFmt.format( autoSellTimeMs ) ) + .append( " ms" ); + } + + debugInfo.append( " ] " ); + } + + } + + // if (sellAllUtil.isAutoSellPerUserToggleable) { // if (sellAllUtil.isPlayerAutoSellEnabled(player)) { // if (sellAllUtil.isAutoSellNotificationEnabled) { @@ -971,17 +1004,19 @@ protected void dropExtra( HashMap extra, Player player // SellAllUtil.get().sellAllSell(player, false, true, false, false, false, true); // } // } - - // Now that something might have been sold, try to add all the extra inventory items back to the - // player's inventory so it is not lost then pass the moreExtras along to be handled as the - // configurations require. - HashMap moreExtras = new HashMap<>(); - for (SpigotItemStack itemStack : extra.values()) { - moreExtras.putAll(SpigotUtil.addItemToPlayerInventory(player, itemStack)); + + // Now that something might have been sold, try to add all the extra inventory items back to the + // player's inventory so it is not lost then pass the moreExtras along to be handled as the + // configurations require. + HashMap moreExtras = new HashMap<>(); + for (SpigotItemStack itemStack : extra.values()) { + moreExtras.putAll(SpigotUtil.addItemToPlayerInventory(player, itemStack)); + } + extra = moreExtras; } - extra = moreExtras; } + // drop the player's items if they should be dropped. Also check to see if // the player should be notified. Ignore zero count itemStacks. @@ -1011,6 +1046,7 @@ protected void dropExtra( HashMap extra, Player player } } + } // private boolean isBoolean( Configuration sellAllConfig, String config ) { From 2364ea4feb48bd3eb7897126fc1a6fa281dcff52 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 16 Feb 2022 01:05:45 -0500 Subject: [PATCH 093/297] New feature: debug count down timer. Able to now set a debug count down timer where debugging is turned off after logging that number of entries. --- docs/changelog_v3.3.x.md | 6 +- .../tech/mcprison/prison/PrisonCommand.java | 8 ++- .../tech/mcprison/prison/output/Output.java | 58 ++++++++++++++++++- .../prison/tasks/PrisonCommandTasks.java | 2 +- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 2d133e781..bda38d55a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8 2022-02-15 +# 3.3.0-alpha.8 2022-02-16 + + +* **New feature: debug count down timer.** +Able to now set a debug count down timer where debugging is turned off after logging that number of entries. * **Potential bug fix in better managing if sellall should be enabled by directly checking the configuration parameter that enables it.** 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 522ec88d9..a01816423 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -1019,14 +1019,16 @@ public void autoFeaturesInformation(CommandSender sender) { public void toggleDebug(CommandSender sender, @Wildcard(join=true) @Arg(name = "targets", def = " ", - description = "Optional. Enable or disable a debugging target. " + - "[on, off, targets, selective, jarScan, " + + description = "Optional. Enable or disable a debugging target, or set a count down timer. " + + "[on, off, targets, (count-down-timer), selective, jarScan, " + "testPlayerUtil, testLocale, rankup ] " + "Use 'targets' to list all available targets. Use 'on' or 'off' to toggle " + "on and off individual targets, or 'all' targets if no target is specified. " + "If any targets are enabled, then debug in general will be enabled. Selective will only " + "activate debug with the specified targets. " + - "jarScan will identify what Java version compiled the class files within the listed jars" + "A positive integer value will enable the count down timer mode to enable " + + "debug mode for a number of loggings, then debug mode will be turned off. " + + "jarScan will identify what Java version compiled the class files within the listed jars." ) String targets ) { if ( targets != null && "jarScan".equalsIgnoreCase( targets ) ) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/output/Output.java b/prison-core/src/main/java/tech/mcprison/prison/output/Output.java index 165f711f1..c1c06f954 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/output/Output.java +++ b/prison-core/src/main/java/tech/mcprison/prison/output/Output.java @@ -58,6 +58,8 @@ public class Output private boolean debug = false; private Set activeDebugTargets; private Set selectiveDebugTargets; + + private int debugCountDown = -1; public enum DebugTarget { all, @@ -310,6 +312,10 @@ public void logError(String message, Throwable... throwable) { public void logDebug(String message, Object... args) { if ( isDebug() ) { + if ( debugCountDown != -1 && debugCountDown-- == 1 ) { + setDebugCountDown( -1 ); + setDebug( false ); + } log(message, LogLevel.DEBUG, args); } } @@ -317,7 +323,10 @@ public void logDebug(String message, Object... args) { public void logDebug( DebugTarget debugTarget, String message, Object... args) { if ( isDebug( debugTarget ) ) { - + if ( debugCountDown != -1 && debugCountDown-- == 1 ) { + setDebugCountDown( -1 ); + setDebug( false ); + } log(message, LogLevel.DEBUG, args); // logDebug(message, args ); } @@ -343,6 +352,42 @@ public String getDebugTargetsString() { public void applyDebugTargets( String targets ) { + // targets really cannot be null since it defaults to " "... + if ( targets != null ) { + + // Check to see if its and integer: + + try + { + int countDownNumber = Integer.parseInt( targets.trim() ); + + // Is a number, so use it as a countdown timer: + if ( countDownNumber > 1 ) { + + setDebugCountDown( countDownNumber ); + setDebug( true ); + + log( "Prison Debugger Enabled: Count down usage set to %d", LogLevel.DEBUG, countDownNumber ); + return; + } + else { + // Number was zero or negative, so turn off debug mode and disable + // countdown timer by setting to -1 + setDebugCountDown( -1 ); + setDebug( false ); + + log( "Prison Debugger Disabled: Count down timer is disabled: %d", LogLevel.DEBUG, countDownNumber ); + return; + } + } + catch ( Exception e ) + { + // Not a number... so ignore: + } + + } + + boolean isSelective = targets.contains( "selective" ); TreeSet trgts = DebugTarget.fromMultiString( targets ); @@ -363,6 +408,11 @@ public void applyDebugTargets( String targets ) { // Clear all existing targets: getActiveDebugTargets().clear(); + + // Turn off the countdown timer if it was set (not -1): + if ( !isDebug() && getDebugCountDown() != -1 ) { + setDebugCountDown( -1 ); + } } } @@ -443,6 +493,12 @@ public void setDebug( boolean debug ) { this.debug = debug; } + public int getDebugCountDown() { + return debugCountDown; + } + public void setDebugCountDown( int debugCountDown ) { + this.debugCountDown = debugCountDown; + } public Set getActiveDebugTargets() { return activeDebugTargets; diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java index 0854780ca..8706a810d 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java @@ -70,7 +70,7 @@ else if ( Output.get().isDebug() && cmTasksPosition > 0 ) { // Done running all tasks. If debug is enabled, print: String message = String.format( "Prison Command Debug Details: %d", cmTasksPosition ); - Output.get().logInfo( message ); + Output.get().logDebug( message ); for ( PrisonCommandTaskData cmdTask : cmdTasks ) { From e1c37c3a5c6ea26a02d33b0615e7577be8ddb43d Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 16 Feb 2022 01:07:04 -0500 Subject: [PATCH 094/297] Fixed a reversal of some calculations when converting nano seconds to milliseconds. --- docs/changelog_v3.3.x.md | 3 +++ .../tech/mcprison/prison/tasks/PrisonCommandTaskData.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index bda38d55a..c989de123 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-16 +* **Fixed a reversal of some calculations when converting nano seconds to milliseconds.** + + * **New feature: debug count down timer.** Able to now set a debug count down timer where debugging is turned off after logging that number of entries. diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java index 2ac5e4295..eba6dca18 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java +++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTaskData.java @@ -309,14 +309,14 @@ public String getDebugDetails() { } nanoTotal += elapsedNano; - double elapsedMs = 1000000.0d / elapsedNano; + double elapsedMs = elapsedNano / 1000000.0d; sb.append( dFmt.format( elapsedMs ) ); } sb.insert( 0, "[" ); sb.append( "]" ); - double totalNano = 1000000.0 / nanoTotal; + double totalNano = nanoTotal / 1000000.0; String message = null; From 1032428aaf1d871762f309bb305dc92ba9546b9a Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 16 Feb 2022 02:08:30 -0500 Subject: [PATCH 095/297] Clean up the way the command tasks were being called. Added mine name to the blockEvent logging. --- docs/changelog_v3.3.x.md | 4 ++++ .../mcprison/prison/mines/data/MineReset.java | 17 ++++++++--------- .../prison/mines/data/MineScheduler.java | 4 ++-- .../utils/tasks/PrisonUtilsTaskTypes.java | 3 ++- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c989de123..8777be8ff 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8 2022-02-16 +* **Clean up the way the command tasks were being called.** +Added mine name to the blockEvent logging. + + * **Fixed a reversal of some calculations when converting nano seconds to milliseconds.** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index d8b96bb43..380dba4b7 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -257,9 +257,9 @@ private void resetSynchonouslyInternal() { if ( command.startsWith( "before: " )) { String cmd = command.replace( "before: ", "" ); + String debugInfo = "MineReset sync: " + getName() + " Before:"; PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( - "MineReset sync: " + getName() + " Before:", cmd ); - cmdTask.setCommandRow( row ); + debugInfo, cmd, row ); cmdTasks.add( cmdTask ); // PrisonCommandTasks.submitTasks( cmdTask ); @@ -303,10 +303,9 @@ private void resetSynchonouslyInternal() { if ( command.startsWith( "after: " )) { String cmd = command.replace( "after: ", "" ); - + String debugInfo = "MineReset sync: " + getName() + " After:"; PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( - "MineReset sync: " + getName() + " After:", cmd ); - cmdTask.setCommandRow( row ); + debugInfo, cmd, row ); cmdTasks.add( cmdTask ); } @@ -870,9 +869,9 @@ public void asynchronouslyResetSetup() { if ( command.startsWith( "before: " )) { String cmd = command.replace( "before: ", "" ); + String debugInfo = "MineReset: " + getName() + " Before:"; PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( - "MineReset: " + getName() + " Before:", cmd ); - cmdTask.setCommandRow( row ); + debugInfo, cmd, row ); cmdTasks.add( cmdTask ); // PrisonCommandTasks.submitTasks( cmdTask ); @@ -919,9 +918,9 @@ public void asynchronouslyResetFinalize( List jobResetActions if ( command.startsWith( "after: " )) { String cmd = command.replace( "after: ", "" ); + String debugInfo = "MineReset: " + getName() + " After:"; PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( - "MineReset: " + getName() + " After:", cmd ); - cmdTask.setCommandRow( row ); + debugInfo, cmd, row ); cmdTasks.add( cmdTask ); } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java index ed742d400..a207ca126 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java @@ -615,9 +615,9 @@ private void processBlockEventDetails( Player player, PrisonBlock prisonBlock, PrisonBlockStatusData originalBlock = targetBlock.getPrisonBlock(); - PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( "BlockEvent", blockEvent.getCommand() ); + String debugInfo = "BlockEvent: " + getName(); + PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( debugInfo, blockEvent.getCommand(), row ); cmdTask.setTaskMode( blockEvent.getTaskMode() ); - cmdTask.setCommandRow( row ); cmdTask.addCustomPlaceholder( CustomPlaceholders.blockName, originalBlock.getBlockName() ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java index 096e1b1f3..1c751f5a6 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/tasks/PrisonUtilsTaskTypes.java @@ -132,7 +132,8 @@ public UtilTaskType getTaskType() { @Override public void run() { - PrisonCommandTaskData pCmd = new PrisonCommandTaskData( "PrisonUtilsTaskTypRunCommand", getCommand(), 1 ); + PrisonCommandTaskData pCmd = new PrisonCommandTaskData( + "PrisonUtilsTaskTypRunCommand", getCommand(), 1 ); PrisonCommandTasks.submitTasks( pCmd ); // pCmd.submitCommandTask( getPlayer() ); From bccf1ded2cae4d92f149233bf2822a0ae6e147da Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 16 Feb 2022 15:04:39 -0500 Subject: [PATCH 096/297] v3.3.0-apha.8b --- 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 8777be8ff..11219cd15 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8 2022-02-16 +# 3.3.0-alpha.8b 2022-02-16 + + +* **v3.3.0-alpha.8b** * **Clean up the way the command tasks were being called.** diff --git a/gradle.properties b/gradle.properties index 0fb5fff22..fee24407e 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.8 +version=3.3.0-alpha.8b #version=3.3.0-alpha.7 From aae3f8d33ad806dc748ee13c159b43540429f351 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 16 Feb 2022 15:09:08 -0500 Subject: [PATCH 097/297] Added logging for when a delayed world comes online and list all mines that are activated. --- docs/changelog_v3.3.x.md | 3 +++ .../mcprison/prison/mines/managers/MineManager.java | 10 ++++++++++ .../tech/mcprison/prison/spigot/SpigotListener.java | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 11219cd15..0cf1d64ed 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8b 2022-02-16 +* **Added logging for when a delayed world comes online and list all mines that are activated.** + + * **v3.3.0-alpha.8b** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java index acec1c970..bf9f1fc32 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java @@ -648,6 +648,11 @@ public void assignAvailableWorld( String worldName ) { World world = worldOptional.get(); + + StringBuilder sb = new StringBuilder(); + sb.append( "Enabling world: " ).append( worldName ).append( " Mines: " ); + + // Store this mine and the world in MineManager's unavailableWorld for later // processing and hooking up to the world object. List unenabledMines = getUnavailableWorlds().get( worldName ); @@ -656,6 +661,9 @@ public void assignAvailableWorld( String worldName ) { for ( Mine mine : unenabledMines ) { if ( !mine.isEnabled() ) { + + sb.append( mine.getName() ).append( " " ); + mine.setWorld( world ); // Make sure world is hooked up properly to all locations. @@ -685,6 +693,8 @@ public void assignAvailableWorld( String worldName ) { // getUnavailableWorlds().remove( worldName ); // } + Output.get().logInfo( sb.toString() ); + // Since the world is loaded and all available mines have been hooked up // with the world, so remove these entries. unenabledMines.clear(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java index e4a320454..5478ae0f2 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java @@ -205,6 +205,12 @@ public void onBlockBreak(BlockBreakEvent e) { */ @EventHandler public void onWorldLoadEvent( WorldLoadEvent e ) { + + if ( Output.get().isDebug() ) { + String message = String.format( + "Prison WorldLoadEvent: world: %s", e.getWorld().getName() ); + Output.get().logDebug( message ); + } PrisonWorldLoadEvent pwlEvent = new PrisonWorldLoadEvent(e.getWorld().getName()); Prison.get().getEventBus().post(pwlEvent); From a570d33e90b307d499ea51c86e63a3f77b9d87b9 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 16 Feb 2022 15:11:32 -0500 Subject: [PATCH 098/297] Fixed a potential error if targetBlocks are not loaded yet, or loaded at all for a given mine. Was causing NPEs.... --- docs/changelog_v3.3.x.md | 4 ++ .../events/PrisonDebugBlockInspector.java | 53 +++++++++++-------- .../spigot/block/OnBlockBreakMines.java | 10 +++- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0cf1d64ed..c70c457af 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8b 2022-02-16 +* **Fixed a potential error if targetBlocks are not loaded yet, or loaded at all for a given mine.** +Was causing NPEs.... + + * **Added logging for when a delayed world comes online and list all mines that are activated.** 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 36a3df7fb..b7a71c75d 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 @@ -81,7 +81,7 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) { targetBlock = mine.getTargetPrisonBlock( sBlock ); - if ( obbMines.isBlockAMatch( targetBlock.getPrisonBlock(), sBlock ) ) { + if ( targetBlock != null && obbMines.isBlockAMatch( targetBlock.getPrisonBlock(), sBlock ) ) { // Match ... PrisonBlockType and blockName was updated in isBlockAMatch(): } @@ -101,27 +101,36 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) { // Get the mine's targetBlock: // MineTargetPrisonBlock tBlock = mine.getTargetPrisonBlock( sBlock ); - - String message = String.format( "&3TargetBlock: &7%s " + - "&3Mined: %s%b &3Broke: &7%b", - targetBlock.getPrisonBlock().getBlockName(), - (targetBlock.isMined() ? "&d" : "&2"), - targetBlock.isMined(), - targetBlock.isAirBroke() - ); - - player.sendMessage( message ); - - String message2 = String.format( " &3Counted: &7%b &3Edge: &7%b " + - "&3Exploded: %s%b &3IgnorAllEvents: &7%b", - targetBlock.isCounted(), - targetBlock.isEdge(), - (targetBlock.isExploded() ? "&d" : "&2"), - targetBlock.isExploded(), - targetBlock.isIgnoreAllBlockEvents() - ); - - player.sendMessage( message2 ); + if ( targetBlock == null ) { + player.sendMessage( "Notice: Unable to get a mine's targetBlock. This could imply " + + "that the mine was not reset since the server started up, or that the air-block " + + "check was not ran yet. Use `/mine reset " + mine.getName() + "' to reset the " + + "target blocks." ); + } + else { + + String message = String.format( "&3TargetBlock: &7%s " + + "&3Mined: %s%b &3Broke: &7%b", + targetBlock.getPrisonBlock().getBlockName(), + (targetBlock.isMined() ? "&d" : "&2"), + targetBlock.isMined(), + targetBlock.isAirBroke() + ); + + player.sendMessage( message ); + + String message2 = String.format( " &3Counted: &7%b &3Edge: &7%b " + + "&3Exploded: %s%b &3IgnorAllEvents: &7%b", + targetBlock.isCounted(), + targetBlock.isEdge(), + (targetBlock.isExploded() ? "&d" : "&2"), + targetBlock.isExploded(), + targetBlock.isIgnoreAllBlockEvents() + ); + + player.sendMessage( message2 ); + + } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java index 5719e06bf..944abdb30 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java @@ -240,11 +240,19 @@ public void checkZeroBlockReset( Mine mine ) { } + /** + *

Checks only if the names match. Does not check locations within any worlds. + *

+ * @param pbTargetBlock + * @param pbBlockHit + * @return + */ public boolean isBlockAMatch( PrisonBlockStatusData pbTargetBlock, PrisonBlock pbBlockHit ) { boolean results = false; if ( pbTargetBlock != null && pbBlockHit != null ) { + if ( pbTargetBlock.getBlockType() == PrisonBlockType.CustomItems ) { // The pbBlockHit will never match the pbTargetBlock.. must check the actual block: @@ -269,7 +277,7 @@ public boolean isBlockAMatch( PrisonBlockStatusData pbTargetBlock, PrisonBlock p } } - else if ( pbTargetBlock != null && pbBlockHit != null ) { + else { results = pbTargetBlock.equals( pbBlockHit ); } From adab0732b90031e1644ace352d09e5cbdbb6ffa7 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 16 Feb 2022 20:32:51 -0500 Subject: [PATCH 099/297] Fixed a start up issue with multiverse-core in that it now runs the air-count processes so the mines can have their targetBlocks defined. Many issues were resulting from failure to get the target blocks. Not sure how it was working before, other than targetBlocks were not being used as much as they are now. --- docs/changelog_v3.3.x.md | 4 ++ .../prison/mines/managers/MineManager.java | 42 ++++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c70c457af..76265a82d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8b 2022-02-16 +* **Fixed a start up issue with multiverse-core in that it now runs the air-count processes so the mines can have their targetBlocks defined.** +Many issues were resulting from failure to get the target blocks. Not sure how it was working before, other than targetBlocks were not being used as much as they are now. + + * **Fixed a potential error if targetBlocks are not loaded yet, or loaded at all for a given mine.** Was causing NPEs.... diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java index bf9f1fc32..856f62f50 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java @@ -660,23 +660,31 @@ public void assignAvailableWorld( String worldName ) { // List remove = new ArrayList<>(); for ( Mine mine : unenabledMines ) { + if ( !mine.isEnabled() ) { - sb.append( mine.getName() ).append( " " ); - - mine.setWorld( world ); - - // Make sure world is hooked up properly to all locations. - // Since world is an object, it may already be auto hooked: - - - if ( mine.getBounds() != null ) { - mine.getBounds().setWorld( world ); - } - - - if ( mine.getSpawn() != null ) { - mine.getSpawn().setWorld( world ); + if ( !mine.isVirtual() ) { + + sb.append( mine.getName() ).append( " " ); + + mine.setWorld( world ); + + // Make sure world is hooked up properly to all locations. + // Since world is an object, it may already be auto hooked: + + + if ( mine.getBounds() != null ) { + mine.getBounds().setWorld( world ); + } + + + if ( mine.getSpawn() != null ) { + mine.getSpawn().setWorld( world ); + } + + // Run the air-counts now that mine can be activated: + mine.refreshBlockBreakCountUponStartup(); + } } @@ -701,6 +709,8 @@ public void assignAvailableWorld( String worldName ) { getUnavailableWorlds().remove( worldName ); } } + + getUnavailableWorldsListings(); } public List getUnavailableWorldsListings() { @@ -721,7 +731,7 @@ public List getUnavailableWorldsListings() { } } results.add( - String.format( "&7 world: &3%s &7(&c%s &7of &c%s &7mines enabled) ", + String.format( "&7 world: &3%s &7(&c%s mines enabled out &7of &c%s &7mines in the world) ", worldName, Integer.toString( enabledCount ), Integer.toString( mines.size() ))); } From e57e892bc1def727d2e2b392849a98c20d254489 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 17 Feb 2022 01:23:02 -0500 Subject: [PATCH 100/297] v3.3.0-alpha.8c --- 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 76265a82d..3d31e5c5d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8b 2022-02-16 +# 3.3.0-alpha.8c 2022-02-16 + + +* **v3.3.0-alpha.8c 2022-02-16** * **Fixed a start up issue with multiverse-core in that it now runs the air-count processes so the mines can have their targetBlocks defined.** diff --git a/gradle.properties b/gradle.properties index fee24407e..9dc7af863 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.8b +version=3.3.0-alpha.8c #version=3.3.0-alpha.7 From 9714f96f1fe5cc99969bd73cf7aa555f87724eef Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 18 Feb 2022 07:42:32 -0500 Subject: [PATCH 101/297] Slight adjustment to addBalance so as to help reduce out of synch possibilities. --- docs/changelog_v3.3.x.md | 6 +++++- .../java/tech/mcprison/prison/ranks/data/RankPlayer.java | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 3d31e5c5d..12f8b6838 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8c 2022-02-16 +# 3.3.0-alpha.8c 2022-02-18 + + +* **Slight adjustment to addBalance so as to help reduce out of synch possibilities.** +The access to economy hooks, has been moved in to the sychronized block. * **v3.3.0-alpha.8c 2022-02-16** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index 6a61f0903..a5b7b567e 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -956,10 +956,12 @@ public void addBalance( double amount ) { synchronized ( unsavedBalanceLock ) { tempBalance = unsavedBalance; + + addBalanceEconomy( tempBalance ); + unsavedBalance = 0; ubTaskId = 0; } - addBalanceEconomy( tempBalance ); }, DELAY_THREE_SECONDS ); } } From 27c1bdd6301418888ef6884f01eed3fc045f990f Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 18 Feb 2022 07:47:53 -0500 Subject: [PATCH 102/297] Added validation check to make sure the player's balance was decreased, or increased, successfully before actually applying the rank change. If the balance does not reflect the change, then the rank change will be prevented. --- docs/changelog_v3.3.x.md | 4 +++ .../tech/mcprison/prison/ranks/RankUtil.java | 33 +++++++++++++++---- .../prison/ranks/commands/RankUpCommand.java | 7 ++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 12f8b6838..943deca7f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8c 2022-02-18 +* **Added validation check to make sure the player's balance was decreased, or increased, successfully before actually applying the rank change.** +If the balance does not reflect the change, then the rank change will be prevented. + + * **Slight adjustment to addBalance so as to help reduce out of synch possibilities.** The access to economy hooks, has been moved in to the sychronized block. diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java index 570e7abee..e42ce4e41 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java @@ -75,6 +75,8 @@ public enum RankupStatus { RANKUP_FAILURE_CURRENCY_IS_NOT_SUPPORTED, RANKUP_FAILURE_NO_PLAYERRANK, + RANKUP_FAILURE_ECONOMY_FAILED, + RANKUP_EVENT_CANCELED, RANKUP_LOWEST, @@ -138,6 +140,8 @@ public enum RankupTransactions { player_balance_final, zero_cost_to_player, + economy_failed_to_update_player_balance, + attempting_to_delete_ladder_from_player, cannot_delete_default_ladder, ladder_was_removed_from_player, @@ -489,22 +493,29 @@ private void rankupPlayerInternal(RankupResults results, } results.addTransaction( RankupTransactions.player_balance_initial ); - results.setBalanceInitial( rankPlayer.getBalance( targetRank.getCurrency() ) ); + double balanceInitial = rankPlayer.getBalance( targetRank.getCurrency() ); + double balanceTargetFinal = balanceInitial; + + results.setBalanceInitial( balanceInitial ); results.setCurrency( targetRank.getCurrency() ); if ( pForceCharge == PromoteForceCharge.charge_player) { - if ( rankPlayer.getBalance(targetRank.getCurrency()) < nextRankCost ) { + if ( balanceInitial < nextRankCost ) { results.addTransaction( RankupStatus.RANKUP_CANT_AFFORD, RankupTransactions.player_cannot_afford ); return; } + balanceTargetFinal -= nextRankCost; + results.addTransaction( RankupTransactions.player_balance_decreased ); rankPlayer.removeBalance( targetRank.getCurrency(), nextRankCost ); - } else - if ( pForceCharge == PromoteForceCharge.refund_player) { + } + else if ( pForceCharge == PromoteForceCharge.refund_player) { - results.addTransaction( RankupTransactions.player_balance_increased); + balanceTargetFinal += nextRankCost; + + results.addTransaction( RankupTransactions.player_balance_increased); if ( results.getOriginalRank() != null ) { rankPlayer.addBalance( results.getOriginalRank().getCurrency(), currentRankCost ); } @@ -512,8 +523,18 @@ private void rankupPlayerInternal(RankupResults results, // Should never hit this code!! } + double balanceFinal = rankPlayer.getBalance( targetRank.getCurrency() ); + + // Check to ensure the player's balance is correct.. + if ( balanceFinal != balanceTargetFinal ) { + + results.addTransaction( RankupStatus.RANKUP_FAILURE_ECONOMY_FAILED, + RankupTransactions.economy_failed_to_update_player_balance ); + return; + } + results.addTransaction( RankupTransactions.player_balance_final ); - results.setBalanceFinal( rankPlayer.getBalance( targetRank.getCurrency() ) ); + results.setBalanceFinal( balanceFinal ); } else { 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 f0f21b8fc..44d7f6b04 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 @@ -711,6 +711,13 @@ public void processResults( CommandSender sender, String playerName, break; + case RANKUP_FAILURE_ECONOMY_FAILED: + // TODO externalize message + sender.sendMessage( "Failed to adjust player's balance. Could be an issue with vault or " + + "a cache timing issue. Try again." ); + + break; + case RANKUP_LADDER_REMOVED: ranksRankupFailureLadderRemovedMsg( sender, ladder ); From a524e8dd845fd23482abe4c28dd9d6d71fd8a317 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 19 Feb 2022 12:34:48 -0500 Subject: [PATCH 103/297] Mine bombs: Added a {countdown} placeholder for use with the MineBomb's tagName field. A few other adjustments such as adding more "color" to the default bomb tagNames. --- docs/changelog_v3.3.x.md | 6 +++- .../tech/mcprison/prison/bombs/MineBombs.java | 15 +++++++-- .../utils/PrisonUtilsMineBombsTasks.java | 31 +++++++++++++++++-- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 943deca7f..c5bb58883 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8c 2022-02-18 +# 3.3.0-alpha.8c 2022-02-19 + + +* **Mine bombs: Added a {countdown} placeholder for use with the MineBomb's tagName field.** +A few other adjustments such as adding more "color" to the default bomb tagNames. * **Added validation check to make sure the player's balance was decreased, or increased, successfully before actually applying the rank change.** 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 8cbf61ccb..49a0d26aa 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 @@ -320,6 +320,9 @@ public void setupDefaultMineBombData() { MineBombData mbd = new MineBombData( "SmallBomb", "brewing_stand", ExplosionShape.sphere.name(), 2, "Small Mine Bomb" ); + + mbd.setNameTag( "&6&kABC&r&c-= &7{name}&c =-&6&kCBA" ); + mbd.setToolInHandName( "DIAMOND_PICKAXE" ); mbd.setToolInHandFortuneLevel( 0 ); mbd.setDescription("A small mine bomb made with some chemicals and a brewing stand."); @@ -335,7 +338,7 @@ public void setupDefaultMineBombData() mbd.getVisualEffects().add( mbeExplode10.clone() ); mbd.getVisualEffects().add( mbeExplode06.clone() ); - mbd.setCooldownTicks( 60 ); + mbd.setCooldownTicks( 10 ); getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); @@ -346,6 +349,9 @@ public void setupDefaultMineBombData() "MediumBomb", "firework_rocket", ExplosionShape.sphere.name(), 5, "Medium Mine Bomb" ); mbd.setDescription("A medium mine bomb made from leftover fireworks, " + "but supercharged with a strange green glowing liquid."); + + mbd.setNameTag( "&6&k1 23 456&r&a-=- &7{name}&a -=-&6&k654 32 1" ); + mbd.setToolInHandName( "DIAMOND_PICKAXE" ); mbd.setToolInHandFortuneLevel( 3 ); @@ -392,8 +398,11 @@ public void setupDefaultMineBombData() { MineBombData mbd = new MineBombData( - "OofBomb", "tnt_minecart", ExplosionShape.sphereHollow.name(), 19, "Oof Mine Bomb" ); + "OofBomb", "tnt_minecart", ExplosionShape.sphereHollow.name(), 21, "Oof Mine Bomb" ); mbd.setRadiusInner( 3 ); + + mbd.setNameTag( "&c&k1&6&k23&e&k456&r&a-=- &4{countdown} &5-=- &7{name} &5-=- &4{countdown} &a-=-&e&k654&6&k32&c&k1" ); + mbd.setDescription("An oof-ably large mine bomb made with a minecart heaping with TNT. " + "Unlike the large mine bomb, this one obviously is built with alien technology."); @@ -438,7 +447,7 @@ public void setupDefaultMineBombData() mbd.setAutosell( true ); mbd.setCooldownTicks( 60 ); - mbd.setFuseDelayTicks( 3 * 20 ); // 3 seconds + mbd.setFuseDelayTicks( 13 * 20 ); // 13 seconds getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java index 0d9072da6..1d0ee5ddd 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java @@ -1,5 +1,6 @@ package tech.mcprison.prison.spigot.utils; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -466,12 +467,16 @@ public class PlacedMineBombItemTask private double twoPI; private ArmorStand armorStand; + private boolean isDyanmicTag = false; + private String tagName; // long ageTicks = 0L; long terminateOnZeroTicks = 0L; private BukkitTask bukkitTask; + private DecimalFormat dFmt; + public PlacedMineBombItemTask( MineBombData bomb, SpigotBlock sBombBlock, SpigotItemStack item ) { super(); @@ -480,10 +485,16 @@ public PlacedMineBombItemTask( MineBombData bomb, this.sBlock = sBombBlock; this.item = item; + this.twoPI = Math.PI * 2; // this.ageTicks = 0; this.terminateOnZeroTicks = getTaskLifeSpan(); + + this.isDyanmicTag = bomb.getNameTag().contains( "{countdown}" ); + this.tagName = ""; + + this.dFmt = new DecimalFormat( "0.0" ); initializeArmorStand(); } @@ -539,8 +550,10 @@ private void initializeArmorStand() { if ( tagName.contains( "{name}" ) ) { tagName = tagName.replace( "{name}", bomb.getName() ); } - tagName = Text.convertToAmpColorCodes( tagName ); - armorStand.setCustomName( tagName ); + this.tagName = Text.convertToAmpColorCodes( tagName ); + + //updateArmorStandCustomName(); + armorStand.setCustomName( this.tagName ); armorStand.setCustomNameVisible(true); } else { @@ -562,6 +575,18 @@ private void initializeArmorStand() { } } + private void updateArmorStandCustomName() + { + if ( isDyanmicTag ) { + + double countdown = (terminateOnZeroTicks / 20.0d); + String tagName = this.tagName.replace( "{countdown}", dFmt.format( countdown) ); + + armorStand.setCustomName( tagName ); + } + } + + @Override public void run() { @@ -597,6 +622,8 @@ public void run() this.cancel(); } + updateArmorStandCustomName(); + } public BukkitTask getBukkitTask() { From 9c9b98a3e74219a58ee8d17e30c25250c78ec24f Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 19 Feb 2022 12:36:13 -0500 Subject: [PATCH 104/297] Add equals and hashCode to the MineTargetBlockKey so it can be better used in structures like HashMaps. --- docs/changelog_v3.3.x.md | 3 ++ .../internal/block/MineTargetBlockKey.java | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c5bb58883..325d950c2 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8c 2022-02-19 +* **Add equals and hashCode to the MineTargetBlockKey so it can be better used in structures like HashMaps.** + + * **Mine bombs: Added a {countdown} placeholder for use with the MineBomb's tagName field.** A few other adjustments such as adding more "color" to the default bomb tagNames. diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/MineTargetBlockKey.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/MineTargetBlockKey.java index 0b51b0e2c..a1ba58713 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/MineTargetBlockKey.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/MineTargetBlockKey.java @@ -82,4 +82,33 @@ public int compareTo( MineTargetBlockKey key ) { return result; } + + @Override + public boolean equals( Object obj ) { + boolean results = false; + + if ( obj != null && obj instanceof MineTargetBlockKey ) { + MineTargetBlockKey mtbKey = (MineTargetBlockKey) obj; + + results = compareTo( mtbKey ) == 0; + } + return results; + } + + @Override + public int hashCode() + { + int hash = getWorld().getName().hashCode(); + + hash += x * 13 + y * 37 + z * 17; + + // TODO Auto-generated method stub +// return super.hashCode(); + + return hash; + } + + + + } From 5cd2e7e76544b974df18eff8985de690d85c3eab Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 19 Feb 2022 12:39:29 -0500 Subject: [PATCH 105/297] Address a rare condition where the mineTargetPrisonBlocks is being "accessed" before the system is done initializing the mine. This creates an empty collection, but it will prevent errors in the long run. --- docs/changelog_v3.3.x.md | 4 ++++ .../java/tech/mcprison/prison/mines/data/MineReset.java | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 325d950c2..48abb4964 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8c 2022-02-19 +* **Address a rare condition where the mineTargetPrisonBlocks is being "accessed" before the system is done initializing the mine.** +This creates an empty collection, but it will prevent errors in the long run. + + * **Add equals and hashCode to the MineTargetBlockKey so it can be better used in structures like HashMaps.** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index 380dba4b7..2af6c0420 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -2,6 +2,7 @@ import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Optional; import java.util.Random; @@ -29,9 +30,9 @@ import tech.mcprison.prison.mines.tasks.MineTeleportTask; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.tasks.PrisonCommandTaskData; +import tech.mcprison.prison.tasks.PrisonCommandTasks; import tech.mcprison.prison.tasks.PrisonRunnable; import tech.mcprison.prison.tasks.PrisonTaskSubmitter; -import tech.mcprison.prison.tasks.PrisonCommandTasks; import tech.mcprison.prison.util.Bounds; import tech.mcprison.prison.util.Bounds.Edges; import tech.mcprison.prison.util.Location; @@ -133,7 +134,10 @@ public abstract class MineReset public MineReset() { super(); - this.mineTargetPrisonBlocks = new ArrayList<>(); + int mineSize = getBounds() != null ? + getBounds().getTotalBlockCount() : 2000; + + this.mineTargetPrisonBlocks = new ArrayList<>( mineSize ); this.mineTargetPrisonBlocksMap = new TreeMap<>(); this.statsMineSweeperTaskMs = new ArrayList<>(); From 004787ba96a253be9da6b97284cd709cb7b6afd5 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 19 Feb 2022 12:41:54 -0500 Subject: [PATCH 106/297] To prevent NPEs, isBlockAMatch has been changed to use the MineTargetPrisonBlock as a parameter and then internally, checking for nulls, it will extract the status data block. This was causing errors when processes were trying to access target blocks before they had a chance to initialize. --- docs/changelog_v3.3.x.md | 4 ++ .../events/PrisonDebugBlockInspector.java | 7 +-- .../spigot/block/OnBlockBreakEventCore.java | 4 +- .../spigot/block/OnBlockBreakMines.java | 49 ++++++++++--------- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 48abb4964..defa26c55 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8c 2022-02-19 +* **To prevent NPEs, isBlockAMatch has been changed to use the MineTargetPrisonBlock as a parameter and then internally, checking for nulls, it will extract the status data block.** +This was causing errors when processes were trying to access target blocks before they had a chance to initialize. + + * **Address a rare condition where the mineTargetPrisonBlocks is being "accessed" before the system is done initializing the mine.** This creates an empty collection, but it will prevent errors in the long run. 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 b7a71c75d..b6fa4f288 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 @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.UUID; import org.bukkit.event.EventException; import org.bukkit.event.block.BlockBreakEvent; @@ -12,12 +11,8 @@ import com.google.common.eventbus.Subscribe; import tech.mcprison.prison.Prison; -import tech.mcprison.prison.PrisonAPI; -import tech.mcprison.prison.integration.CustomBlockIntegration; import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; -import tech.mcprison.prison.internal.block.PrisonBlock; -import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.internal.events.player.PrisonPlayerInteractEvent; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.output.Output; @@ -81,7 +76,7 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) { targetBlock = mine.getTargetPrisonBlock( sBlock ); - if ( targetBlock != null && obbMines.isBlockAMatch( targetBlock.getPrisonBlock(), sBlock ) ) { + if ( targetBlock != null && obbMines.isBlockAMatch( targetBlock, sBlock ) ) { // Match ... PrisonBlockType and blockName was updated in isBlockAMatch(): } 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 55617d6ab..4c48095a3 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 @@ -635,7 +635,7 @@ private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder MineTargetPrisonBlock targetBlock = mine.getTargetPrisonBlock( sBlockHit ); pmEvent.setTargetBlock( targetBlock ); - boolean matchedBlocks = isBlockAMatch( targetBlock.getPrisonBlock(), sBlockHit ); + boolean matchedBlocks = isBlockAMatch( targetBlock, sBlockHit ); // If ignore all block events has been set on this target block, then shutdown. // Same if this block was already included in an explosion... prevent it from spawning @@ -790,7 +790,7 @@ else if ( sBlockMined.isEmpty() ) { // Get the mine's targetBlock: MineTargetPrisonBlock targetExplodedBlock = mine.getTargetPrisonBlock( sBlockMined ); - boolean matchedExplodedBlocks = isBlockAMatch( targetExplodedBlock.getPrisonBlock(), sBlockMined ); + boolean matchedExplodedBlocks = isBlockAMatch( targetExplodedBlock, sBlockMined ); if ( targetExplodedBlock == null || targetExplodedBlock.getPrisonBlock() == null ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java index 944abdb30..b5bf98c7d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java @@ -247,39 +247,42 @@ public void checkZeroBlockReset( Mine mine ) { * @param pbBlockHit * @return */ - public boolean isBlockAMatch( PrisonBlockStatusData pbTargetBlock, PrisonBlock pbBlockHit ) + public boolean isBlockAMatch( MineTargetPrisonBlock targetBlock, PrisonBlock pbBlockHit ) { boolean results = false; - - if ( pbTargetBlock != null && pbBlockHit != null ) { + if ( targetBlock != null ) { + PrisonBlockStatusData pbTargetBlock = targetBlock.getPrisonBlock(); - if ( pbTargetBlock.getBlockType() == PrisonBlockType.CustomItems ) { - // The pbBlockHit will never match the pbTargetBlock.. must check the actual block: - - List cbIntegrations = - PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); + if ( pbTargetBlock != null && pbBlockHit != null ) { - for ( CustomBlockIntegration customBlock : cbIntegrations ) - { - String cbId = customBlock.getCustomBlockId( pbBlockHit ); + if ( pbTargetBlock.getBlockType() == PrisonBlockType.CustomItems ) { + // The pbBlockHit will never match the pbTargetBlock.. must check the actual block: + + List cbIntegrations = + PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); - if ( cbId != null ) { + for ( CustomBlockIntegration customBlock : cbIntegrations ) + { + String cbId = customBlock.getCustomBlockId( pbBlockHit ); - if ( pbTargetBlock.getBlockName().equalsIgnoreCase( cbId ) ) { + if ( cbId != null ) { - pbBlockHit.setBlockType( customBlock.getBlockType() ); - pbBlockHit.setBlockName( cbId ); - - results = true; - break; + if ( pbTargetBlock.getBlockName().equalsIgnoreCase( cbId ) ) { + + pbBlockHit.setBlockType( customBlock.getBlockType() ); + pbBlockHit.setBlockName( cbId ); + + results = true; + break; + } } } + + } + else { + + results = pbTargetBlock.equals( pbBlockHit ); } - - } - else { - - results = pbTargetBlock.equals( pbBlockHit ); } } From fd5b28d6de973e02fc8dfcac439b207951c1b313 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:06:21 -0500 Subject: [PATCH 107/297] Fixed issues with vault economy and withdrawling from a player's balance. It now also reports any errors that may be returned. --- docs/changelog_v3.3.x.md | 4 ++ .../integration/EconomyIntegration.java | 6 +-- .../prison/ranks/data/RankPlayer.java | 50 ++++++++++++++----- .../spigot/economies/EssentialsEconomy.java | 11 ++-- .../prison/spigot/economies/GemsEconomy.java | 9 ++-- .../prison/spigot/economies/SaneEconomy.java | 11 ++-- .../prison/spigot/economies/VaultEconomy.java | 18 ++++--- .../spigot/economies/VaultEconomyWrapper.java | 49 ++++++++++++++++-- 8 files changed, 118 insertions(+), 40 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index defa26c55..ec6288990 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8c 2022-02-19 +- **Fixed issues with vault economy and withdrawing from a player's balance.** +It now also reports any errors that may be returned. + + * **To prevent NPEs, isBlockAMatch has been changed to use the MineTargetPrisonBlock as a parameter and then internally, checking for nulls, it will extract the status data block.** This was causing errors when processes were trying to access target blocks before they had a chance to initialize. diff --git a/prison-core/src/main/java/tech/mcprison/prison/integration/EconomyIntegration.java b/prison-core/src/main/java/tech/mcprison/prison/integration/EconomyIntegration.java index acfa60304..1cd42d4fb 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/integration/EconomyIntegration.java +++ b/prison-core/src/main/java/tech/mcprison/prison/integration/EconomyIntegration.java @@ -31,7 +31,7 @@ public EconomyIntegration( String keyName, String providerName ) { * @param player The {@link Player}. * @param amount The amount. */ - public abstract void setBalance(Player player, double amount); + public abstract boolean setBalance(Player player, double amount); /** * Adds to the player's current balance. @@ -39,7 +39,7 @@ public EconomyIntegration( String keyName, String providerName ) { * @param player The {@link Player}. * @param amount The amount. */ - public abstract void addBalance(Player player, double amount); + public abstract boolean addBalance(Player player, double amount); /** * Removes from the player's current balance. @@ -47,7 +47,7 @@ public EconomyIntegration( String keyName, String providerName ) { * @param player The {@link Player}. * @param amount The amount. */ - public abstract void removeBalance(Player player, double amount); + public abstract boolean removeBalance(Player player, double amount); /** * Returns whether or not the player can afford a transaction. diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index a5b7b567e..4fa09b360 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -931,7 +931,13 @@ public double getBalance() { if ( economy != null ) { - results = economy.getBalance( this ) + getBalanceUnsaved(); + results = economy.getBalance( this ); + + synchronized ( unsavedBalanceLock ) + { + results += getBalanceUnsaved(); + } + setCachedRankPlayerBalance( null, results ); } @@ -969,31 +975,49 @@ public void addBalance( double amount ) { } - private void addBalanceEconomy( double amount ) { + private boolean addBalanceEconomy( double amount ) { + boolean results = false; + EconomyIntegration economy = getEconomy(); if ( economy != null ) { - economy.addBalance( this, amount ); + results = economy.addBalance( this, amount ); addCachedRankPlayerBalance( null, amount ); } + return results; } public void removeBalance( double amount ) { - EconomyIntegration economy = getEconomy(); - if ( economy != null ) { - economy.removeBalance( this, amount ); - addCachedRankPlayerBalance( null, -1 * amount ); - } + double targetAmount = -1 * amount; + addBalance( targetAmount ); + addCachedRankPlayerBalance( null, targetAmount ); + +// EconomyIntegration economy = getEconomy(); +// +// if ( economy != null ) { +// economy.removeBalance( this, amount ); +// addCachedRankPlayerBalance( null, -1 * amount ); +// } } public void setBalance( double amount ) { - EconomyIntegration economy = getEconomy(); - if ( economy != null ) { - economy.setBalance( this, amount ); - setCachedRankPlayerBalance( null, amount ); - } + // First subtract current balance: + double targetAmount = -1 * getBalance(); + + // add current amount which will result in the correct "ajustment": + targetAmount += amount; + + addBalance( targetAmount ); + addCachedRankPlayerBalance( null, targetAmount ); + +// EconomyIntegration economy = getEconomy(); +// +// if ( economy != null ) { +// economy.setBalance( this, amount ); +// setCachedRankPlayerBalance( null, amount ); +// } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/EssentialsEconomy.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/EssentialsEconomy.java index 484f421f9..520e4d63c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/EssentialsEconomy.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/EssentialsEconomy.java @@ -105,18 +105,19 @@ public double getBalance(Player player) { } @Override - public void setBalance(Player player, double amount) { + public boolean setBalance(Player player, double amount) { wrapper.setBalance(player, amount); + return true; } @Override - public void addBalance(Player player, double amount) { - setBalance(player, getBalance(player) + amount); + public boolean addBalance(Player player, double amount) { + return setBalance(player, getBalance(player) + amount); } @Override - public void removeBalance(Player player, double amount) { - setBalance(player, getBalance(player) - amount); + public boolean removeBalance(Player player, double amount) { + return setBalance(player, getBalance(player) - amount); } @Override diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/GemsEconomy.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/GemsEconomy.java index 819e85693..955894774 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/GemsEconomy.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/GemsEconomy.java @@ -68,7 +68,7 @@ public double getBalance(Player player, String currencyName) { } @Override - public void setBalance(Player player, double amount) { + public boolean setBalance(Player player, double amount) { if ( wrapper != null ) { double remainder = amount - getBalance(player); if ( remainder > 0 ) { @@ -77,6 +77,7 @@ public void setBalance(Player player, double amount) { wrapper.withdraw( player, amount ); } } + return true; } @Override @@ -92,10 +93,11 @@ public void setBalance(Player player, double amount, String currencyName) { } @Override - public void addBalance(Player player, double amount) { + public boolean addBalance(Player player, double amount) { if ( wrapper != null ) { wrapper.addBalance(player, amount); } + return true; } @Override @@ -106,10 +108,11 @@ public void addBalance(Player player, double amount, String currencyName) { } @Override - public void removeBalance(Player player, double amount) { + public boolean removeBalance(Player player, double amount) { if ( wrapper != null ) { wrapper.withdraw(player, amount); } + return true; } @Override diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/SaneEconomy.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/SaneEconomy.java index 66040d397..dc50b3c77 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/SaneEconomy.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/SaneEconomy.java @@ -42,18 +42,19 @@ public double getBalance(Player player) { } @Override - public void setBalance(Player player, double amount) { + public boolean setBalance(Player player, double amount) { econWrapper.setBalance(player, amount); + return true; } @Override - public void addBalance(Player player, double amount) { - setBalance(player, getBalance(player) + amount); + public boolean addBalance(Player player, double amount) { + return setBalance(player, getBalance(player) + amount); } @Override - public void removeBalance(Player player, double amount) { - setBalance(player, getBalance(player) - amount); + public boolean removeBalance(Player player, double amount) { + return setBalance(player, getBalance(player) - amount); } @Override diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomy.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomy.java index 319b7256d..9217bbfdb 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomy.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomy.java @@ -62,24 +62,30 @@ public double getBalance(Player player) { } @Override - public void setBalance(Player player, double amount) { + public boolean setBalance(Player player, double amount) { + boolean results = false; if (hasIntegrated()) { - econWrapper.setBalance( player, amount ); + results = econWrapper.setBalance( player, amount ); } + return results; } @Override - public void addBalance(Player player, double amount) { + public boolean addBalance(Player player, double amount) { + boolean results = false; if (hasIntegrated()) { - econWrapper.addBalance( player, amount ); + results = econWrapper.addBalance( player, amount ); } + return results; } @Override - public void removeBalance(Player player, double amount) { + public boolean removeBalance(Player player, double amount) { + boolean results = false; if (hasIntegrated()) { - econWrapper.removeBalance( player, amount ); + results = econWrapper.removeBalance( player, amount ); } + return results; } @Override diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomyWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomyWrapper.java index 697d6fd40..0007104c1 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomyWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomyWrapper.java @@ -1,9 +1,12 @@ package tech.mcprison.prison.spigot.economies; +import java.text.DecimalFormat; + import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.plugin.RegisteredServiceProvider; +import net.milkbowl.vault.economy.EconomyResponse; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotUtil; @@ -164,7 +167,11 @@ public boolean setBalance(Player player, double amount) { @SuppressWarnings( "deprecation" ) public boolean addBalance(Player player, double amount) { boolean results = false; - if (economy != null) { + + if ( amount < 0 ) { + results = removeBalance( player, amount ); + } + else if (economy != null) { if ( isPreV1_4() ) { economy.depositPlayer( player.getName(), amount ); results = true; @@ -177,8 +184,21 @@ public boolean addBalance(Player player, double amount) { player.getName(), Double.toString( amount )); } else { - economy.depositPlayer( oPlayer, amount ); - results = true; + EconomyResponse response = economy.depositPlayer( oPlayer, amount ); + + results = response.transactionSuccess(); + + if ( !results ) { + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); + String message = String.format( + "VaultEconomy.addBalance failed: %s amount: %s " + + "balance: %s error: %s", + oPlayer.getName(), + dFmt.format(amount), dFmt.format(response.balance), + response.errorMessage ); + Output.get().logError( message ); + } +// results = true; } } // if ( economy.hasBankSupport() ) { @@ -193,6 +213,12 @@ public boolean addBalance(Player player, double amount) { @SuppressWarnings( "deprecation" ) public boolean removeBalance(Player player, double amount) { boolean results = false; + + // Needs to be a positive amount: + if ( amount < 0 ) { + amount *= -1; + } + if (economy != null) { if ( isPreV1_4() ) { economy.withdrawPlayer( player.getName(), amount ); @@ -206,8 +232,21 @@ public boolean removeBalance(Player player, double amount) { player.getName(), Double.toString( amount )); } else { - economy.withdrawPlayer( oPlayer, amount ); - results = true; + EconomyResponse response = economy.withdrawPlayer( oPlayer, amount ); + + results = response.transactionSuccess(); + + if ( !results ) { + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); + String message = String.format( + "VaultEconomy.removeBalance failed: %s amount: %s " + + "balance: %s error: %s", + oPlayer.getName(), + dFmt.format(amount), dFmt.format(response.balance), + response.errorMessage ); + Output.get().logError( message ); + } +// results = true; } } From ce088044598612e8b3447ea4bdcd9a2e29384919 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 20 Feb 2022 02:39:03 -0500 Subject: [PATCH 108/297] Release v3.3.0-alpha.8d --- 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 ec6288990..1f8a428db 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8c 2022-02-19 +# 3.3.0-alpha.8d 2022-02-20 + + +* **Release v3.3.0-alpha.8d 2022-02-20** - **Fixed issues with vault economy and withdrawing from a player's balance.** diff --git a/gradle.properties b/gradle.properties index 9dc7af863..a285c6201 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.8c +version=3.3.0-alpha.8d #version=3.3.0-alpha.7 From 16c7fac6168de853e03adb35b8224cf4bb1ade10 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 20 Feb 2022 02:43:47 -0500 Subject: [PATCH 109/297] Made many changes to the default configurations of the autoFeatures. This is to try to make it easier to use prison by using more of the settigs that are most useful --- docs/changelog_v3.3.x.md | 5 +++ .../autofeatures/AutoFeaturesFileConfig.java | 33 +++++++++++++++--- .../tech/mcprison/prison/file/YamlFileIO.java | 34 ++++++++++++++++++- .../prison/spigot/SpigotPlatform.java | 7 +++- .../autofeatures/AutoManagerFeatures.java | 3 +- .../prison/spigot/util/SpigotYamlFileIO.java | 5 +-- 6 files changed, 78 insertions(+), 9 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 1f8a428db..5a4a532de 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8d 2022-02-20 +* **Made many changes to the default configurations of the autoFeatures.** +This is to try to make it easier to use prison by using more of the settings that are most useful. +Added more comments to make it easier to understand these settings too. + + * **Release v3.3.0-alpha.8d 2022-02-20** 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 89c58b32c..b4bdb1d8f 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 @@ -66,28 +66,49 @@ public enum AutoFeatures { otherPlugins(options), - isProcessMcMMOBlockBreakEvents(otherPlugins, true), + isProcessMcMMOBlockBreakEvents(otherPlugins, false), isProcessEZBlocksBlockBreakEvents(otherPlugins, false), - isProcessQuestsBlockBreakEvents(otherPlugins, true), + isProcessQuestsBlockBreakEvents(otherPlugins, false), + otherPluginSupport__ReadMe(otherPlugins, + "NOTE: If you are using spigot v1.12.0 or higher, then do not use these " + + "'forced' settings, instead adjust both 'cancelAllBlockBreakEvents' and " + + "'cancelAllBlockEventBlockDrops' since that will help ensure it works better."), blockBreakEvents(options), // Setting this to true will cancel the block break events (normal prison behavior): // Canceling events is mandatory for Spigot v1.8 through v1.11.x. cancelAllBlockBreakEvents(blockBreakEvents, true), + + cancelAllBlockBreakEvents__ReadMe(blockBreakEvents, + "NOTE: If spigot v1.8.0 through 1.11.x you must use 'true' for this setting, " + + "otherwise if using Spigot v1.13.0, or higher, can use 'false'."), + + // Setting this to false will not zero out the block drops (normal prison behavior). // When set to true, it will zero it out so if the block break event is not canceled, // then it will prevent double drops: // Canceling the drops was added in Spigot v1.12.x. cancelAllBlockEventBlockDrops(blockBreakEvents, false), + cancelAllBlockEventBlockDrops__ReadMe(blockBreakEvents, + "NOTE: If spigot v1.8.0 through 1.11.x you must use 'false' for this setting, " + + "otherwise if using Spigot v1.13.0, or higher, can use 'true'. " + + "This setting MUST be the opposit of 'cancelAllBlockBreakEvents'."), + + applyBlockBreaksThroughSyncTask(blockBreakEvents, true), blockBreakEventPriority(blockBreakEvents, "LOW"), + + ProcessPrisons_ExplosiveBlockBreakEventsPriority(blockBreakEvents, "LOW"), + + + TokenEnchantBlockExplodeEventPriority(blockBreakEvents, "DISABLED"), @@ -97,7 +118,6 @@ public enum AutoFeatures { PrisonEnchantsExplosiveEventPriority(blockBreakEvents, "DISABLED"), - ProcessPrisons_ExplosiveBlockBreakEventsPriority(blockBreakEvents, "DISABLED"), blockBreakEvents__ReadMe(blockBreakEvents, @@ -124,8 +144,12 @@ public enum AutoFeatures { isAutoSellPerBlockBreakEnabled(inventory, false), permissionAutoSellPerBlockBreakEnabled(inventory, "prison.automanager.autosell"), + + permissionAutoSellPerBlockBreakEnabled__ReadMe(inventory, + "If OP then you cannot use this permission node since it would always " + + "be enabled. Using a value of 'disable' will turn it off for everyone."), // - isAutoSellPerBlockBreakInlinedEnabled(general, false), +// isAutoSellPerBlockBreakInlinedEnabled(general, false), isAutoSellIfInventoryIsFull(inventory, true), @@ -684,6 +708,7 @@ protected AutoFeaturesFileConfig() { // is handled within the loadYamlAutoFeatures code. YamlFileIO yamlFileIO = Prison.get().getPlatform().getYamlFileIO( getConfigFile() ); + List dne = yamlFileIO.loadYamlAutoFeatures( getConfig() ); dne.size(); diff --git a/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java b/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java index 022d741fc..326d63fa9 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java +++ b/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java @@ -21,10 +21,14 @@ public abstract class YamlFileIO { private File yamlFile; - public YamlFileIO( File yamlFile ) { + private boolean supportsDropsCanceling = false; + + public YamlFileIO( File yamlFile, boolean supportsDropsCanceling ) { super(); this.yamlFile = yamlFile; + + this.supportsDropsCanceling = supportsDropsCanceling; } public boolean saveYamlAutoFeatures( Map config ) { @@ -101,6 +105,8 @@ public List loadYamlAutoFeatures( Map config ) // Load from the actual yaml file: loadYaml(); + boolean isNewConfig = getKeys().size() == 0; + Map yaml = new TreeMap<>(); Set keys = getKeys(); for ( String key : keys ) { @@ -163,6 +169,25 @@ else if ( autoFeat.isStringList() ) { } } + // If the Spigot version is 1.12.0 or greater, then it will support the + // canceling of the bukkit drops, so flip the canceling of the + // block breaks and drops. + // 1.8.0 through 1.11.x : + // cancelAllBlockBreakEvents: true + // cancelAllBlockEventBlockDrops: false + // 1.12.0 and higher : + // cancelAllBlockBreakEvents: false + // cancelAllBlockEventBlockDrops: true + if ( isNewConfig && isSupportsDropsCanceling() ) { + + ValueNode valueFalse = BooleanNode.valueOf( false ); + config.put( AutoFeatures.cancelAllBlockBreakEvents.getKey(), valueFalse ); + + ValueNode valueTrue = BooleanNode.valueOf( true ); + config.put( AutoFeatures.cancelAllBlockEventBlockDrops.getKey(), valueTrue ); + + } + if ( dne.size() > 0 ) { // New configs were found. Saving the configs. saveYamlAutoFeatures( config ); @@ -213,5 +238,12 @@ public File getYamlFile() { abstract protected long getLong( String key ); abstract protected long getLong( String key, long defaultValue ); + + public boolean isSupportsDropsCanceling() { + return supportsDropsCanceling; + } + public void setSupportsDropsCanceling( boolean supportsDropsCanceling ) { + this.supportsDropsCanceling = supportsDropsCanceling; + } } 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 4501b7fb8..acb3773dc 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 @@ -794,7 +794,12 @@ public SpigotPlaceholders getPlaceholders() { @Override public YamlFileIO getYamlFileIO( File yamlFile ) { - return new SpigotYamlFileIO( yamlFile ); + + boolean supportsDropsCanceling = + ( new BluesSpigetSemVerComparator().compareMCVersionTo("1.12.0") >= 0 ); + + + return new SpigotYamlFileIO( yamlFile, supportsDropsCanceling ); } 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 4bbd8fb25..915abf7eb 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 @@ -510,7 +510,8 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, if ( Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) && (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || pmEvent.isForceAutoSell() || - !player.isOp() && player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) && + !player.isOp() && !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) && + player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) && SellAllUtil.get() != null ) { final long nanoStart = System.nanoTime(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java index 3e2a0a034..8cd5528b0 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java @@ -16,8 +16,9 @@ public class SpigotYamlFileIO private YamlConfiguration yamlConfig; - public SpigotYamlFileIO( File yamlFile ) { - super( yamlFile ); + + public SpigotYamlFileIO( File yamlFile, boolean supportsDropsCanceling ) { + super( yamlFile, supportsDropsCanceling ); this.yamlConfig = new YamlConfiguration(); From 90537d9cb8a55b00cf81af9168088d136671b152 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 20 Feb 2022 03:04:35 -0500 Subject: [PATCH 110/297] Getting the collection size was an issue by the time it was done processing the blocks, so getting them first may help prevent errors. --- docs/changelog_v3.3.x.md | 3 +++ .../mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5a4a532de..1a84af61a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8d 2022-02-20 +* **Getting the collection size was an issue by the time it was done processing the blocks, so getting them first may help prevent errors.** + + * **Made many changes to the default configurations of the autoFeatures.** This is to try to make it easier to use prison by using more of the settings that are most useful. Added more comments to make it easier to understand these settings too. diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java index f3261a5c0..1d643126a 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java @@ -162,10 +162,11 @@ public void run() { } List tBlocks = targetBlocks.subList( position, endIndex ); + int size = tBlocks.size(); mine.getWorld().get().setBlocksSynchronously( tBlocks, resetType, getNanos() ); - position += tBlocks.size(); + position += size; } From 5acee5ba249255b175af5aee879b9207adaacdc6 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 20 Feb 2022 21:13:36 -0500 Subject: [PATCH 111/297] Bug Fix: Mine reset changes: Eliminate paged resets, some code that is not being use anymore, disabled the RESET_ASYNC type to be similar to RESET_SYNC since they are now the same, locked out checkZeroBlockResets so mines cannot reset multiple times at the same time using the MineStateMutex. The major issue here was that mines were being reset in the middle of a reset action. Used a preexisting MineStateMutex to secure the checkZeroBlockResets() function to prevent it from kicking off many resets. These multiple resets were happening because many players were triggering the resets... as a side effect, there were many situations of collections failing due to concurrent modification exceptions. --- docs/changelog_v3.3.x.md | 4 + .../prison/internal/block/MineResetType.java | 2 +- .../prison/mines/commands/MinesCommands.java | 116 +-- .../tech/mcprison/prison/mines/data/Mine.java | 6 +- .../mcprison/prison/mines/data/MineData.java | 16 +- .../mcprison/prison/mines/data/MineReset.java | 674 +++++++++--------- .../prison/mines/data/MineScheduler.java | 75 +- .../prison/mines/events/MineResetEvent.java | 16 +- .../mines/tasks/MinePagedResetAsyncTask.java | 12 +- .../prison/mines/data/MineSchedulerTest.java | 4 +- .../spigot/block/OnBlockBreakEventCore.java | 30 +- .../prison/spigot/game/SpigotWorld.java | 6 +- 12 files changed, 500 insertions(+), 461 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 1a84af61a..d304ae31a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8d 2022-02-20 +* **Bug Fix: Mine reset changes: Eliminate paged resets, some code that is not being use anymore, disabled the RESET_ASYNC type to be similar to RESET_SYNC since they are now the same, locked out checkZeroBlockResets so mines cannot reset multiple times at the same time using the MineStateMutex.** +The major issue here was that mines were being reset in the middle of a reset action. Used a preexisting MineStateMutex to secure the checkZeroBlockResets() function to prevent it from kicking off many resets. These multiple resets were happening because many players were triggering the resets... as a side effect, there were many situations of collections failing due to concurrent modification exceptions. + + * **Getting the collection size was an issue by the time it was done processing the blocks, so getting them first may help prevent errors.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/MineResetType.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/MineResetType.java index f300b2470..bb38a8643 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/MineResetType.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/MineResetType.java @@ -3,7 +3,7 @@ public enum MineResetType { normal, - paged, +// paged, clear, tracer; } 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 300ce900b..5f38217f9 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 @@ -1064,22 +1064,22 @@ else if ( !mineAccessByRank && tpAccessByRank ) { row.addTextComponent( "&3Mine Reset Count: &7%s ", dFmt.format(m.getResetCount()) ); - if ( m.isUsePagingOnReset() ) { - row.addTextComponent( " &7-= &5Reset Paging Enabled &7=-" ); - } - else if ( cmdPageData.isShowAll() ) { - row.addTextComponent( " &7-= &3Reset Paging Disabled &7=-" ); - } +// if ( m.isUsePagingOnReset() ) { +// row.addTextComponent( " &7-= &5Reset Paging Enabled &7=-" ); +// } +// else if ( cmdPageData.isShowAll() ) { +// row.addTextComponent( " &7-= &3Reset Paging Disabled &7=-" ); +// } chatDisplay.addComponent( row ); - double resetTimeSeconds = m.getStatsResetTimeMS() / 1000.0; - if ( !m.isUsePagingOnReset() && resetTimeSeconds > 0.5 ) { - String resetTimeSec = PlaceholdersUtil.formattedTime( resetTimeSeconds ); - chatDisplay.addText("&5 Warning: &3Reset time is &7%s&3, which is high. " + - "It is recommened that you try to enable &7/mines set resetPaging help", - resetTimeSec ); - } +// double resetTimeSeconds = m.getStatsResetTimeMS() / 1000.0; +// if ( !m.isUsePagingOnReset() && resetTimeSeconds > 0.5 ) { +// String resetTimeSec = PlaceholdersUtil.formattedTime( resetTimeSeconds ); +// chatDisplay.addText("&5 Warning: &3Reset time is &7%s&3, which is high. " + +// "It is recommened that you try to enable &7/mines set resetPaging help", +// resetTimeSec ); +// } } if ( !m.isVirtual() && resetTime > 0 ) { @@ -1639,11 +1639,11 @@ private BulletedListComponent getMinesLineItemList( PrisonSortableResults sorted } - if ( m.isUsePagingOnReset() ) { - row.addFancy( - new FancyMessage("&5Paged ") - .tooltip("&7Paging Used during Mine Reset")); - } +// if ( m.isUsePagingOnReset() ) { +// row.addFancy( +// new FancyMessage("&5Paged ") +// .tooltip("&7Paging Used during Mine Reset")); +// } @@ -2788,48 +2788,48 @@ else if ( linerPattern == LinerPatterns.remove ) { - @Command(identifier = "mines set resetpaging", permissions = "mines.resetpaging", - description = "Enable paging during a mine reset.") - public void setMineResetPagingCommand(CommandSender sender, - @Arg(name = "mineName", description = "The name of the mine to edit.") String mineName, - @Arg(name = "paging", def="disabled", - description = "Enable or disable paging [disable, enable]") - String paging - ) { - - if (performCheckMineExists(sender, mineName)) { - setLastMineReferenced(mineName); - - PrisonMines pMines = PrisonMines.getInstance(); - Mine m = pMines.getMine(mineName); - -// if ( !m.isEnabled() ) { -// sender.sendMessage( "&cMine is disabled&7. Use &a/mines info &7for possible cause." ); +// @Command(identifier = "mines set resetpaging", permissions = "mines.resetpaging", +// description = "Enable paging during a mine reset.") +// public void setMineResetPagingCommand(CommandSender sender, +// @Arg(name = "mineName", description = "The name of the mine to edit.") String mineName, +// @Arg(name = "paging", def="disabled", +// description = "Enable or disable paging [disable, enable]") +// String paging +// ) { +// +// if (performCheckMineExists(sender, mineName)) { +// setLastMineReferenced(mineName); +// +// PrisonMines pMines = PrisonMines.getInstance(); +// Mine m = pMines.getMine(mineName); +// +//// if ( !m.isEnabled() ) { +//// sender.sendMessage( "&cMine is disabled&7. Use &a/mines info &7for possible cause." ); +//// return; +//// } +// +// if ( paging == null || !"disable".equalsIgnoreCase( paging ) && !"enable".equalsIgnoreCase( paging ) ) { +// sender.sendMessage( "&cInvalid paging option&7. Use &adisable&7 or &aenable&7" ); // return; // } - - if ( paging == null || !"disable".equalsIgnoreCase( paging ) && !"enable".equalsIgnoreCase( paging ) ) { - sender.sendMessage( "&cInvalid paging option&7. Use &adisable&7 or &aenable&7" ); - return; - } - - if ( "disable".equalsIgnoreCase( paging ) && m.isUsePagingOnReset() ) { - m.setUsePagingOnReset( false ); - pMines.getMineManager().saveMine( m ); - sender.sendMessage( String.format( "&7Mine Reset Paging has been disabled for mine %s.", m.getTag()) ); - } - else if ( "enable".equalsIgnoreCase( paging ) && !m.isUsePagingOnReset() ) { - m.setUsePagingOnReset( true ); - pMines.getMineManager().saveMine( m ); - sender.sendMessage( String.format( "&7Mine Reset Paging has been enabled for mine %s.", m.getTag()) ); - } - else { - sender.sendMessage( String.format( "&7Mine Reset Paging status has not changed for mine %s.", m.getTag()) ); - - } - - } - } +// +// if ( "disable".equalsIgnoreCase( paging ) && m.isUsePagingOnReset() ) { +// m.setUsePagingOnReset( false ); +// pMines.getMineManager().saveMine( m ); +// sender.sendMessage( String.format( "&7Mine Reset Paging has been disabled for mine %s.", m.getTag()) ); +// } +// else if ( "enable".equalsIgnoreCase( paging ) && !m.isUsePagingOnReset() ) { +// m.setUsePagingOnReset( true ); +// pMines.getMineManager().saveMine( m ); +// sender.sendMessage( String.format( "&7Mine Reset Paging has been enabled for mine %s.", m.getTag()) ); +// } +// else { +// sender.sendMessage( String.format( "&7Mine Reset Paging status has not changed for mine %s.", m.getTag()) ); +// +// } +// +// } +// } @Command(identifier = "mines set mineSweeper", permissions = "mines.set", diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java index 7e5d4f6a9..9c53a3e5a 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java @@ -538,8 +538,8 @@ else if ( validateBlockNames.contains( prisonBlock.getBlockName() ) ) { setResetCommands( commands == null ? new ArrayList<>() : commands ); - Boolean usePagingOnReset = (Boolean) document.get( "usePagingOnReset" ); - setUsePagingOnReset( usePagingOnReset == null ? false : usePagingOnReset.booleanValue() ); +// Boolean usePagingOnReset = (Boolean) document.get( "usePagingOnReset" ); +// setUsePagingOnReset( usePagingOnReset == null ? false : usePagingOnReset.booleanValue() ); List mineBlockEvents = (List) document.get("mineBlockEvents"); @@ -685,7 +685,7 @@ public Document toDocument() { ret.put("commands", getResetCommands()); - ret.put( "usePagingOnReset", isUsePagingOnReset() ); +// ret.put( "usePagingOnReset", isUsePagingOnReset() ); if ( getRank() != null ) { diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java index 19504fd96..714d29d48 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java @@ -136,7 +136,7 @@ public abstract class MineData private List resetCommands; - private boolean usePagingOnReset = false; +// private boolean usePagingOnReset = false; private ModuleElement rank; /** @@ -232,7 +232,7 @@ public MineData() { this.resetCommands = new ArrayList<>(); - this.usePagingOnReset = false; +// this.usePagingOnReset = false; this.rank = null; this.rankString = null; @@ -1212,12 +1212,12 @@ public void setResetCommands( List resetCommands ) { this.resetCommands = resetCommands; } - public boolean isUsePagingOnReset() { - return usePagingOnReset; - } - public void setUsePagingOnReset( boolean usePagingOnReset ) { - this.usePagingOnReset = usePagingOnReset; - } +// public boolean isUsePagingOnReset() { +// return usePagingOnReset; +// } +// public void setUsePagingOnReset( boolean usePagingOnReset ) { +// this.usePagingOnReset = usePagingOnReset; +// } public ModuleElement getRank() { return rank; diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index 2af6c0420..cca839e69 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -2,7 +2,6 @@ import java.text.DecimalFormat; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Optional; import java.util.Random; @@ -134,10 +133,7 @@ public abstract class MineReset public MineReset() { super(); - int mineSize = getBounds() != null ? - getBounds().getTotalBlockCount() : 2000; - - this.mineTargetPrisonBlocks = new ArrayList<>( mineSize ); + this.mineTargetPrisonBlocks = new ArrayList<>(); this.mineTargetPrisonBlocksMap = new TreeMap<>(); this.statsMineSweeperTaskMs = new ArrayList<>(); @@ -168,178 +164,178 @@ protected void initialize() { } } - /** - *

Optimized the mine reset to focus on itself. Also set the Y plane to refresh at the top and work its - * way down. That way if the play is teleported to the top, it will appear like the whole mine has reset - * instantly and they will not see the delay from the bottom of the mine working up to the top. This will - * also reduce the likelihood of the player falling back in to the mine if there is no spawn set. - *

- * - *

The ONLY code that could be asynchronous ran is the random generation of the blocks. The other - * lines of code is using bukkit and/or spigot api calls which MUST be ran synchronously. - *

- */ - protected void resetSynchonously() { - - if ( isDeleted() ) { - // if the mine is deleted, just return without doing anything. This will - // cancel the job. - return; - } - - long start = System.currentTimeMillis(); - - // The all-important event - MineResetEvent event = new MineResetEvent(this); - Prison.get().getEventBus().post(event); - if (!event.isCanceled()) { - resetSynchonouslyInternal(); - } - - long stop = System.currentTimeMillis(); - setStatsResetTimeMS( stop - start ); - - // Tie to the command stats mode so it logs it if stats are enabled: - if ( PrisonMines.getInstance().getMineManager().isMineStats() ) { - DecimalFormat dFmt = new DecimalFormat("#,##0"); - Output.get().logInfo("&cMine reset: &7" + getTag() + - "&c Blocks: &7" + dFmt.format( getBounds().getTotalBlockCount() ) + - statsMessage() ); - } - - } - - /** - *

This function now follows the general behavior as the async reset in that it now - * uses a target block listing to help ensure the constraints are honored when - * generating the blocks. - *

- * - */ - private void resetSynchonouslyInternal() { - try { - - if ( isVirtual() || isDeleted() ) { - // Mine is virtual and cannot be reset. Just skip this with no error messages. - // If the mine is deleted, just return without doing anything. - return; - } - - if ( !isEnabled() ) { - Output.get().logError( - String.format( "MineReset: Reset failure: Mine is not enabled. " + - "Ensure world exists. mine= %s ", - getName() )); - return; - } - - - teleportAllPlayersOut(); -// setStatsTeleport1TimeMS( -// teleportAllPlayersOut( getBounds().getyBlockMax() ) ); - - - // Reset stats: - resetStats(); - - - generateBlockListAsync(); - - - if ( !getCurrentJob().getResetActions().contains( MineResetActions.NO_COMMANDS )) { - - // Before reset commands: - if ( getResetCommands() != null && getResetCommands().size() > 0 ) { - - List cmdTasks = new ArrayList<>(); - - int row = 0; - for (String command : getResetCommands() ) { - row++; -// String formatted = cmd.replace("{player}", prisonPlayer.getName()) -// .replace("{player_uid}", player.uid.toString()); - if ( command.startsWith( "before: " )) { - String cmd = command.replace( "before: ", "" ); - - String debugInfo = "MineReset sync: " + getName() + " Before:"; - PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( - debugInfo, cmd, row ); - - cmdTasks.add( cmdTask ); -// PrisonCommandTasks.submitTasks( cmdTask ); - //PrisonAPI.dispatchCommand(cmd); - } - } - - PrisonCommandTasks.submitTasks( cmdTasks ); - } - } - - - MinePagedResetAsyncTask resetTask = new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal ); - resetTask.submitTaskAsync(); -// resetAsynchonouslyUpdate( false ); - - - - // If a player falls back in to the mine before it is fully done being reset, - // such as could happen if there is lag or a lot going on within the server, - // this will TP anyone out who would otherwise suffocate. I hope! lol - teleportAllPlayersOut(); -// setStatsTeleport2TimeMS( -// teleportAllPlayersOut( getBounds().getyBlockMax() ) ); - - - incrementResetCount(); - - if ( !getCurrentJob().getResetActions().contains( MineResetActions.NO_COMMANDS )) { - - // After reset commands: - if ( getResetCommands() != null && getResetCommands().size() > 0 ) { - - List cmdTasks = new ArrayList<>(); - - int row = 0; - for (String command : getResetCommands() ) { - row++; -// String formatted = cmd.replace("{player}", prisonPlayer.getName()) -// .replace("{player_uid}", player.uid.toString()); - if ( command.startsWith( "after: " )) { - String cmd = command.replace( "after: ", "" ); - - String debugInfo = "MineReset sync: " + getName() + " After:"; - PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( - debugInfo, cmd, row ); - - cmdTasks.add( cmdTask ); - } - } - - PrisonCommandTasks.submitTasks( cmdTasks ); - } - } - - - // Broadcast message to all players within a certain radius of this mine: - broadcastResetMessageToAllPlayersWithRadius(); -// broadcastResetMessageToAllPlayersWithRadius( MINE_RESET__BROADCAST_RADIUS_BLOCKS ); - - - submitTeleportGlassBlockRemoval(); - - - // If part of a chained_resets, then kick off the next reset: - if ( getCurrentJob().getResetActions().contains( MineResetActions.CHAINED_RESETS )) { - - PrisonMines pMines = PrisonMines.getInstance(); - pMines.resetAllMinesNext(); - } +// /** +// *

Optimized the mine reset to focus on itself. Also set the Y plane to refresh at the top and work its +// * way down. That way if the play is teleported to the top, it will appear like the whole mine has reset +// * instantly and they will not see the delay from the bottom of the mine working up to the top. This will +// * also reduce the likelihood of the player falling back in to the mine if there is no spawn set. +// *

+// * +// *

The ONLY code that could be asynchronous ran is the random generation of the blocks. The other +// * lines of code is using bukkit and/or spigot api calls which MUST be ran synchronously. +// *

+// */ +// protected void resetSynchonously() { +// +// if ( isDeleted() ) { +// // if the mine is deleted, just return without doing anything. This will +// // cancel the job. +// return; +// } +// +// long start = System.currentTimeMillis(); +// +// // The all-important event +// MineResetEvent event = new MineResetEvent(this, resetType); +// Prison.get().getEventBus().post(event); +// if (!event.isCanceled()) { +// resetSynchonouslyInternal(); +// } +// +// long stop = System.currentTimeMillis(); +// setStatsResetTimeMS( stop - start ); +// +// // Tie to the command stats mode so it logs it if stats are enabled: +// if ( PrisonMines.getInstance().getMineManager().isMineStats() ) { +// DecimalFormat dFmt = new DecimalFormat("#,##0"); +// Output.get().logInfo("&cMine reset: &7" + getTag() + +// "&c Blocks: &7" + dFmt.format( getBounds().getTotalBlockCount() ) + +// statsMessage() ); +// } +// +// } - - } catch (Exception e) { - Output.get().logError("&cFailed to reset mine " + getName(), e); - } - } +// /** +// *

This function now follows the general behavior as the async reset in that it now +// * uses a target block listing to help ensure the constraints are honored when +// * generating the blocks. +// *

+// * +// */ +// private void resetSynchonouslyInternal() { +// try { +// +// if ( isVirtual() || isDeleted() ) { +// // Mine is virtual and cannot be reset. Just skip this with no error messages. +// // If the mine is deleted, just return without doing anything. +// return; +// } +// +// if ( !isEnabled() ) { +// Output.get().logError( +// String.format( "MineReset: Reset failure: Mine is not enabled. " + +// "Ensure world exists. mine= %s ", +// getName() )); +// return; +// } +// +// +// teleportAllPlayersOut(); +//// setStatsTeleport1TimeMS( +//// teleportAllPlayersOut( getBounds().getyBlockMax() ) ); +// +// +// // Reset stats: +// resetStats(); +// +// +// generateBlockListAsync(); +// +// +// if ( !getCurrentJob().getResetActions().contains( MineResetActions.NO_COMMANDS )) { +// +// // Before reset commands: +// if ( getResetCommands() != null && getResetCommands().size() > 0 ) { +// +// List cmdTasks = new ArrayList<>(); +// +// int row = 0; +// for (String command : getResetCommands() ) { +// row++; +//// String formatted = cmd.replace("{player}", prisonPlayer.getName()) +//// .replace("{player_uid}", player.uid.toString()); +// if ( command.startsWith( "before: " )) { +// String cmd = command.replace( "before: ", "" ); +// +// String debugInfo = "MineReset sync: " + getName() + " Before:"; +// PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( +// debugInfo, cmd, row ); +// +// cmdTasks.add( cmdTask ); +//// PrisonCommandTasks.submitTasks( cmdTask ); +// //PrisonAPI.dispatchCommand(cmd); +// } +// } +// +// PrisonCommandTasks.submitTasks( cmdTasks ); +// } +// } +// +// +// MinePagedResetAsyncTask resetTask = new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal ); +// resetTask.submitTaskAsync(); +//// resetAsynchonouslyUpdate( false ); +// +// +// +// // If a player falls back in to the mine before it is fully done being reset, +// // such as could happen if there is lag or a lot going on within the server, +// // this will TP anyone out who would otherwise suffocate. I hope! lol +// teleportAllPlayersOut(); +//// setStatsTeleport2TimeMS( +//// teleportAllPlayersOut( getBounds().getyBlockMax() ) ); +// +// +// incrementResetCount(); +// +// if ( !getCurrentJob().getResetActions().contains( MineResetActions.NO_COMMANDS )) { +// +// // After reset commands: +// if ( getResetCommands() != null && getResetCommands().size() > 0 ) { +// +// List cmdTasks = new ArrayList<>(); +// +// int row = 0; +// for (String command : getResetCommands() ) { +// row++; +//// String formatted = cmd.replace("{player}", prisonPlayer.getName()) +//// .replace("{player_uid}", player.uid.toString()); +// if ( command.startsWith( "after: " )) { +// String cmd = command.replace( "after: ", "" ); +// +// String debugInfo = "MineReset sync: " + getName() + " After:"; +// PrisonCommandTaskData cmdTask = new PrisonCommandTaskData( +// debugInfo, cmd, row ); +// +// cmdTasks.add( cmdTask ); +// } +// } +// +// PrisonCommandTasks.submitTasks( cmdTasks ); +// } +// } +// +// +// // Broadcast message to all players within a certain radius of this mine: +// broadcastResetMessageToAllPlayersWithRadius(); +//// broadcastResetMessageToAllPlayersWithRadius( MINE_RESET__BROADCAST_RADIUS_BLOCKS ); +// +// +// submitTeleportGlassBlockRemoval(); +// +// +// // If part of a chained_resets, then kick off the next reset: +// if ( getCurrentJob().getResetActions().contains( MineResetActions.CHAINED_RESETS )) { +// +// PrisonMines pMines = PrisonMines.getInstance(); +// pMines.resetAllMinesNext(); +// } +// +// +// } catch (Exception e) { +// Output.get().logError("&cFailed to reset mine " + getName(), e); +// } +// } public String statsMessage() { @@ -696,159 +692,159 @@ public void generateBlockListAsync() { // // } - /** - * - *

Update 2021-08-25 : This function should only be called once now. The main - * work on performing the actual resets is now performed within the task - * MinePagedResetAsyncTask. This is now to be ran asynchronously. - *

- * - *

Yeah I know, it has async in the name of the function, but it still can only - * be ran synchronously. The async part implies this is the reset "part" for the - * async workflow. - *

- * - *

Before this part is ran, the generateBlockListAsync() function must be ran - * to regenerate the new block list. - *

- * - */ - protected void resetAsynchonously() { - boolean canceled = false; - -// Output.get().logInfo( "MineRest.resetAsynchonously() " + getName() ); - - if ( isVirtual() ) { - canceled = true; - } - - if ( !canceled && getResetPage() == 0 ) { - generateBlockListAsync(); - - canceled = resetAsynchonouslyInitiate(); - } - - if ( !canceled ) { - -// // First time through... reset the block break count and run the before reset commands: -// if ( getResetPosition() == 0 ) { -// -// // Reset the block break count before resetting the blocks: -// // Set it to the original air count, if subtracted from total block count -// // in the mine, then the result will be blocks remaining. -// setBlockBreakCount( getAirCountOriginal() ); -// -// -// if ( !getCurrentJob().getResetActions().contains( MineResetActions.NO_COMMANDS )) { -// -// // Before reset commands: -// if ( getResetCommands() != null && getResetCommands().size() > 0 ) { -// -// for (String command : getResetCommands() ) { -//// String formatted = cmd.replace("{player}", prisonPlayer.getName()) -//// .replace("{player_uid}", player.uid.toString()); -// if ( command.startsWith( "before: " )) { -// String cmd = command.replace( "before: ", "" ); -// -// PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: Before:" ); -// cmdTask.submitCommandTask( cmd ); -// -// // PrisonAPI.dispatchCommand(cmd); -// } -// } -// } -// } -// -// } - - asynchronouslyResetSetup(); - - MinePagedResetAsyncTask resetTask = new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal ); - resetTask.submitTaskAsync(); - - asynchronouslyResetFinalize( null ); - - -// resetAsynchonouslyUpdate( true ); - -// if ( getResetPosition() == getMineTargetPrisonBlocks().size() ) { -// // Done resetting the mine... wrap up: -// -// -// // If a player falls back in to the mine before it is fully done being reset, -// // such as could happen if there is lag or a lot going on within the server, -// // this will TP anyone out who would otherwise suffocate. I hope! lol -// teleportAllPlayersOut(); -//// setStatsTeleport2TimeMS( -//// teleportAllPlayersOut( getBounds().getyBlockMax() ) ); -// -// // Reset the paging for the next reset: -// setResetPage( 0 ); -// -// incrementResetCount(); -// -// if ( !getCurrentJob().getResetActions().contains( MineResetActions.NO_COMMANDS )) { -// -// // After reset commands: -// if ( getResetCommands() != null && getResetCommands().size() > 0 ) { -// -// for (String command : getResetCommands() ) { -//// String formatted = cmd.replace("{player}", prisonPlayer.getName()) -//// .replace("{player_uid}", player.uid.toString()); -// if ( command.startsWith( "after: " )) { -// String cmd = command.replace( "after: ", "" ); -// -// PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: After:" ); -// cmdTask.submitCommandTask( cmd ); +// /** +// * +// *

Update 2021-08-25 : This function should only be called once now. The main +// * work on performing the actual resets is now performed within the task +// * MinePagedResetAsyncTask. This is now to be ran asynchronously. +// *

+// * +// *

Yeah I know, it has async in the name of the function, but it still can only +// * be ran synchronously. The async part implies this is the reset "part" for the +// * async workflow. +// *

+// * +// *

Before this part is ran, the generateBlockListAsync() function must be ran +// * to regenerate the new block list. +// *

+// * +// */ +// protected void resetAsynchonously() { +// boolean canceled = false; +// +//// Output.get().logInfo( "MineRest.resetAsynchonously() " + getName() ); // -// // PrisonAPI.dispatchCommand(cmd); -// } -// } -// } -// } -// -// -// // Broadcast message to all players within a certain radius of this mine: -// broadcastResetMessageToAllPlayersWithRadius(); -//// broadcastResetMessageToAllPlayersWithRadius( MINE_RESET__BROADCAST_RADIUS_BLOCKS ); -// -// -// submitTeleportGlassBlockRemoval(); -// -// -// // Tie to the command stats mode so it logs it if stats are enabled: -// if ( PrisonMines.getInstance().getMineManager().isMineStats() || -// getCurrentJob().getResetActions().contains( MineResetActions.DETAILS ) ) { -// DecimalFormat dFmt = new DecimalFormat("#,##0"); -// Output.get().logInfo("&cMine reset: &7" + getTag() + -// "&c Blocks: &7" + dFmt.format( getBounds().getTotalBlockCount() ) + -// statsMessage() ); -// } -// -// // If part of a chained_resets, then kick off the next reset: -// if ( getCurrentJob().getResetActions().contains( MineResetActions.CHAINED_RESETS )) { -// -// PrisonMines pMines = PrisonMines.getInstance(); -// pMines.resetAllMinesNext(); -// } -// -// -// } - -// NOTE: Only run this ONCE now... MinePagedResetAsyncTask handles the paging now -// else { -// -// // Need to continue to reset the mine. Resubmit it to run again. -// MineResetAsyncResubmitTask mrAsyncRT = new MineResetAsyncResubmitTask( this, null, -// getCurrentJob().getResetActions() ); -// -// // Must run synchronously!! -// submitSyncTask( mrAsyncRT ); -// } - } - - - } +// if ( isVirtual() ) { +// canceled = true; +// } +// +// if ( !canceled && getResetPage() == 0 ) { +// generateBlockListAsync(); +// +// canceled = resetAsynchonouslyInitiate( MineResetType.normal ); +// } +// +// if ( !canceled ) { +// +//// // First time through... reset the block break count and run the before reset commands: +//// if ( getResetPosition() == 0 ) { +//// +//// // Reset the block break count before resetting the blocks: +//// // Set it to the original air count, if subtracted from total block count +//// // in the mine, then the result will be blocks remaining. +//// setBlockBreakCount( getAirCountOriginal() ); +//// +//// +//// if ( !getCurrentJob().getResetActions().contains( MineResetActions.NO_COMMANDS )) { +//// +//// // Before reset commands: +//// if ( getResetCommands() != null && getResetCommands().size() > 0 ) { +//// +//// for (String command : getResetCommands() ) { +////// String formatted = cmd.replace("{player}", prisonPlayer.getName()) +////// .replace("{player_uid}", player.uid.toString()); +//// if ( command.startsWith( "before: " )) { +//// String cmd = command.replace( "before: ", "" ); +//// +//// PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: Before:" ); +//// cmdTask.submitCommandTask( cmd ); +//// +//// // PrisonAPI.dispatchCommand(cmd); +//// } +//// } +//// } +//// } +//// +//// } +// +// asynchronouslyResetSetup(); +// +// MinePagedResetAsyncTask resetTask = new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal ); +// resetTask.submitTaskAsync(); +// +// asynchronouslyResetFinalize( null ); +// +// +//// resetAsynchonouslyUpdate( true ); +// +//// if ( getResetPosition() == getMineTargetPrisonBlocks().size() ) { +//// // Done resetting the mine... wrap up: +//// +//// +//// // If a player falls back in to the mine before it is fully done being reset, +//// // such as could happen if there is lag or a lot going on within the server, +//// // this will TP anyone out who would otherwise suffocate. I hope! lol +//// teleportAllPlayersOut(); +////// setStatsTeleport2TimeMS( +////// teleportAllPlayersOut( getBounds().getyBlockMax() ) ); +//// +//// // Reset the paging for the next reset: +//// setResetPage( 0 ); +//// +//// incrementResetCount(); +//// +//// if ( !getCurrentJob().getResetActions().contains( MineResetActions.NO_COMMANDS )) { +//// +//// // After reset commands: +//// if ( getResetCommands() != null && getResetCommands().size() > 0 ) { +//// +//// for (String command : getResetCommands() ) { +////// String formatted = cmd.replace("{player}", prisonPlayer.getName()) +////// .replace("{player_uid}", player.uid.toString()); +//// if ( command.startsWith( "after: " )) { +//// String cmd = command.replace( "after: ", "" ); +//// +//// PrisonCommandTask cmdTask = new PrisonCommandTask( "MineReset: After:" ); +//// cmdTask.submitCommandTask( cmd ); +//// +//// // PrisonAPI.dispatchCommand(cmd); +//// } +//// } +//// } +//// } +//// +//// +//// // Broadcast message to all players within a certain radius of this mine: +//// broadcastResetMessageToAllPlayersWithRadius(); +////// broadcastResetMessageToAllPlayersWithRadius( MINE_RESET__BROADCAST_RADIUS_BLOCKS ); +//// +//// +//// submitTeleportGlassBlockRemoval(); +//// +//// +//// // Tie to the command stats mode so it logs it if stats are enabled: +//// if ( PrisonMines.getInstance().getMineManager().isMineStats() || +//// getCurrentJob().getResetActions().contains( MineResetActions.DETAILS ) ) { +//// DecimalFormat dFmt = new DecimalFormat("#,##0"); +//// Output.get().logInfo("&cMine reset: &7" + getTag() + +//// "&c Blocks: &7" + dFmt.format( getBounds().getTotalBlockCount() ) + +//// statsMessage() ); +//// } +//// +//// // If part of a chained_resets, then kick off the next reset: +//// if ( getCurrentJob().getResetActions().contains( MineResetActions.CHAINED_RESETS )) { +//// +//// PrisonMines pMines = PrisonMines.getInstance(); +//// pMines.resetAllMinesNext(); +//// } +//// +//// +//// } +// +//// NOTE: Only run this ONCE now... MinePagedResetAsyncTask handles the paging now +//// else { +//// +//// // Need to continue to reset the mine. Resubmit it to run again. +//// MineResetAsyncResubmitTask mrAsyncRT = new MineResetAsyncResubmitTask( this, null, +//// getCurrentJob().getResetActions() ); +//// +//// // Must run synchronously!! +//// submitSyncTask( mrAsyncRT ); +//// } +// } +// +// +// } public void asynchronouslyResetSetup() { @@ -962,7 +958,7 @@ public void asynchronouslyResetFinalize( List jobResetActions } - public boolean resetAsynchonouslyInitiate() { + public boolean resetAsynchonouslyInitiate( MineResetType resetType ) { boolean canceled = false; if ( isVirtual()) { @@ -980,7 +976,7 @@ public boolean resetAsynchonouslyInitiate() { // long start = System.currentTimeMillis(); // The all-important event - MineResetEvent event = new MineResetEvent(this); + MineResetEvent event = new MineResetEvent(this, resetType); Prison.get().getEventBus().post(event); canceled = event.isCanceled(); @@ -1890,18 +1886,32 @@ private void addMineTargetPrisonBlock( PrisonBlockStatusData block, Location tar // } private void clearMineTargetPrisonBlocks() { - getMineTargetPrisonBlocks().clear(); - getMineTargetPrisonBlocksMap().clear(); + + // Instead of clearing the collections, set them to null so that way if + // other reference exist, they will be able to continue to use them + // until the release the references. + + mineTargetPrisonBlocks = null; + mineTargetPrisonBlocksMap = null; + +// getMineTargetPrisonBlocks().clear(); +// getMineTargetPrisonBlocksMap().clear(); } public List getMineTargetPrisonBlocks() { + if ( mineTargetPrisonBlocks == null ) { + mineTargetPrisonBlocks = new ArrayList<>(); + } return mineTargetPrisonBlocks; } public TreeMap getMineTargetPrisonBlocksMap() { + if ( mineTargetPrisonBlocksMap == null ) { + mineTargetPrisonBlocksMap = new TreeMap<>(); + } return mineTargetPrisonBlocksMap; } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java index a207ca126..254a8c272 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java @@ -269,8 +269,9 @@ protected List initializeJobWorkflow( double resetTime, boolean include targetResetTime = 60 * 60 * 4; // one hour * 4 } + // Should always NOW use async reset action for this workflow. // Determine if the sync or async reset action should be used for this workflow. - MineJobAction resetAction = isUsePagingOnReset() ? MineJobAction.RESET_ASYNC : MineJobAction.RESET_SYNC; + MineJobAction resetAction = MineJobAction.RESET_ASYNC; // : MineJobAction.RESET_SYNC; if ( includeMessages ) { // Need to ensure that the reset warning times are sorted in ascending order: @@ -374,13 +375,14 @@ public void run() break; + case RESET_SYNC: case RESET_ASYNC: if ( !skip ) { List resetActions = getCurrentJob().getResetActions(); MinePagedResetAsyncTask resetTask = - new MinePagedResetAsyncTask( (Mine) this, MineResetType.paged, resetActions ); + new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal, resetActions ); resetTask.submitTaskAsync(); // resetAsynchonously(); @@ -390,23 +392,23 @@ public void run() break; - case RESET_SYNC: - // synchronous reset. Will be phased out in the future? - if ( !skip ) { - - List resetActions = getCurrentJob().getResetActions(); - - MinePagedResetAsyncTask resetTask = - new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal, resetActions ); - - resetTask.submitTaskAsync(); - -// resetSynchonously(); - } else { - incrementSkipResetBypassCount(); - } - - break; +// case RESET_SYNC: +// // synchronous reset. Will be phased out in the future? +// if ( !skip ) { +// +// List resetActions = getCurrentJob().getResetActions(); +// +// MinePagedResetAsyncTask resetTask = +// new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal, resetActions ); +// +// resetTask.submitTaskAsync(); +// +//// resetSynchonously(); +// } else { +// incrementSkipResetBypassCount(); +// } +// +// break; default: break; @@ -732,18 +734,22 @@ public boolean checkZeroBlockReset() { // Reset if the mine runs out of blocks: - - if ( !isVirtual() && ( - getRemainingBlockCount() <= 0 && !isZeroBlockResetDisabled() || - getResetThresholdPercent() > 0 && - getRemainingBlockCount() < (getBounds().getTotalBlockCount() * - getResetThresholdPercent() / 100.0d) - )) { + if ( !isVirtual() && getMineStateMutex().isMinable() ) { + + if ( !isVirtual() && ( + getRemainingBlockCount() <= 0 && !isZeroBlockResetDisabled() || + getResetThresholdPercent() > 0 && + getRemainingBlockCount() < (getBounds().getTotalBlockCount() * + getResetThresholdPercent() / 100.0d) + )) { + + // submit a manual reset since the mine is empty: + manualReset( MineResetScheduleType.NORMAL, getZeroBlockResetDelaySec() ); + reset = true; + } - // submit a manual reset since the mine is empty: - manualReset( MineResetScheduleType.NORMAL, getZeroBlockResetDelaySec() ); - reset = true; } + return reset; } @@ -787,11 +793,15 @@ public void manualReset( MineResetScheduleType resetType, List private void manualReset( MineResetScheduleType resetType, double delayActionSec, List resetActions ) { - if ( isVirtual() ) { - // Nope... nothing to reset... + if ( isVirtual() || !getMineStateMutex().isMinable() ) { + // Nope... nothing to reset... or it's locked out alredy with a reset return; } + // Lock the mine's mutex: + getMineStateMutex().setMineStateResetStart(); + + // cancel existing job: if ( getTaskId() != null ) { PrisonTaskSubmitter.cancelTask( getTaskId() ); @@ -800,8 +810,7 @@ private void manualReset( MineResetScheduleType resetType, double delayActionSec // Clear jobStack and set currentJob to run the RESET with zero delay: getJobStack().clear(); - MineJobAction action = isUsePagingOnReset() ? - MineJobAction.RESET_ASYNC : MineJobAction.RESET_SYNC; + MineJobAction action = MineJobAction.RESET_ASYNC; // : MineJobAction.RESET_SYNC; MineJob mineJob = new MineJob( action, delayActionSec, 0, resetType ); mineJob.setResetType( resetType ); diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/events/MineResetEvent.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/events/MineResetEvent.java index 7f248f954..dcaf815fe 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/events/MineResetEvent.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/events/MineResetEvent.java @@ -18,6 +18,7 @@ package tech.mcprison.prison.mines.events; +import tech.mcprison.prison.internal.block.MineResetType; import tech.mcprison.prison.internal.events.Cancelable; import tech.mcprison.prison.mines.data.MineReset; @@ -27,10 +28,13 @@ public class MineResetEvent implements Cancelable { private MineReset mine; + private MineResetType resetType; private boolean canceled = false; // false by default - public MineResetEvent(MineReset mine) { - this.mine = mine; + public MineResetEvent(MineReset mine, MineResetType resetType) { + super(); + this.mine = mine; + this.resetType = resetType; } /** @@ -59,4 +63,12 @@ public boolean isCanceled() { public void setCanceled(boolean canceled) { this.canceled = canceled; } + + public MineResetType getResetType() { + return resetType; + } + public void setResetType( MineResetType resetType ) { + this.resetType = resetType; + } + } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java index 1d643126a..ae105c388 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java @@ -193,16 +193,16 @@ private boolean runSetupCancelReset() { // Set the MineStateMutex to a state of starting a mine reset: mine.getMineStateMutex().setMineStateResetStart(); + mine.generateBlockListAsync(); - if ( resetType == MineResetType.normal || resetType == MineResetType.paged ) { - mine.generateBlockListAsync(); + if ( resetType == MineResetType.normal ) { - // resetAsynchonouslyInitiate() will confirm if the reset should happened - // and will raise Prison's mine reset event. - // A return value of true means cancel the reset: - cancel = mine.resetAsynchonouslyInitiate(); } + // resetAsynchonouslyInitiate() will confirm if the reset should happened + // and will raise Prison's mine reset event. + // A return value of true means cancel the reset: + cancel = mine.resetAsynchonouslyInitiate( resetType ); mine.asynchronouslyResetSetup(); diff --git a/prison-mines/src/test/java/tech/mcprison/prison/mines/data/MineSchedulerTest.java b/prison-mines/src/test/java/tech/mcprison/prison/mines/data/MineSchedulerTest.java index f15d45d7b..935fa78d4 100644 --- a/prison-mines/src/test/java/tech/mcprison/prison/mines/data/MineSchedulerTest.java +++ b/prison-mines/src/test/java/tech/mcprison/prison/mines/data/MineSchedulerTest.java @@ -70,7 +70,7 @@ public void testInitializeJobWorkflow01() assertEquals( 0, jobStack.size() ); - assertTrue( job3.getAction() == MineJobAction.RESET_SYNC ); +// assertTrue( job3.getAction() == MineJobAction.RESET_ASYNC ); assertEquals( 45.0d, job3.getDelayActionSec(), 0.1d ); assertEquals( 0.0d, job3.getResetInSec(), 0.1d ); totalTime += job3.getDelayActionSec(); @@ -112,7 +112,7 @@ public void testInitializeJobWorkflow02() assertEquals( 0L, jobStack.size() ); // Tests that the first job that is popped off the stack is a message and not the reset: - assertTrue( job.getAction() == MineJobAction.RESET_SYNC ); +// assertTrue( job.getAction() == MineJobAction.RESET_SYNC ); assertEquals( resetTime, job.getDelayActionSec(), 0.1d ); } 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 4c48095a3..defc72ba6 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 @@ -473,24 +473,24 @@ else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && protected boolean ignoreMinesBlockBreakEvent( Cancellable event, Player player, Block block ) { - MinesEventResults eventResults = ignoreMinesBlockBreakEvent( player, block ); - - if ( eventResults.isCancelEvent() ) { - event.setCancelled( eventResults.isCancelEvent() ); + MinesEventResults eventResults = ignoreMinesBlockBreakEvent( player, block ); + + if ( eventResults.isCancelEvent() ) { + event.setCancelled( eventResults.isCancelEvent() ); + } + return eventResults.isIgnoreEvent(); } - return eventResults.isIgnoreEvent(); -} - -protected boolean processMinesBlockBreakEvent( PEExplosionEvent event, Player player, Block block ) { - - MinesEventResults eventResults = ignoreMinesBlockBreakEvent( player, block ); - if ( eventResults.isCancelEvent() ) { - event.setCancelled( eventResults.isCancelEvent() ); + protected boolean processMinesBlockBreakEvent( PEExplosionEvent event, Player player, Block block ) { + + MinesEventResults eventResults = ignoreMinesBlockBreakEvent( player, block ); + + if ( eventResults.isCancelEvent() ) { + event.setCancelled( eventResults.isCancelEvent() ); + } + return eventResults.isIgnoreEvent(); } - return eventResults.isIgnoreEvent(); -} - + /** *

This processes the block finalizations, which are counting the block breakage, diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java index 9f13040c7..f572b3a6c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java @@ -18,6 +18,7 @@ package tech.mcprison.prison.spigot.game; +import java.util.ArrayList; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @@ -213,6 +214,9 @@ public void setBlockAsync( PrisonBlock prisonBlock, Location location ) { public void setBlocksSynchronously( List tBlocks, MineResetType resetType, PrisonStatsElapsedTimeNanos nanos ) { + List tBlocksCloned = new ArrayList<>(); + tBlocksCloned.addAll( tBlocks ); + new BukkitRunnable() { @Override public void run() { @@ -222,7 +226,7 @@ public void run() { MineTargetPrisonBlock current = null; try { - for ( MineTargetPrisonBlock tBlock : tBlocks ) + for ( MineTargetPrisonBlock tBlock : tBlocksCloned ) { current = tBlock; From cab08c67521508b4c0dfbab0ca716f1242950454 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 20 Feb 2022 22:30:03 -0500 Subject: [PATCH 112/297] Mine reset mutex is conditionally enabled to ensure the locks remain balanced. To ensure the mutex is enabled ASAP, its engaged outside of the normal location... it may only be a few nano-seconds savings, but with OP pickaxes mining with many players within one mine, the mutex must be enabled rapidly. --- docs/changelog_v3.3.x.md | 4 +++ .../prison/mines/data/MineScheduler.java | 33 ++++++++++++++++--- .../prison/mines/data/MineStateMutex.java | 11 ++++++- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d304ae31a..c15a3537d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8d 2022-02-20 +* **Mine reset mutex is conditionally enabled to ensure the locks remain balanced.** +To ensure the mutex is enabled ASAP, its engaged outside of the normal location... it may only be a few nano-seconds savings, but with OP pickaxes mining with many players within one mine, the mutex must be enabled rapidly. + + * **Bug Fix: Mine reset changes: Eliminate paged resets, some code that is not being use anymore, disabled the RESET_ASYNC type to be similar to RESET_SYNC since they are now the same, locked out checkZeroBlockResets so mines cannot reset multiple times at the same time using the MineStateMutex.** The major issue here was that mines were being reset in the middle of a reset action. Used a preexisting MineStateMutex to secure the checkZeroBlockResets() function to prevent it from kicking off many resets. These multiple resets were happening because many players were triggering the resets... as a side effect, there were many situations of collections failing due to concurrent modification exceptions. diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java index 254a8c272..34cd7c0b7 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java @@ -736,12 +736,12 @@ public boolean checkZeroBlockReset() { if ( !isVirtual() && getMineStateMutex().isMinable() ) { - if ( !isVirtual() && ( + if ( getRemainingBlockCount() <= 0 && !isZeroBlockResetDisabled() || getResetThresholdPercent() > 0 && getRemainingBlockCount() < (getBounds().getTotalBlockCount() * getResetThresholdPercent() / 100.0d) - )) { + ) { // submit a manual reset since the mine is empty: manualReset( MineResetScheduleType.NORMAL, getZeroBlockResetDelaySec() ); @@ -798,8 +798,33 @@ private void manualReset( MineResetScheduleType resetType, double delayActionSec return; } - // Lock the mine's mutex: - getMineStateMutex().setMineStateResetStart(); + // Lock the mine's mutex if it's still minable. Otherwise skip it since the + // state has been incremented by one already. + if ( getMineStateMutex().isMinable() ) { + + getMineStateMutex().setMineStateResetStart(); + } + else if ( getMineStateMutex().getMineStateSn() > 1 ) { + + synchronized ( getMineStateMutex() ) { + + // synchronizing on the mutex this will allow only one thread to be + // processed at a time, which will weed out extra threads from being + // wrongfully shutdown. Based upon this "technique" the last thread to + // be paused by this synchronized block will be the one that will actually + // initiate the reset. + if ( getMineStateMutex().getMineStateSn() > 1 ) { + + // This may be a double submission sinc the mineStateSn should only be 1 at this + // point. So release this lock and shutdown this duplicate submission. + getMineStateMutex().setMineStateResetFinished(); + + // duplicate reset request, so exit... + return; + } + } + + } // cancel existing job: diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineStateMutex.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineStateMutex.java index 7dbef5007..6b9bb7bd9 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineStateMutex.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineStateMutex.java @@ -44,7 +44,16 @@ public void setMineStateResetFinished() { synchronized ( this ) { - this.mineState = MineState.UNLOCKED; + this.mineStateSn--; + + // If the state serial number is zero, then that means + // this can now be unlocked. Otherwise if non-zero it + // must remain locked. + if ( mineStateSn == 0 ) { + + this.mineState = MineState.UNLOCKED; + } + } } From 7f7c619494600bd4e89281e0a310c85405e37caf Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 20 Feb 2022 22:32:32 -0500 Subject: [PATCH 113/297] v3.3.0-alpha.8e --- 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 c15a3537d..7bf37a064 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8d 2022-02-20 +# 3.3.0-alpha.8e 2022-02-20 + + +* **v3.3.0-alpha.8e 2022-02-20** * **Mine reset mutex is conditionally enabled to ensure the locks remain balanced.** diff --git a/gradle.properties b/gradle.properties index a285c6201..2b88f0ea7 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.8d +version=3.3.0-alpha.8e #version=3.3.0-alpha.7 From e53a147cb1a807c841101a8b2e111723f5234277 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 22 Feb 2022 02:42:24 -0500 Subject: [PATCH 114/297] Adjustments to the configuration of the mutex to better ensure that only one job is submitted for the reset, and to ensure other tasks are not locked up, or locked out. There was a report that the prior way was causing the mines to lockup. --- docs/changelog_v3.3.x.md | 6 +- .../prison/mines/data/MineScheduler.java | 63 ++++++++++++------- .../prison/mines/data/MineStateMutex.java | 19 ++++++ .../mines/tasks/MinePagedResetAsyncTask.java | 36 +++++++---- 4 files changed, 88 insertions(+), 36 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7bf37a064..ec7d33474 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8e 2022-02-20 +# 3.3.0-alpha.8e 2022-02-22 + + +* **Adjustments to the configuration of the mutex to better ensure that only one job is submitted for the reset, and to ensure other tasks are not locked up, or locked out.** +There was a report that the prior way was causing the mines to lockup. * **v3.3.0-alpha.8e 2022-02-20** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java index 34cd7c0b7..73b16b7f8 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java @@ -794,36 +794,51 @@ private void manualReset( MineResetScheduleType resetType, double delayActionSec List resetActions ) { if ( isVirtual() || !getMineStateMutex().isMinable() ) { - // Nope... nothing to reset... or it's locked out alredy with a reset + // Nope... nothing to reset... or it's locked out already with a reset return; } - // Lock the mine's mutex if it's still minable. Otherwise skip it since the - // state has been incremented by one already. - if ( getMineStateMutex().isMinable() ) { - - getMineStateMutex().setMineStateResetStart(); - } - else if ( getMineStateMutex().getMineStateSn() > 1 ) { + synchronized ( getMineStateMutex() ) { + + // The synchronized block will halt threads and will wait. + // So there is a chance that more than one reset will make it in to this + // block, so need to check the mutex state again and exist if the mine + // is not minable, since that indicates an earlier thread won the + // reset: - synchronized ( getMineStateMutex() ) { - - // synchronizing on the mutex this will allow only one thread to be - // processed at a time, which will weed out extra threads from being - // wrongfully shutdown. Based upon this "technique" the last thread to - // be paused by this synchronized block will be the one that will actually - // initiate the reset. - if ( getMineStateMutex().getMineStateSn() > 1 ) { - - // This may be a double submission sinc the mineStateSn should only be 1 at this - // point. So release this lock and shutdown this duplicate submission. - getMineStateMutex().setMineStateResetFinished(); - - // duplicate reset request, so exit... - return; - } + if ( !getMineStateMutex().isMinable() ) { + // exit since another reset has been started. + return; } + + getMineStateMutex().setMineStateResetStart(); + + +// // Lock the mine's mutex if it's still minable. Otherwise skip it since the +// // state has been incremented by one already. +// if ( getMineStateMutex().isMinable() ) { +// +// getMineStateMutex().setMineStateResetStart(); +// } +// else if ( getMineStateMutex().getMineStateSn() > 1 ) { +// +// // synchronizing on the mutex this will allow only one thread to be +// // processed at a time, which will weed out extra threads from being +// // wrongfully shutdown. Based upon this "technique" the last thread to +// // be paused by this synchronized block will be the one that will actually +// // initiate the reset. +// if ( getMineStateMutex().getMineStateSn() > 1 ) { +// +// // This may be a double submission sinc the mineStateSn should only be 1 at this +// // point. So release this lock and shutdown this duplicate submission. +// getMineStateMutex().setMineStateResetFinished(); +// +// // duplicate reset request, so exit... +// return; +// } +// +// } } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineStateMutex.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineStateMutex.java index 6b9bb7bd9..62b4e869a 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineStateMutex.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineStateMutex.java @@ -57,6 +57,25 @@ public void setMineStateResetFinished() { } } + + /** + *

This function will force the release of the mutex no matter how many + * layered locks were initiated. This should only be called when it + * certain when the task is completed. + *

+ * + * + */ + public void setMineStateResetFinishedForced() { + + synchronized ( this ) { + + this.mineStateSn = 0; + + this.mineState = MineState.UNLOCKED; + } + + } public boolean isMinable() { boolean results = false; diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java index ae105c388..40b14e902 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java @@ -141,7 +141,7 @@ public void run() { // The first time running this, need to setup the block list if a reset: if ( position == 0 ) { - if ( runSetupCancelReset() ) { + if ( runSetupCancelAutoResets() ) { // If the reset should be canceled then just return, and that will // terminate the reset. There is nothing else that needs to be done. return; @@ -184,27 +184,41 @@ public void run() { /** + *

The primary purpose of this function is to cancel the auto resets + * and to prepare for a manual reset. + *

+ * *

This is ran before the initial actual processing is performed. - * This calls the functions to + * This calls the resetAsynchonouslyInitiate function which raises the + * MineResetEvent. If that event is not canceled then it will run the + * pre-reset commands within the function asynchronouslyResetSetup. + *

*/ - private boolean runSetupCancelReset() { + private boolean runSetupCancelAutoResets() { boolean cancel = false; - // Set the MineStateMutex to a state of starting a mine reset: - mine.getMineStateMutex().setMineStateResetStart(); + // If it makes it this far and the mutex is not locked, then lock it: + if ( mine.getMineStateMutex().isMinable() ) { + + // Set the MineStateMutex to a state of starting a mine reset: + mine.getMineStateMutex().setMineStateResetStart(); + } mine.generateBlockListAsync(); - if ( resetType == MineResetType.normal ) { - - - } +// if ( resetType == MineResetType.normal ) { +// +// +// } // resetAsynchonouslyInitiate() will confirm if the reset should happened // and will raise Prison's mine reset event. // A return value of true means cancel the reset: cancel = mine.resetAsynchonouslyInitiate( resetType ); - mine.asynchronouslyResetSetup(); + if ( !cancel ) { + + mine.asynchronouslyResetSetup(); + } return cancel; } @@ -216,7 +230,7 @@ private void runShutdown() { // Set the MineStateMutex to a state of Finishing a mine reset: // It is now safe to allow mining in the mine. - mine.getMineStateMutex().setMineStateResetFinished(); + mine.getMineStateMutex().setMineStateResetFinishedForced(); // Run items such as post-mine-reset commands: From 8131e9988e49ef83ea0e5e32c77d7635ab7753b5 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 22 Feb 2022 02:50:55 -0500 Subject: [PATCH 115/297] The creation of a new sellall module which will eventually contain the code to manage multiple shops that will be based upon ranks. --- docs/changelog_v3.3.x.md | 3 + prison-sellall/build.gradle | 79 ++++++++++++++++ .../prison/sellall/PrisonSellall.java | 94 +++++++++++++++++++ .../prison/sellall/PrisonSellallMessages.java | 44 +++++++++ .../sellall/commands/SellallCommands.java | 17 ++++ .../commands/SellallCommandsMessages.java | 38 ++++++++ prison-spigot/build.gradle | 2 + .../mcprison/prison/spigot/SpigotPrison.java | 18 ++++ settings.gradle | 2 +- 9 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 prison-sellall/build.gradle create mode 100644 prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellall.java create mode 100644 prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellallMessages.java create mode 100644 prison-sellall/src/main/java/tech/mcprison/prison/sellall/commands/SellallCommands.java create mode 100644 prison-sellall/src/main/java/tech/mcprison/prison/sellall/commands/SellallCommandsMessages.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ec7d33474..ae78281f0 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8e 2022-02-22 +* **The creation of a new sellall module which will eventually contain the code to manage multiple shops that will be based upon ranks.** + + * **Adjustments to the configuration of the mutex to better ensure that only one job is submitted for the reset, and to ensure other tasks are not locked up, or locked out.** There was a report that the prior way was causing the mines to lockup. diff --git a/prison-sellall/build.gradle b/prison-sellall/build.gradle new file mode 100644 index 000000000..e01ec22ef --- /dev/null +++ b/prison-sellall/build.gradle @@ -0,0 +1,79 @@ +/* + * 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: 'eclipse' +apply plugin: 'idea' +apply plugin: 'java' + +compileJava.options.encoding = 'UTF-8' +compileTestJava.options.encoding = "UTF-8" + +repositories { + mavenCentral() + + // net.luckperm.api: + maven { url = "https://hub.spigotmc.org/nexus/content/groups/public" } + + maven { url = "https://nexus.hc.to/content/repositories/pub_releases" } + + maven { url = "https://repo.codemc.org/repository/maven-public/" } + +// maven { +// url = 'https://mvnrepository.com/artifact/com.github.cryptomorin/XSeries' +// content { +// includeGroup 'com.github.cryptomorin' +// } +// } + +} + + + +dependencies { + implementation project(':prison-core') + implementation project(':prison-mines') + implementation project(':prison-ranks') + + + + // https://mvnrepository.com/artifact/com.github.cryptomorin/XSeries +// implementation 'com.github.cryptomorin:XSeries:8.5.0.1' + + + + compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT' + + + + testImplementation group: 'junit', name: 'junit', version: '4.12' + +} + +shadowJar { + dependencies { +// include(dependency('org.apache.commons:commons-lang3:3.12.0')) +// include(dependency('com.google.code.gson:gson:2.8.6')) + } + classifier 'API' + archiveVersion = null +} + +build.dependsOn(shadowJar) + diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellall.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellall.java new file mode 100644 index 000000000..6f7e06814 --- /dev/null +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellall.java @@ -0,0 +1,94 @@ +package tech.mcprison.prison.sellall; + +import java.util.List; + +import tech.mcprison.prison.localization.LocaleManager; +import tech.mcprison.prison.output.LogLevel; +import tech.mcprison.prison.output.Output; + +public class PrisonSellall + extends PrisonSellallMessages +{ + public static final String MODULE_NAME = "Sellall"; + + private static PrisonSellall instance; + + private List prisonStartupDetails; + + private LocaleManager localeManager; + + public PrisonSellall(String version) { + super(MODULE_NAME, version, 3); + } + + + @Override + public String getBaseCommands() { + return "/sellall"; + } + + /* + * Methods + */ + + public static PrisonSellall getInstance() { + return instance; + } + + @Override + public void enable() { + instance = this; + + this.localeManager = new LocaleManager(this, "lang/sellall"); + + } + + + /** + * This function deferredStartup() will be called after the integrations have been + * loaded. + * + */ + @Override + public void deferredStartup() { + } + + /** + *

Do not save ranks upon server shutdown or plugin disable events. The + * ranks should be saved every time there is a modification to them. + *

+ */ + @Override + public void disable() { + } + + + + private void logStartupMessageError( String message ) { + logStartupMessage( LogLevel.ERROR, message ); + + } + + private void logStartupMessage( String message ) { + logStartupMessage( LogLevel.INFO, message ); + + } + private void logStartupMessage( LogLevel logLevel, String message ) { + + Output.get().log( message, logLevel ); + + getPrisonStartupDetails().add( message ); + } + + public List getPrisonStartupDetails() { + return prisonStartupDetails; + } + public void setPrisonStartupDetails( List prisonStartupDetails ){ + this.prisonStartupDetails = prisonStartupDetails; + } + + public LocaleManager getSellallMessages() { + return localeManager; + } + +} diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellallMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellallMessages.java new file mode 100644 index 000000000..36cc153b2 --- /dev/null +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellallMessages.java @@ -0,0 +1,44 @@ +package tech.mcprison.prison.sellall; + +import tech.mcprison.prison.modules.Module; + +public abstract class PrisonSellallMessages + extends Module +{ + public PrisonSellallMessages( String name, String version, int target ) + { + super( name, version, target ); + } + + + // This does nothing. Used as an example until real messages can be added. + protected String prisonSellallTest01Msg() { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_01" ) + .localize(); + } + + // This does nothing. Used as an example until real messages can be added. + protected String prisonSellallTest02Msg( String parameter ) { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_02" ) + .withReplacements( parameter ) + .localize(); + } + + protected String prisonSellallTest03Msg() { + + String msg01 = prisonSellallTest01Msg(); + String msg02 = prisonSellallTest02Msg( "sample02" ); + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_03" ) + .withReplacements( + msg01, + msg02 ) + .localize(); + + } +} diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/commands/SellallCommands.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/commands/SellallCommands.java new file mode 100644 index 000000000..6adc2c0f9 --- /dev/null +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/commands/SellallCommands.java @@ -0,0 +1,17 @@ +package tech.mcprison.prison.sellall.commands; + +import tech.mcprison.prison.commands.Command; +import tech.mcprison.prison.internal.CommandSender; + +public class SellallCommands + extends SellallCommandsMessages +{ + + @Command(identifier = "sellall module", + onlyPlayers = false, permissions = "prison.sellall.admin", + description = "Test of new sellall module.") + public void ranksSetSubcommands(CommandSender sender) { + sender.dispatchCommand( "sellall help" ); + } + +} diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/commands/SellallCommandsMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/commands/SellallCommandsMessages.java new file mode 100644 index 000000000..4f34ecdca --- /dev/null +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/commands/SellallCommandsMessages.java @@ -0,0 +1,38 @@ +package tech.mcprison.prison.sellall.commands; + +import tech.mcprison.prison.sellall.PrisonSellall; + +public class SellallCommandsMessages +{ + + // This does nothing. Used as an example until real messages can be added. + protected String prisonSellallTest01Msg() { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_01" ) + .localize(); + } + + // This does nothing. Used as an example until real messages can be added. + protected String prisonSellallTest02Msg( String parameter ) { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_02" ) + .withReplacements( parameter ) + .localize(); + } + + protected String prisonSellallTest03Msg() { + + String msg01 = prisonSellallTest01Msg(); + String msg02 = prisonSellallTest02Msg( "sample02" ); + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_03" ) + .withReplacements( + msg01, + msg02 ) + .localize(); + + } +} diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index 733da3809..062c9d0c1 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -79,6 +79,7 @@ dependencies { implementation project(':prison-core') implementation project(':prison-mines') implementation project(':prison-ranks') + implementation project(':prison-sellall') implementation 'org.bstats:bstats-base:2.2.1' @@ -195,6 +196,7 @@ shadowJar { include(project(':prison-core')) include(project(':prison-mines')) include(project(':prison-ranks')) + include(project(':prison-sellall')) } relocate 'org.bstats', 'tech.mcprison.prison.bstats' 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 dfcb423d5..bda985eb5 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 @@ -63,6 +63,8 @@ import tech.mcprison.prison.ranks.commands.FailedRankCommands; import tech.mcprison.prison.ranks.data.Rank; import tech.mcprison.prison.ranks.managers.RankManager; +import tech.mcprison.prison.sellall.PrisonSellall; +import tech.mcprison.prison.sellall.commands.SellallCommands; import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerBlockBreakEvents; import tech.mcprison.prison.spigot.backpacks.BackpacksListeners; @@ -726,6 +728,22 @@ private void initModulesAndCommands() { Prison.get().getModuleManager().getDisabledModules().add( PrisonRanks.MODULE_NAME ); } + + if (modulesConf.getBoolean( PrisonSellall.MODULE_NAME.toLowerCase() ) ) { + PrisonSellall sellallModule = new PrisonSellall(getDescription().getVersion() ); + + // Register and enable Ranks: + Prison.get().getModuleManager().registerModule( sellallModule ); + + Prison.get().getCommandHandler().registerCommands( new SellallCommands() ); + + } + else { + Output.get().logInfo("&3Modules: &cPrison sellall module is disabled and was not Loaded. "); + Prison.get().getModuleManager().getDisabledModules().add( PrisonSellall.MODULE_NAME ); + } + + // The following linkMinesAndRanks() function must be called only after the // Module deferred tasks are ran. diff --git a/settings.gradle b/settings.gradle index fdd891d2b..a840f34b9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,4 +23,4 @@ include 'prison-spigot' /* include 'prison-sponge' */ include 'prison-mines' include 'prison-ranks' - +include 'prison-sellall' From 420b519f877da7f58abb2626ac09935ab2efde81 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 23 Feb 2022 00:25:51 -0500 Subject: [PATCH 116/297] v3.3.0-alpha.8e --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2b88f0ea7..1367a13b3 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.8e +version=3.3.0-alpha.8f #version=3.3.0-alpha.7 From 0799b8b09ba891ec7667796e7d9c883d2ccc34aa Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 23 Feb 2022 00:31:19 -0500 Subject: [PATCH 117/297] For the admin commands for tokens, added an option to be able to suppress the messages. --- docs/changelog_v3.3.x.md | 5 +- .../tech/mcprison/prison/PrisonCommand.java | 151 +++++++++++------- 2 files changed, 101 insertions(+), 55 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ae78281f0..3e3860192 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8e 2022-02-22 +# 3.3.0-alpha.8e 2022-02-23 + + +* **For the admin commands for tokens, added an option to be able to suppress the messages.** * **The creation of a new sellall module which will eventually contain the code to manage multiple shops that will be based upon ranks.** 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 a01816423..f31701bc4 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -1628,13 +1628,23 @@ public void tokensAdd( CommandSender sender, description = "Player to add the tokens to.") String playerName, @Arg(name = "amount", verifiers = "min[1]", - description = "The number of tokens to add to the player's account.") long amount + description = "The number of tokens to add to the player's account.") long amount, + + @Wildcard(join=true) + @Arg(name = "options", description = "Optional settings: [silent] Silent suppresses " + + "all messages related to the transaction, including failures.", + def = "") String options ) { + boolean silent = options != null && options.toLowerCase().contains( "silent" ); + if ( playerName == null || playerName.isEmpty() ) { - String message = "Prison Tokens: A player's name is required."; - Output.get().logWarn( message ); + if ( !silent ) { + String message = "Prison Tokens: A player's name is required."; + Output.get().logWarn( message ); + } + return; } @@ -1642,11 +1652,14 @@ public void tokensAdd( CommandSender sender, if ( amount <= 0 ) { - String message = - String.format( - "Prison Tokens: Invalid amount: '%s'. Must be greater than zero.", - dFmt.format( amount ) ); - Output.get().logWarn( message ); + if ( !silent ) { + String message = + String.format( + "Prison Tokens: Invalid amount: '%s'. Must be greater than zero.", + dFmt.format( amount ) ); + Output.get().logWarn( message ); + } + return; } @@ -1655,20 +1668,23 @@ public void tokensAdd( CommandSender sender, player.getPlayerCachePlayerData().addTokensAdmin( amount ); - - String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); - - String message = String.format( "&3%s now has &7%s &3tokens after adding &7%s&3.", + if ( !silent ) { + + String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); + + String message = String.format( "&3%s now has &7%s &3tokens after adding &7%s&3.", player.getName(), tokens, dFmt.format( amount ) ); - - // The person adding the tokens, or console: - sender.sendMessage( message ); - - // The player getting the tokens, if they are online: - if ( player.isOnline() && !player.getName().equalsIgnoreCase( sender.getName() ) ) { - player.sendMessage( message ); + // The person adding the tokens, or console: + sender.sendMessage( message ); + + // The player getting the tokens, if they are online: + if ( player.isOnline() && !player.getName().equalsIgnoreCase( sender.getName() ) ) { + + player.sendMessage( message ); + } } + } @Command(identifier = "prison tokens remove", @@ -1682,13 +1698,23 @@ public void tokensRemove( CommandSender sender, @Arg(name = "amount", verifiers = "min[1]", description = "The number of tokens to remove from the player's account. " + - "This amount must be positive. ") long amount + "This amount must be positive. ") long amount, + + @Wildcard(join=true) + @Arg(name = "options", description = "Optional settings: [silent] Silent suppresses " + + "all messages related to the transaction, including failures.", + def = "") String options ) { + boolean silent = options != null && options.toLowerCase().contains( "silent" ); + if ( playerName == null || playerName.isEmpty() ) { - String message = "Prison Tokens: A player's name is required."; - Output.get().logWarn( message ); + if ( !silent ) { + String message = "Prison Tokens: A player's name is required."; + Output.get().logWarn( message ); + } + return; } @@ -1696,11 +1722,14 @@ public void tokensRemove( CommandSender sender, if ( amount <= 0 ) { - String message = - String.format( - "Prison Tokens: Invalid amount: '%s'. Must be greater than zero.", - dFmt.format( amount ) ); - Output.get().logWarn( message ); + if ( !silent ) { + String message = + String.format( + "Prison Tokens: Invalid amount: '%s'. Must be greater than zero.", + dFmt.format( amount ) ); + Output.get().logWarn( message ); + } + return; } @@ -1709,19 +1738,21 @@ public void tokensRemove( CommandSender sender, player.getPlayerCachePlayerData().removeTokensAdmin( amount ); - - String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); - - String message = String.format( "&3%s now has &7%s &3tokens after removing &7%s&3.", - player.getName(), tokens, dFmt.format( amount ) ); - - // The person adding the tokens, or console: - sender.sendMessage( message ); - - // The player getting the tokens, if they are online: - if ( player.isOnline() && !player.getName().equalsIgnoreCase( sender.getName() ) ) { + if ( !silent ) { + + String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); - player.sendMessage( message ); + String message = String.format( "&3%s now has &7%s &3tokens after removing &7%s&3.", + player.getName(), tokens, dFmt.format( amount ) ); + + // The person adding the tokens, or console: + sender.sendMessage( message ); + + // The player getting the tokens, if they are online: + if ( player.isOnline() && !player.getName().equalsIgnoreCase( sender.getName() ) ) { + + player.sendMessage( message ); + } } } @@ -1737,13 +1768,23 @@ public void tokensSet( CommandSender sender, @Arg(name = "amount", description = "The number of tokens to set the player's account to. " + - "This amount must amount can be negative. ") long amount + "This amount must amount can be negative. ") long amount, + + @Wildcard(join=true) + @Arg(name = "options", description = "Optional settings: [silent] Silent suppresses " + + "all messages related to the transaction, including failures.", + def = "") String options ) { + boolean silent = options != null && options.toLowerCase().contains( "silent" ); + if ( playerName == null || playerName.isEmpty() ) { - String message = "Prison Tokens: A player's name is required."; - Output.get().logWarn( message ); + if ( !silent ) { + String message = "Prison Tokens: A player's name is required."; + Output.get().logWarn( message ); + } + return; } @@ -1758,19 +1799,21 @@ public void tokensSet( CommandSender sender, player.getPlayerCachePlayerData().setTokensAdmin( amount ); - - String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); - - String message = String.format( "&3%s now has &7%s &3tokens.", - player.getName(), tokens ); - - // The person adding the tokens, or console: - sender.sendMessage( message ); - - // The player getting the tokens, if they are online: - if ( player.isOnline() && !player.getName().equalsIgnoreCase( sender.getName() ) ) { + if ( !silent ) { + + String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); + + String message = String.format( "&3%s now has &7%s &3tokens.", + player.getName(), tokens ); - player.sendMessage( message ); + // The person adding the tokens, or console: + sender.sendMessage( message ); + + // The player getting the tokens, if they are online: + if ( player.isOnline() && !player.getName().equalsIgnoreCase( sender.getName() ) ) { + + player.sendMessage( message ); + } } } From 64f604bbbe0666e014eff2cc69b2ffe9f95de1c8 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Wed, 23 Feb 2022 03:05:25 -0500 Subject: [PATCH 118/297] Prison tokens: externalize the messages related to the admin tokens commands. --- docs/changelog_v3.3.x.md | 4 + .../tech/mcprison/prison/PrisonCommand.java | 179 ++++++++++++------ .../prison/PrisonCommandMessages.java | 98 ++++++++++ .../main/resources/lang/core/de_DE.properties | 11 +- .../main/resources/lang/core/en_GB.properties | 11 +- .../main/resources/lang/core/en_US.properties | 11 +- .../main/resources/lang/core/es_ES.properties | 11 +- .../main/resources/lang/core/hu_HU.properties | 11 +- .../main/resources/lang/core/it_IT.properties | 11 +- .../main/resources/lang/core/nl_BE.properties | 11 +- .../main/resources/lang/core/nl_NL.properties | 11 +- .../main/resources/lang/core/zh_TW.properties | 11 +- 12 files changed, 310 insertions(+), 70 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 3e3860192..6be3bc029 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8e 2022-02-23 + +* **Prison tokens: externalize the messages related to the admin tokens commands.** + + * **For the admin commands for tokens, added an option to be able to suppress the messages.** 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 f31701bc4..487d3bec5 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -1583,9 +1583,10 @@ public void tokensBalance(CommandSender sender, if ( ( player == null || !player.isOnline() ) && ( playerName == null || playerName.isEmpty() ) ) { - String message = "Prison Tokens: A player's name is required when used from console."; - - Output.get().logWarn( message ); + coreTokensNameRequiredMsg(sender); +// String message = "Prison Tokens: A player's name is required when used from console."; +// +// Output.get().logWarn( message ); return; } else @@ -1593,9 +1594,10 @@ public void tokensBalance(CommandSender sender, if ( !sender.isOp() && !sender.hasPermission( "tokens.bal.others" ) ) { - String message = "Prison Tokens: You do not have permission to view other " + - "player's balances."; - Output.get().logWarn( message ); + coreTokensBalanceCannotViewOthersMsg(sender); +// String message = "Prison Tokens: You do not have permission to view other " + +// "player's balances."; +// Output.get().logWarn( message ); return; } @@ -1609,19 +1611,23 @@ public void tokensBalance(CommandSender sender, // player.getPlayerCache() - DecimalFormat dFmt = new DecimalFormat("#,##0"); - long tokens = player.getPlayerCachePlayerData().getTokens(); - String tokensMsg = dFmt.format( tokens ); - - String message = String.format( "&3%s has %s tokens.", player.getName(), tokensMsg ); + coreTokensBalanceViewMsg( sender, player.getName(), tokens ); - sender.sendMessage( message ); +// DecimalFormat dFmt = new DecimalFormat("#,##0"); +// String tokensMsg = dFmt.format( tokens ); +// +// String message = String.format( "&3%s has %s tokens.", player.getName(), tokensMsg ); +// +// sender.sendMessage( message ); } @Command(identifier = "prison tokens add", - description = "Prison tokens Admin: an admins tool to give more tokens to a player", + description = "Prison tokens Admin: an admins tool to give more tokens to a player. The " + + "tokens added by admin will not count as earned tokens, so they cannot be used in " + + "situations where the player must earn them. This restriction can be forced to " + + "be attributed to being earned by the player.", permissions = "tokens.admin.add" ) public void tokensAdd( CommandSender sender, @Arg(name = "player", @@ -1631,33 +1637,39 @@ public void tokensAdd( CommandSender sender, description = "The number of tokens to add to the player's account.") long amount, @Wildcard(join=true) - @Arg(name = "options", description = "Optional settings: [silent] Silent suppresses " + - "all messages related to the transaction, including failures.", + @Arg(name = "options", description = "Optional settings: [silent forcePlayer] Silent suppresses " + + "all messages related to the transaction, including failures. The option 'forcePlayer' " + + "will not use the admin logging of this transaction, but instead will assign it to the " + + "player as if they actually earned the tokens through normal ways. It is not advised to " + + "use 'forcePlayer' since it could be used to cheat the system in some ways.", def = "") String options ) { boolean silent = options != null && options.toLowerCase().contains( "silent" ); + boolean forcePlayer = options != null && options.toLowerCase().contains( "forceplayer" ); if ( playerName == null || playerName.isEmpty() ) { if ( !silent ) { - String message = "Prison Tokens: A player's name is required."; - Output.get().logWarn( message ); + coreTokensNameRequiredMsg(sender); +// String message = "Prison Tokens: A player's name is required."; +// Output.get().logWarn( message ); } return; } - DecimalFormat dFmt = new DecimalFormat("#,##0"); +// DecimalFormat dFmt = new DecimalFormat("#,##0"); if ( amount <= 0 ) { if ( !silent ) { - String message = - String.format( - "Prison Tokens: Invalid amount: '%s'. Must be greater than zero.", - dFmt.format( amount ) ); - Output.get().logWarn( message ); + coreTokensAddInvalidAmountMsg( sender, amount ); +// String message = +// String.format( +// "Prison Tokens: Invalid amount: '%s'. Must be greater than zero.", +// dFmt.format( amount ) ); +// Output.get().logWarn( message ); } return; @@ -1665,15 +1677,25 @@ public void tokensAdd( CommandSender sender, Player player = getPlayer( playerName ); - player.getPlayerCachePlayerData().addTokensAdmin( amount ); + if ( forcePlayer ) { + + player.getPlayerCachePlayerData().addTokens( amount ); + } + else { + + player.getPlayerCachePlayerData().addTokensAdmin( amount ); + } if ( !silent ) { - String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); + String message = coreTokensAddedAmountMsg( player.getName(), + player.getPlayerCachePlayerData().getTokens(), amount ); - String message = String.format( "&3%s now has &7%s &3tokens after adding &7%s&3.", - player.getName(), tokens, dFmt.format( amount ) ); +// String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); +// +// String message = String.format( "&3%s now has &7%s &3tokens after adding &7%s&3.", +// player.getName(), tokens, dFmt.format( amount ) ); // The person adding the tokens, or console: sender.sendMessage( message ); @@ -1690,7 +1712,10 @@ public void tokensAdd( CommandSender sender, @Command(identifier = "prison tokens remove", description = "Prison tokens Admin: an admins tool to remove tokens from a player. " + "It is possible to remove more tokens than what the player has, which can " + - "be treated like a debt.", + "be treated like a debt. The " + + "tokens added by admin will not count as earned tokens, so they cannot be used in " + + "situations where the player must earn them. This restriction can be forced to " + + "be attributed to being earned by the player.", permissions = "tokens.admin.add" ) public void tokensRemove( CommandSender sender, @Arg(name = "player", @@ -1701,33 +1726,39 @@ public void tokensRemove( CommandSender sender, "This amount must be positive. ") long amount, @Wildcard(join=true) - @Arg(name = "options", description = "Optional settings: [silent] Silent suppresses " + - "all messages related to the transaction, including failures.", - def = "") String options + @Arg(name = "options", description = "Optional settings: [silent forcePlayer] Silent suppresses " + + "all messages related to the transaction, including failures. The option 'forcePlayer' " + + "will not use the admin logging of this transaction, but instead will assign it to the " + + "player as if they actually earned the tokens through normal ways. It is not advised to " + + "use 'forcePlayer' since it could be used to cheat the system in some ways.", + def = "") String options ) { boolean silent = options != null && options.toLowerCase().contains( "silent" ); + boolean forcePlayer = options != null && options.toLowerCase().contains( "forceplayer" ); if ( playerName == null || playerName.isEmpty() ) { if ( !silent ) { - String message = "Prison Tokens: A player's name is required."; - Output.get().logWarn( message ); + coreTokensNameRequiredMsg(sender); +// String message = "Prison Tokens: A player's name is required."; +// Output.get().logWarn( message ); } return; } - DecimalFormat dFmt = new DecimalFormat("#,##0"); +// DecimalFormat dFmt = new DecimalFormat("#,##0"); if ( amount <= 0 ) { if ( !silent ) { - String message = - String.format( - "Prison Tokens: Invalid amount: '%s'. Must be greater than zero.", - dFmt.format( amount ) ); - Output.get().logWarn( message ); + coreTokensAddInvalidAmountMsg( sender, amount ); +// String message = +// String.format( +// "Prison Tokens: Invalid amount: '%s'. Must be greater than zero.", +// dFmt.format( amount ) ); +// Output.get().logWarn( message ); } return; @@ -1735,15 +1766,24 @@ public void tokensRemove( CommandSender sender, Player player = getPlayer( playerName ); - player.getPlayerCachePlayerData().removeTokensAdmin( amount ); + if ( forcePlayer ) { + + player.getPlayerCachePlayerData().removeTokens( amount ); + } + else { + + player.getPlayerCachePlayerData().removeTokensAdmin( amount ); + } if ( !silent ) { - String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); - - String message = String.format( "&3%s now has &7%s &3tokens after removing &7%s&3.", - player.getName(), tokens, dFmt.format( amount ) ); + String message = coreTokensRemovedAmountMsg( player.getName(), + player.getPlayerCachePlayerData().getTokens(), amount ); +// String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); +// +// String message = String.format( "&3%s now has &7%s &3tokens after removing &7%s&3.", +// player.getName(), tokens, dFmt.format( amount ) ); // The person adding the tokens, or console: sender.sendMessage( message ); @@ -1757,38 +1797,46 @@ public void tokensRemove( CommandSender sender, } @Command(identifier = "prison tokens set", - description = "Prison tokens Admin: an admins tool to set number of tokens " + + description = "Prison tokens Admin: an admins tool to set the number of tokens " + "for a player to a specific amount. " + - "It is possible to set the tokens to a negavtie amount, which can " + - "be treated like a debt.", + "It is possible to set the tokens to a negative amount, which can " + + "be treated like a debt. The " + + "tokens added by admin will not count as earned tokens, so they cannot be used in " + + "situations where the player must earn them. This restriction can be forced to " + + "be attributed to being earned by the player.", permissions = "tokens.admin.add" ) public void tokensSet( CommandSender sender, @Arg(name = "player", - description = "Player to remove the tokens from.") String playerName, + description = "Player to adjust their tokens balance.") String playerName, @Arg(name = "amount", description = "The number of tokens to set the player's account to. " + - "This amount must amount can be negative. ") long amount, + "This amount can be negative. ") long amount, @Wildcard(join=true) - @Arg(name = "options", description = "Optional settings: [silent] Silent suppresses " + - "all messages related to the transaction, including failures.", - def = "") String options - ) { + @Arg(name = "options", description = "Optional settings: [silent forcePlayer] Silent suppresses " + + "all messages related to the transaction, including failures. The option 'forcePlayer' " + + "will not use the admin logging of this transaction, but instead will assign it to the " + + "player as if they actually earned the tokens through normal ways. It is not advised to " + + "use 'forcePlayer' since it could be used to cheat the system in some ways.", + def = "") String options + ) { boolean silent = options != null && options.toLowerCase().contains( "silent" ); + boolean forcePlayer = options != null && options.toLowerCase().contains( "forceplayer" ); if ( playerName == null || playerName.isEmpty() ) { if ( !silent ) { - String message = "Prison Tokens: A player's name is required."; - Output.get().logWarn( message ); + coreTokensNameRequiredMsg(sender); +// String message = "Prison Tokens: A player's name is required."; +// Output.get().logWarn( message ); } return; } - DecimalFormat dFmt = new DecimalFormat("#,##0"); +// DecimalFormat dFmt = new DecimalFormat("#,##0"); Player player = getPlayer( playerName ); @@ -1796,15 +1844,24 @@ public void tokensSet( CommandSender sender, // long totalTokens = player.getPlayerCachePlayerData().getTokens(); // player.getPlayerCachePlayerData().removeTokensAdmin( totalTokens ); - - player.getPlayerCachePlayerData().setTokensAdmin( amount ); + if ( forcePlayer ) { + + player.getPlayerCachePlayerData().setTokens( amount ); + } + else { + + player.getPlayerCachePlayerData().setTokensAdmin( amount ); + } if ( !silent ) { - String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); + String message = coreTokensSetAmountMsg( player.getName(), + player.getPlayerCachePlayerData().getTokens() ); - String message = String.format( "&3%s now has &7%s &3tokens.", - player.getName(), tokens ); +// String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); +// +// String message = String.format( "&3%s now has &7%s &3tokens.", +// player.getName(), tokens ); // The person adding the tokens, or console: sender.sendMessage( message ); diff --git a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommandMessages.java b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommandMessages.java index 075bb4722..86253572b 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommandMessages.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommandMessages.java @@ -1,5 +1,7 @@ package tech.mcprison.prison; +import java.text.DecimalFormat; + import tech.mcprison.prison.internal.CommandSender; public class PrisonCommandMessages @@ -10,4 +12,100 @@ protected void coreDebugTestLocaleseMsg( CommandSender sender ) { .setFailSilently() .sendTo( sender ); } + +/* + * + +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + * + */ + + protected void coreTokensNameRequiredMsg( CommandSender sender ) { + Prison.get().getLocaleManager() + .getLocalizable( "core_tokens__name_required" ) + .setFailSilently() + .sendTo( sender ); + } + + protected void coreTokensBalanceCannotViewOthersMsg( CommandSender sender ) { + Prison.get().getLocaleManager() + .getLocalizable( "core_tokens__cannot_view_others_balances" ) + .setFailSilently() + .sendTo( sender ); + } + + protected void coreTokensBalanceViewMsg( CommandSender sender, String name, long tokens ) { + + DecimalFormat dFmt = new DecimalFormat("#,##0"); + String tokensMsg = dFmt.format( tokens ); + + Prison.get().getLocaleManager() + .getLocalizable( "core_tokens__view_balance" ) + .setFailSilently() + .withReplacements( name, tokensMsg ) + .sendTo( sender ); + } + + protected void coreTokensAddInvalidAmountMsg( CommandSender sender, long tokens ) { + + DecimalFormat dFmt = new DecimalFormat("#,##0"); + String tokensMsg = dFmt.format( tokens ); + + Prison.get().getLocaleManager() + .getLocalizable( "core_tokens__add_invalid_amount" ) + .setFailSilently() + .withReplacements( tokensMsg ) + .sendTo( sender ); + } + + protected String coreTokensAddedAmountMsg( + String name, long tokens, long amount ) { + + DecimalFormat dFmt = new DecimalFormat("#,##0"); + String tokensMsg = dFmt.format( tokens ); + String amountMsg = dFmt.format( amount ); + + return Prison.get().getLocaleManager() + .getLocalizable( "core_tokens__added_amount" ) + .setFailSilently() + .withReplacements( name, tokensMsg, amountMsg ) + .localize(); + } + + protected String coreTokensRemovedAmountMsg( + String name, long tokens, long amount ) { + + DecimalFormat dFmt = new DecimalFormat("#,##0"); + String tokensMsg = dFmt.format( tokens ); + String amountMsg = dFmt.format( amount ); + + return Prison.get().getLocaleManager() + .getLocalizable( "core_tokens__removed_amount" ) + .setFailSilently() + .withReplacements( name, tokensMsg, amountMsg ) + .localize(); + } + + protected String coreTokensSetAmountMsg( + String name, long tokens ) { + + DecimalFormat dFmt = new DecimalFormat("#,##0"); + String tokensMsg = dFmt.format( tokens ); + + return Prison.get().getLocaleManager() + .getLocalizable( "core_tokens__set_amount" ) + .setFailSilently() + .withReplacements( name, tokensMsg ) + .localize(); + } + + + } diff --git a/prison-core/src/main/resources/lang/core/de_DE.properties b/prison-core/src/main/resources/lang/core/de_DE.properties index 82d7391cf..495d2e346 100644 --- a/prison-core/src/main/resources/lang/core/de_DE.properties +++ b/prison-core/src/main/resources/lang/core/de_DE.properties @@ -70,7 +70,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -99,6 +99,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] hat einen ungültigen Wert. diff --git a/prison-core/src/main/resources/lang/core/en_GB.properties b/prison-core/src/main/resources/lang/core/en_GB.properties index 0ea0a99ab..812366ca3 100644 --- a/prison-core/src/main/resources/lang/core/en_GB.properties +++ b/prison-core/src/main/resources/lang/core/en_GB.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -96,6 +96,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] has an invalid value. diff --git a/prison-core/src/main/resources/lang/core/en_US.properties b/prison-core/src/main/resources/lang/core/en_US.properties index d0ce2ebf2..84cd1dcc2 100644 --- a/prison-core/src/main/resources/lang/core/en_US.properties +++ b/prison-core/src/main/resources/lang/core/en_US.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -96,6 +96,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + core_prison_utf8_test=Привет! Давай поÑмотрим, работает ли? Test 01 diff --git a/prison-core/src/main/resources/lang/core/es_ES.properties b/prison-core/src/main/resources/lang/core/es_ES.properties index b10152c9c..6e912d7d2 100644 --- a/prison-core/src/main/resources/lang/core/es_ES.properties +++ b/prison-core/src/main/resources/lang/core/es_ES.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -96,6 +96,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] tiene un valor inválido. diff --git a/prison-core/src/main/resources/lang/core/hu_HU.properties b/prison-core/src/main/resources/lang/core/hu_HU.properties index c7cef480b..268375054 100644 --- a/prison-core/src/main/resources/lang/core/hu_HU.properties +++ b/prison-core/src/main/resources/lang/core/hu_HU.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -96,6 +96,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] érvénytelen értékkel rendelkezik. diff --git a/prison-core/src/main/resources/lang/core/it_IT.properties b/prison-core/src/main/resources/lang/core/it_IT.properties index c19dfab68..e3e53bc4c 100644 --- a/prison-core/src/main/resources/lang/core/it_IT.properties +++ b/prison-core/src/main/resources/lang/core/it_IT.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -96,6 +96,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] Ha un valore invalido. diff --git a/prison-core/src/main/resources/lang/core/nl_BE.properties b/prison-core/src/main/resources/lang/core/nl_BE.properties index da203160d..795a35472 100644 --- a/prison-core/src/main/resources/lang/core/nl_BE.properties +++ b/prison-core/src/main/resources/lang/core/nl_BE.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -96,6 +96,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] heeft een onjuiste waarde. diff --git a/prison-core/src/main/resources/lang/core/nl_NL.properties b/prison-core/src/main/resources/lang/core/nl_NL.properties index da203160d..795a35472 100644 --- a/prison-core/src/main/resources/lang/core/nl_NL.properties +++ b/prison-core/src/main/resources/lang/core/nl_NL.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -96,6 +96,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] heeft een onjuiste waarde. diff --git a/prison-core/src/main/resources/lang/core/zh_TW.properties b/prison-core/src/main/resources/lang/core/zh_TW.properties index 4b8b68c51..eafec4865 100644 --- a/prison-core/src/main/resources/lang/core/zh_TW.properties +++ b/prison-core/src/main/resources/lang/core/zh_TW.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=2 +messages__version=3 messages__auto_refresh=true @@ -96,6 +96,15 @@ core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_tokens__name_required=Prison Tokens=A player's name is required when used from console. +core_tokens__cannot_view_others_balances=Prison Tokens: You do not have permission to view other player's balances. +core_tokens__view_balance=&3%1 has %2 tokens. +core_tokens__add_invalid_amount=Prison Tokens: Invalid amount: '%1'. Must be greater than zero. +core_tokens__added_amount=&3%1 now has &7%2 &3tokens after adding &7%3&3. +core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. +core_tokens__set_amount=&3%1 now has &7%2 &3tokens. + + includeError=[%1] 有一個無效值 excludeError=[%1] 有一個無效值 cantAsConsole=您ä¸èƒ½ä½œç‚ºæŽ§åˆ¶å°åŸ·è¡Œæ­¤æ“作 From fcb3ece74fda01267fbc7d5583e2f1a61741b9ff Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 24 Feb 2022 01:56:29 -0500 Subject: [PATCH 119/297] Extracted the BlockBreakPriority enum to be an object on its own. Added BLOCKEVENT and added information on what the various priorities should do. This is in preperation to refactoring how evnts are processed. --- docs/changelog_v3.3.x.md | 8 ++- .../prison/spigot/SpigotListener.java | 2 +- .../prison/spigot/SpigotPlatform.java | 2 +- .../events/AutoManagerBlockBreakEvents.java | 2 +- .../events/AutoManagerCrazyEnchants.java | 2 +- .../events/AutoManagerPrisonEnchants.java | 2 +- ...nagerPrisonsExplosiveBlockBreakEvents.java | 2 +- .../events/AutoManagerTokenEnchant.java | 2 +- .../events/AutoManagerZenchantments.java | 2 +- .../spigot/block/BlockBreakPriority.java | 51 +++++++++++++++++++ .../block/OnBlockBreakEventListener.java | 30 ----------- 11 files changed, 66 insertions(+), 39 deletions(-) create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/BlockBreakPriority.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 6be3bc029..5a8854682 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,9 +13,12 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8e 2022-02-23 +# 3.3.0-alpha.8e 2022-02-24 +* **Extracted the BlockBreakPriority enum to be an object on its own.** +Added BLOCKEVENT and added information on what the various priorities should do. This is in preparation to refactoring how events are processed. + * **Prison tokens: externalize the messages related to the admin tokens commands.** @@ -23,6 +26,9 @@ These build logs represent the work that has been going on within prison. * **For the admin commands for tokens, added an option to be able to suppress the messages.** +* **v3.3.0-alpha.8f 2022-02-23** + + * **The creation of a new sellall module which will eventually contain the code to manage multiple shops that will be based upon ranks.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java index 5478ae0f2..7d1be0f33 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java @@ -50,7 +50,7 @@ import tech.mcprison.prison.internal.events.player.PrisonPlayerInteractEvent.Action; import tech.mcprison.prison.internal.events.world.PrisonWorldLoadEvent; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.compat.Compatibility; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; 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 acb3773dc..c30f93c92 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 @@ -97,7 +97,7 @@ import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerPrisonsExplosiveBlockBreakEvents; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerTokenEnchant; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerZenchantments; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.commands.PrisonSpigotSellAllCommands; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; import tech.mcprison.prison.spigot.game.SpigotCommandSender; 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 f9b2d53e2..e423b1dd0 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 @@ -14,8 +14,8 @@ import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; import tech.mcprison.prison.spigot.game.SpigotHandlerList; 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 c81ae901c..9fc8e773b 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 @@ -14,7 +14,7 @@ import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.game.SpigotHandlerList; public class AutoManagerCrazyEnchants 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 3dba79a87..42bd413bf 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 @@ -14,8 +14,8 @@ import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; import tech.mcprison.prison.spigot.game.SpigotHandlerList; public class AutoManagerPrisonEnchants 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 41133d4b0..d4a1d2123 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 @@ -14,8 +14,8 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.api.ExplosiveBlockBreakEvent; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; import tech.mcprison.prison.spigot.game.SpigotHandlerList; public class AutoManagerPrisonsExplosiveBlockBreakEvents 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 a9cc01921..7347a60e1 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 @@ -15,7 +15,7 @@ import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.game.SpigotHandlerList; public class AutoManagerTokenEnchant 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 1528a2b1e..3dcc20944 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 @@ -13,8 +13,8 @@ import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener.BlockBreakPriority; import tech.mcprison.prison.spigot.game.SpigotHandlerList; import zedly.zenchantments.BlockShredEvent; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/BlockBreakPriority.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/BlockBreakPriority.java new file mode 100644 index 000000000..0c00a42c1 --- /dev/null +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/BlockBreakPriority.java @@ -0,0 +1,51 @@ +package tech.mcprison.prison.spigot.block; + +/** + *

This BlockBreakPriority sets both the actual priorities of the event, but it also + * is able disable it, or only handle Prison's blockEvents. For priorities + * LOWEST through HIGHEST, this will allow normal processing of the events. + *

+ * + *

DISABLED will prevent the activation of monitoring for the related block events. + *

+ * + *

MONITOR should be minimal interaction, such as only recording the blocks being + * broken and the blocks counted. It cannot change any blocks, process any drops, + * nor can it run any commands through the BlockEvents. + *

+ * + *

BLOCKEVENT will run with a priority of HIGHEST, but will process the same as + * MONITOR with the addition of running the BlockEvents. This will NOT break any + * blocks, or process any drops. + *

+ * + */ +public enum BlockBreakPriority { + + DISABLED, + BLOCKEVENT, + + LOWEST, + LOW, + NORMAL, + HIGH, + HIGHEST, + MONITOR + ; + + public static BlockBreakPriority fromString( String value ) { + BlockBreakPriority results = BlockBreakPriority.DISABLED; + + if ( value != null ) { + + for ( BlockBreakPriority bbPriority : values() ) { + if ( bbPriority.name().equalsIgnoreCase( value )) { + results = bbPriority; + break; + } + } + } + + return results; + } +} \ No newline at end of file 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 527e4ec89..b57718218 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 @@ -90,36 +90,6 @@ public OnBlockBreakEventListener() { } - - public enum BlockBreakPriority { - - DISABLED, - - LOWEST, - LOW, - NORMAL, - HIGH, - HIGHEST, - MONITOR - ; - - public static BlockBreakPriority fromString( String value ) { - BlockBreakPriority results = BlockBreakPriority.LOW; - - if ( value != null ) { - - for ( BlockBreakPriority bbPriority : values() ) { - if ( bbPriority.name().equalsIgnoreCase( value )) { - results = bbPriority; - break; - } - } - } - - return results; - } - } - public void registerAllBlockBreakEvents(SpigotPrison spigotPrison ) { // Only register these event listeners if these are enabled. From 827682643d3c4fecc2aa1584e407779b69ad3925 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 25 Feb 2022 01:07:35 -0500 Subject: [PATCH 120/297] Setting up support for the BLOCKEVENTS on all block break event listeners. Changed around how the listeners are created to simplify and be more accurate in the event states. --- docs/changelog_v3.3.x.md | 6 +- .../autofeatures/AutoFeaturesFileConfig.java | 2 +- .../prison/spigot/SpigotPlatform.java | 18 +- .../api/PrisonMinesBlockBreakEvent.java | 58 ++- .../events/AutoManagerBlockBreakEvents.java | 199 +++++----- .../events/AutoManagerCrazyEnchants.java | 198 +++++----- .../events/AutoManagerPrisonEnchants.java | 207 ++++++----- ...nagerPrisonsExplosiveBlockBreakEvents.java | 206 ++++++----- .../events/AutoManagerTokenEnchant.java | 202 ++++++----- .../events/AutoManagerZenchantments.java | 227 +++++++----- .../spigot/block/BlockBreakPriority.java | 28 +- .../spigot/block/OnBlockBreakEventCore.java | 341 +++++++++--------- 12 files changed, 952 insertions(+), 740 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5a8854682..c566e4c75 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8e 2022-02-24 +# 3.3.0-alpha.8e 2022-02-25 + + +* **Setting up support for the BLOCKEVENTS on all block break event listeners.** +Changed around how the listeners are created to simplify and be more accurate in the event states. * **Extracted the BlockBreakPriority enum to be an object on its own.** 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 b4bdb1d8f..d4eec8a29 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 @@ -122,7 +122,7 @@ public enum AutoFeatures { blockBreakEvents__ReadMe(blockBreakEvents, "Use the following event priorities with the blockBreakEvents: " + - "DISABLED, LOWEST, LOW, NORMAL, HIGH, HIGHEST, MONITOR" ), + "DISABLED, LOWEST, LOW, NORMAL, HIGH, HIGHEST, BLOCKEVENTS, MONITOR" ), 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 c30f93c92..2ce688f97 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 @@ -2186,14 +2186,18 @@ public String dumpEventListenersBlockBreakEvents() { sb.append( "&2. . Prison Internal BlockBreakEvents: " + "tech.mcprison.prison.spigot.SpigotListener\n" ); - sb.append( "&2. . Auto Feature Core: Non-AutoManager: " + - "AutoManagerBlockBreakEvents$OnBlockBreakEventListenerNormal\n" ); - sb.append( "&2. . Auto Feature Core: AutoManager: " + + sb.append( "&2. . Auto Features: " + "AutoManagerBlockBreakEvents$AutoManagerBlockBreakEventListener\n" ); - sb.append( "&2. . Prison MONITOR Events manages block counts, " + - "Mine Sweeper, and zero block conditions.\n" ); - sb.append( "&2. . AutoManager and enchantment event listeners are " + - "identified by their class names.\n" ); + sb.append( "&2. . Prison's multi-block explosions (bombs): " + + "AutoManagerPrisonsExplosiveBlockBreakEvents$AutoManagerExplosiveBlockBreakEventListener\n" ); + + +// sb.append( "&2. . Auto Feature Core: Non-AutoManager: " + +// "AutoManagerBlockBreakEvents$OnBlockBreakEventListenerNormal\n" ); +// sb.append( "&2. . Prison MONITOR Events manages block counts, " + +// "Mine Sweeper, and zero block conditions.\n" ); +// sb.append( "&2. . AutoManager and enchantment event listeners are " + +// "identified by their class names.\n" ); sb.append( "\n" ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java index 1d0124fcb..fce14d27f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java @@ -13,6 +13,7 @@ import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; @@ -98,14 +99,22 @@ public class PrisonMinesBlockBreakEvent private boolean forceAutoSell = false; - private boolean monitor = false; + private BlockBreakPriority bbPriority; + +// @Deprecated +// private boolean monitor = false; +// // replace with BlockBreakPriority +// +// +// // blockEventsOnly was intended to be able to run the block events when +// // the the AutoManager is disabled. But now, as of 2021-11-23, if +// // AutoManager is disabled, then nothing related to auto features, +// // including block events will be active. +// @Deprecated +// private boolean blockEventsOnly = false; +// // replace with BlockBreakPriority bbPriority - // blockEventsOnly was intended to be able to run the block events when - // the the AutoManager is disabled. But now, as of 2021-11-23, if - // AutoManager is disabled, then nothing related to auto features, - // including block events will be active. - private boolean blockEventsOnly = false; // Normally the explosion will ONLY work if the center target block was non-AIR. @@ -120,7 +129,8 @@ public class PrisonMinesBlockBreakEvent public PrisonMinesBlockBreakEvent( Block theBlock, Player player, SpigotBlock spigotBlock, SpigotPlayer spigotPlayer, - boolean monitor, boolean blockEventsOnly, + BlockBreakPriority bbPriority, +// boolean monitor, boolean blockEventsOnly, BlockEventType blockEventType, String triggered) { super( theBlock, player ); @@ -130,8 +140,9 @@ public PrisonMinesBlockBreakEvent( Block theBlock, Player player, this.itemInHand = SpigotCompatibility.getInstance().getPrisonItemInMainHand( player ); - this.monitor = monitor; - this.blockEventsOnly = blockEventsOnly; + this.bbPriority = bbPriority; +// this.monitor = monitor; +// this.blockEventsOnly = blockEventsOnly; this.blockEventType = blockEventType; this.triggered = triggered; @@ -345,20 +356,27 @@ public void setForceAutoSell( boolean forceAutoSell ) { this.forceAutoSell = forceAutoSell; } - public boolean isMonitor() { - return monitor; - } - public void setMonitor( boolean monitor ) { - this.monitor = monitor; + public BlockBreakPriority getBbPriority() { + return bbPriority; } - - public boolean isBlockEventsOnly() { - return blockEventsOnly; - } - public void setBlockEventsOnly( boolean blockEventsOnly ) { - this.blockEventsOnly = blockEventsOnly; + public void setBbPriority( BlockBreakPriority bbPriority ) { + this.bbPriority = bbPriority; } +// public boolean isMonitor() { +// return monitor; +// } +// public void setMonitor( boolean monitor ) { +// this.monitor = monitor; +// } +// +// public boolean isBlockEventsOnly() { +// return blockEventsOnly; +// } +// public void setBlockEventsOnly( boolean blockEventsOnly ) { +// this.blockEventsOnly = blockEventsOnly; +// } + public List getUnprocessedRawBlocks() { return unprocessedRawBlocks; } 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 e423b1dd0..9e4f3c48e 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 @@ -15,7 +15,6 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.block.BlockBreakPriority; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener; import tech.mcprison.prison.spigot.game.SpigotHandlerList; @@ -63,39 +62,42 @@ public class AutoManagerBlockBreakEventListener implements Listener { @EventHandler(priority=EventPriority.NORMAL) - public void onBlockBreak(BlockBreakEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockEventAutoManager( e ); - } - } - - public class OnBlockBreakEventListenerNormal - extends OnBlockBreakEventListener - implements Listener { - - @EventHandler(priority=EventPriority.NORMAL) - public void onBlockBreak(BlockBreakEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockEvent( e ); - } - } - - public class OnBlockBreakEventListenerNormalMonitor - extends OnBlockBreakEventListener - implements Listener { + public void onBlockBreak( BlockBreakEvent e, BlockBreakPriority bbPriority ) { - @EventHandler(priority=EventPriority.MONITOR) - public void onBlockBreak(BlockBreakEvent e) { if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { return; } - genericBlockEventMonitor( e ); + + genericBlockEvent( e, bbPriority ); +// genericBlockEventAutoManager( e ); } } + +// public class OnBlockBreakEventListenerNormal +// extends OnBlockBreakEventListener +// implements Listener { +// +// @EventHandler(priority=EventPriority.NORMAL) +// public void onBlockBreak(BlockBreakEvent e) { +// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockEvent( e ); +// } +// } +// +// public class OnBlockBreakEventListenerNormalMonitor +// extends OnBlockBreakEventListener +// implements Listener { +// +// @EventHandler(priority=EventPriority.MONITOR) +// public void onBlockBreak(BlockBreakEvent e) { +// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockEventMonitor( e ); +// } +// } public void initialize() { @@ -105,78 +107,97 @@ public void initialize() { Output.get().logInfo( "AutoManager: Trying to register BlockBreakEvent" ); String eP = getMessage( AutoFeatures.blockBreakEventPriority ); - BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); - if ( eventPriority != BlockBreakPriority.DISABLED ) { + if ( bbPriority != BlockBreakPriority.DISABLED ) { - EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); + SpigotPrison prison = SpigotPrison.getInstance(); + PluginManager pm = Bukkit.getServer().getPluginManager(); + EventPriority ePriority = bbPriority.getBukkitEventPriority(); + + AutoManagerBlockBreakEventListener autoManagerlListener = + new AutoManagerBlockBreakEventListener(); + + + pm.registerEvent(BlockBreakEvent.class, autoManagerlListener, ePriority, + new EventExecutor() { + public void execute(Listener l, Event e) { + if ( l instanceof AutoManagerBlockBreakEventListener && + e instanceof BlockBreakEvent ) { + + ((AutoManagerBlockBreakEventListener)l) + .onBlockBreak( (BlockBreakEvent)e, bbPriority ); + } + } + }, + prison); + + prison.getRegisteredBlockListeners().add( autoManagerlListener ); - OnBlockBreakEventListenerNormalMonitor normalListenerMonitor = - new OnBlockBreakEventListenerNormalMonitor(); +// OnBlockBreakEventListenerNormalMonitor normalListenerMonitor = +// new OnBlockBreakEventListenerNormalMonitor(); - SpigotPrison prison = SpigotPrison.getInstance(); - PluginManager pm = Bukkit.getServer().getPluginManager(); - if ( eventPriority != BlockBreakPriority.MONITOR ) { +// if ( eventPriority != BlockBreakPriority.MONITOR ) { +// +// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { +// +// AutoManagerBlockBreakEventListener autoManagerlListener = +// new AutoManagerBlockBreakEventListener(); +// +// pm.registerEvent(BlockBreakEvent.class, autoManagerlListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// if ( l instanceof AutoManagerBlockBreakEventListener && +// e instanceof BlockBreakEvent ) { +// ((AutoManagerBlockBreakEventListener)l) +// .onBlockBreak((BlockBreakEvent)e); +// } +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( autoManagerlListener ); +// } +// else if ( isBoolean( AutoFeatures.normalDrop ) ) { +// +// OnBlockBreakEventListenerNormal normalListener = +// new OnBlockBreakEventListenerNormal(); +// +// pm.registerEvent(BlockBreakEvent.class, normalListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// if ( l instanceof OnBlockBreakEventListenerNormal && +// e instanceof BlockBreakEvent ) { +// ((OnBlockBreakEventListenerNormal)l) +// .onBlockBreak((BlockBreakEvent)e); +// } +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListener ); +// } - if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { - - AutoManagerBlockBreakEventListener autoManagerlListener = - new AutoManagerBlockBreakEventListener(); - - pm.registerEvent(BlockBreakEvent.class, autoManagerlListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - if ( l instanceof AutoManagerBlockBreakEventListener && - e instanceof BlockBreakEvent ) { - ((AutoManagerBlockBreakEventListener)l) - .onBlockBreak((BlockBreakEvent)e); - } - } - }, - prison); - prison.getRegisteredBlockListeners().add( autoManagerlListener ); - } - else if ( isBoolean( AutoFeatures.normalDrop ) ) { - - OnBlockBreakEventListenerNormal normalListener = - new OnBlockBreakEventListenerNormal(); - - pm.registerEvent(BlockBreakEvent.class, normalListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - if ( l instanceof OnBlockBreakEventListenerNormal && - e instanceof BlockBreakEvent ) { - ((OnBlockBreakEventListenerNormal)l) - .onBlockBreak((BlockBreakEvent)e); - } - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListener ); - } - - } - else { - - pm.registerEvent(BlockBreakEvent.class, normalListenerMonitor, EventPriority.MONITOR, - new EventExecutor() { - public void execute(Listener l, Event e) { - if ( l instanceof OnBlockBreakEventListenerNormalMonitor && - e instanceof BlockBreakEvent ) { - ((OnBlockBreakEventListenerNormalMonitor)l) - .onBlockBreak((BlockBreakEvent)e); - } - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListenerMonitor ); - } +// } +// else { +// +// pm.registerEvent(BlockBreakEvent.class, normalListenerMonitor, EventPriority.MONITOR, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// if ( l instanceof OnBlockBreakEventListenerNormalMonitor && +// e instanceof BlockBreakEvent ) { +// ((OnBlockBreakEventListenerNormalMonitor)l) +// .onBlockBreak((BlockBreakEvent)e); +// } +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); +// } } 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 9fc8e773b..ab5b53f0b 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 @@ -38,48 +38,52 @@ public class AutoManagerBlastUseEventListener implements Listener { @EventHandler(priority=EventPriority.NORMAL) - public void onCrazyEnchantsBlockExplode(BlastUseEvent e) { + public void onCrazyEnchantsBlockExplode( BlastUseEvent e, BlockBreakPriority bbPriority) { + if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ) { return; } - genericBlockExplodeEventAutoManager( e ); + + genericBlastUseEvent( e, bbPriority ); } } - public class OnBlockBreakBlastUseEventListener - extends AutoManagerCrazyEnchants - implements Listener { - - @EventHandler(priority=EventPriority.NORMAL) - public void onCrazyEnchantsBlockExplode(BlastUseEvent e) { - if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockExplodeEvent( e ); - } - } - - public class OnBlockBreakBlastUseEventListenerMonitor - extends AutoManagerCrazyEnchants - implements Listener { - - @EventHandler(priority=EventPriority.MONITOR) - public void onCrazyEnchantsBlockExplode(BlastUseEvent e) { - if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockExplodeEventMonitor( e ); - } - } +// public class OnBlockBreakBlastUseEventListener +// extends AutoManagerCrazyEnchants +// implements Listener { +// +// @EventHandler(priority=EventPriority.NORMAL) +// public void onCrazyEnchantsBlockExplode(BlastUseEvent e) { +// if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockExplodeEvent( e ); +// } +// } +// +// public class OnBlockBreakBlastUseEventListenerMonitor +// extends AutoManagerCrazyEnchants +// implements Listener { +// +// @EventHandler(priority=EventPriority.MONITOR) +// public void onCrazyEnchantsBlockExplode(BlastUseEvent e) { +// if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockExplodeEventMonitor( e ); +// } +// } @Override public void initialize() { String eP = getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority ); - boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); - if ( !isEventEnabled ) { +// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + + if ( bbPriority == BlockBreakPriority.DISABLED ) { return; } @@ -92,69 +96,91 @@ public void initialize() { Output.get().logInfo( "AutoManager: Trying to register CrazyEnchants" ); - BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); - if ( eventPriority != BlockBreakPriority.DISABLED ) { - - EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); - - - OnBlockBreakBlastUseEventListenerMonitor normalListenerMonitor = - new OnBlockBreakBlastUseEventListenerMonitor(); - - - SpigotPrison prison = SpigotPrison.getInstance(); - - PluginManager pm = Bukkit.getServer().getPluginManager(); - - if ( eventPriority != BlockBreakPriority.MONITOR ) { + SpigotPrison prison = SpigotPrison.getInstance(); + PluginManager pm = Bukkit.getServer().getPluginManager(); + EventPriority ePriority = bbPriority.getBukkitEventPriority(); + + + AutoManagerBlastUseEventListener autoManagerlListener = + new AutoManagerBlastUseEventListener(); + + pm.registerEvent(BlastUseEvent.class, autoManagerlListener, ePriority, + new EventExecutor() { + public void execute(Listener l, Event e) { - if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { - - AutoManagerBlastUseEventListener autoManagerlListener = - new AutoManagerBlastUseEventListener(); - - pm.registerEvent(BlastUseEvent.class, autoManagerlListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((AutoManagerBlastUseEventListener)l) - .onCrazyEnchantsBlockExplode((BlastUseEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( autoManagerlListener ); - } - else if ( isBoolean( AutoFeatures.normalDrop ) ) { - - OnBlockBreakBlastUseEventListener normalListener = - new OnBlockBreakBlastUseEventListener(); - - pm.registerEvent(BlastUseEvent.class, normalListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((OnBlockBreakBlastUseEventListener)l) - .onCrazyEnchantsBlockExplode((BlastUseEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListener ); - } + BlastUseEvent buEvent = (BlastUseEvent) e; + ((AutoManagerBlastUseEventListener)l) + .onCrazyEnchantsBlockExplode( buEvent, bbPriority ); } - else { + }, + prison); + prison.getRegisteredBlockListeners().add( autoManagerlListener ); + + + + + + +// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); + +// if ( eventPriority != BlockBreakPriority.DISABLED ) { +// +// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); +// +// +// OnBlockBreakBlastUseEventListenerMonitor normalListenerMonitor = +// new OnBlockBreakBlastUseEventListenerMonitor(); + +// if ( eventPriority != BlockBreakPriority.MONITOR ) { - pm.registerEvent(BlastUseEvent.class, normalListenerMonitor, EventPriority.MONITOR, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((OnBlockBreakBlastUseEventListenerMonitor)l) - .onCrazyEnchantsBlockExplode((BlastUseEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListenerMonitor ); - } +// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { +// +// AutoManagerBlastUseEventListener autoManagerlListener = +// new AutoManagerBlastUseEventListener(); +// +// pm.registerEvent(BlastUseEvent.class, autoManagerlListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((AutoManagerBlastUseEventListener)l) +// .onCrazyEnchantsBlockExplode((BlastUseEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( autoManagerlListener ); +// } +// else if ( isBoolean( AutoFeatures.normalDrop ) ) { +// +// OnBlockBreakBlastUseEventListener normalListener = +// new OnBlockBreakBlastUseEventListener(); +// +// pm.registerEvent(BlastUseEvent.class, normalListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((OnBlockBreakBlastUseEventListener)l) +// .onCrazyEnchantsBlockExplode((BlastUseEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListener ); +// } + +// } +// else { +// +// pm.registerEvent(BlastUseEvent.class, normalListenerMonitor, EventPriority.MONITOR, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((OnBlockBreakBlastUseEventListenerMonitor)l) +// .onCrazyEnchantsBlockExplode((BlastUseEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); +// } - } +// } // The following is paper code: // var executor = EventExecutor 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 42bd413bf..adb8a69fe 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 @@ -15,7 +15,6 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.block.BlockBreakPriority; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener; import tech.mcprison.prison.spigot.game.SpigotHandlerList; public class AutoManagerPrisonEnchants @@ -33,13 +32,17 @@ public void registerEvents() { } - + /** + * For Pulsi_'s PrisonEnchants plugin: + * + */ public class AutoManagerPEExplosiveEventListener extends AutoManagerBlockBreakEvents implements Listener { @EventHandler(priority=EventPriority.NORMAL) - public void onPrisonEnchantsExplosiveEvent(PEExplosionEvent e) { + public void onPrisonEnchantsExplosiveEvent( PEExplosionEvent e, BlockBreakPriority bbPriority ) { + if ( isDisabled( e.getBlockBroken().getLocation().getWorld().getName() ) ) { return; } @@ -47,43 +50,47 @@ public void onPrisonEnchantsExplosiveEvent(PEExplosionEvent e) { // me.pulsi_.prisonenchants.events.PEExplosionEvent - genericBlockExplodeEventAutoManager( e ); - } - } - - public class OnBlockBreakPEExplosiveEventListener - extends OnBlockBreakEventListener - implements Listener { - - @EventHandler(priority=EventPriority.NORMAL) - public void onPrisonEnchantsExplosiveEvent(PEExplosionEvent e) { - if ( isDisabled( e.getBlockBroken().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockExplodeEvent( e ); + genericExplosiveEvent( e, bbPriority ); + +// genericBlockExplodeEventAutoManager( e ); } } - public class OnBlockBreakPEExplosiveEventListenerMonitor - extends OnBlockBreakEventListener - implements Listener { - - @EventHandler(priority=EventPriority.MONITOR) - public void onPrisonEnchantsExplosiveEvent(PEExplosionEvent e) { - if ( isDisabled( e.getBlockBroken().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockExplodeEventMonitor( e ); - } - } +// public class OnBlockBreakPEExplosiveEventListener +// extends OnBlockBreakEventListener +// implements Listener { +// +// @EventHandler(priority=EventPriority.NORMAL) +// public void onPrisonEnchantsExplosiveEvent(PEExplosionEvent e) { +// if ( isDisabled( e.getBlockBroken().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockExplodeEvent( e ); +// } +// } +// +// public class OnBlockBreakPEExplosiveEventListenerMonitor +// extends OnBlockBreakEventListener +// implements Listener { +// +// @EventHandler(priority=EventPriority.MONITOR) +// public void onPrisonEnchantsExplosiveEvent(PEExplosionEvent e) { +// if ( isDisabled( e.getBlockBroken().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockExplodeEventMonitor( e ); +// } +// } @Override public void initialize() { String eP = getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority ); - boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + +// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( !isEventEnabled ) { + if ( bbPriority == BlockBreakPriority.DISABLED ) { return; } @@ -97,72 +104,96 @@ public void initialize() { Output.get().logInfo( "AutoManager: Trying to register Pulsi_'s PrisonEnchants" ); - BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); - if ( eventPriority != BlockBreakPriority.DISABLED ) { - - EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); - - - OnBlockBreakPEExplosiveEventListenerMonitor normalListenerMonitor = - new OnBlockBreakPEExplosiveEventListenerMonitor(); - + + SpigotPrison prison = SpigotPrison.getInstance(); + PluginManager pm = Bukkit.getServer().getPluginManager(); + EventPriority ePriority = bbPriority.getBukkitEventPriority(); + + AutoManagerPEExplosiveEventListener autoManagerlListener = + new AutoManagerPEExplosiveEventListener(); + + pm.registerEvent(PEExplosionEvent.class, autoManagerlListener, ePriority, + new EventExecutor() { + public void execute(Listener l, Event e) { + + PEExplosionEvent peeEvent = (PEExplosionEvent) e; + + ((AutoManagerPEExplosiveEventListener)l) + .onPrisonEnchantsExplosiveEvent( peeEvent, bbPriority ); + } + }, + prison); + prison.getRegisteredBlockListeners().add( autoManagerlListener ); + + + + + +// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); +// +// if ( eventPriority != BlockBreakPriority.DISABLED ) { +// +// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); +// +// +// OnBlockBreakPEExplosiveEventListenerMonitor normalListenerMonitor = +// new OnBlockBreakPEExplosiveEventListenerMonitor(); +// - SpigotPrison prison = SpigotPrison.getInstance(); - PluginManager pm = Bukkit.getServer().getPluginManager(); - if ( eventPriority != BlockBreakPriority.MONITOR ) { +// if ( eventPriority != BlockBreakPriority.MONITOR ) { +// +// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { +// +// AutoManagerPEExplosiveEventListener autoManagerlListener = +// new AutoManagerPEExplosiveEventListener(); +// +// pm.registerEvent(PEExplosionEvent.class, autoManagerlListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((AutoManagerPEExplosiveEventListener)l) +// .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( autoManagerlListener ); +// } +// else if ( isBoolean( AutoFeatures.normalDrop ) ) { +// +// OnBlockBreakPEExplosiveEventListener normalListener = +// new OnBlockBreakPEExplosiveEventListener(); +// +// pm.registerEvent(PEExplosionEvent.class, normalListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((OnBlockBreakPEExplosiveEventListener)l) +// .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListener ); +// } - if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { - - AutoManagerPEExplosiveEventListener autoManagerlListener = - new AutoManagerPEExplosiveEventListener(); - - pm.registerEvent(PEExplosionEvent.class, autoManagerlListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((AutoManagerPEExplosiveEventListener)l) - .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( autoManagerlListener ); - } - else if ( isBoolean( AutoFeatures.normalDrop ) ) { - - OnBlockBreakPEExplosiveEventListener normalListener = - new OnBlockBreakPEExplosiveEventListener(); - - pm.registerEvent(PEExplosionEvent.class, normalListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((OnBlockBreakPEExplosiveEventListener)l) - .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListener ); - } - - } - else { - - pm.registerEvent(PEExplosionEvent.class, normalListenerMonitor, EventPriority.MONITOR, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((OnBlockBreakPEExplosiveEventListenerMonitor)l) - .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListenerMonitor ); - } +// } +// else { +// +// pm.registerEvent(PEExplosionEvent.class, normalListenerMonitor, EventPriority.MONITOR, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((OnBlockBreakPEExplosiveEventListenerMonitor)l) +// .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); +// } - } +// } } catch ( ClassNotFoundException e ) { 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 d4a1d2123..aa65d1380 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 @@ -15,7 +15,6 @@ import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.api.ExplosiveBlockBreakEvent; import tech.mcprison.prison.spigot.block.BlockBreakPriority; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener; import tech.mcprison.prison.spigot.game.SpigotHandlerList; public class AutoManagerPrisonsExplosiveBlockBreakEvents @@ -40,124 +39,151 @@ public class AutoManagerExplosiveBlockBreakEventListener implements Listener { @EventHandler(priority=EventPriority.NORMAL) - public void onPrisonsExplosiveBlockBreakEvent(ExplosiveBlockBreakEvent e) { + public void onPrisonsExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e, BlockBreakPriority bbPriority ) { + if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { return; } -// me.pulsi_.prisonenchants.events.PEExplosionEvent + genericExplosiveEvent( e, bbPriority ); - genericBlockExplodeEventAutoManager( e ); - } - } - - public class OnBlockBreakExplosiveBlockBreakEventListener - extends OnBlockBreakEventListener - implements Listener { - - @EventHandler(priority=EventPriority.NORMAL) - public void onPrisonExplosiveBlockBreakEvent(ExplosiveBlockBreakEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockExplodeEvent( e ); +// genericBlockExplodeEventAutoManager( e ); } } - public class OnBlockBreakExplosiveBlockBreakEventListenerMonitor - extends OnBlockBreakEventListener - implements Listener { - - @EventHandler(priority=EventPriority.MONITOR) - public void onPrisonExplosiveBlockBreakEventMonitor(ExplosiveBlockBreakEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockExplodeEventMonitor( e ); - } - } +// public class OnBlockBreakExplosiveBlockBreakEventListener +// extends OnBlockBreakEventListener +// implements Listener { +// +// @EventHandler(priority=EventPriority.NORMAL) +// public void onPrisonExplosiveBlockBreakEvent(ExplosiveBlockBreakEvent e) { +// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockExplodeEvent( e ); +// } +// } +// +// public class OnBlockBreakExplosiveBlockBreakEventListenerMonitor +// extends OnBlockBreakEventListener +// implements Listener { +// +// @EventHandler(priority=EventPriority.MONITOR) +// public void onPrisonExplosiveBlockBreakEventMonitor(ExplosiveBlockBreakEvent e) { +// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockExplodeEventMonitor( e ); +// } +// } @Override public void initialize() { String eP = getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority ); - boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + +// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( !isEventEnabled ) { + if ( bbPriority == BlockBreakPriority.DISABLED ) { return; } try { Output.get().logInfo( "AutoManager: Trying to register ExplosiveBlockBreakEvent Listener" ); + + SpigotPrison prison = SpigotPrison.getInstance(); + PluginManager pm = Bukkit.getServer().getPluginManager(); + EventPriority ePriority = bbPriority.getBukkitEventPriority(); - BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); - if ( eventPriority != BlockBreakPriority.DISABLED ) { - - EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); - - - OnBlockBreakExplosiveBlockBreakEventListenerMonitor normalListenerMonitor = - new OnBlockBreakExplosiveBlockBreakEventListenerMonitor(); - - - SpigotPrison prison = SpigotPrison.getInstance(); - - - PluginManager pm = Bukkit.getServer().getPluginManager(); - - if ( eventPriority != BlockBreakPriority.MONITOR ) { + AutoManagerExplosiveBlockBreakEventListener autoManagerlListener = + new AutoManagerExplosiveBlockBreakEventListener(); + + pm.registerEvent(ExplosiveBlockBreakEvent.class, autoManagerlListener, ePriority, + new EventExecutor() { + public void execute(Listener l, Event e) { - if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { - - AutoManagerExplosiveBlockBreakEventListener autoManagerlListener = - new AutoManagerExplosiveBlockBreakEventListener(); - - pm.registerEvent(ExplosiveBlockBreakEvent.class, autoManagerlListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((AutoManagerExplosiveBlockBreakEventListener)l) - .onPrisonsExplosiveBlockBreakEvent((ExplosiveBlockBreakEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( autoManagerlListener ); - } - else if ( isBoolean( AutoFeatures.normalDrop ) ) { - - OnBlockBreakExplosiveBlockBreakEventListener normalListener = - new OnBlockBreakExplosiveBlockBreakEventListener(); - - pm.registerEvent(ExplosiveBlockBreakEvent.class, normalListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((OnBlockBreakExplosiveBlockBreakEventListener)l) - .onPrisonExplosiveBlockBreakEvent((ExplosiveBlockBreakEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListener ); - } + ExplosiveBlockBreakEvent ebbEvent = (ExplosiveBlockBreakEvent) e; + ((AutoManagerExplosiveBlockBreakEventListener)l) + .onPrisonsExplosiveBlockBreakEvent( ebbEvent, bbPriority ); } - else { - - pm.registerEvent(ExplosiveBlockBreakEvent.class, normalListenerMonitor, EventPriority.MONITOR, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((OnBlockBreakExplosiveBlockBreakEventListenerMonitor)l) - .onPrisonExplosiveBlockBreakEventMonitor((ExplosiveBlockBreakEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListenerMonitor ); + }, + prison); + prison.getRegisteredBlockListeners().add( autoManagerlListener ); + + + + + + +// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); +// +// if ( eventPriority != BlockBreakPriority.DISABLED ) { +// +// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); +// +// +// OnBlockBreakExplosiveBlockBreakEventListenerMonitor normalListenerMonitor = +// new OnBlockBreakExplosiveBlockBreakEventListenerMonitor(); +// +// +// +// +// +// if ( eventPriority != BlockBreakPriority.MONITOR ) { +// +// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { +// +// AutoManagerExplosiveBlockBreakEventListener autoManagerlListener = +// new AutoManagerExplosiveBlockBreakEventListener(); +// +// pm.registerEvent(ExplosiveBlockBreakEvent.class, autoManagerlListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((AutoManagerExplosiveBlockBreakEventListener)l) +// .onPrisonsExplosiveBlockBreakEvent((ExplosiveBlockBreakEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( autoManagerlListener ); +// } +// else if ( isBoolean( AutoFeatures.normalDrop ) ) { +// +// OnBlockBreakExplosiveBlockBreakEventListener normalListener = +// new OnBlockBreakExplosiveBlockBreakEventListener(); +// +// pm.registerEvent(ExplosiveBlockBreakEvent.class, normalListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((OnBlockBreakExplosiveBlockBreakEventListener)l) +// .onPrisonExplosiveBlockBreakEvent((ExplosiveBlockBreakEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListener ); +// } - } +// } +// else { +// +// pm.registerEvent(ExplosiveBlockBreakEvent.class, normalListenerMonitor, EventPriority.MONITOR, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((OnBlockBreakExplosiveBlockBreakEventListenerMonitor)l) +// .onPrisonExplosiveBlockBreakEventMonitor((ExplosiveBlockBreakEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); +// +// } - } +// } } catch ( Exception e ) { 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 7347a60e1..60543dedb 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 @@ -40,47 +40,51 @@ public class AutoManagerTokenEnchantEventListener implements Listener { @EventHandler(priority=EventPriority.LOW) - public void onTEBlockExplode(TEBlockExplodeEvent e) { + public void onTEBlockExplode( TEBlockExplodeEvent e, BlockBreakPriority bbPriority) { if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { return; } - genericBlockExplodeEventAutoManager( e ); + + genericBlockExplodeEvent( e, bbPriority ); +// genericBlockExplodeEventAutoManager( e ); } } - public class OnBlockBreakEventTokenEnchantEventListener - extends AutoManagerTokenEnchant - implements Listener { - - @EventHandler(priority=EventPriority.NORMAL) - public void onTEBlockExplode(TEBlockExplodeEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockExplodeEvent( e ); - } - } - - public class OnBlockBreakEventTokenEnchantEventListenerMonitor - extends AutoManagerTokenEnchant - implements Listener { - - @EventHandler(priority=EventPriority.MONITOR) - public void onTEBlockExplode(TEBlockExplodeEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockExplodeEventMonitor( e ); - } - } +// public class OnBlockBreakEventTokenEnchantEventListener +// extends AutoManagerTokenEnchant +// implements Listener { +// +// @EventHandler(priority=EventPriority.NORMAL) +// public void onTEBlockExplode(TEBlockExplodeEvent e) { +// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockExplodeEvent( e ); +// } +// } +// +// public class OnBlockBreakEventTokenEnchantEventListenerMonitor +// extends AutoManagerTokenEnchant +// implements Listener { +// +// @EventHandler(priority=EventPriority.MONITOR) +// public void onTEBlockExplode(TEBlockExplodeEvent e) { +// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockExplodeEventMonitor( e ); +// } +// } @Override public void initialize() { String eP = getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority ); - boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + +// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( !isEventEnabled ) { + if ( bbPriority == BlockBreakPriority.DISABLED ) { return; } @@ -93,70 +97,90 @@ public void initialize() { Output.get().logInfo( "AutoManager: Trying to register TokenEnchant" ); + SpigotPrison prison = SpigotPrison.getInstance(); + PluginManager pm = Bukkit.getServer().getPluginManager(); + EventPriority ePriority = bbPriority.getBukkitEventPriority(); - BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); - if ( eventPriority != BlockBreakPriority.DISABLED ) { - - EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); - - - OnBlockBreakEventTokenEnchantEventListenerMonitor normalListenerMonitor = - new OnBlockBreakEventTokenEnchantEventListenerMonitor(); - - - SpigotPrison prison = SpigotPrison.getInstance(); - - PluginManager pm = Bukkit.getServer().getPluginManager(); - - if ( eventPriority != BlockBreakPriority.MONITOR ) { - - if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { - - AutoManagerTokenEnchantEventListener autoManagerlListener = - new AutoManagerTokenEnchantEventListener(); - - pm.registerEvent(TEBlockExplodeEvent.class, autoManagerlListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((AutoManagerTokenEnchantEventListener)l) - .onTEBlockExplode((TEBlockExplodeEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( autoManagerlListener ); - } - else if ( isBoolean( AutoFeatures.normalDrop ) ) { - - OnBlockBreakEventTokenEnchantEventListener normalListener = - new OnBlockBreakEventTokenEnchantEventListener(); - - pm.registerEvent(TEBlockExplodeEvent.class, normalListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((OnBlockBreakEventTokenEnchantEventListener)l) - .onTEBlockExplode((TEBlockExplodeEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListener ); - } - - } - else { - - pm.registerEvent(TEBlockExplodeEvent.class, normalListenerMonitor, EventPriority.MONITOR, - new EventExecutor() { - public void execute(Listener l, Event e) { - ((OnBlockBreakEventTokenEnchantEventListenerMonitor)l) - .onTEBlockExplode((TEBlockExplodeEvent)e); - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListenerMonitor ); + AutoManagerTokenEnchantEventListener autoManagerlListener = + new AutoManagerTokenEnchantEventListener(); + + pm.registerEvent(TEBlockExplodeEvent.class, autoManagerlListener, ePriority, + new EventExecutor() { + public void execute(Listener l, Event e) { + ((AutoManagerTokenEnchantEventListener)l) + .onTEBlockExplode( (TEBlockExplodeEvent)e, bbPriority ); } + }, + prison); + prison.getRegisteredBlockListeners().add( autoManagerlListener ); + + + + + + + +// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); +// +// if ( eventPriority != BlockBreakPriority.DISABLED ) { +// +// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); +// +// +// OnBlockBreakEventTokenEnchantEventListenerMonitor normalListenerMonitor = +// new OnBlockBreakEventTokenEnchantEventListenerMonitor(); +// +// +// +// if ( eventPriority != BlockBreakPriority.MONITOR ) { +// +// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { +// +// AutoManagerTokenEnchantEventListener autoManagerlListener = +// new AutoManagerTokenEnchantEventListener(); +// +// pm.registerEvent(TEBlockExplodeEvent.class, autoManagerlListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((AutoManagerTokenEnchantEventListener)l) +// .onTEBlockExplode((TEBlockExplodeEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( autoManagerlListener ); +// } +// else if ( isBoolean( AutoFeatures.normalDrop ) ) { +// +// OnBlockBreakEventTokenEnchantEventListener normalListener = +// new OnBlockBreakEventTokenEnchantEventListener(); +// +// pm.registerEvent(TEBlockExplodeEvent.class, normalListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((OnBlockBreakEventTokenEnchantEventListener)l) +// .onTEBlockExplode((TEBlockExplodeEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListener ); +// } + +// } +// else { +// +// pm.registerEvent(TEBlockExplodeEvent.class, normalListenerMonitor, EventPriority.MONITOR, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// ((OnBlockBreakEventTokenEnchantEventListenerMonitor)l) +// .onTEBlockExplode((TEBlockExplodeEvent)e); +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); +// } - } +// } } catch ( ClassNotFoundException e ) { 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 3dcc20944..fc13eaaec 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 @@ -14,7 +14,6 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.block.BlockBreakPriority; -import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener; import tech.mcprison.prison.spigot.game.SpigotHandlerList; import zedly.zenchantments.BlockShredEvent; @@ -39,48 +38,54 @@ public class AutoManagerBlockShredEventListener implements Listener { @EventHandler(priority=EventPriority.NORMAL) - public void onBlockShredBreak(BlockShredEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { + public void onBlockShredBreak( BlockShredEvent e, BlockBreakPriority bbPriority ) { + + if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { return; } - genericBlockEventAutoManager( e ); + + genericBlockEvent( e, bbPriority ); + +// genericBlockEventAutoManager( e ); } } - public class OnBlockBreakBlockShredEventListener - extends OnBlockBreakEventListener - implements Listener { - - @EventHandler(priority=EventPriority.NORMAL) - public void onBlockShredBreak(BlockShredEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockEvent( e ); - } - } - - public class OnBlockBreakBlockShredEventListenerMonitor - extends OnBlockBreakEventListener - implements Listener { - - @EventHandler(priority=EventPriority.MONITOR) - public void onBlockShredBreakMonitor(BlockShredEvent e) { - if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { - return; - } - genericBlockEventMonitor( e ); - } - } +// public class OnBlockBreakBlockShredEventListener +// extends OnBlockBreakEventListener +// implements Listener { +// +// @EventHandler(priority=EventPriority.NORMAL) +// public void onBlockShredBreak(BlockShredEvent e) { +// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockEvent( e ); +// } +// } +// +// public class OnBlockBreakBlockShredEventListenerMonitor +// extends OnBlockBreakEventListener +// implements Listener { +// +// @EventHandler(priority=EventPriority.MONITOR) +// public void onBlockShredBreakMonitor(BlockShredEvent e) { +// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { +// return; +// } +// genericBlockEventMonitor( e ); +// } +// } @Override public void initialize() { String eP = getMessage( AutoFeatures.ZenchantmentsBlockShredEventPriority ); - boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + +// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( !isEventEnabled ) { + if ( bbPriority == BlockBreakPriority.DISABLED ) { return; } @@ -93,85 +98,109 @@ public void initialize() { Output.get().logInfo( "AutoManager: Trying to register Zenchantments" ); + SpigotPrison prison = SpigotPrison.getInstance(); + PluginManager pm = Bukkit.getServer().getPluginManager(); + EventPriority ePriority = bbPriority.getBukkitEventPriority(); - BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); + AutoManagerBlockShredEventListener autoManagerlListener = + new AutoManagerBlockShredEventListener(); - if ( eventPriority != BlockBreakPriority.DISABLED ) { - - EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); + pm.registerEvent(BlockShredEvent.class, autoManagerlListener, ePriority, + new EventExecutor() { + public void execute(Listener l, Event e) { + if ( l instanceof AutoManagerBlockShredEventListener && + e instanceof BlockShredEvent ) { + + AutoManagerBlockShredEventListener lmon = + (AutoManagerBlockShredEventListener) l; + + BlockShredEvent event = (BlockShredEvent) e; + lmon.onBlockShredBreak( event, bbPriority ); + } + } + }, + prison); + prison.getRegisteredBlockListeners().add( autoManagerlListener ); + + + + + +// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); + +// if ( eventPriority != BlockBreakPriority.DISABLED ) { +// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); - OnBlockBreakBlockShredEventListenerMonitor normalListenerMonitor = - new OnBlockBreakBlockShredEventListenerMonitor(); +// OnBlockBreakBlockShredEventListenerMonitor normalListenerMonitor = +// new OnBlockBreakBlockShredEventListenerMonitor(); - SpigotPrison prison = SpigotPrison.getInstance(); - PluginManager pm = Bukkit.getServer().getPluginManager(); - if ( eventPriority != BlockBreakPriority.MONITOR ) { +// if ( eventPriority != BlockBreakPriority.MONITOR ) { - if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { - - AutoManagerBlockShredEventListener autoManagerlListener = - new AutoManagerBlockShredEventListener(); - - pm.registerEvent(BlockShredEvent.class, autoManagerlListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && - e instanceof BlockShredEvent ) { - OnBlockBreakBlockShredEventListenerMonitor lmon = - (OnBlockBreakBlockShredEventListenerMonitor) l; - BlockShredEvent event = (BlockShredEvent) e; - lmon.onBlockShredBreakMonitor( event ); - } - } - }, - prison); - prison.getRegisteredBlockListeners().add( autoManagerlListener ); - } - else if ( isBoolean( AutoFeatures.normalDrop ) ) { - - OnBlockBreakBlockShredEventListener normalListener = - new OnBlockBreakBlockShredEventListener(); - - pm.registerEvent(BlockShredEvent.class, normalListener, ePriority, - new EventExecutor() { - public void execute(Listener l, Event e) { - if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && - e instanceof BlockShredEvent ) { - OnBlockBreakBlockShredEventListenerMonitor lmon = - (OnBlockBreakBlockShredEventListenerMonitor) l; - BlockShredEvent event = (BlockShredEvent) e; - lmon.onBlockShredBreakMonitor( event ); - } - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListener ); - } - - } - else { +// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { +// +// AutoManagerBlockShredEventListener autoManagerlListener = +// new AutoManagerBlockShredEventListener(); +// +// pm.registerEvent(BlockShredEvent.class, autoManagerlListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && +// e instanceof BlockShredEvent ) { +// OnBlockBreakBlockShredEventListenerMonitor lmon = +// (OnBlockBreakBlockShredEventListenerMonitor) l; +// BlockShredEvent event = (BlockShredEvent) e; +// lmon.onBlockShredBreakMonitor( event ); +// } +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( autoManagerlListener ); +// } +// else if ( isBoolean( AutoFeatures.normalDrop ) ) { +// +// OnBlockBreakBlockShredEventListener normalListener = +// new OnBlockBreakBlockShredEventListener(); +// +// pm.registerEvent(BlockShredEvent.class, normalListener, ePriority, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && +// e instanceof BlockShredEvent ) { +// OnBlockBreakBlockShredEventListenerMonitor lmon = +// (OnBlockBreakBlockShredEventListenerMonitor) l; +// BlockShredEvent event = (BlockShredEvent) e; +// lmon.onBlockShredBreakMonitor( event ); +// } +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListener ); +// } - pm.registerEvent(BlockShredEvent.class, normalListenerMonitor, EventPriority.MONITOR, - new EventExecutor() { - public void execute(Listener l, Event e) { - if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && - e instanceof BlockShredEvent ) { - OnBlockBreakBlockShredEventListenerMonitor lmon = - (OnBlockBreakBlockShredEventListenerMonitor) l; - BlockShredEvent event = (BlockShredEvent) e; - lmon.onBlockShredBreakMonitor( event ); - } - } - }, - prison); - prison.getRegisteredBlockListeners().add( normalListenerMonitor ); - } +// } +// else { +// +// pm.registerEvent(BlockShredEvent.class, normalListenerMonitor, EventPriority.MONITOR, +// new EventExecutor() { +// public void execute(Listener l, Event e) { +// if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && +// e instanceof BlockShredEvent ) { +// OnBlockBreakBlockShredEventListenerMonitor lmon = +// (OnBlockBreakBlockShredEventListenerMonitor) l; +// BlockShredEvent event = (BlockShredEvent) e; +// lmon.onBlockShredBreakMonitor( event ); +// } +// } +// }, +// prison); +// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); +// } - } +// } } catch ( ClassNotFoundException e ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/BlockBreakPriority.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/BlockBreakPriority.java index 0c00a42c1..8d0df0060 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/BlockBreakPriority.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/BlockBreakPriority.java @@ -1,5 +1,7 @@ package tech.mcprison.prison.spigot.block; +import org.bukkit.event.EventPriority; + /** *

This BlockBreakPriority sets both the actual priorities of the event, but it also * is able disable it, or only handle Prison's blockEvents. For priorities @@ -22,17 +24,23 @@ */ public enum BlockBreakPriority { - DISABLED, - BLOCKEVENT, + DISABLED( null ), + BLOCKEVENTS( EventPriority.HIGHEST ), - LOWEST, - LOW, - NORMAL, - HIGH, - HIGHEST, - MONITOR + LOWEST( EventPriority.LOWEST ), + LOW( EventPriority.LOW ), + NORMAL( EventPriority.NORMAL ), + HIGH( EventPriority.HIGH ), + HIGHEST( EventPriority.HIGHEST ), + MONITOR( EventPriority.MONITOR ) ; + private final EventPriority bukkitEventPriority; + private BlockBreakPriority( EventPriority bukkitEventPriority ) { + + this.bukkitEventPriority = bukkitEventPriority; + } + public static BlockBreakPriority fromString( String value ) { BlockBreakPriority results = BlockBreakPriority.DISABLED; @@ -48,4 +56,8 @@ public static BlockBreakPriority fromString( String value ) { return results; } + + public EventPriority getBukkitEventPriority() { + return bukkitEventPriority; + } } \ No newline at end of file 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 defc72ba6..a03c50eab 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 @@ -164,119 +164,119 @@ public enum ItemLoreEnablers { - protected void genericBlockEventMonitor( BlockBreakEvent e ) { - genericBlockEvent( e, true, false, false ); - } +// protected void genericBlockEventMonitor( BlockBreakEvent e ) { +// genericBlockEvent( e, true, false, false ); +// } +// +// protected void genericBlockEvent( BlockBreakEvent e ) { +// genericBlockEvent( e, false, false, false ); +// } + +// protected void genericBlockEventAutoManager( BlockBreakEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericBlockEvent( e, false, blockEventsOnly, true ); +// } - protected void genericBlockEvent( BlockBreakEvent e ) { - genericBlockEvent( e, false, false, false ); - } - - protected void genericBlockEventAutoManager( BlockBreakEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericBlockEvent( e, false, blockEventsOnly, true ); - } - - protected void genericBlockExplodeEventMonitor( TEBlockExplodeEvent e ) { - genericBlockExplodeEvent( e, true, false, false ); - } - - protected void genericBlockExplodeEvent( TEBlockExplodeEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericBlockExplodeEvent( e, false, blockEventsOnly, false ); - } +// protected void genericBlockExplodeEventMonitor( TEBlockExplodeEvent e ) { +// genericBlockExplodeEvent( e, true, false, false ); +// } +// +// protected void genericBlockExplodeEvent( TEBlockExplodeEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericBlockExplodeEvent( e, false, blockEventsOnly, false ); +// } - protected void genericBlockExplodeEventAutoManager( TEBlockExplodeEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericBlockExplodeEvent( e, false, blockEventsOnly, true ); - } +// protected void genericBlockExplodeEventAutoManager( TEBlockExplodeEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericBlockExplodeEvent( e, false, blockEventsOnly, true ); +// } - protected void genericBlockExplodeEventMonitor( BlastUseEvent e ) { - genericBlastUseEvent( e, true, false, false ); - } - - protected void genericBlockExplodeEvent( BlastUseEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericBlastUseEvent( e, false, blockEventsOnly, false ); - } +// protected void genericBlockExplodeEventMonitor( BlastUseEvent e ) { +// genericBlastUseEvent( e, true, false, false ); +// } +// +// protected void genericBlockExplodeEvent( BlastUseEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericBlastUseEvent( e, false, blockEventsOnly, false ); +// } - protected void genericBlockExplodeEventAutoManager( BlastUseEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericBlastUseEvent( e, false, blockEventsOnly, true ); - } +// protected void genericBlockExplodeEventAutoManager( BlastUseEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericBlastUseEvent( e, false, blockEventsOnly, true ); +// } - /** - * For Pulsi_'s PrisonEnchants plugin: - * - * @param e - */ - protected void genericBlockExplodeEventMonitor( PEExplosionEvent e ) { - genericExplosiveEvent( e, true, false, false ); - } - - /** - * For Pulsi_'s PrisonEnchants plugin: - * - * @param e - */ - protected void genericBlockExplodeEvent( PEExplosionEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericExplosiveEvent( e, false, blockEventsOnly, false ); - } +// /** +// * For Pulsi_'s PrisonEnchants plugin: +// * +// * @param e +// */ +// protected void genericBlockExplodeEventMonitor( PEExplosionEvent e ) { +// genericExplosiveEvent( e, true, false, false ); +// } +// +// /** +// * For Pulsi_'s PrisonEnchants plugin: +// * +// * @param e +// */ +// protected void genericBlockExplodeEvent( PEExplosionEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericExplosiveEvent( e, false, blockEventsOnly, false ); +// } - /** - * For Pulsi_'s PrisonEnchants plugin: - * - * @param e - */ - protected void genericBlockExplodeEventAutoManager( PEExplosionEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericExplosiveEvent( e, false, blockEventsOnly, true ); - } +// /** +// * For Pulsi_'s PrisonEnchants plugin: +// * +// * @param e +// */ +// protected void genericBlockExplodeEventAutoManager( PEExplosionEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericExplosiveEvent( e, false, blockEventsOnly, true ); +// } - /** - * For Prison's very own ExplosiveBlockBreakEvent: - * - * @param e - */ - protected void genericBlockExplodeEventMonitor( ExplosiveBlockBreakEvent e ) { - genericExplosiveEvent( e, true, false, false ); - } - - /** - * For Prison's very own ExplosiveBlockBreakEvent: - * - * @param e - */ - protected void genericBlockExplodeEvent( ExplosiveBlockBreakEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericExplosiveEvent( e, false, blockEventsOnly, false ); - } +// /** +// * For Prison's very own ExplosiveBlockBreakEvent: +// * +// * @param e +// */ +// protected void genericBlockExplodeEventMonitor( ExplosiveBlockBreakEvent e ) { +// genericExplosiveEvent( e, true, false, false ); +// } +// +// /** +// * For Prison's very own ExplosiveBlockBreakEvent: +// * +// * @param e +// */ +// protected void genericBlockExplodeEvent( ExplosiveBlockBreakEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericExplosiveEvent( e, false, blockEventsOnly, false ); +// } - /** - * For Prison's very own ExplosiveBlockBreakEvent: - * - * @param e - */ - protected void genericBlockExplodeEventAutoManager( ExplosiveBlockBreakEvent e ) { - // NOTE: If autoManager is turned off, then process only the blockEvents: - boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); - genericExplosiveEvent( e, false, blockEventsOnly, true ); - } +// /** +// * For Prison's very own ExplosiveBlockBreakEvent: +// * +// * @param e +// */ +// protected void genericBlockExplodeEventAutoManager( ExplosiveBlockBreakEvent e ) { +// // NOTE: If autoManager is turned off, then process only the blockEvents: +// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); +// genericExplosiveEvent( e, false, blockEventsOnly, true ); +// } // protected boolean processMinesBlockBreakEvent( Cancellable event, Player player, Block block ) { // boolean processEvent = true; @@ -324,8 +324,10 @@ protected void genericBlockExplodeEventAutoManager( ExplosiveBlockBreakEvent e ) * @param montior Identifies that a monitor event called this function. A monitor should only record * block break counts. */ - protected void genericBlockEvent( BlockBreakEvent e, boolean monitor, boolean blockEventsOnly, - boolean autoManager ) { + public void genericBlockEvent( BlockBreakEvent e, BlockBreakPriority bbPriority ) { + +// boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { if ( e instanceof PrisonMinesBlockBreakEvent ) { return; @@ -337,22 +339,21 @@ protected void genericBlockEvent( BlockBreakEvent e, boolean monitor, boolean bl return; } - // Register all external events such as mcMMO and EZBlocks: OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); StringBuilder debugInfo = new StringBuilder(); - debugInfo.append( String.format( "### ** genericBlockEvent ** ### %s%s%s%s ", - (autoManager ? "autoManager " : ""), - (e.isCancelled() ? "CANCELED " : ""), - (monitor ? "MONITOR " : ""), (blockEventsOnly ? "BlockEventsOnly" : "" )) ); + debugInfo.append( String.format( "### ** genericBlockEvent ** ### " + + "(event: BlockBreakEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); - // NOTE that check for auto manager has happened prior to accessing this function. - if ( !monitor && !e.isCancelled() || monitor ) - { + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { // Need to wrap in a Prison block so it can be used with the mines: SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); @@ -362,7 +363,7 @@ protected void genericBlockEvent( BlockBreakEvent e, boolean monitor, boolean bl String triggered = null; PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), - sBlock, sPlayer, monitor, blockEventsOnly, eventType, triggered ); + sBlock, sPlayer, bbPriority, eventType, triggered ); if ( !validateEvent( pmEvent, debugInfo ) ) { @@ -375,7 +376,7 @@ protected void genericBlockEvent( BlockBreakEvent e, boolean monitor, boolean bl } } - else if ( pmEvent.isMonitor() ) { + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { // Stop here, and prevent additional processing. Monitors should never process the event beyond this. } @@ -973,11 +974,8 @@ else if ( targetExplodedBlock.isMined() ) { - if ( results && pmEvent.isBlockEventsOnly() ) { + if ( results && pmEvent.getBbPriority() == BlockBreakPriority.BLOCKEVENTS ) { - // NOTE: This "should" never be activated since blockEventsOnly used to be enabled - // when AutoManager is disabled. As of 2021-11-23 if AutoManager is disabled, - // then everything related to auto manager is disabled. String triggered = null; doActionBlockEventOnly( sBlockHit, mine, pmEvent.getPlayer(), @@ -1000,13 +998,13 @@ else if ( targetExplodedBlock.isMined() ) { results = false; } - else if ( results && pmEvent.isMonitor() && mine == null ) { + else if ( results && pmEvent.getBbPriority() == BlockBreakPriority.MONITOR && mine == null ) { // bypass all processing since the block break is outside any mine: debugInfo.append( "(bypassed monitor no mine) " ); results = false; } - else if ( results && pmEvent.isMonitor() && mine != null ) { + else if ( results && pmEvent.getBbPriority() == BlockBreakPriority.MONITOR && mine != null ) { doActionMonitor( sBlockHit, mine ); @@ -1155,8 +1153,10 @@ else if ( results && pmEvent.isMonitor() && mine != null ) { * * @param e */ - private void genericBlockExplodeEvent( TEBlockExplodeEvent e, boolean monitor, boolean blockEventsOnly, - boolean autoManager ) { + public void genericBlockExplodeEvent( TEBlockExplodeEvent e, BlockBreakPriority bbPriority ) { + +// , boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { long start = System.nanoTime(); @@ -1170,16 +1170,20 @@ private void genericBlockExplodeEvent( TEBlockExplodeEvent e, boolean monitor, b StringBuilder debugInfo = new StringBuilder(); - debugInfo.append( String.format( "### ** genericBlockExplodeEvent(TEBlockExplodeEvent) ** ### %s%s%s%s ", - (autoManager ? "autoManager " : ""), - (e.isCancelled() ? "CANCELED " : ""), - (monitor ? "MONITOR " : ""), (blockEventsOnly ? "BlockEventsOnly" : "" )) ); + debugInfo.append( String.format( "### ** genericBlockExplodeEvent ** ### " + + "(event: TEBlockExplodeEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { + - // NOTE that check for auto manager has happened prior to accessing this function. - if ( !monitor && !e.isCancelled() || monitor ) { - String eP = getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority ); boolean isTEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); @@ -1193,7 +1197,7 @@ private void genericBlockExplodeEvent( TEBlockExplodeEvent e, boolean monitor, b String triggered = checkCEExplosionTriggered( e ); PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), - sBlock, sPlayer, monitor, blockEventsOnly, eventType, triggered ); + sBlock, sPlayer, bbPriority, eventType, triggered ); // NOTE: Token Enchant will pass the event's block to prison, but that block may // have already been processed by prison. Therefore the PrisonMinesBlockBreakEvent @@ -1214,7 +1218,7 @@ private void genericBlockExplodeEvent( TEBlockExplodeEvent e, boolean monitor, b } } - else if ( pmEvent.isMonitor() ) { + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { // Stop here, and prevent additional processing. Monitors should never process the event beyond this. } @@ -1350,8 +1354,10 @@ private String checkCEExplosionTriggered( TEBlockExplodeEvent e ) * * @param e */ - protected void genericBlastUseEvent( BlastUseEvent e, boolean monitor, boolean blockEventsOnly, - boolean autoManager ) { + public void genericBlastUseEvent( BlastUseEvent e, BlockBreakPriority bbPriority ) { + +// boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { long start = System.nanoTime(); @@ -1365,16 +1371,17 @@ protected void genericBlastUseEvent( BlastUseEvent e, boolean monitor, boolean b StringBuilder debugInfo = new StringBuilder(); - debugInfo.append( String.format( "### ** genericBlastUseEvent(BlastUseEvent) ** ### %s%s%s%s ", - (autoManager ? "autoManager " : ""), - (e.isCancelled() ? "CANCELED " : ""), - (monitor ? "MONITOR " : ""), (blockEventsOnly ? "BlockEventsOnly" : "" )) ); + debugInfo.append( String.format( "### ** genericBlastUseEvent ** ### " + + "(event: BlastUseEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + - - // NOTE that check for auto manager has happened prior to accessing this function. - if ( (!monitor && !e.isCancelled() || monitor) && - e.getBlockList().size() > 0 ) { + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR && + e.getBlockList().size() > 0 ) { String eP = getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority ); @@ -1392,7 +1399,7 @@ protected void genericBlastUseEvent( BlastUseEvent e, boolean monitor, boolean b PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( bukkitBlock, e.getPlayer(), - sBlock, sPlayer, monitor, blockEventsOnly, eventType, triggered ); + sBlock, sPlayer, bbPriority, eventType, triggered ); for ( int i = 1; i < e.getBlockList().size(); i++ ) { @@ -1412,7 +1419,7 @@ protected void genericBlastUseEvent( BlastUseEvent e, boolean monitor, boolean b } - else if ( pmEvent.isMonitor() ) { + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { // Stop here, and prevent additional processing. Monitors should never process the event beyond this. } @@ -1517,8 +1524,11 @@ else if ( isCEBlockExplodeEnabled && * * @param e */ - protected void genericExplosiveEvent( PEExplosionEvent e, boolean monitor, boolean blockEventsOnly, - boolean autoManager ) { + public void genericExplosiveEvent( PEExplosionEvent e, BlockBreakPriority bbPriority) { + + +// , boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { long start = System.nanoTime(); @@ -1532,16 +1542,18 @@ protected void genericExplosiveEvent( PEExplosionEvent e, boolean monitor, boole StringBuilder debugInfo = new StringBuilder(); - debugInfo.append( String.format( "### ** genericExplosiveEvent(PrisonEnchants - ExplosiveEvent) ** ### %s%s%s%s ", - (autoManager ? "autoManager " : ""), - (e.isCancelled() ? "CANCELED " : ""), - (monitor ? "MONITOR " : ""), (blockEventsOnly ? "BlockEventsOnly" : "" )) ); + debugInfo.append( String.format( "### ** genericExplosiveEvent (Pulsi) ** ### " + + "(event: PEExplosionEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { - // NOTE that check for auto manager has happened prior to accessing this function. - if ( !monitor && !e.isCancelled() || monitor ) { - String eP = getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority ); boolean isPEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); @@ -1555,7 +1567,7 @@ protected void genericExplosiveEvent( PEExplosionEvent e, boolean monitor, boole String triggered = null; // e.getTriggeredBy(); PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlockBroken(), e.getPlayer(), - sBlock, sPlayer, monitor, blockEventsOnly, eventType, triggered ); + sBlock, sPlayer, bbPriority, eventType, triggered ); pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); @@ -1572,7 +1584,7 @@ protected void genericExplosiveEvent( PEExplosionEvent e, boolean monitor, boole } - else if ( pmEvent.isMonitor() ) { + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { // Stop here, and prevent additional processing. Monitors should never process the event beyond this. } @@ -1657,8 +1669,10 @@ else if ( isPEExplosiveEnabled && } - protected void genericExplosiveEvent( ExplosiveBlockBreakEvent e, boolean monitor, boolean blockEventsOnly, - boolean autoManager ) { + protected void genericExplosiveEvent( ExplosiveBlockBreakEvent e, BlockBreakPriority bbPriority ) { + +// boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { long start = System.nanoTime(); @@ -1672,14 +1686,17 @@ protected void genericExplosiveEvent( ExplosiveBlockBreakEvent e, boolean monito StringBuilder debugInfo = new StringBuilder(); - debugInfo.append( String.format( "### ** genericExplosiveEvent(Prison's - ExplosiveBlockBreakEvent) ** ### %s%s%s%s ", - (autoManager ? "autoManager " : ""), - (e.isCancelled() ? "CANCELED " : ""), - (monitor ? "MONITOR " : ""), (blockEventsOnly ? "BlockEventsOnly" : "" )) ); - // NOTE that check for auto manager has happened prior to accessing this function. - if ( !monitor && !e.isCancelled() || monitor ) { - + debugInfo.append( String.format( "### ** genericExplosiveEvent (Prisons's bombs) ** ### " + + "(event: ExplosiveBlockBreakEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { + String eP = getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority ); boolean isPPrisonExplosiveBlockBreakEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); @@ -1693,7 +1710,7 @@ protected void genericExplosiveEvent( ExplosiveBlockBreakEvent e, boolean monito String triggered = e.getTriggeredBy(); PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), - sBlock, sPlayer, monitor, blockEventsOnly, eventType, triggered ); + sBlock, sPlayer, bbPriority, eventType, triggered ); // If this event is fired, but yet there are no exploded blocks, then do not set @@ -1737,7 +1754,7 @@ protected void genericExplosiveEvent( ExplosiveBlockBreakEvent e, boolean monito } - else if ( pmEvent.isMonitor() ) { + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { // Stop here, and prevent additional processing. Monitors should never process the event beyond this. } From cc41951d0bdd50bf0a388911a9faee07ad72af72 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 25 Feb 2022 17:37:53 -0500 Subject: [PATCH 121/297] More adjustments to the block events so the config setting can be shown in the header of the /prison support listeners blockevent command. --- docs/changelog_v3.3.x.md | 3 +++ .../events/AutoManagerBlockBreakEvents.java | 19 +++++++++++++------ .../events/AutoManagerCrazyEnchants.java | 16 +++++++++++----- .../events/AutoManagerEventsManager.java | 11 ++++++++++- .../events/AutoManagerPrisonEnchants.java | 17 +++++++++++------ ...nagerPrisonsExplosiveBlockBreakEvents.java | 17 ++++++++++++----- .../events/AutoManagerTokenEnchant.java | 15 ++++++++++----- .../events/AutoManagerZenchantments.java | 16 +++++++++++----- 8 files changed, 81 insertions(+), 33 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c566e4c75..5be329818 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8e 2022-02-25 +* **More adjustments to the block events so the config setting can be shown in the header of the /prison support listeners blockevent command.** + + * **Setting up support for the BLOCKEVENTS on all block break event listeners.** Changed around how the listeners are created to simplify and be more accurate in the event states. 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 9e4f3c48e..9ee60360d 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 @@ -20,7 +20,7 @@ public class AutoManagerBlockBreakEvents extends AutoManagerEventsManager - { +{ public AutoManagerBlockBreakEvents() { super(); @@ -107,13 +107,13 @@ public void initialize() { Output.get().logInfo( "AutoManager: Trying to register BlockBreakEvent" ); String eP = getMessage( AutoFeatures.blockBreakEventPriority ); - BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + setBbPriority( BlockBreakPriority.fromString( eP ) ); - if ( bbPriority != BlockBreakPriority.DISABLED ) { + if ( getBbPriority() != BlockBreakPriority.DISABLED ) { SpigotPrison prison = SpigotPrison.getInstance(); PluginManager pm = Bukkit.getServer().getPluginManager(); - EventPriority ePriority = bbPriority.getBukkitEventPriority(); + EventPriority ePriority = getBbPriority().getBukkitEventPriority(); AutoManagerBlockBreakEventListener autoManagerlListener = new AutoManagerBlockBreakEventListener(); @@ -126,7 +126,7 @@ public void execute(Listener l, Event e) { e instanceof BlockBreakEvent ) { ((AutoManagerBlockBreakEventListener)l) - .onBlockBreak( (BlockBreakEvent)e, bbPriority ); + .onBlockBreak( (BlockBreakEvent)e, getBbPriority() ); } } }, @@ -249,9 +249,16 @@ public void dumpEventListeners( StringBuilder sb ) { // Check to see if the class BlockBreakEvent even exists: try { + + String eP = getMessage( AutoFeatures.blockBreakEventPriority ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + String title = String.format( + "BlockBreakEvent (%s)", + ( bbPriority == null ? "--none--" : bbPriority.name()) ); + ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay( - "BlockBreakEvent", + title, new SpigotHandlerList( BlockBreakEvent.getHandlerList()) ); if ( eventDisplay != null ) { 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 ab5b53f0b..67a1ed727 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 @@ -79,11 +79,11 @@ public void onCrazyEnchantsBlockExplode( BlastUseEvent e, BlockBreakPriority bbP public void initialize() { String eP = getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority ); - BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + setBbPriority( BlockBreakPriority.fromString( eP ) ); // boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( bbPriority == BlockBreakPriority.DISABLED ) { + if ( getBbPriority() == BlockBreakPriority.DISABLED ) { return; } @@ -99,7 +99,7 @@ public void initialize() { SpigotPrison prison = SpigotPrison.getInstance(); PluginManager pm = Bukkit.getServer().getPluginManager(); - EventPriority ePriority = bbPriority.getBukkitEventPriority(); + EventPriority ePriority = getBbPriority().getBukkitEventPriority(); AutoManagerBlastUseEventListener autoManagerlListener = @@ -112,7 +112,7 @@ public void execute(Listener l, Event e) { BlastUseEvent buEvent = (BlastUseEvent) e; ((AutoManagerBlastUseEventListener)l) - .onCrazyEnchantsBlockExplode( buEvent, bbPriority ); + .onCrazyEnchantsBlockExplode( buEvent, getBbPriority() ); } }, prison); @@ -243,9 +243,15 @@ public void dumpEventListeners( StringBuilder sb ) { Class.forName( "me.badbones69.crazyenchantments.api.events.BlastUseEvent", false, this.getClass().getClassLoader() ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + + + String title = String.format( + "BlastUseEvent (%s)", + ( bbPriority == null ? "--none--" : bbPriority.name()) ); ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay( - "BlastUseEvent", + title, new SpigotHandlerList( BlastUseEvent.getHandlerList()) ); if ( eventDisplay != null ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerEventsManager.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerEventsManager.java index 30a1a7ee3..d2ac3cc9f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerEventsManager.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerEventsManager.java @@ -7,12 +7,14 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures; +import tech.mcprison.prison.spigot.block.BlockBreakPriority; public abstract class AutoManagerEventsManager extends AutoManagerFeatures implements PrisonEventManager { - + private BlockBreakPriority bbPriority; + public AutoManagerEventsManager() { super(); @@ -51,5 +53,12 @@ public void unregisterListeners() { Output.get().logInfo( "AutoManagerEventsManager: unregistered a total of %d event listeners.", count ); } + + public BlockBreakPriority getBbPriority() { + return bbPriority; + } + public void setBbPriority( BlockBreakPriority bbPriority ) { + this.bbPriority = bbPriority; + } } 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 adb8a69fe..f84b9a152 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 @@ -86,11 +86,11 @@ public void onPrisonEnchantsExplosiveEvent( PEExplosionEvent e, BlockBreakPriori public void initialize() { String eP = getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority ); - BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + setBbPriority( BlockBreakPriority.fromString( eP ) ); // boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( bbPriority == BlockBreakPriority.DISABLED ) { + if ( getBbPriority() == BlockBreakPriority.DISABLED ) { return; } @@ -108,7 +108,7 @@ public void initialize() { SpigotPrison prison = SpigotPrison.getInstance(); PluginManager pm = Bukkit.getServer().getPluginManager(); - EventPriority ePriority = bbPriority.getBukkitEventPriority(); + EventPriority ePriority = getBbPriority().getBukkitEventPriority(); AutoManagerPEExplosiveEventListener autoManagerlListener = new AutoManagerPEExplosiveEventListener(); @@ -120,7 +120,7 @@ public void execute(Listener l, Event e) { PEExplosionEvent peeEvent = (PEExplosionEvent) e; ((AutoManagerPEExplosiveEventListener)l) - .onPrisonEnchantsExplosiveEvent( peeEvent, bbPriority ); + .onPrisonEnchantsExplosiveEvent( peeEvent, getBbPriority() ); } }, prison); @@ -249,9 +249,14 @@ public void dumpEventListeners( StringBuilder sb ) { Class.forName( "me.pulsi_.prisonenchants.events.PEExplosionEvent", false, this.getClass().getClassLoader() ); - + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + + String title = String.format( + "Pulsi_'s PEExplosionEvent (%s)", + ( bbPriority == null ? "--none--" : bbPriority.name())); + ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay( - "Pulsi_'s PEExplosionEvent", + title, new SpigotHandlerList( PEExplosionEvent.getHandlerList()) ); if ( eventDisplay != null ) { 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 aa65d1380..c63c370e3 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 @@ -81,11 +81,11 @@ public void onPrisonsExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e, Block public void initialize() { String eP = getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority ); - BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + setBbPriority( BlockBreakPriority.fromString( eP ) ); // boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( bbPriority == BlockBreakPriority.DISABLED ) { + if ( getBbPriority() == BlockBreakPriority.DISABLED ) { return; } @@ -96,7 +96,7 @@ public void initialize() { SpigotPrison prison = SpigotPrison.getInstance(); PluginManager pm = Bukkit.getServer().getPluginManager(); - EventPriority ePriority = bbPriority.getBukkitEventPriority(); + EventPriority ePriority = getBbPriority().getBukkitEventPriority(); AutoManagerExplosiveBlockBreakEventListener autoManagerlListener = @@ -109,7 +109,7 @@ public void execute(Listener l, Event e) { ExplosiveBlockBreakEvent ebbEvent = (ExplosiveBlockBreakEvent) e; ((AutoManagerExplosiveBlockBreakEventListener)l) - .onPrisonsExplosiveBlockBreakEvent( ebbEvent, bbPriority ); + .onPrisonsExplosiveBlockBreakEvent( ebbEvent, getBbPriority() ); } }, prison); @@ -232,8 +232,15 @@ public void dumpEventListeners( StringBuilder sb ) { // Check to see if the class ExplosiveEvent even exists: try { + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + + String title = String.format( + "ExplosiveBlockBreakEvent (%s)", + ( bbPriority == null ? "--none--" : bbPriority.name()) ); + + ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay( - "ExplosiveBlockBreakEvent", + title, new SpigotHandlerList( ExplosiveBlockBreakEvent.getHandlerList()) ); if ( eventDisplay != null ) { 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 60543dedb..03a26276e 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 @@ -80,11 +80,11 @@ public void onTEBlockExplode( TEBlockExplodeEvent e, BlockBreakPriority bbPriori public void initialize() { String eP = getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority ); - BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + setBbPriority( BlockBreakPriority.fromString( eP ) ); // boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( bbPriority == BlockBreakPriority.DISABLED ) { + if ( getBbPriority() == BlockBreakPriority.DISABLED ) { return; } @@ -99,7 +99,7 @@ public void initialize() { SpigotPrison prison = SpigotPrison.getInstance(); PluginManager pm = Bukkit.getServer().getPluginManager(); - EventPriority ePriority = bbPriority.getBukkitEventPriority(); + EventPriority ePriority = getBbPriority().getBukkitEventPriority(); AutoManagerTokenEnchantEventListener autoManagerlListener = @@ -109,7 +109,7 @@ public void initialize() { new EventExecutor() { public void execute(Listener l, Event e) { ((AutoManagerTokenEnchantEventListener)l) - .onTEBlockExplode( (TEBlockExplodeEvent)e, bbPriority ); + .onTEBlockExplode( (TEBlockExplodeEvent)e, getBbPriority() ); } }, prison); @@ -236,9 +236,14 @@ public void dumpEventListeners( StringBuilder sb ) { Class.forName( "com.vk2gpz.tokenenchant.event.TEBlockExplodeEvent", false, this.getClass().getClassLoader() ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + String title = String.format( + "TEBlockExplodeEvent (%s)", + ( bbPriority == null ? "--none--" : bbPriority.name()) ); + ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay( - "TEBlockExplodeEvent", + title, new SpigotHandlerList( TEBlockExplodeEvent.getHandlerList()) ); if ( eventDisplay != null ) { 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 fc13eaaec..c195cc7c7 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 @@ -81,11 +81,11 @@ public void onBlockShredBreak( BlockShredEvent e, BlockBreakPriority bbPriority public void initialize() { String eP = getMessage( AutoFeatures.ZenchantmentsBlockShredEventPriority ); - BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + setBbPriority( BlockBreakPriority.fromString( eP ) ); // boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - if ( bbPriority == BlockBreakPriority.DISABLED ) { + if ( getBbPriority() == BlockBreakPriority.DISABLED ) { return; } @@ -100,7 +100,7 @@ public void initialize() { SpigotPrison prison = SpigotPrison.getInstance(); PluginManager pm = Bukkit.getServer().getPluginManager(); - EventPriority ePriority = bbPriority.getBukkitEventPriority(); + EventPriority ePriority = getBbPriority().getBukkitEventPriority(); AutoManagerBlockShredEventListener autoManagerlListener = new AutoManagerBlockShredEventListener(); @@ -115,7 +115,7 @@ public void execute(Listener l, Event e) { (AutoManagerBlockShredEventListener) l; BlockShredEvent event = (BlockShredEvent) e; - lmon.onBlockShredBreak( event, bbPriority ); + lmon.onBlockShredBreak( event, getBbPriority() ); } } }, @@ -254,9 +254,15 @@ public void dumpEventListeners( StringBuilder sb ) { Class.forName( "zedly.zenchantments.BlockShredEvent", false, this.getClass().getClassLoader() ); + BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP ); + + String title = String.format( + "BlockShredEvent (%s)", + ( bbPriority == null ? "--none--" : bbPriority.name()) ); + ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay( - "BlockShredEvent", + title, new SpigotHandlerList( BlockShredEvent.getHandlerList()) ); if ( eventDisplay != null ) { From 4fbd923fac7d67ab6c4c1f30643c9fa293a2b325 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 25 Feb 2022 17:39:44 -0500 Subject: [PATCH 122/297] Version 3.3.0-alpha.8g --- docs/changelog_v3.3.x.md | 5 +- docs/knownissues_v3.3.x.md | 112 +++++++++++++++++++++++++++++-------- gradle.properties | 2 +- 3 files changed, 93 insertions(+), 26 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5be329818..c841f469b 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8e 2022-02-25 +# 3.3.0-alpha.8g 2022-02-25 + + +* **3.3.0-alpha.8g 2022-02-25** * **More adjustments to the block events so the config setting can be shown in the header of the /prison support listeners blockevent command.** diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index 6ed8d329a..d876d831f 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -5,30 +5,81 @@ -# TODO Items for v3.3.0-alpha.7 +# TODO Items for v3.3.0-alpha.8 +* HiPriority: Inventory full not producing any messages. alexaille -- custom blocks not working with sellall. Sellall is not honoring the custom block's names. +* HiPriority: NPCs are generating a lot of errors. Real_Ganster + - Citizens running command `mines` as player +` Prison | VaultEconomyWrapper.getBalance(): Error: Cannot get economy for player vote so returning a value of 0. Failed to get an bukkit offline player.` + - https://pastebin.com/JusySWDs + -- DONE: placeholder for player blocks mined. artic1409 - - maybe use **prison_player_total_blocks__blockname** +* DONE: HiPriority: Add a event priority of BLOCKEVENTS which only does the block events and counts. + +* HiPriority: calculated infinite prestiges - Fluffy_ak47 + +* HiPriority: sellall for custom items + + + +- DONE: **Fixed issues with vault economy and withdrawing from a player's balance.** +It now also reports any errors that may be returned. + + +- In mines block list, new feature to prevent drops for that item... which then can use blockEvents, but that would bypass auto pickup and autosell. + + +- update LP docs with more info... + - https://discord.com/channels/332602419483770890/943874819101982790/943905937641574420 + + + +- %prison_rrt% (prison_rankup_rank_tag) Does not show the next prestige rank if you are not on the prestige ladder yet + + +- Prison GUI modifications to allow customizations + - Notify Nick1 when changes are made + -- DONE: update placeholderAPI with prison's updated placeholders -- Auto smelt is missing some blocks? Symadude23 +- Mine Bomb Issues + - DONE: Not dropping blocks + - DONE: give bombs only works with lower case... camel case not working + - DONE: with a stack of 2 oof bombs, setting off one removes both. + - The is happening when the bomb is so large that it breaks the durability on the pseudo tool, which then removes whatever is in the player's hand when it breaks the item. + - DONE: color names for bombs do not work - xGeorge26 + - DONE: Control Y adjustment when setting the bomb. Defaults to -1. + - DONE: armorstand appears in animation when using color coded bomb name? - xGeorge26 + - Update to include more colorful names.. + - Provide a "count down" placeholder function within the armor stand bomb name?? -- placeholder attributes: Add overrides for "units". kstance requested it for time, such as h,m,s... +- DONE: Need to externalize the time defaults... like Mine x will reset in x seconds from now. 1 seconds. - ShockCharge +- DONE: Six - air count needs to be asynch'd since it is causing server not to respond for more than 10 seconds upon startup. + - Most mines are greater than 120,000 blocks. -- DONE: prison support submit are only sending to console, not the user if they are in game -- DONE: When a mine reset time is disabled... it cancels/stops a /mines reset *all* +- custom block support: Items Adder - No one is using it currently. +- add `/mines set rank *all*` +- add `/mines set mineAccessByRank *all*` +- add `/mines set tpAccessByRank *all*` +- add `/mines set resetTime *all*` + + +- custom blocks not working with sellall. Sellall is not honoring the custom block's names. + +- Add ItemAddr for another custom block integration + +- Smelt and blocking: rewrite to provide a list of conversions to eliminate current hard coding. + +- Auto smelt is missing some blocks? Symadude23 + +- placeholder attributes: Add overrides for "units". kstance requested it for time, such as h,m,s... -- DONE: when rank tag = none - was showing "null" for placeholder -- DONE: work on getting CustomItems working in mines again - Need to get CustomItems working with sellall @@ -46,16 +97,6 @@ -- DONE: remove this warning message: no longer used. -[18:58:51 INFO]: | Prison | Cannot initialize NMS components - ClassNotFoundException - NMS is not functional - net.minecraft.server.v1_18_R1.EntityPlayer - - - -- DONE: RankPlayer addBalance cache for default currency -- RankPlayer addBalance cache for custom currency - still needed! - - - * Problems with blocks: - Sand or any other block that falls is no longer in original location so cannot break it. - Might have to tag the blocks with NMS? @@ -84,6 +125,7 @@ https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main * ShiftAndRightClickSellAll is not working +-> DONE: Hook in to quests - Only on block break events so may not work as expected? * Found a problem with mcMMO, Quest, and EZBlock support... only works on BlockBreakEvents. I added logging to identify when they are called, but if an explosion has 20,000 blocks, then it will log 20,000 times! 😂 So I need to figure out something before hooking it up to multi-block breaks. @@ -92,11 +134,33 @@ https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main - so a ladder value of 0.05 would apply p1 = 1.05, p2 = 1.10, p3 = 1.15, etc... +* auto run autoConfigure upon startup. Use autoStart as the base configuration for prison instead of nothing. --> DONE: Hook in to quests - Only on block break events so may not work as expected? + +- DONE: placeholder for player blocks mined. artic1409 + - maybe use **prison_player_total_blocks__blockname** + +- DONE: update placeholderAPI with prison's updated placeholders + +- DONE: prison support submit are only sending to console, not the user if they are in game + +- DONE: When a mine reset time is disabled... it cancels/stops a /mines reset *all* + + +- DONE: when rank tag = none - was showing "null" for placeholder + +- DONE: work on getting CustomItems working in mines again + +- DONE: remove this warning message: no longer used. +[18:58:51 INFO]: | Prison | Cannot initialize NMS components - ClassNotFoundException - NMS is not functional - net.minecraft.server.v1_18_R1.EntityPlayer + +- DONE: RankPlayer addBalance cache for default currency +- RankPlayer addBalance cache for custom currency - still needed! + + - DONE: You cannot afford the rankup is using a NBSP for the thousand separator. Using Prison v3.2.11, Java 16, and spigot 1.16.5. Cannot reproduce. Was a server hosting config issue, but not sure why it only impacted that one message. @@ -163,10 +227,10 @@ See SelectionManager... Prison wand uses the whole items stack to identify a wan * Add Mine Regions - Similar to mines in a way, where they will allow players to have access to the region, have mine effects (outside of a mine)... and mine effects would also be tied to these too. -* DONE: command handler - Ignore commands in certain worlds +* Placing mines could triggers many resets... also placing mines may not clear all blocks. -* Placing mines could triggers many resets... also placing mines may not clear all blocks. +* DONE: command handler - Ignore commands in certain worlds * DONE: Player Cache - Make sure the cache is loadable otherwise a new instance may be created that could wipe out the existing data. diff --git a/gradle.properties b/gradle.properties index 1367a13b3..b244340d3 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.8f +version=3.3.0-alpha.8g #version=3.3.0-alpha.7 From be657022e1db122aa73d0415197e2f13630bcedb Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Fri, 25 Feb 2022 21:10:45 -0500 Subject: [PATCH 123/297] Bug fix: Fixed an inventory glitch that was preventing items from being added to the inventory. Basically the inventory had items, but it was not updating the contents of the inventory on the client side. This was fixed by updating inventory when finished processing the adds. If autosell on full inventory is enabled, and there are extra drops, then sell them all before they make it to the inventory. This works most of the time, but sometimes the inventory still fills up. This is now more of a characteristic than a bug. --- docs/changelog_v3.3.x.md | 5 ++++ .../resources/lang/spigot/en_US.properties | 2 +- .../mcprison/prison/spigot/SpigotUtil.java | 1 + .../autofeatures/AutoManagerFeatures.java | 27 +++++++++++++++++-- .../spigot/backpacks/BackpacksUtil.java | 1 + 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c841f469b..3c226bcbe 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8g 2022-02-25 +* **Bug fix: Fixed an inventory glitch that was preventing items from being added to the inventory.** +Basically the inventory had items, but it was not updating the contents of the inventory on the client side. This was fixed by updating inventory when finished processing the adds. +If autosell on full inventory is enabled, and there are extra drops, then sell them all before they make it to the inventory. This works most of the time, but sometimes the inventory still fills up. This is now more of a characteristic than a bug. + + * **3.3.0-alpha.8g 2022-02-25** diff --git a/prison-core/src/main/resources/lang/spigot/en_US.properties b/prison-core/src/main/resources/lang/spigot/en_US.properties index 4ea8c78af..4f21290ac 100644 --- a/prison-core/src/main/resources/lang/spigot/en_US.properties +++ b/prison-core/src/main/resources/lang/spigot/en_US.properties @@ -256,7 +256,7 @@ spigot_message_sellall_delay_disabled_cant_use=Sorry, please enable SellAll Dela spigot_message_sellall_delay_edit_success=Sellall Delay edited with success. spigot_message_sellall_delay_enabled=SellAll Delay enabled with success. spigot_message_sellall_delay_not_number=SellAll Delay number isn't valid. -spigot_message_sellall_delay_wait=Please wait the end of the delay before using again the command. +spigot_message_sellall_delay_wait=Sellall delay is enabled, please slow down. spigot_message_sellall_gui_disabled=SellAll GUI is disabled. spigot_message_sellall_money_earned=You earned &a$ spigot_message_sellall_multiplier_add_success=SellAll Multiplier added with success. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java index d2ff0de9b..fb2648fe6 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java @@ -227,6 +227,7 @@ public static HashMap addItemToPlayerInventory( if ( itemStack != null && itemStack.getBukkitStack() != null ) { HashMap overflow = player.getInventory().addItem( itemStack.getBukkitStack() ); + player.updateInventory(); // Insert overflow in to Prison's backpack: if ( BackpacksUtil.isEnabled() ) { 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 915abf7eb..702cf34f4 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 @@ -578,6 +578,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, // extras.clear(); // } + dropExtra( extras, player, debugInfo ); // dropExtra( player.getInventory().addItem(itemStack), player, block ); } @@ -939,7 +940,10 @@ protected boolean checkLore( SpigotItemStack itemInHand, String loreValue ) { */ protected void dropExtra( HashMap extra, Player player, StringBuilder debugInfo ) { - if ( extra != null && extra.size() > 0 && SpigotPrison.getInstance().isSellAllEnabled()) { + if ( SpigotPrison.getInstance().isSellAllEnabled() && ( + extra != null && extra.size() > 0 || + player.getInventory().firstEmpty() == -1 + )) { if ( Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) ) { @@ -961,7 +965,9 @@ protected void dropExtra( HashMap extra, Player player List amounts = new ArrayList<>(); final long nanoStart = System.nanoTime(); - SellAllUtil.get().sellAllSell(player, false, !saNote, saNote, saNote, false, true, amounts ); + + // bypass delay (cooldown), no sound + SellAllUtil.get().sellAllSell(player, false, !saNote, saNote, false, false, false, amounts ); final long nanoStop = System.nanoTime(); long nanoTime = nanoStop - nanoStart; @@ -970,6 +976,23 @@ protected void dropExtra( HashMap extra, Player player amount += amt; } + // Since sellall on inventory full, sell the extras too... + if ( extra.size() > 0 ) { + for ( Entry drop : extra.entrySet() ) + { + SpigotItemStack itemStack = drop.getValue(); + final long nanoStart2 = System.nanoTime(); + double amount2 = SellAllUtil.get().sellAllSell( player, itemStack, false, false, true ); + final long nanoStop2 = System.nanoTime(); + + nanoTime += nanoStop2 - nanoStart2; + + amount += amount2; + + } + + } + if ( amount > 0d ) { DecimalFormat fFmt = new DecimalFormat("#,##0.0000"); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksUtil.java index d01a8cf4a..d882bb4ed 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksUtil.java @@ -1288,6 +1288,7 @@ private void backPackItem(Player p) { if (item != null) { inv.addItem(item); + p.updateInventory(); } } } From d0973ffeff74bd5461590d3f7a4b028d77b9588e Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 26 Feb 2022 01:02:35 -0500 Subject: [PATCH 124/297] Bug fix: Synchronized some of the collections that are needing it within the PlayerCache. --- docs/changelog_v3.3.x.md | 5 +- .../mcprison/prison/cache/PlayerCache.java | 99 ++++++++++++------- .../cache/PlayerCacheCheckTimersTask.java | 11 ++- .../cache/PlayerCacheLoadPlayerTask.java | 5 +- .../cache/PlayerCacheSaveAllPlayersTask.java | 34 ++++--- .../cache/PlayerCacheUnloadPlayerTask.java | 12 ++- 6 files changed, 108 insertions(+), 58 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 3c226bcbe..798edd05c 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8g 2022-02-25 +# 3.3.0-alpha.8g 2022-02-26 + + +* **Bug fix: Synchronized some of the collections that are needing it within the PlayerCache.** * **Bug fix: Fixed an inventory glitch that was preventing items from being added to the inventory.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java index 3e4e4ee2f..a4cee4b0d 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java @@ -1,12 +1,11 @@ package tech.mcprison.prison.cache; -import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedMap; import java.util.TreeMap; -import java.util.TreeSet; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; @@ -34,7 +33,7 @@ public class PlayerCache { private PlayerCacheStats stats; - private TreeMap players; + private SortedMap players; private Map tasks; @@ -46,9 +45,9 @@ public class PlayerCache { private PlayerCache() { super(); - this.players = new TreeMap<>(); + this.players = Collections.synchronizedSortedMap( new TreeMap<>() ); - this.tasks = new HashMap<>(); + this.tasks = Collections.synchronizedMap( new HashMap<>() ); this.cacheFiles = new PlayerCacheFiles(); @@ -124,31 +123,37 @@ private void onDisableInternal() { // save all dirty cache items and purge cache: if ( getPlayers().size() > 0 ) { - // Create a new set so as to prevent keys from being removed when purging - // the getPlayers() collection: - Set keys = new TreeSet<>(getPlayers().keySet()); - for ( String key : keys ) { - // Remove the player from the cache and get the playerData: - PlayerCachePlayerData playerData = getPlayers().remove( key ); + Set keys = getPlayers().keySet(); + + synchronized ( getPlayers() ) { - if ( playerData != null ) { - - // Note: Since we are logging online time, then all players that are - // in the cache are considered constantly dirty and needs to be - // saved. - - // Since the disable function has been called, we can only assume the - // server is shutting down. We need to save dirty player caches, but - // they must be done in-line so the shutdown process will wait for all - // players to be saved. + for ( String key : keys ) { + // Remove the player from the cache and get the playerData: + PlayerCachePlayerData playerData = getPlayers().remove( key ); - getCacheFiles().toJsonFile( playerData ); - - if ( playerData.getTask() != null ) { - getTasks().remove( playerData.getTask() ); - - PrisonTaskSubmitter.cancelTask( playerData.getTask().getTaskId() ); + if ( playerData != null ) { + + // Note: Since we are logging online time, then all players that are + // in the cache are considered constantly dirty and needs to be + // saved. + + // Since the disable function has been called, we can only assume the + // server is shutting down. We need to save dirty player caches, but + // they must be done in-line so the shutdown process will wait for all + // players to be saved. + + getCacheFiles().toJsonFile( playerData ); + + if ( playerData.getTask() != null ) { + + synchronized( getTasks() ) { + + getTasks().remove( playerData.getTask() ); + } + + PrisonTaskSubmitter.cancelTask( playerData.getTask().getTaskId() ); + } } } } @@ -157,7 +162,9 @@ private void onDisableInternal() { // Cancel and flush any uncompleted tasks that are scheduled to run: if ( getTasks().size() > 0 ) { - List keys = new ArrayList<>( getTasks().keySet() ); + + + Set keys = getTasks().keySet(); for ( PlayerCacheRunnable key : keys ) { @@ -166,7 +173,12 @@ private void onDisableInternal() { key.cancel(); // Remove the task and get the player data: - PlayerCachePlayerData playerData = getTasks().remove( key ); + PlayerCachePlayerData playerData = null; + + synchronized( getTasks() ) { + + playerData = getTasks().remove( key ); + } if ( playerData != null && playerData.getTask() != null && @@ -190,7 +202,10 @@ public void addPlayerData( PlayerCachePlayerData playerData ) { if ( playerData != null ) { getStats().incrementLoadPlayers(); - getPlayers().put( playerData.getPlayerUuid(), playerData ); + synchronized ( getPlayers() ) { + + getPlayers().put( playerData.getPlayerUuid(), playerData ); + } } } @@ -200,7 +215,10 @@ public PlayerCachePlayerData removePlayerData( PlayerCachePlayerData playerData if ( playerData != null ) { getStats().incrementRemovePlayers(); - removed = getPlayers().remove( playerData.getPlayerUuid() ); + synchronized ( getPlayers() ) { + + removed = getPlayers().remove( playerData.getPlayerUuid() ); + } } return removed; } @@ -272,7 +290,10 @@ private PlayerCachePlayerData getPlayer( Player player ) { else { // Note: if the player has not been loaded yet, this will return a null: - playerData = getPlayers().get( playerUuid ); + synchronized ( getPlayers() ) { + + playerData = getPlayers().get( playerUuid ); + } } if ( playerData != null ) { @@ -474,13 +495,17 @@ public long getPlayerBlocksTotalByBlockType( Player player, String blockType ) public String getPlayerDumpStats() { StringBuilder sb = new StringBuilder(); - List keys = new ArrayList<>( getPlayers().keySet() ); + Set keys = getPlayers().keySet(); - for ( String key : keys ) { - PlayerCachePlayerData playerData = getPlayers().get( key ); + synchronized ( getPlayers() ) { - sb.append( playerData.toString() ); + for ( String key : keys ) { + PlayerCachePlayerData playerData = getPlayers().get( key ); + + sb.append( playerData.toString() ); + } } + return sb.toString(); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheCheckTimersTask.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheCheckTimersTask.java index 7ace3b302..d9dac7c3f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheCheckTimersTask.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheCheckTimersTask.java @@ -1,9 +1,8 @@ package tech.mcprison.prison.cache; -import java.util.ArrayList; import java.util.ConcurrentModificationException; import java.util.HashSet; -import java.util.List; +import java.util.Set; /** *

This periodically ran task will go through all cached players and update @@ -66,7 +65,7 @@ private void processCache() { try { - List keys = new ArrayList<>( pCache.getPlayers().keySet() ); + Set keys = pCache.getPlayers().keySet(); for ( String key : keys ) { @@ -76,8 +75,12 @@ private void processCache() { } processedKeys.add( key ); + PlayerCachePlayerData playerData = null; - PlayerCachePlayerData playerData = pCache.getPlayers().get( key ); + synchronized ( pCache.getPlayers() ) { + + playerData = pCache.getPlayers().get( key ); + } if ( playerData != null ) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheLoadPlayerTask.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheLoadPlayerTask.java index f2c03a26e..917647530 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheLoadPlayerTask.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheLoadPlayerTask.java @@ -22,7 +22,10 @@ public void run() { if ( playerData != null ) { - pCache.addPlayerData( playerData ); + synchronized ( pCache.getPlayers() ) { + + pCache.addPlayerData( playerData ); + } } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheSaveAllPlayersTask.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheSaveAllPlayersTask.java index a3f0d3234..0dd418f35 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheSaveAllPlayersTask.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheSaveAllPlayersTask.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Set; import tech.mcprison.prison.output.Output; @@ -54,11 +55,16 @@ public void run() List purge = new ArrayList<>(); - List keys = new ArrayList<>( pCache.getPlayers().keySet() ); + Set keys = pCache.getPlayers().keySet(); for ( String key : keys ) { - PlayerCachePlayerData playerData = pCache.getPlayers().get( key ); + PlayerCachePlayerData playerData = null; + + synchronized ( pCache.getPlayers() ) { + + playerData = pCache.getPlayers().get( key ); + } if ( playerData != null ) { @@ -67,7 +73,7 @@ public void run() if ( playerData.isOnline() && (playerData.isDirty() || playerData.getLastSeenDate() == 0 || - (System.currentTimeMillis() - playerData.getLastSeenDate()) + (System.currentTimeMillis() - playerData.getLastSeenDate()) > LAST_SEEN_INTERVAL_30_MINUTES ) ) { // Update the player's last seen date only when dirty and they // are online: @@ -102,17 +108,19 @@ public void run() } } - - for ( PlayerCachePlayerData playerData : purge ) { - try { - if ( !playerData.isDirty() ) { - - pCache.getPlayers().remove( playerData.getPlayerUuid() ); + synchronized ( pCache.getPlayers() ) { + + for ( PlayerCachePlayerData playerData : purge ) { + try { + if ( !playerData.isDirty() ) { + + pCache.getPlayers().remove( playerData.getPlayerUuid() ); + } + } + catch ( Exception e ) { + // Ignore any possible errors. They will be addressed on the next + // run of this task. } - } - catch ( Exception e ) { - // Ignore any possible errors. They will be addressed on the next - // run of this task. } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheUnloadPlayerTask.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheUnloadPlayerTask.java index 80ac4aee3..79b948bb6 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheUnloadPlayerTask.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheUnloadPlayerTask.java @@ -14,9 +14,17 @@ public void run() { PlayerCache pCache = PlayerCache.getInstance(); // Remove from the player cache: - PlayerCachePlayerData removed = pCache.removePlayerData( getPlayerData() ); + PlayerCachePlayerData removed = null; + + synchronized ( pCache.getPlayers() ) { + + removed = pCache.removePlayerData( getPlayerData() ); + } - pCache.getCacheFiles().toJsonFile( removed ); + if ( removed != null ) { + + pCache.getCacheFiles().toJsonFile( removed ); + } } From 5ec6e1735c56fef3ca1fc459e20b066ec098e317 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 26 Feb 2022 01:17:16 -0500 Subject: [PATCH 125/297] v3.3.0-alpha.8h --- docs/changelog_v3.3.x.md | 3 +++ gradle.properties | 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 798edd05c..91ecbab29 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8g 2022-02-26 +* **v3.3.0-alpha.8h 2022-02-26** + + * **Bug fix: Synchronized some of the collections that are needing it within the PlayerCache.** diff --git a/gradle.properties b/gradle.properties index b244340d3..0a98b1b62 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.8g +version=3.3.0-alpha.8h #version=3.3.0-alpha.7 From 73048ee1d58754bafb6912566ddfe57b06bfa707 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 26 Feb 2022 19:31:39 -0500 Subject: [PATCH 126/297] New command added to '/prison support runCmd' to allow an OP process, such as a NPC in Citizens, to run a command as a player. For example this is handy for having an NPC open the player's GUIs such as mines or ranks. --- docs/changelog_v3.3.x.md | 4 +++ .../tech/mcprison/prison/PrisonCommand.java | 36 +++++++++++++++++++ .../prison/PrisonCommandMessages.java | 16 +++++++++ .../main/resources/lang/core/de_DE.properties | 6 +++- .../main/resources/lang/core/en_GB.properties | 6 +++- .../main/resources/lang/core/en_US.properties | 6 +++- .../main/resources/lang/core/es_ES.properties | 6 +++- .../main/resources/lang/core/hu_HU.properties | 6 +++- .../main/resources/lang/core/it_IT.properties | 6 +++- .../main/resources/lang/core/nl_BE.properties | 6 +++- .../main/resources/lang/core/nl_NL.properties | 6 +++- .../main/resources/lang/core/zh_TW.properties | 6 +++- .../prison/spigot/SpigotPlatform.java | 15 +++++++- 13 files changed, 115 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 91ecbab29..56bf5f0c1 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8g 2022-02-26 +* **New command added to '/prison support runCmd' to allow an OP process, such as a NPC in Citizens, to run a command as a player.** +For example this is handy for having an NPC open the player's GUIs such as mines or ranks. + + * **v3.3.0-alpha.8h 2022-02-26** 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 487d3bec5..d12504d62 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -1114,6 +1114,42 @@ public void findCommand(CommandSender sender, } + + @Command(identifier = "prison support runCmd", + description = "For use in other plugins to force a player to run a prison command. " + + "Its been seen that when enabling NPCs to run commands as players, that the " + + "NPC is still the active entity associated with the command when it enters " + + "the Prison command handler. This command will ensure the actual player is " + + "used. The commands that are specified to run, do not have to prison's commands.", + onlyPlayers = false, permissions = "prison.runcmd", + aliases = "prison utils runCmd") + public void runCommand(CommandSender sender, + @Arg(name = "player", + description = "Player to run the command as.") String playerName, + + @Wildcard(join=true) + @Arg(name = "command", description = "The command to run for the player." ) String command + ) { + + + if ( playerName == null || playerName.isEmpty() ) { + + coreRunCommandNameRequiredMsg(sender); + + return; + } + + if ( command == null || command.trim().length() == 0 ) { + coreRunCommandCommandRequiredMsg(sender); + } + + Player player = getPlayer( playerName ); + + PrisonAPI.dispatchCommand( player, command ); + + } + + @Command(identifier = "prison support setSupportName", description = "This sets the support name that is used with the submissions so its " + "easier to track who the submissions belong to. It is recommended that you " + diff --git a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommandMessages.java b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommandMessages.java index 86253572b..5903b215a 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommandMessages.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommandMessages.java @@ -107,5 +107,21 @@ protected String coreTokensSetAmountMsg( } + protected void coreRunCommandNameRequiredMsg( CommandSender sender ) { + + Prison.get().getLocaleManager() + .getLocalizable( "core_runCmd__name_required" ) + .setFailSilently() + .sendTo( sender ); + } + + protected void coreRunCommandCommandRequiredMsg( CommandSender sender ) { + + Prison.get().getLocaleManager() + .getLocalizable( "core_runCmd__command_required" ) + .setFailSilently() + .sendTo( sender ); + } + } diff --git a/prison-core/src/main/resources/lang/core/de_DE.properties b/prison-core/src/main/resources/lang/core/de_DE.properties index 495d2e346..ae61ed3f9 100644 --- a/prison-core/src/main/resources/lang/core/de_DE.properties +++ b/prison-core/src/main/resources/lang/core/de_DE.properties @@ -70,7 +70,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -108,6 +108,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] hat einen ungültigen Wert. diff --git a/prison-core/src/main/resources/lang/core/en_GB.properties b/prison-core/src/main/resources/lang/core/en_GB.properties index 812366ca3..def341497 100644 --- a/prison-core/src/main/resources/lang/core/en_GB.properties +++ b/prison-core/src/main/resources/lang/core/en_GB.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -105,6 +105,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] has an invalid value. diff --git a/prison-core/src/main/resources/lang/core/en_US.properties b/prison-core/src/main/resources/lang/core/en_US.properties index 84cd1dcc2..b5dd0523c 100644 --- a/prison-core/src/main/resources/lang/core/en_US.properties +++ b/prison-core/src/main/resources/lang/core/en_US.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -105,6 +105,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + core_prison_utf8_test=Привет! Давай поÑмотрим, работает ли? Test 01 diff --git a/prison-core/src/main/resources/lang/core/es_ES.properties b/prison-core/src/main/resources/lang/core/es_ES.properties index 6e912d7d2..c1a4a0714 100644 --- a/prison-core/src/main/resources/lang/core/es_ES.properties +++ b/prison-core/src/main/resources/lang/core/es_ES.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -105,6 +105,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] tiene un valor inválido. diff --git a/prison-core/src/main/resources/lang/core/hu_HU.properties b/prison-core/src/main/resources/lang/core/hu_HU.properties index 268375054..c0152e48c 100644 --- a/prison-core/src/main/resources/lang/core/hu_HU.properties +++ b/prison-core/src/main/resources/lang/core/hu_HU.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -105,6 +105,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] érvénytelen értékkel rendelkezik. diff --git a/prison-core/src/main/resources/lang/core/it_IT.properties b/prison-core/src/main/resources/lang/core/it_IT.properties index e3e53bc4c..9b47bd634 100644 --- a/prison-core/src/main/resources/lang/core/it_IT.properties +++ b/prison-core/src/main/resources/lang/core/it_IT.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -105,6 +105,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] Ha un valore invalido. diff --git a/prison-core/src/main/resources/lang/core/nl_BE.properties b/prison-core/src/main/resources/lang/core/nl_BE.properties index 795a35472..2c11e8dbf 100644 --- a/prison-core/src/main/resources/lang/core/nl_BE.properties +++ b/prison-core/src/main/resources/lang/core/nl_BE.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -105,6 +105,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] heeft een onjuiste waarde. diff --git a/prison-core/src/main/resources/lang/core/nl_NL.properties b/prison-core/src/main/resources/lang/core/nl_NL.properties index 795a35472..2c11e8dbf 100644 --- a/prison-core/src/main/resources/lang/core/nl_NL.properties +++ b/prison-core/src/main/resources/lang/core/nl_NL.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -105,6 +105,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + # The following are the original messages and they will eventually be replaced. includeError=[%1] heeft een onjuiste waarde. diff --git a/prison-core/src/main/resources/lang/core/zh_TW.properties b/prison-core/src/main/resources/lang/core/zh_TW.properties index eafec4865..5962401c4 100644 --- a/prison-core/src/main/resources/lang/core/zh_TW.properties +++ b/prison-core/src/main/resources/lang/core/zh_TW.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=3 +messages__version=4 messages__auto_refresh=true @@ -105,6 +105,10 @@ core_tokens__removed_amount=&3%1 now has &7%2 &3tokens after removing &7%3&3. core_tokens__set_amount=&3%1 now has &7%2 &3tokens. +core_runCmd__name_required=A valid player name is required. +core_runCmd__command_required=A command is required. + + includeError=[%1] 有一個無效值 excludeError=[%1] 有一個無效值 cantAsConsole=您ä¸èƒ½ä½œç‚ºæŽ§åˆ¶å°åŸ·è¡Œæ­¤æ“作 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 2ce688f97..a42851b58 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 @@ -519,7 +519,20 @@ public PluginCommand findCommand( String label ) { } @Override public void dispatchCommand(tech.mcprison.prison.internal.CommandSender sender, String cmd) { - Bukkit.getServer().dispatchCommand( ((SpigotCommandSender) sender).getWrapper(), cmd); + + if ( sender instanceof SpigotCommandSender ) { + SpigotCommandSender cmdSender = (SpigotCommandSender) sender; + + Bukkit.getServer().dispatchCommand( cmdSender.getWrapper(), cmd); + } + else { + + Player player = getPlayer( sender.getName() ).orElse( null ); + if ( player != null ) { + player.dispatchCommand( cmd ); + } + } + } @Override public Scheduler getScheduler() { From be45ba894f6c13be453e6f4f7becd175035c00cb Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 26 Feb 2022 19:36:29 -0500 Subject: [PATCH 127/297] Removed warnings from the Vault economy wrapper since NPCs can actually initiate commands and NPC will always return nulls for OfflinePlayers.... therefore just return a value of zero. --- docs/changelog_v3.3.x.md | 3 + .../spigot/economies/VaultEconomyWrapper.java | 85 ++++++++++++------- 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 56bf5f0c1..15a6aaf2b 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8g 2022-02-26 +* **Removed warnings from the Vault economy wrapper since NPCs can actually initiate commands and NPC will always return nulls for OfflinePlayers....** therefore just return a value of zero. + + * **New command added to '/prison support runCmd' to allow an OP process, such as a NPC in Citizens, to run a command as a player.** For example this is handy for having an NPC open the player's GUIs such as mines or ranks. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomyWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomyWrapper.java index 0007104c1..ae0f20c35 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomyWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/VaultEconomyWrapper.java @@ -92,6 +92,20 @@ private OfflinePlayer getOfflinePlayer(Player player) { } + /** + *

This gets a player's balance. + *

+ * + *

Note that if OfflinePlayer is null, then it appears that this is a + * symptom of using a plugin, such as Citizens, and that a NPC is + * running a prison command. So a null OfflinePlayer is not a sign + * of failure, as much as a sign of usage of an NPC. So ignore + * these conditions and no longer print an error message. + *

+ * + * @param player + * @return + */ @SuppressWarnings( "deprecation" ) public double getBalance(Player player) { double results = 0; @@ -101,17 +115,22 @@ public double getBalance(Player player) { } else { OfflinePlayer oPlayer = getOfflinePlayer( player ); - if ( oPlayer == null ) { - Output.get().logInfo( "VaultEconomyWrapper.getBalance(): Error: " + - "Cannot get economy for player %s so returning a value of 0. " + - "Failed to get an bukkit offline player.", - player.getName()); - results = 0; - } - else { + if ( oPlayer != null ) { results = economy.getBalance(oPlayer); } + +// if ( oPlayer == null ) { +// Output.get().logInfo( "VaultEconomyWrapper.getBalance(): Error: " + +// "Cannot get economy for player %s so returning a value of 0. " + +// "Failed to get an bukkit offline player.", +// player.getName()); +// results = 0; +// } +// else { +// results = economy.getBalance(oPlayer); +// } + } // if ( economy.hasBankSupport() ) { // @@ -141,12 +160,12 @@ public boolean setBalance(Player player, double amount) { } else { OfflinePlayer oPlayer = getOfflinePlayer( player ); - if ( oPlayer == null ) { - Output.get().logInfo( "VaultEconomyWrapper.setBalance(): Error: " + - "Cannot get economy for player %s so cannot set balance to %s.", - player.getName(), Double.toString( amount )); - } - else { + if ( oPlayer != null ) { +// Output.get().logInfo( "VaultEconomyWrapper.setBalance(): Error: " + +// "Cannot get economy for player %s so cannot set balance to %s.", +// player.getName(), Double.toString( amount )); +// } +// else { economy.withdrawPlayer( oPlayer, getBalance( player ) ); economy.depositPlayer( oPlayer, amount ); results = true; @@ -178,12 +197,12 @@ else if (economy != null) { } else { OfflinePlayer oPlayer = getOfflinePlayer( player ); - if ( oPlayer == null ) { - Output.get().logInfo( "VaultEconomyWrapper.addBalance(): Error: " + - "Cannot get economy for player %s so cannot add a balance of %s.", - player.getName(), Double.toString( amount )); - } - else { + if ( oPlayer != null ) { +// Output.get().logInfo( "VaultEconomyWrapper.addBalance(): Error: " + +// "Cannot get economy for player %s so cannot add a balance of %s.", +// player.getName(), Double.toString( amount )); +// } +// else { EconomyResponse response = economy.depositPlayer( oPlayer, amount ); results = response.transactionSuccess(); @@ -226,12 +245,12 @@ public boolean removeBalance(Player player, double amount) { } else { OfflinePlayer oPlayer = getOfflinePlayer( player ); - if ( oPlayer == null ) { - Output.get().logInfo( "VaultEconomyWrapper.removeBalance(): Error: " + - "Cannot get economy for player %s so cannot remove a balance of %s.", - player.getName(), Double.toString( amount )); - } - else { + if ( oPlayer != null ) { +// Output.get().logInfo( "VaultEconomyWrapper.removeBalance(): Error: " + +// "Cannot get economy for player %s so cannot remove a balance of %s.", +// player.getName(), Double.toString( amount )); +// } +// else { EconomyResponse response = economy.withdrawPlayer( oPlayer, amount ); results = response.transactionSuccess(); @@ -270,13 +289,13 @@ public boolean canAfford(Player player, double amount) { } else { OfflinePlayer oPlayer = getOfflinePlayer( player ); - if ( oPlayer == null ) { - Output.get().logInfo( "VaultEconomyWrapper.canAfford(): Error: " + - "Cannot get economy for player %s so cannot tell if " + - "player can afford the amount of %s.", - player.getName(), Double.toString( amount )); - } - else { + if ( oPlayer != null ) { +// Output.get().logInfo( "VaultEconomyWrapper.canAfford(): Error: " + +// "Cannot get economy for player %s so cannot tell if " + +// "player can afford the amount of %s.", +// player.getName(), Double.toString( amount )); +// } +// else { results = economy.has(oPlayer, amount); } } From 8c87282abe2c326c72909f6a2fd1735019c7f58f Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Feb 2022 00:30:30 -0500 Subject: [PATCH 128/297] Mine Bombs: add a reload function for mine bombs. /prison reload bombs or /prison utils bomb reload --- docs/changelog_v3.3.x.md | 6 ++++- .../spigot/utils/PrisonUtilsMineBombs.java | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 15a6aaf2b..a5e640792 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8g 2022-02-26 +# 3.3.0-alpha.8g 2022-02-27 + + +* **Mine Bombs: add a reload function for mine bombs.** +/prison reload bombs or /prison utils bomb reload * **Removed warnings from the Vault economy wrapper since NPCs can actually initiate commands and NPC will always return nulls for OfflinePlayers....** therefore just return a value of zero. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index fdb8ae0cf..335d95588 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -159,6 +159,28 @@ public void utilsMineBombs( CommandSender sender, + @Command(identifier = "prison utils bomb reload", + description = "Reloads and validates the mine bombs.", + onlyPlayers = false, + permissions = "prison.utils.bombs", + aliases = "prison reload bombs") + public void utilsMineBombsReload( CommandSender sender + + ) { + if ( !isEnableMineBombs() ) { + + Output.get().logInfo( "Prison's utils command mine bombs is disabled in modules.yml." ); + } + else { + + MineBombs mBombs = MineBombs.getInstance(); + + mBombs.loadConfigJson(); + + } + } + + @Command(identifier = "prison utils bomb list", description = "A list of all available bombs, including their full details. " + "This command also shows a list of settings for shapes, sounds, and visual effects.", From 8c5d3fad7abef2ba84d1cf6d60acb9e34c301689 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Feb 2022 00:45:34 -0500 Subject: [PATCH 129/297] Mine Bombs: Add some basic validations when loading the mine bombs from the config files --- docs/changelog_v3.3.x.md | 3 + .../mcprison/prison/bombs/MineBombData.java | 14 +- .../tech/mcprison/prison/bombs/MineBombs.java | 156 +++++++++++++++++- .../spigot/utils/PrisonUtilsMineBombs.java | 1 + 4 files changed, 164 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a5e640792..a4b2b9bbb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8g 2022-02-27 +* **Mine Bombs: Add some basic validations when loading the mine bombs from the config files** + + * **Mine Bombs: add a reload function for mine bombs.** /prison reload bombs or /prison utils bomb reload 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 e3a0c3ba6..35a76c375 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 @@ -19,7 +19,7 @@ public class MineBombData { * it really needs to be unique and not match any other bomb's id. *

*/ - private String bombItemId; + private String loreBombItemId; private List lore; @@ -200,7 +200,7 @@ public MineBombData( String name, String itemType, String explosionShape, this.explosionShape = explosionShape; this.radius = radius; - this.bombItemId = "PrisonMineBomb: " + name; + this.loreBombItemId = "PrisonMineBomb: " + name; this.lore = new ArrayList<>(); @@ -233,7 +233,7 @@ public MineBombData clone() { MineBombData cloned = new MineBombData( getName(), getItemType(), getExplosionShape(), getRadius() ); - cloned.setBombItemId( getBombItemId() ); + cloned.setLoreBombItemId( getLoreBombItemId() ); cloned.setDescription( getDescription() ); @@ -303,11 +303,11 @@ public void setDescription( String description ) { this.description = description; } - public String getBombItemId() { - return bombItemId; + public String getLoreBombItemId() { + return loreBombItemId; } - public void setBombItemId( String bombItemId ) { - this.bombItemId = bombItemId; + public void setLoreBombItemId( String loreBombItemId ) { + this.loreBombItemId = loreBombItemId; } public List getLore() { 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 49a0d26aa..2f6639a27 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 @@ -6,6 +6,7 @@ import tech.mcprison.prison.bombs.MineBombEffectsData.EffectState; import tech.mcprison.prison.file.JsonFileIO; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.util.Location; import tech.mcprison.prison.util.Text; @@ -80,6 +81,8 @@ private MineBombs() { this.configData = new MineBombsConfigData(); loadConfigJson(); + + validateMineBombs(); } public static MineBombs getInstance() { @@ -184,9 +187,156 @@ public void loadConfigJson() { } } + + } + /** + *

This will apply simple validation to the mine bombs that were just loaded. + */ + public void validateMineBombs() + { + boolean isDirty = false; + List errors = new ArrayList<>(); + + + MineBombsConfigData config = getConfigData(); + + if ( config.getDataFormatVersion() > MineBombsConfigData.MINE_BOMB_DATA_FORMAT_VERSION || + config.getDataFormatVersion() < 0 ) { + config.setDataFormatVersion( MineBombsConfigData.MINE_BOMB_DATA_FORMAT_VERSION ); + + errors.add( String.format( + "Invalid dataFormatVersion was found and it was set to %d.", + config.getDataFormatVersion()) ); + isDirty = true; + } + + for ( String key : config.getBombs().keySet() ) + { + MineBombData bomb = config.getBombs().get( key ); + + // bombItemId is the first line of the lore and should id the bomb: +// String cleanBombItemId = Text.stripColor( bomb.getBombItemId().replace( " ", "" )); +// if ( !cleanBombItemId.equalsIgnoreCase( bomb.getBombItemId() ) ) { +// +// errors.add( String.format( +// "Invalid bombItemId: was: [%s] fixed: [%s].", +// bomb.getBombItemId(), +// cleanBombItemId ) ); +// bomb.setBombItemId( cleanBombItemId ); +// isDirty = true; +// } + + String cleanName = Text.stripColor( bomb.getName().replace( " ", "_" )); + if ( !cleanName.equalsIgnoreCase( bomb.getName() ) ) { + + errors.add( String.format( + "Invalid bomb name: Cannot contain spaces or colors. " + + "was: [%s] fixed: [%s].", + bomb.getName(), + cleanName ) ); + bomb.setName( cleanName ); + isDirty = true; + } + + if ( bomb.getItemType() == null || bomb.getItemType().trim().length() == 0 ) { + + errors.add( String.format( + "Invalid bomb itemType: Cannot be empty." ) ); + + } + + PrisonBlock item = PrisonBlock.parseFromSaveFileFormat( bomb.getItemType() ); + if ( item == null ) { + + errors.add( String.format( + "Invalid itemType for bomb: %s Cannot be mapped. " + + "currently: [%s] ", + bomb.getName(), + bomb.getItemType() ) ); +// isDirty = true; + } + + if ( bomb.getItemType().trim().length() == 0 ) { + errors.add( String.format( + "Invalid itemType for bomb: %s Cannot be empty. Using 'cobblestone'. " + + "was: [%s] ", + bomb.getName(), + bomb.getItemType() ) ); + + bomb.setItemType( PrisonBlock.fromBlockName( "cobblestone" ).getBlockName() ); + isDirty = true; + } + + if ( bomb.getRadius() < 0 ) { + errors.add( String.format( + "Invalid radius for bomb: %s Cannot be less than 1. Setting to 1. " + + "was: [%d] ", + bomb.getName(), + bomb.getRadius() ) ); + + bomb.setRadius( 1 ); + isDirty = true; + } + + if ( bomb.getRadiusInner() < 0 ) { + errors.add( String.format( + "Invalid radiusInner for bomb: %s Cannot be negative. Setting to 0. " + + "was: [%d] ", + bomb.getName(), + bomb.getRadiusInner() ) ); + + bomb.setRadiusInner( 0 ); + isDirty = true; + } + + if ( bomb.getHeight() < 0 ) { + errors.add( String.format( + "Invalid height for bomb: %s Cannot be negative. Setting to 0. " + + "was: [%d] ", + bomb.getName(), + bomb.getHeight() ) ); + + bomb.setHeight( 0 ); + isDirty = true; + } + + if ( bomb.getRemovalChance() <= 0d || bomb.getRemovalChance() > 100d ) { + errors.add( String.format( + "Invalid removalChance for bomb: %s Cannot be <= 0 or > 100. " + + "Setting to 100. " + + "was: [%d] ", + bomb.getName(), + bomb.getRemovalChance() ) ); + + bomb.setRemovalChance( 100d ); + isDirty = true; + } + + } + + + if ( isDirty ) { + // save configs + + String message = String.format( + "&4Prison Mine Bombs Validation Errors Detected: &3Changes were " + + "made to the structure of the mine bomb configurations and are being " + + "saved."); + + Output.get().logWarn( message ); + + for ( String error : errors ) + { + Output.get().logWarn( " " + error ); + } + + saveConfigJson(); + } + } + public List calculateCylinder( Location loc, int radius, boolean hollow ) { List results = new ArrayList<>(); @@ -456,7 +606,7 @@ public void setupDefaultMineBombData() MineBombData mbd = new MineBombData( "WimpyBomb", "GUNPOWDER", ExplosionShape.sphere.name(), 5, "A Wimpy Mine Bomb" ); - mbd.setBombItemId( "&7A &2Wimpy &cBomb &9...&02A3F" ); + mbd.setLoreBombItemId( "&7A &2Wimpy &cBomb &9...&02A3F" ); mbd.setNameTag( "&7A &2Wimpy &cBomb" ); @@ -559,8 +709,8 @@ public MineBombData findBombByItemId( String bombItemId ) { MineBombData bomb = getConfigData().getBombs().get( bombKey ); - if ( bomb != null && bomb.getBombItemId() != null && - bomb.getBombItemId().equalsIgnoreCase( bombItemIdConvered ) ) { + if ( bomb != null && bomb.getLoreBombItemId() != null && + bomb.getLoreBombItemId().equalsIgnoreCase( bombItemIdConvered ) ) { results = bomb; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index 335d95588..084b2ff03 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -177,6 +177,7 @@ public void utilsMineBombsReload( CommandSender sender mBombs.loadConfigJson(); + mBombs.validateMineBombs(); } } From 472d32ae13c6b0ed26f88284a90440ced7cf24cd Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Feb 2022 00:50:25 -0500 Subject: [PATCH 130/297] Mine bombs: fixed issue with lore not being added. Was adding the wrong source; was adding the destination to the destination. --- docs/changelog_v3.3.x.md | 4 ++ .../spigot/utils/PrisonUtilsMineBombs.java | 41 +++---------------- 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a4b2b9bbb..31b76b5ab 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8g 2022-02-27 +* **Mine bombs: fixed issue with lore not being added.** +Was adding the wrong source; was adding the destination to the destination. + + * **Mine Bombs: Add some basic validations when loading the mine bombs from the config files** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index 084b2ff03..0c3969b37 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -610,17 +610,17 @@ public void utilsMineBombsGive( CommandSender sender, } - public static SpigotItemStack getItemStackBomb( MineBombData bomb ) { + public static SpigotItemStack getItemStackBomb( MineBombData bombData ) { SpigotItemStack bombs = null; - XMaterial xBomb = XMaterial.matchXMaterial( bomb.getItemType() ).orElse( null ); + XMaterial xBomb = XMaterial.matchXMaterial( bombData.getItemType() ).orElse( null ); if ( xBomb != null ) { bombs = new SpigotItemStack( xBomb.parseItem() ); if ( bombs != null ) { - bombs.setDisplayName( bomb.getName() ); + bombs.setDisplayName( bombData.getName() ); //bombs.setAmount( count ); // if ( bomb.isGlowing() ) { @@ -629,38 +629,7 @@ public static SpigotItemStack getItemStackBomb( MineBombData bomb ) { List lore = new ArrayList<>( bombs.getLore() ); - lore.add( 0, bomb.getBombItemId() ); - -// lore.add( MINE_BOMBS_LORE_1 ); -// lore.add( MINE_BOMBS_LORE_2_PREFIX + bomb.getName() ); -// lore.add( " " ); -// -// lore.add( "Size, Diameter: " + ( 1 + 2 * bomb.getRadius()) ); -// lore.add( "Shape: " + bomb.getExplosionShape() ); - -// String bombDesc = bomb.getDescription(); -// String[] desc = ( bombDesc == null ? "" : bombDesc ).split( " " ); -// StringBuilder sb = new StringBuilder(); -// -// for ( String d : desc ) { -// -// sb.append( d ).append( " " ); -// -// if ( sb.length() > 30 ) { -// sb.insert( 0, " " ); -// -// lore.add( sb.toString() ); -// sb.setLength( 0 ); -// } -// } -// if ( sb.length() > 0 ) { -// sb.insert( 0, " " ); -// -// lore.add( sb.toString() ); -// } -//// lore.add( " " + bomb.getDescription() ); -// -// lore.add( " " ); + lore.add( 0, bombData.getLoreBombItemId() ); bombs.setLore( lore ); @@ -672,7 +641,7 @@ public static SpigotItemStack getItemStackBomb( MineBombData bomb ) { "Invalid MineBomb Item: Bomb: %s Cannot map '%s' to an XMaterial. " + "See this URL for valid XMaterial types: " + "https://github.com/CryptoMorin/XSeries/blob/master/src/main/java" + - "/com/cryptomorin/xseries/XMaterial.java", bomb.getName(), bomb.getItemType() ); + "/com/cryptomorin/xseries/XMaterial.java", bombData.getName(), bombData.getItemType() ); Output.get().logError( message ); } From eb2966f4f1dae15db327cbd84a83b1fd1b7896bf Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Feb 2022 00:55:33 -0500 Subject: [PATCH 131/297] Bug fix: Sellall error: Resolve an issue with the off-hand not being removed when selling. Turned out that you can read all inventory slots, which includes the off-and slot, but when removing ItemStacks, the remove(ItemStack) function then ignores the off-hand slot. Has to directly remove from the off-hand slot. --- .../prison/spigot/sellall/SellAllUtil.java | 62 ++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) 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 694fe6e95..3ff3c0b8b 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,6 +9,7 @@ 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; @@ -33,11 +34,13 @@ 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.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; /** * @author AnonymousGCA (GABRYCA) @@ -469,8 +472,11 @@ private double getSellMoney( Player p, SpigotItemStack itemStack ) * @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)){ @@ -913,6 +919,7 @@ private HashMap addInventoryToHashMap(HashMap 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 { - inv.remove(itemStack); + removeable.add( itemStack ); +// inv.remove(itemStack); } } } catch (IllegalArgumentException ignored){} } } + for ( ItemStack remove : removeable ) + { + inv.remove(remove); + } + return inv; } + 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 all Player inventories directly hooked. * @@ -1296,6 +1345,8 @@ public void removeSellableItems(Player p){ } removeSellableItems(p, p.getInventory()); + + removeSellableItemsInOffHand( p ); } /** @@ -1554,6 +1605,7 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile } 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) { Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_sign_only)); @@ -1585,8 +1637,14 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile SpigotPlayer sPlayer = new SpigotPlayer(p); RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName()); - if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) sellAllCurrency = null; + + if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) { + sellAllCurrency = null; + } + + removeSellableItems(p); + rankPlayer.addBalance(sellAllCurrency, money); if (isSellAllDelayEnabled){ From ba6db2ebfbd5a5503deb0093eee37f28bf148832 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Feb 2022 00:55:55 -0500 Subject: [PATCH 132/297] Bug fix: Sellall error: Resolve an issue with the off-hand not being removed when selling. Turned out that you can read all inventory slots, which includes the off-and slot, but when removing ItemStacks, the remove(ItemStack) function then ignores the off-hand slot. Has to directly remove from the off-hand slot. --- docs/changelog_v3.3.x.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 31b76b5ab..02b4bbb63 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.8g 2022-02-27 +* **Bug fix: Sellall error: Resolve an issue with the off-hand not being removed when selling.** +Turned out that you can read all inventory slots, which includes the off-and slot, but when removing ItemStacks, the remove(ItemStack) function then ignores the off-hand slot. Has to directly remove from the off-hand slot. + + * **Mine bombs: fixed issue with lore not being added.** Was adding the wrong source; was adding the destination to the destination. From f4a0bc00871d7b1041584e66b3bcf02dd853a58a Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Feb 2022 01:24:28 -0500 Subject: [PATCH 133/297] Prison v3.3.0-alpha.9 --- docs/changelog_v3.3.x.md | 5 ++++- docs/knownissues_v3.3.x.md | 17 ++++++++++++++++- gradle.properties | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 02b4bbb63..5ce7cd00e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.8g 2022-02-27 +# 3.3.0-alpha.9 2022-02-27 + + +* **v3.3.0-alpha.9 2022-02-27** * **Bug fix: Sellall error: Resolve an issue with the off-hand not being removed when selling.** diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index d876d831f..591c4b500 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -7,7 +7,22 @@ # TODO Items for v3.3.0-alpha.8 -* HiPriority: Inventory full not producing any messages. alexaille + +* Mine bombs: + - prison reload bombs + - validate mine bombs when initially loading... + - bomb name cannot have spaces or color formatting + - mineBombId should not have spaces in the name + - glowing effect (enchantment) + - give madog24 stone{Enchantments:[{}]} + - ItemMeta.addFlags(ItemFlag.HIDE_ENCHANTMENTS) + - throwing... as in egg or ender pearl + throwableEnable: true, + throwVectorVelocity: 1, + thrownInstantExplode: true, + + +* DONE: Works for me. HiPriority: Inventory full not producing any messages. alexaille * HiPriority: NPCs are generating a lot of errors. Real_Ganster diff --git a/gradle.properties b/gradle.properties index 0a98b1b62..46bf5b077 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.8h +version=3.3.0-alpha.9 #version=3.3.0-alpha.7 From 48ff808a048387ad391e60acc68ce6296f032f7f Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Feb 2022 16:19:21 -0500 Subject: [PATCH 134/297] Mine manager when enabling mines after the delayed loading from multiverse-core delayed loading... put a slight delay on each submission of the startup air counts for each mine... spacing them out by one tick so they are not all trying to run at the same time. --- docs/changelog_v3.3.x.md | 4 +++ .../mcprison/prison/mines/data/MineReset.java | 14 +++++++---- .../prison/mines/data/MineResetAsyncTask.java | 2 +- .../prison/mines/data/MineSweeperTask.java | 2 +- .../mcprison/prison/mines/data/MineTasks.java | 25 +++++++++++++------ ...StartupRefreshBlockBreakCountSyncTask.java | 6 ++--- .../prison/mines/managers/MineManager.java | 3 ++- 7 files changed, 37 insertions(+), 19 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5ce7cd00e..59eb6a553 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9 2022-02-27 +* **Mine manager when enabling mines after the delayed loading from multiverse-core delayed loading...** +put a slight delay on each submission of the startup air counts for each mine... spacing them out by one tick so they are not all trying to run at the same time. + + * **v3.3.0-alpha.9 2022-02-27** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index cca839e69..f86ec9c97 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -160,7 +160,7 @@ protected void initialize() { if ( !isVirtual() ) { // Once the mine has been loaded, MUST get a count of all air blocks. - refreshBlockBreakCountUponStartup(); + refreshBlockBreakCountUponStartup( 0 ); } } @@ -460,9 +460,13 @@ public void saveIfUnsavedBlockCounts() { * * @param callbackAsync */ - public abstract int submitAsyncTask( PrisonRunnable callbackAsync ); +// public abstract int submitAsyncTask( PrisonRunnable callbackAsync ); - public abstract int submitSyncTask( PrisonRunnable callbackSync ); + public abstract int submitAsyncTask( PrisonRunnable callbackAsync, long delay ); + +// public abstract int submitSyncTask( PrisonRunnable callbackSync ); + + public abstract int submitSyncTask( PrisonRunnable callbackSync, long delay ); @@ -1122,13 +1126,13 @@ public boolean resetAsynchonouslyInitiate( MineResetType resetType ) { * But as a warning, this may trigger stack traces if there are active * entities in the unloaded chunks. May have run this synchronously. :( */ - public void refreshBlockBreakCountUponStartup() { + public void refreshBlockBreakCountUponStartup( long delay) { // if the mine is being used in a unit test, then it will not have a value for // bounds and therefore do not run the task. if ( getBounds() != null ) { - OnStartupRefreshBlockBreakCountSyncTask.submit( this ); + OnStartupRefreshBlockBreakCountSyncTask.submit( this, delay ); // OnStartupRefreshBlockBreakCountAsyncTask cabAsyncTask = new OnStartupRefreshBlockBreakCountAsyncTask(this); // diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineResetAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineResetAsyncTask.java index 85f24788e..17bbcd0f7 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineResetAsyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineResetAsyncTask.java @@ -18,7 +18,7 @@ public void run() { this.mine.refreshMineAsyncTask(); if ( this.callbackAsync != null ) { - this.mine.submitAsyncTask( callbackAsync ); + this.mine.submitAsyncTask( callbackAsync, 0 ); } } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineSweeperTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineSweeperTask.java index 793299b58..8d174f640 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineSweeperTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineSweeperTask.java @@ -18,7 +18,7 @@ public void run() { this.mine.runMineSweeperTask(); if ( this.callbackAsync != null ) { - this.mine.submitAsyncTask( callbackAsync ); + this.mine.submitAsyncTask( callbackAsync, 0 ); } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java index d63461fa1..ce8b92aca 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineTasks.java @@ -51,17 +51,26 @@ protected void initialize() { * * @param callbackAsync */ +// @Override +// public int submitAsyncTask( PrisonRunnable callbackAsync ) { +// return submitAsyncTask( callbackAsync, 0L ); +// } @Override - public int submitAsyncTask( PrisonRunnable callbackAsync ) { - return Prison.get().getPlatform().getScheduler().runTaskLaterAsync( callbackAsync, - getResetPagePageSubmitDelayTicks() ); - } + public int submitAsyncTask( PrisonRunnable callbackAsync, long delay ) { + return Prison.get().getPlatform().getScheduler().runTaskLaterAsync( callbackAsync, + getResetPagePageSubmitDelayTicks() + delay ); + } +// @Override +// public int submitSyncTask( PrisonRunnable callbackSync ) { +// return submitSyncTask( callbackSync, 0L ); +// } + @Override - public int submitSyncTask( PrisonRunnable callbackSync ) { - return Prison.get().getPlatform().getScheduler().runTaskLater( callbackSync, - getResetPagePageSubmitDelayTicks() ); - } + public int submitSyncTask( PrisonRunnable callbackSync, long delay ) { + return Prison.get().getPlatform().getScheduler().runTaskLater( callbackSync, + getResetPagePageSubmitDelayTicks() + delay ); + } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountSyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountSyncTask.java index 2dec70ff4..c02cf30a8 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountSyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/OnStartupRefreshBlockBreakCountSyncTask.java @@ -27,7 +27,7 @@ public OnStartupRefreshBlockBreakCountSyncTask(MineReset mine) { this.mine = mine; } - public static void submit( MineReset mine ) { + public static void submit( MineReset mine, long delay ) { OnStartupRefreshBlockBreakCountSyncTask syncTask = new OnStartupRefreshBlockBreakCountSyncTask( mine ); @@ -37,7 +37,7 @@ public static void submit( MineReset mine ) { // The first phase generates a List of Locations which // can be ran async... - syncTask.setJobId( mine.submitAsyncTask( syncTask ) ); + syncTask.setJobId( mine.submitAsyncTask( syncTask, delay ) ); } } @@ -45,7 +45,7 @@ public static void submit( MineReset mine ) { private void resubmit() { // Must run synchronously!! - setJobId( mine.submitSyncTask( this ) ); + setJobId( mine.submitSyncTask( this, 0 ) ); } @Override diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java index 856f62f50..88fc48225 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java @@ -659,6 +659,7 @@ public void assignAvailableWorld( String worldName ) { // List remove = new ArrayList<>(); + long delay = 0; for ( Mine mine : unenabledMines ) { if ( !mine.isEnabled() ) { @@ -683,7 +684,7 @@ public void assignAvailableWorld( String worldName ) { } // Run the air-counts now that mine can be activated: - mine.refreshBlockBreakCountUponStartup(); + mine.refreshBlockBreakCountUponStartup( delay++ ); } From 27e9a7a6e29cc15c71f2447ddb3726bea998370b Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:07:44 -0500 Subject: [PATCH 135/297] Fix placeholder for prison_player_tool_lore to provide the actual tool's lore. The placeholder was not hooked up. --- docs/changelog_v3.3.x.md | 6 ++- .../mcprison/prison/internal/PlayerUtil.java | 2 + .../prison/ranks/managers/PlayerManager.java | 13 ++++- .../prison/spigot/game/SpigotPlayerUtil.java | 49 +++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 59eb6a553..72e2d862c 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9 2022-02-27 +# 3.3.0-alpha.9 2022-02-28 + + +* **Fix placeholder for prison_player_tool_lore to provide the actual tool's lore.** +The placeholder was not hooked up. * **Mine manager when enabling mines after the delayed loading from multiverse-core delayed loading...** diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/PlayerUtil.java b/prison-core/src/main/java/tech/mcprison/prison/internal/PlayerUtil.java index 49be5f869..25f1c3ca4 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/PlayerUtil.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/PlayerUtil.java @@ -142,6 +142,8 @@ public PlayerUtil( UUID playerUuid ) { public abstract int getItemInHandEnchantmentLuck(); + public abstract String getItemInHandLore(); + public UUID getPlayerUuid() { return playerUuid; } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index 21ff052a9..ee4dd63fc 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -1277,6 +1277,9 @@ public String getPlayerNextRankName( RankPlayer rankPlayer, String ladderName ) public String getPlayerNextRankTag( RankPlayer rankPlayer, String ladderName ) { StringBuilder sb = new StringBuilder(); + boolean hasDefault = false; + boolean hasPrestige = false; + if ( !rankPlayer.getLadderRanks().isEmpty()) { RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); @@ -1665,12 +1668,18 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_data: case prison_ptdata: - + { + + results = ""; + } break; case prison_player_tool_lore: case prison_ptlore: - + { + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + results = pUtil.getItemInHandLore(); + } break; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java index df736630f..4eed2fe89 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java @@ -1,6 +1,7 @@ package tech.mcprison.prison.spigot.game; import java.lang.reflect.Method; +import java.util.Set; import java.util.UUID; import org.bukkit.enchantments.Enchantment; @@ -417,7 +418,55 @@ public int getItemInHandEnchantmentLuck() { } +// public String getEnchantments() { +// StringBuilder sb = new StringBuilder(); +// +// SpigotItemStack itemStack = getItemInHand(); +// +// if ( itemStack != null && itemStack.getBukkitStack() != null) { +// try { +// +// Set keys = itemStack.getBukkitStack().getEnchantments().keySet(); +// +// for ( Enchantment key : keys ) { +// Integer value = itemStack.getBukkitStack().getEnchantments().get( key ); +// +// if ( value != null ) { +// if ( sb.length() > 0 ) { +// sb.append( ", " ); +// } +// sb.append( key.getName() ).append( ": " ).append( value ); +// key.getItemTarget().toString() +// } +// } +// +// } +// catch ( NullPointerException e ) { +// // Ignore. This happens when a TokeEnchanted tool is used when TE is not installed anymore. +// // It throws this exception: Caused by: java.lang.NullPointerException: null key in entry: null=5 +// } +// } +// } + public String getItemInHandLore() { + StringBuilder sb = new StringBuilder(); + + SpigotItemStack itemStack = getItemInHand(); + + if ( itemStack.getLore() != null && itemStack.getLore().size() > 0 ) { + for ( String lore : itemStack.getLore() ) + { + if ( lore.trim().length() > 0 ) { + if ( sb.length() > 0 ) { + sb.append( "\\" ); + } + sb.append( lore ); + } + } + } + + return sb.toString(); + } public SpigotPlayer getSpigotPlayer() { return spigotPlayer; From ed01a356302c777b53c5142ec7d9fe6b3a7aae9e Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:12:37 -0500 Subject: [PATCH 136/297] Fixed a bug with the blockEvent block filter for adding blocks, it was using the blockEvents collection instead of the prison blocks collection. --- docs/changelog_v3.3.x.md | 3 +++ .../tech/mcprison/prison/mines/commands/MinesCommands.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 72e2d862c..6e6655613 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9 2022-02-28 +* **Fixed a bug with the blockEvent block filter for adding blocks, it was using the blockEvents collection instead of the prison blocks collection.** + + * **Fix placeholder for prison_player_tool_lore to provide the actual tool's lore.** The placeholder was not hooked up. 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 5f38217f9..7f7433656 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 @@ -4088,7 +4088,7 @@ public void blockEventBlockAdd(CommandSender sender, if ( blockEvent != null ) { if ( rowBlockName == null || rowBlockName == 0 || - rowBlockName > m.getBlockEvents().size() ) { + rowBlockName > m.getPrisonBlocks().size() ) { String commandBlockEvent = String.format( "" + "%s %d ", commandRoot, rowBlockEvent ); From 207555d43b581d529ff0a4f29e82de1c28bcf5b2 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:15:43 -0500 Subject: [PATCH 137/297] Module prison-sellall cleaned up gradle config to remove a few configs that are not needed. --- docs/changelog_v3.3.x.md | 3 +++ prison-sellall/build.gradle | 9 --------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 6e6655613..539881c6e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9 2022-02-28 +* **Module prison-sellall cleaned up gradle config to remove a few configs that are not needed.** + + * **Fixed a bug with the blockEvent block filter for adding blocks, it was using the blockEvents collection instead of the prison blocks collection.** diff --git a/prison-sellall/build.gradle b/prison-sellall/build.gradle index e01ec22ef..f23eaf0ae 100644 --- a/prison-sellall/build.gradle +++ b/prison-sellall/build.gradle @@ -28,11 +28,6 @@ compileTestJava.options.encoding = "UTF-8" repositories { mavenCentral() - // net.luckperm.api: - maven { url = "https://hub.spigotmc.org/nexus/content/groups/public" } - - maven { url = "https://nexus.hc.to/content/repositories/pub_releases" } - maven { url = "https://repo.codemc.org/repository/maven-public/" } // maven { @@ -58,10 +53,6 @@ dependencies { - compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT' - - - testImplementation group: 'junit', name: 'junit', version: '4.12' } From 370d08eac059bdd1d3c3b581a136b089f3f034c5 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:28:34 -0500 Subject: [PATCH 138/297] Sellall bug fix... was using the wrapper to map it to an XMaterial which was causing NPEs. Using the prison's compatibility functions to perform the mapping, which will now provide a safer mapping that will not cause NPEs. --- docs/changelog_v3.3.x.md | 4 ++++ .../mcprison/prison/spigot/sellall/SellAllUtil.java | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 539881c6e..70ba610bb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9 2022-02-28 +* **Sellall bug fix... was using the wrapper to map it to an XMaterial which was causing NPEs.** +Using the prison's compatibility functions to perform the mapping, which will now provide a safer mapping that will not cause NPEs. + + * **Module prison-sellall cleaned up gradle config to remove a few configs that are not needed.** 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 3ff3c0b8b..568d9a8a3 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 @@ -25,6 +25,7 @@ import tech.mcprison.prison.Prison; import tech.mcprison.prison.PrisonAPI; import tech.mcprison.prison.integration.EconomyCurrencyIntegration; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.data.PlayerRank; @@ -48,15 +49,20 @@ public class SellAllUtil { private static SellAllUtil instance; + private static final boolean isEnabled = Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ); + // private static final boolean isEnabled = getBoolean(SpigotPrison.getInstance().getConfig().getString("sellall")); private final Compatibility compat = SpigotPrison.getInstance().getCompatibility(); + private final ItemStack lapisLazuli = compat.getLapisItemStack(); public Configuration sellAllConfig; + private HashMap sellAllBlocks; private HashMap sellAllPrestigeMultipliers; private HashMap autoSellEarningsNotificationWaiting = new HashMap<>(); private ArrayList sellAllItemTriggers; + private ArrayList activePlayerDelay = new ArrayList<>(); private List sellAllDisabledWorlds; private MessagesConfig messages; @@ -451,7 +457,9 @@ private double getSellMoney( Player p, SpigotItemStack itemStack ) HashMap xMaterialIntegerHashMap = new HashMap<>(); - XMaterial xMat = XMaterial.matchXMaterial( itemStack.getBukkitStack() ); + PrisonBlock pBlock = itemStack.getMaterial(); + + XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( pBlock ); if ( xMat != null ) { xMaterialIntegerHashMap.put( xMat, itemStack.getAmount() ); From ad3e2399dbdb554b464024d82ce0ba764a9e6725 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 28 Feb 2022 12:56:28 -0500 Subject: [PATCH 139/297] v3.3.0-alpha.9b --- docs/changelog_v3.3.x.md | 3 +++ gradle.properties | 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 70ba610bb..2e7683b16 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9 2022-02-28 +* **v3.3.0-alpha.9b 2022-02-28** + + * **Sellall bug fix... was using the wrapper to map it to an XMaterial which was causing NPEs.** Using the prison's compatibility functions to perform the mapping, which will now provide a safer mapping that will not cause NPEs. diff --git a/gradle.properties b/gradle.properties index 46bf5b077..854f767c1 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.9 +version=3.3.0-alpha.9b #version=3.3.0-alpha.7 From 1c85433c0c934fadac0f4bf218d07aa2b8c681a4 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 28 Feb 2022 13:02:18 -0500 Subject: [PATCH 140/297] PlayerCache: Unloading Players... when a player is being unloaded, and they are not in the cache, the unloading process is now able to indicate that the player should not be loaded. Also when trying to load a player, it will not attempt the load if the file does not exist. --- docs/changelog_v3.3.x.md | 4 ++ .../mcprison/prison/cache/PlayerCache.java | 27 ++++++++------ .../prison/cache/PlayerCacheFiles.java | 37 +++++++++++-------- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 2e7683b16..bbdebbe28 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -19,6 +19,10 @@ These build logs represent the work that has been going on within prison. * **v3.3.0-alpha.9b 2022-02-28** +* **PlayerCache: Unloading Players... when a player is being unloaded, and they are not in the cache, the unloading process is now able to indicate that the player should not be loaded.** +Also when trying to load a player, it will not attempt the load if the file does not exist. + + * **Sellall bug fix... was using the wrapper to map it to an XMaterial which was causing NPEs.** Using the prison's compatibility functions to perform the mapping, which will now provide a safer mapping that will not cause NPEs. diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java index a4cee4b0d..9b1ca5727 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCache.java @@ -252,6 +252,10 @@ public PlayerCachePlayerData getOnlinePlayer( Player player ) { return playerData; } + private PlayerCachePlayerData getPlayer( Player player ) { + return getPlayer( player, true ); + } + /** *

This returns the cached player object. If they have not been loaded * yet, then this will load the player object while waiting for it. @@ -264,7 +268,7 @@ public PlayerCachePlayerData getOnlinePlayer( Player player ) { * @return The cached player object. If null, then may indicate the player is * actively being loaded, so try again later. */ - private PlayerCachePlayerData getPlayer( Player player ) { + private PlayerCachePlayerData getPlayer( Player player, boolean loadIfNotInCache ) { PlayerCachePlayerData playerData = null; getStats().incrementGetPlayers(); @@ -272,7 +276,16 @@ private PlayerCachePlayerData getPlayer( Player player ) { String playerUuid = player.getUUID().toString(); - if ( !getPlayers().containsKey( playerUuid ) ) { + + if ( getPlayers().containsKey( playerUuid ) ) { + + // Note: if the player has not been loaded yet, this will return a null: + synchronized ( getPlayers() ) { + + playerData = getPlayers().get( playerUuid ); + } + } + else if ( loadIfNotInCache ) { // Load the player's existing balance: playerData = getCacheFiles().fromJson( player ); @@ -287,14 +300,6 @@ private PlayerCachePlayerData getPlayer( Player player ) { // runLoadPlayerNow( player ); // submitAsyncLoadPlayer( player ); } - else { - - // Note: if the player has not been loaded yet, this will return a null: - synchronized ( getPlayers() ) { - - playerData = getPlayers().get( playerUuid ); - } - } if ( playerData != null ) { @@ -350,7 +355,7 @@ protected void submitAsyncLoadPlayer( Player player ) { protected void submitAsyncUnloadPlayer( Player player ) { - PlayerCachePlayerData playerData = getPlayer( player ); + PlayerCachePlayerData playerData = getPlayer( player, false ); if ( playerData != null ) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java index d179c749f..db120784f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCacheFiles.java @@ -188,22 +188,29 @@ private File createTempFile( File file ) { */ private PlayerCachePlayerData fromJsonFile( File inputFile ) { PlayerCachePlayerData results = null; - try ( - FileReader fr = new FileReader( inputFile ); - ) { - - results = getGson().fromJson( - fr, PlayerCachePlayerData.class ); + + if ( inputFile.exists() ) { - results.setPlayerFile( inputFile ); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - catch ( JsonSyntaxException | JsonIOException e ) - { - e.printStackTrace(); + try ( + FileReader fr = new FileReader( inputFile ); + ) { + + results = getGson().fromJson( + fr, PlayerCachePlayerData.class ); + + if ( results != null ) { + + results.setPlayerFile( inputFile ); + } + } + catch ( IOException e ) + { + e.printStackTrace(); + } + catch ( JsonSyntaxException | JsonIOException e ) + { + e.printStackTrace(); + } } return results; From b444d2c6e9f7b40a9a36831003939dc297a5ccd2 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 28 Feb 2022 17:11:20 -0500 Subject: [PATCH 141/297] Fixed the command '/ranks ladder command remove' when specifying a row value that was too large. The message was only providing one value when it should have had two, and the first parameter was '%d' instead of '%1'. --- docs/changelog_v3.3.x.md | 4 ++++ prison-core/src/main/resources/lang/ranks/en_US.properties | 4 ++-- prison-core/src/main/resources/lang/ranks/zh_TW.properties | 4 ++-- .../tech/mcprison/prison/ranks/commands/CommandCommands.java | 4 ++-- .../prison/ranks/commands/CommandCommandsMessages.java | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index bbdebbe28..c6f9bb020 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -19,6 +19,10 @@ These build logs represent the work that has been going on within prison. * **v3.3.0-alpha.9b 2022-02-28** +* **Fixed the command '/ranks ladder command remove' when specifying a row value that was too large.** +The message was only providing one value when it should have had two, and the first parameter was '%d' instead of '%1'. + + * **PlayerCache: Unloading Players... when a player is being unloaded, and they are not in the cache, the unloading process is now able to indicate that the player should not be loaded.** Also when trying to load a player, it will not attempt the load if the file does not exist. diff --git a/prison-core/src/main/resources/lang/ranks/en_US.properties b/prison-core/src/main/resources/lang/ranks/en_US.properties index b510fd4e5..428f6fb79 100644 --- a/prison-core/src/main/resources/lang/ranks/en_US.properties +++ b/prison-core/src/main/resources/lang/ranks/en_US.properties @@ -50,7 +50,7 @@ ## -messages__version=21 +messages__version=22 messages__auto_refresh=true ranks_rankup__rankup_no_player_name=You have @@ -177,7 +177,7 @@ ranks_commandCommands__command_list_click_to_remove=Click to remove. ranks_commandCommands__command_list_add_button=&7[&a+&7] Add a new Command ranks_commandCommands__command_list_add_new_command_tool_tip=&7Add a new Command. ranks_commandCommands__command_row_number_must_be_greater_than_zero=&7Please provide a valid row number greater than zero. Was row=[&b%1&7] -ranks_commandCommands__command_row_number_too_high=&7Please provide a valid row number no greater than &b%d&7. Was row=[&b%1&7] +ranks_commandCommands__command_row_number_too_high=&7Please provide a valid row number no greater than &b%1&7. Was row=[&b%2&7] diff --git a/prison-core/src/main/resources/lang/ranks/zh_TW.properties b/prison-core/src/main/resources/lang/ranks/zh_TW.properties index 087ee5488..426e62ff9 100644 --- a/prison-core/src/main/resources/lang/ranks/zh_TW.properties +++ b/prison-core/src/main/resources/lang/ranks/zh_TW.properties @@ -50,7 +50,7 @@ ## -messages__version=2 +messages__version=3 messages__auto_refresh=true ranks_rankup__rankup_no_player_name=您已經 @@ -169,7 +169,7 @@ ranks_commandCommands__command_list_click_to_remove=點擊刪除. ranks_commandCommands__command_list_add_button=&7[&a+&7] 新增 ranks_commandCommands__command_list_add_new_command_tool_tip=&7新增新的指令 ranks_commandCommands__command_row_number_must_be_greater_than_zero=&7請輸入一個大於0的有效 è¡Œ 的值,è¡Œ 是=[&b%1&7] -ranks_commandCommands__command_row_number_too_high=&7請輸入一個ä¸å¤§æ–¼ &b%d &7的有效 è¡Œ 的值,è¡Œ 是 [&b%1&7] +ranks_commandCommands__command_row_number_too_high=&7請輸入一個ä¸å¤§æ–¼ &b%1 &7的有效 è¡Œ 的值,è¡Œ 是 [&b%2&7] diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java index 7e9051abb..b0749bed7 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java @@ -123,7 +123,7 @@ public void commandRemove(CommandSender sender, } if ( row > rank.getRankUpCommands().size() ) { - rankRowNumberTooHigh( sender, row ); + rankRowNumberTooHigh( sender, rank.getRankUpCommands().size(), row ); return; } @@ -301,7 +301,7 @@ public void commandLadderRemove(CommandSender sender, } if ( row > ladder.getRankUpCommands().size() ) { - rankRowNumberTooHigh( sender, row ); + rankRowNumberTooHigh( sender, ladder.getRankUpCommands().size(), row ); return; } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommandsMessages.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommandsMessages.java index a369f60a9..8d12ab51a 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommandsMessages.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommandsMessages.java @@ -119,10 +119,11 @@ protected void rankRowNumberMustBeGreaterThanZero( CommandSender sender, Integer .sendTo( sender ); } - protected void rankRowNumberTooHigh( CommandSender sender, Integer row ) { + protected void rankRowNumberTooHigh( CommandSender sender, Integer maxValue, Integer row ) { PrisonRanks.getInstance().getRanksMessages() .getLocalizable( "ranks_commandCommands__command_row_number_too_high" ) .withReplacements( + Integer.toString( maxValue ), Integer.toString( row ) ) .sendTo( sender ); } From b182c961190b1831c59fe87e89fb70d9a2479879 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 1 Mar 2022 06:02:51 -0500 Subject: [PATCH 142/297] Bug fix: The clickable delete code is that is generated is off by 1 on the inserted row. The row number needed to be reduced by one since the row number was incremented right before this final injection. --- .../tech/mcprison/prison/ranks/commands/CommandCommands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java index b0749bed7..57c40c769 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/CommandCommands.java @@ -369,7 +369,7 @@ protected ChatDisplay commandLadderListDetail( RankLadder ladder, boolean noRemo if ( !noRemoves ) { FancyMessage msgRemove = new FancyMessage( " &4Remove&3" ) - .suggest("/ranks ladder command remove " + ladder.getName() + " " + rowNumber ) + .suggest("/ranks ladder command remove " + ladder.getName() + " " + (rowNumber - 1) ) .tooltip( ranksCommandListClickToRemoveMsg() ); row.addFancy( msgRemove ); } From 8356e21cf09642fcd4629d05138667c87a359d5d Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 1 Mar 2022 10:40:22 -0500 Subject: [PATCH 143/297] Bug fix: Risk of a null on the blockHit, so add checks to ensure it's not before trying to process. --- docs/changelog_v3.3.x.md | 9 ++++++++- .../prison/spigot/block/OnBlockBreakEventCore.java | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c6f9bb020..75d294c97 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,14 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9 2022-02-28 +# 3.3.0-alpha.9b 2022-03-01 + + +* **Bug fix: Risk of a null on the blockHit, so add checks to ensure it's not before trying to process.** + + +* **Bug fix: The clickable delete code is that is generated is off by 1 on the inserted row.** +The row number needed to be reduced by one since the row number was incremented right before this final injection. * **v3.3.0-alpha.9b 2022-02-28** 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 a03c50eab..8eb66d7b4 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 @@ -773,7 +773,8 @@ private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder // if using CrazyEnchant one of the unprocessedRawBlocks may be the same as the // pmEvent.getSpigotBlock(), so ignore if both are the same. // Compare the locations... - if ( !sBlockHit.getLocation().equals( sBlockMined.getLocation() ) ) { + if ( sBlockHit != null && sBlockMined != null && + !sBlockHit.getLocation().equals( sBlockMined.getLocation() ) ) { if ( !mine.isInMineExact( sBlockMined.getLocation() ) ) { outsideOfMine++; From 0e1a5fcbf1d8339665960c6458243d61f272b05e Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Tue, 1 Mar 2022 20:08:44 -0500 Subject: [PATCH 144/297] Bug fix: Fixed an issue were a block would be added, or changed, and it would change all similar blocks in all mines to have the same percentage. This issue was intermittent and was caused by directly getting the block from the master list, without cloning it. The correction to this issue was to use a search function that would clone the block, but it also would compensate for custom blocks if the block's namespace was not initially provided. --- docs/changelog_v3.3.x.md | 4 ++++ .../mines/commands/MinesBlockCommands.java | 16 ++++++++++------ .../prison/mines/features/MineBlockEvent.java | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 75d294c97..7076fd8f6 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9b 2022-03-01 +* **Bug fix: Fixed an issue were a block would be added, or changed, and it would change all similar blocks in all mines to have the same percentage.** +This issue was intermittent and was caused by directly getting the block from the master list, without cloning it. The correction to this issue was to use a search function that would clone the block, but it also would compensate for custom blocks if the block's namespace was not initially provided. + + * **Bug fix: Risk of a null on the blockHit, so add checks to ensure it's not before trying to process.** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java index 0a60f75fd..dd14006c9 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java @@ -55,9 +55,13 @@ public void addBlockCommand(CommandSender sender, PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); - if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { - prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); + if ( block != null ) { + prisonBlock = prisonBlockTypes.getBlockTypesByName( block ); } +// if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { +// prisonBlock = prisonBlockTypes.getBlockTypesByName( block ); +// prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); +// } if ( prisonBlock == null ) { pMines.getMinesMessages().getLocalizable("not_a_block"). @@ -332,8 +336,8 @@ public void setBlockCommand(CommandSender sender, PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); - if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { - prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); + if ( block != null ) { + prisonBlock = prisonBlockTypes.getBlockTypesByName( block ); } @@ -454,8 +458,8 @@ public void delBlockCommand(CommandSender sender, PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); - if ( block != null && prisonBlockTypes.getBlockTypesByName().containsKey( block ) ) { - prisonBlock = prisonBlockTypes.getBlockTypesByName().get( block ); + if ( block != null ) { + prisonBlock = prisonBlockTypes.getBlockTypesByName( block ); } // Cannot delete a block if it does not exist: 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 899e87fce..cf5ad9b9d 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 @@ -264,7 +264,7 @@ private static MineBlockEvent fromStringV1( String chancePermCommand, String min PrisonBlockTypes pBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes(); for ( String block : blocks.toLowerCase().split( "," ) ) { - PrisonBlock blockType = pBlockTypes.getBlockTypesByName().get( block ); + PrisonBlock blockType = pBlockTypes.getBlockTypesByName( block ); if ( blockType != null ) { results.getPrisonBlocks().add( blockType ); } From 1d497e29cc10557559323058ea72ffc62e91427c Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Mar 2022 01:06:57 -0500 Subject: [PATCH 145/297] Some initial setup for a rankScore. This is not hooked up yet, but the the core basics are there and should work soon. --- docs/changelog_v3.3.x.md | 6 +- .../prison/ranks/data/PlayerRank.java | 16 +++ .../tech/mcprison/prison/ranks/data/Rank.java | 19 ++- .../prison/ranks/data/RankPlayer.java | 135 ++++++++++++++++++ .../prison/ranks/managers/PlayerManager.java | 13 +- .../RankPlayerSortOrderTopRanked.java | 88 ++++++++++++ 6 files changed, 274 insertions(+), 3 deletions(-) create mode 100644 prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankPlayerSortOrderTopRanked.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7076fd8f6..e3f96078c 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9b 2022-03-01 +# 3.3.0-alpha.9b 2022-03-03 + + +* **Some initial setup for a rankScore.** +This is not hooked up yet, but the the core basics are there and should work soon. * **Bug fix: Fixed an issue were a block would be added, or changed, and it would change all similar blocks in all mines to have the same percentage.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/PlayerRank.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/PlayerRank.java index 3e814ab36..f0bd2819e 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/PlayerRank.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/PlayerRank.java @@ -7,6 +7,7 @@ * */ public class PlayerRank + implements Comparable { private final Rank rank; @@ -187,4 +188,19 @@ public Double getRankCost() { // this.rankCost = rankCost; // } + @Override + public int compareTo( PlayerRank pr ) + { + int results = 0; + + if ( pr == null ) { + results = -1; + } + else { + results = getRank().compareTo( pr.getRank() ); + } + + return results; + } + } diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/Rank.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/Rank.java index 72f15671b..976e61da9 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/Rank.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/Rank.java @@ -32,7 +32,8 @@ public class Rank //extends RankMessages implements PrisonSortable, - ModuleElement { + ModuleElement, + Comparable { // // This is to help eliminate RankLadder.PositionRank object: private transient int position = -1; @@ -384,6 +385,22 @@ public int hashCode() { result = 31 * result + currency.hashCode(); return result; } + + + @Override + public int compareTo( Rank r ) + { + int results = 0; + + if ( r == null ) { + results = -1; + } + else { + results = Integer.compare( getPosition(), r.getPosition() ); + } + + return results; + } /** * This new implementation of position is lazy loaded and should never be saved. diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index 4fa09b360..0203b353b 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -49,6 +49,10 @@ public class RankPlayer implements Player { public static final long DELAY_THREE_SECONDS = 20 * 3; // 3 seconds in ticks + + public static final long RANK_SCORE_COOLDOWN_MS = 1000 * 30; // 30 seconds + public static final double RANK_SCORE_BALANCE_THRESHOLD_PERCENT = 0.05d; // 5% + /* * Fields & Constants @@ -85,6 +89,20 @@ public class RankPlayer + /** + *

The 'rankScore' fields are used to calculate the rankScore, of which + * the 'rankScoreBalance' is used to track the player's balance when these + * values were last calculated. It is used to determine if there should + * be a recalculation of the score. + *

+ */ + private double rankScoreBalance = 0; + private String rankScoreCurrency = null; + private double rankScoreBalanceThreshold = 0; + private double rankScore = 0; + private double rankScorePenalty = 0; + private long rankScoreCooldown = 0L; + public RankPlayer() { super(); @@ -1143,4 +1161,121 @@ public PlayerCachePlayerData getPlayerCachePlayerData() { public boolean isSneaking() { return false; } + + /** + *

Calculates the rankScore for the player's rank on the default ladder. + * The calculation is based upon how much the next rank costs. + *

+ * + */ + private void calculateRankScore() { + PlayerRank rankCurrent = getPlayerRankDefault(); + + Rank nRank = rankCurrent.getRank().getRankNext(); + String rankNextCurrency = nRank.getCurrency(); + + PlayerRank pRankNext = rankCurrent.getTargetPlayerRankForPlayer( this, nRank ); + + double cost = pRankNext.getRankCost(); + double balance = getBalance( rankNextCurrency ); + + double score = balance; + double penalty = 0d; + + // Do not apply the penalty if cost is zero: + if ( isHesitancyDelayPenaltyEnabled() && cost > 0 ) { + score = balance > cost ? cost : score; + + double excess = balance > cost ? balance - cost : 0d; + penalty = excess * 0.2d; + } + + score = (score - penalty); + + if ( cost > 0 ) { + score /= cost * 100.0d; + } + + double balanceThreshold = cost * RANK_SCORE_BALANCE_THRESHOLD_PERCENT; + + setRankScoreBalance( balance ); + setRankScoreCurrency( rankNextCurrency ); + setRankScoreBalanceThreshold( balanceThreshold ); + setRankScore( score ); + setRankScorePenalty( penalty ); + + setRankScoreCooldown( System.currentTimeMillis() + RANK_SCORE_COOLDOWN_MS ); + } + + private void checkRecalculateRankScore() { + + if ( getRankScoreCooldown() == 0L || + System.currentTimeMillis() > getRankScoreCooldown() + ) { + + double currentBalance = getBalance( getRankScoreCurrency() ); + + if ( currentBalance == getRankScoreBalance() || + currentBalance >= (getRankScoreBalance() - getRankScoreBalanceThreshold()) || + currentBalance <= (getRankScoreBalance() + getRankScoreBalanceThreshold() ) ) { + + // increment the cooldown since the balance is either the same, or still + // within the threshold range: + setRankScoreCooldown( System.currentTimeMillis() + RANK_SCORE_COOLDOWN_MS ); + } + else { + calculateRankScore(); + } + } + } + + public boolean isHesitancyDelayPenaltyEnabled() { + return Prison.get().getPlatform() + .getConfigBooleanTrue( "top-stats.rank-players.hesitancy-delay-penalty" ); + } + + public double getRankScoreBalance() { + return rankScoreBalance; + } + public void setRankScoreBalance( double rankScoreBalance ) { + this.rankScoreBalance = rankScoreBalance; + } + + public String getRankScoreCurrency() { + return rankScoreCurrency; + } + public void setRankScoreCurrency( String rankScoreCurrency ) { + this.rankScoreCurrency = rankScoreCurrency; + } + + public double getRankScoreBalanceThreshold() { + return rankScoreBalanceThreshold; + } + public void setRankScoreBalanceThreshold( double rankScoreBalanceThreshold ) { + this.rankScoreBalanceThreshold = rankScoreBalanceThreshold; + } + public double getRankScore() { + + // check if the rankScore needs to be reset: + checkRecalculateRankScore(); + + return rankScore; + } + public void setRankScore( double rankScore ) { + this.rankScore = rankScore; + } + + public double getRankScorePenalty() { + return rankScorePenalty; + } + public void setRankScorePenalty( double rankScorePenalty ) { + this.rankScorePenalty = rankScorePenalty; + } + + public long getRankScoreCooldown() { + return rankScoreCooldown; + } + public void setRankScoreCooldown( long rankScoreCooldown ) { + this.rankScoreCooldown = rankScoreCooldown; + } } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index ee4dd63fc..cdf6d5fd7 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -69,8 +70,10 @@ public class PlayerManager private List players; private TreeMap playersByName; -// private List playersByTop; + private RankPlayerSortOrderTopRanked sorterTopN; + private List playersByTop; + private List translatedPlaceHolderKeys; private transient Set playerErrors; @@ -83,6 +86,9 @@ public PlayerManager(Collection collection) { this.players = new ArrayList<>(); this.playersByName = new TreeMap<>(); + this.sorterTopN = new RankPlayerSortOrderTopRanked(); + this.playersByTop= new ArrayList<>(); + this.playerErrors = new HashSet<>(); Prison.get().getEventBus().register(this); @@ -141,9 +147,14 @@ public void loadPlayers() throws IOException { playersByName.put( rankPlayer.getDisplayName(), rankPlayer ); } + + playersByTop.add( rankPlayer ); + } + Collections.sort( playersByTop, sorterTopN ); + // players.forEach( // document -> diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankPlayerSortOrderTopRanked.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankPlayerSortOrderTopRanked.java new file mode 100644 index 000000000..0e8a2a907 --- /dev/null +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankPlayerSortOrderTopRanked.java @@ -0,0 +1,88 @@ +package tech.mcprison.prison.ranks.managers; + +import java.util.Comparator; + +import tech.mcprison.prison.ranks.data.RankPlayer; + +public class RankPlayerSortOrderTopRanked + implements Comparator +{ + + + public RankPlayerSortOrderTopRanked() { + super(); + + } + + + @Override + public int compare( RankPlayer rp1, RankPlayer rp2 ) + { + int results = 0; + + if ( rp1 == null && rp2 == null ) { + results = 0; + } + else if ( rp1 == null ) { + results = -1; + } + else if ( rp2 == null ) { + results = 1; + } + else { + results = compareLadderPrestiges( rp1, rp2 ); + + if ( results == 0 ) { + + results = compareLadderDefault( rp1, rp2 ); + + if ( results == 0 ) { + results = Double.compare( rp1.getRankScore(), rp2.getRankScore() ); + } + } + } + + return results; + } + + private int compareLadderPrestiges( RankPlayer rp1, RankPlayer rp2 ) { + int results = 0; + + if ( rp1.getPlayerRankPrestiges() == null && rp2.getPlayerRankPrestiges() == null ) { + results = 0; + } +// else if ( rp2.getPlayerRankPrestiges() == null ) { +// Handled when comparing PlayerRanks... +// results = -1; +// } + else if ( rp1.getPlayerRankPrestiges() == null ) { + results = 1; + } + else { + results = rp1.getPlayerRankPrestiges().compareTo( rp2.getPlayerRankPrestiges() ); + } + + return results; + } + + private int compareLadderDefault( RankPlayer rp1, RankPlayer rp2 ) { + int results = 0; + + if ( rp1.getPlayerRankDefault() == null && rp2.getPlayerRankDefault() == null ) { + results = 0; + } +// else if ( rp2.getPlayerRankDefault() == null ) { +// Handled when comparing PlayerRanks... +// results = -1; +// } + else if ( rp1.getPlayerRankDefault() == null ) { + results = 1; + } + else { + results = rp1.getPlayerRankDefault().compareTo( rp2.getPlayerRankDefault() ); + } + + return results; + } + +} From 17ea9c8da1b203766fa53312e2fbc542da6224a9 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Thu, 3 Mar 2022 20:11:34 -0500 Subject: [PATCH 146/297] RankLadder: removed obsolete code that was never used. --- docs/changelog_v3.3.x.md | 3 ++ .../prison/ranks/data/RankLadder.java | 28 ++----------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e3f96078c..41d9740ed 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9b 2022-03-03 +* **RankLadder: removed obsolete code that was never used.** + + * **Some initial setup for a rankScore.** This is not hooked up yet, but the the core basics are there and should work soon. diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java index 41c870a3b..9e6329920 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java @@ -35,21 +35,15 @@ public class RankLadder implements PrisonSortable, Comparable { - /* - * Fields & Constants - */ - private int id; private String name; private List ranks; + + // private int maxPrestige; -// private List permissions; -// private List permissionGroups; - - // The commands that are run when this rank is attained. private List rankUpCommands; @@ -67,9 +61,6 @@ public RankLadder() { this.ranks = new ArrayList<>(); -// this.permissions = new ArrayList<>(); -// this.permissionGroups = new ArrayList<>(); - } public RankLadder( int id, String name ) { @@ -531,21 +522,6 @@ public void setRankUpCommands( List rankUpCommands ) { this.rankUpCommands = rankUpCommands; } -// public List getPermissions() { -// return permissions; -// } -// -// public void setPermissions( List permissions ) { -// this.permissions = permissions; -// } -// -// public List getPermissionGroups() { -// return permissionGroups; -// } -// public void setPermissionGroups( List permissionGroups ) { -// this.permissionGroups = permissionGroups; -// } - public double getRankCostMultiplierPerRank() { return rankCostMultiplierPerRank; } From c0b550278b8d6da213cd9ab5051a53e622ecfd22 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 5 Mar 2022 21:50:03 -0500 Subject: [PATCH 147/297] Sync set blocks fixes. Isolate the targetBlocks and add a null check to ensure thre are no problems. --- docs/changelog_v3.3.x.md | 5 +++- .../prison/spigot/game/SpigotPlayerUtil.java | 1 - .../prison/spigot/game/SpigotWorld.java | 23 ++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 41d9740ed..839c54293 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9b 2022-03-03 +# 3.3.0-alpha.9b 2022-03-05 + + +* **Sync set blocks fixes. Isolate the targetBlocks and add a null check to ensure thre are no problems.** * **RankLadder: removed obsolete code that was never used.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java index 4eed2fe89..448b3d0b9 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java @@ -1,7 +1,6 @@ package tech.mcprison.prison.spigot.game; import java.lang.reflect.Method; -import java.util.Set; import java.util.UUID; import org.bukkit.enchantments.Enchantment; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java index f572b3a6c..ed2ae7e75 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java @@ -215,7 +215,10 @@ public void setBlocksSynchronously( List tBlocks, MineRes PrisonStatsElapsedTimeNanos nanos ) { List tBlocksCloned = new ArrayList<>(); - tBlocksCloned.addAll( tBlocks ); + for ( MineTargetPrisonBlock mtpb : tBlocks ) { + + tBlocksCloned.add( mtpb ); + } new BukkitRunnable() { @Override @@ -230,17 +233,21 @@ public void run() { { current = tBlock; - final PrisonBlock pBlock = tBlock.getPrisonBlock( resetType ); - - if ( pBlock != null ) { + if ( tBlock != null ) { - Location location = tBlock.getLocation(); + final PrisonBlock pBlock = tBlock.getPrisonBlock( resetType ); - SpigotBlock sBlock = (SpigotBlock) getBlockAt( location ); + if ( pBlock != null ) { + + Location location = tBlock.getLocation(); + + SpigotBlock sBlock = (SpigotBlock) getBlockAt( location ); // SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); - - sBlock.setPrisonBlock( pBlock ); + + sBlock.setPrisonBlock( pBlock ); + } } + } } catch ( Exception e ) { From f857bab3ea26df322e07ec4fcefbefcb9796ab36 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 5 Mar 2022 21:59:14 -0500 Subject: [PATCH 148/297] Setup a return of success, or failure, on custom currency functions. GemsEconomy does not indicate if it was successful, but added code to check to see if it was successfully manually/indirectly. --- docs/changelog_v3.3.x.md | 4 + .../EconomyCurrencyIntegration.java | 6 +- .../prison/ranks/data/RankPlayer.java | 72 ++++++++++- .../prison/spigot/economies/GemsEconomy.java | 120 ++++++++++++++---- 4 files changed, 175 insertions(+), 27 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 839c54293..5e314da41 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9b 2022-03-05 +* **Setup a return of success, or failure, on custom currency functions.** +GemsEconomy does not indicate if it was successful, but added code to check to see if it was successfully manually/indirectly. + + * **Sync set blocks fixes. Isolate the targetBlocks and add a null check to ensure thre are no problems.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/integration/EconomyCurrencyIntegration.java b/prison-core/src/main/java/tech/mcprison/prison/integration/EconomyCurrencyIntegration.java index 56d693763..34baea931 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/integration/EconomyCurrencyIntegration.java +++ b/prison-core/src/main/java/tech/mcprison/prison/integration/EconomyCurrencyIntegration.java @@ -29,11 +29,11 @@ public boolean hasCurrency( String currency ) { public abstract double getBalance( Player player, String currency ); - public abstract void setBalance( Player player, double amount, String currency ); + public abstract boolean setBalance( Player player, double amount, String currency ); - public abstract void addBalance( Player player, double amount, String currency ); + public abstract boolean addBalance( Player player, double amount, String currency ); - public abstract void removeBalance( Player player, double amount, String currency ); + public abstract boolean removeBalance( Player player, double amount, String currency ); public abstract boolean canAfford( Player player, double amount, String currency ); diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index 0203b353b..63bb7bf58 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -1082,6 +1082,73 @@ public void addBalance( String currency, double amount ) { } } + + public boolean addBalanceBypassCache( double amount ) { + boolean results = false; + + synchronized ( unsavedBalanceLock ) { + + results = addBalanceEconomy( amount ); + } + + return results; + } + + public boolean addBalanceBypassCache( String currency, double amount ) { + boolean results = false; + + if ( currency == null || currency.trim().isEmpty() || "default".equalsIgnoreCase( currency ) ) { + + results = addBalanceBypassCache( amount ); + } + else { + EconomyCurrencyIntegration currencyEcon = PrisonAPI.getIntegrationManager() + .getEconomyForCurrency(currency ); + + if ( currencyEcon != null ) { + + synchronized ( unsavedBalanceLock ) { + results = currencyEcon.addBalance( this, amount, currency ); + } + addCachedRankPlayerBalance( currency, amount ); + } + } + + return results; + } + + public boolean removeBalanceBypassCache( double amount ) { + boolean results = false; + + double targetAmount = -1 * amount; + results = addBalanceBypassCache( targetAmount ); + addCachedRankPlayerBalance( null, targetAmount ); + + return results; + } + + public boolean removeBalanceBypassCache( String currency, double amount ) { + boolean results = false; + + if ( currency == null || currency.trim().isEmpty() ) { + // No currency specified, so use the default currency: + results = removeBalanceBypassCache( amount ); + } + else { + EconomyCurrencyIntegration currencyEcon = PrisonAPI.getIntegrationManager() + .getEconomyForCurrency(currency ); + + if ( currencyEcon != null ) { + + synchronized ( unsavedBalanceLock ) { + results = currencyEcon.removeBalance( this, amount, currency ); + } + addCachedRankPlayerBalance( currency, -1 * amount ); + } + } + return results; + } + public void removeBalance( String currency, double amount ) { if ( currency == null || currency.trim().isEmpty() ) { @@ -1093,7 +1160,10 @@ public void removeBalance( String currency, double amount ) { .getEconomyForCurrency(currency ); if ( currencyEcon != null ) { - currencyEcon.removeBalance( this, amount, currency ); + + synchronized ( unsavedBalanceLock ) { + currencyEcon.removeBalance( this, amount, currency ); + } addCachedRankPlayerBalance( currency, -1 * amount ); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/GemsEconomy.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/GemsEconomy.java index 955894774..24543f422 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/GemsEconomy.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/GemsEconomy.java @@ -53,7 +53,10 @@ public boolean supportedCurrency( String currencyName ) { public double getBalance(Player player) { double amount = 0; if ( wrapper != null ) { - amount = wrapper.getBalance(player); + + synchronized ( wrapper ) { + amount = wrapper.getBalance(player); + } } return amount; } @@ -62,64 +65,135 @@ public double getBalance(Player player) { public double getBalance(Player player, String currencyName) { double amount = 0; if ( wrapper != null ) { - amount = wrapper.getBalance(player, currencyName); + + synchronized ( wrapper ) { + amount = wrapper.getBalance(player, currencyName); + } } return amount; } @Override public boolean setBalance(Player player, double amount) { + boolean results = false; + if ( wrapper != null ) { - double remainder = amount - getBalance(player); - if ( remainder > 0 ) { - wrapper.addBalance( player, amount ); - } if ( remainder < 0 ) { - wrapper.withdraw( player, amount ); + synchronized ( wrapper ) { + + double bal = getBalance(player); + double remainder = amount - bal; + + if ( remainder > 0 ) { + wrapper.addBalance( player, remainder ); + } + else if ( remainder < 0 ) { + wrapper.withdraw( player, (remainder * -1) ); + } + double balResults = getBalance(player); + + results = balResults == amount; } } - return true; + return results; } @Override - public void setBalance(Player player, double amount, String currencyName) { + public boolean setBalance(Player player, double amount, String currencyName) { + boolean results = false; + if ( wrapper != null ) { - double remainder = amount - getBalance(player, currencyName); - if ( remainder > 0 ) { - wrapper.addBalance( player, amount, currencyName ); - } if ( remainder < 0 ) { - wrapper.withdraw( player, amount, currencyName ); - } + + synchronized ( wrapper ) { + + double bal = getBalance(player, currencyName); + double remainder = amount - bal; + + if ( remainder > 0 ) { + wrapper.addBalance( player, remainder, currencyName ); + } + else if ( remainder < 0 ) { + wrapper.withdraw( player, (remainder * -1), currencyName ); + } + double balResults = getBalance(player, currencyName); + + results = balResults == amount; + } } + return results; } @Override public boolean addBalance(Player player, double amount) { + boolean results = false; + if ( wrapper != null ) { - wrapper.addBalance(player, amount); + + synchronized ( wrapper ) { + + double bal = getBalance(player); + wrapper.addBalance(player, amount); + double balResults = getBalance(player); + + results = balResults == amount + bal; + } } - return true; + + return results; } @Override - public void addBalance(Player player, double amount, String currencyName) { + public boolean addBalance(Player player, double amount, String currencyName) { + boolean results = false; + if ( wrapper != null ) { - wrapper.addBalance(player, amount, currencyName); + + synchronized ( wrapper ) { + + double bal = getBalance(player, currencyName); + wrapper.addBalance(player, amount, currencyName); + double balResults = getBalance(player, currencyName); + + results = balResults == amount + bal; + } } + + return results; } @Override public boolean removeBalance(Player player, double amount) { + boolean results = false; + if ( wrapper != null ) { - wrapper.withdraw(player, amount); + synchronized ( wrapper ) { + + double bal = getBalance(player); + wrapper.withdraw(player, amount); + double balResults = getBalance(player); + + results = balResults == bal - amount; + } } - return true; + + return results; } @Override - public void removeBalance(Player player, double amount, String currencyName) { + public boolean removeBalance(Player player, double amount, String currencyName) { + boolean results = false; + if ( wrapper != null ) { - wrapper.withdraw(player, amount, currencyName); + synchronized ( wrapper ) { + + double bal = getBalance(player, currencyName); + wrapper.withdraw(player, amount, currencyName); + double balResults = getBalance(player, currencyName); + + results = balResults == bal - amount; + } } + + return results; } @Override From 833e17aec9cbf8a7952d0e551e8dba210e66a802 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 5 Mar 2022 22:07:34 -0500 Subject: [PATCH 149/297] Added more validation checks and reporting on rankups and demotes. So if something goes wrong, it can hopefully be identified and tracked. If rank change failed, or if a refund failed, it will now better report these conditions. --- docs/changelog_v3.3.x.md | 5 ++ .../resources/lang/ranks/en_US.properties | 3 +- .../resources/lang/ranks/zh_TW.properties | 3 +- .../tech/mcprison/prison/ranks/RankUtil.java | 73 +++++++++++++++++-- .../mcprison/prison/ranks/RankupResults.java | 9 +++ .../ranks/commands/RankUpCommandMessages.java | 7 ++ 6 files changed, 90 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5e314da41..711a1f14a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9b 2022-03-05 +* **Added more validation checks and reporting on rankups and demotes.** +So if something goes wrong, it can hopefully identified and tracked. +If rank change failed, or if a refund failed, it will now better report these conditions. + + * **Setup a return of success, or failure, on custom currency functions.** GemsEconomy does not indicate if it was successful, but added code to check to see if it was successfully manually/indirectly. diff --git a/prison-core/src/main/resources/lang/ranks/en_US.properties b/prison-core/src/main/resources/lang/ranks/en_US.properties index 428f6fb79..0616441d5 100644 --- a/prison-core/src/main/resources/lang/ranks/en_US.properties +++ b/prison-core/src/main/resources/lang/ranks/en_US.properties @@ -50,7 +50,7 @@ ## -messages__version=22 +messages__version=23 messages__auto_refresh=true ranks_rankup__rankup_no_player_name=You have @@ -66,6 +66,7 @@ ranks_rankup__rankup_failure=Generic rankup failure. Review rankup details to id ranks_rankup__rankup_failed_to_load_player=Failed to load player. ranks_rankup__rankup_failed_to_load_ladder=Failed to load ladder. ranks_rankup__rankup_failed_to_assign_rank=Failed to assign a rank. Review rankup details to identify why. +ranks_rankup__rankup_failed_to_assign_rank_with_refund=Failed to assign a rank. Review rankup details to identify why. Refunds have been applied. ranks_rankup__rankup_failed_to_save_player_file=Failed to retrieve or write data. Your files may be corrupted. Alert a server administrator. ranks_rankup__rankup_no_ranks=There are no ranks in this ladder. ranks_rankup__rankup_rank_does_not_exist=The rank %1 does not exist on this server. diff --git a/prison-core/src/main/resources/lang/ranks/zh_TW.properties b/prison-core/src/main/resources/lang/ranks/zh_TW.properties index 426e62ff9..4271e2b12 100644 --- a/prison-core/src/main/resources/lang/ranks/zh_TW.properties +++ b/prison-core/src/main/resources/lang/ranks/zh_TW.properties @@ -50,7 +50,7 @@ ## -messages__version=3 +messages__version=4 messages__auto_refresh=true ranks_rankup__rankup_no_player_name=您已經 @@ -66,6 +66,7 @@ ranks_rankup__rankup_failure=階級æå‡å¤±æ•— è«‹é‡æ–°æª¢æŸ¥ä¾†ç™¼ç¾å•é¡Œ ranks_rankup__rankup_failed_to_load_player=玩家載入失敗 ranks_rankup__rankup_failed_to_load_ladder=階級晉å‡å¤±æ•— ranks_rankup__rankup_failed_to_assign_rank=分é…階級失敗 è«‹é‡æ–°æª¢æŸ¥ä¾†ç™¼ç¾å•é¡Œ +ranks_rankup__rankup_failed_to_assign_rank_with_refund=Failed to assign a rank. Review rankup details to identify why. Refunds have been applied. ranks_rankup__rankup_failed_to_save_player_file=無法檢索/寫入資料,您的資料å¯èƒ½å·²ç¶“æ壞,請通知伺æœå™¨ç®¡ç†å“¡ ranks_rankup__rankup_no_ranks=這個階內沒有階級 ranks_rankup__rankup_rank_does_not_exist=階級 %1 ä¸å­˜åœ¨ diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java index e42ce4e41..1fe7395e6 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java @@ -140,7 +140,14 @@ public enum RankupTransactions { player_balance_final, zero_cost_to_player, + player_balance_refund_increased, + player_balance_refund_decreased, + + economy_failed_to_update_player_balance, + economy_failed_to_reverse_player_rankup_cost, + economy_failed_to_apply_player_rankup_cost, + attempting_to_delete_ladder_from_player, cannot_delete_default_ladder, @@ -163,7 +170,9 @@ public enum RankupTransactions { failure_exception_caught_check_server_logs, successfully_saved_player_rank_data, - failure_orginal_playerRank_does_not_exist + failure_orginal_playerRank_does_not_exist, + + failed_rankup_validation__target_rank_is_not_expected ; } @@ -499,6 +508,8 @@ private void rankupPlayerInternal(RankupResults results, results.setBalanceInitial( balanceInitial ); results.setCurrency( targetRank.getCurrency() ); + boolean success = false; + if ( pForceCharge == PromoteForceCharge.charge_player) { if ( balanceInitial < nextRankCost ) { results.addTransaction( RankupStatus.RANKUP_CANT_AFFORD, @@ -509,7 +520,7 @@ private void rankupPlayerInternal(RankupResults results, balanceTargetFinal -= nextRankCost; results.addTransaction( RankupTransactions.player_balance_decreased ); - rankPlayer.removeBalance( targetRank.getCurrency(), nextRankCost ); + success = rankPlayer.removeBalanceBypassCache( targetRank.getCurrency(), nextRankCost ); } else if ( pForceCharge == PromoteForceCharge.refund_player) { @@ -517,35 +528,79 @@ else if ( pForceCharge == PromoteForceCharge.refund_player) { results.addTransaction( RankupTransactions.player_balance_increased); if ( results.getOriginalRank() != null ) { - rankPlayer.addBalance( results.getOriginalRank().getCurrency(), currentRankCost ); + success = rankPlayer.addBalanceBypassCache( results.getOriginalRank().getCurrency(), currentRankCost ); } } else { // Should never hit this code!! } + if ( !success ) { + + results.addTransaction( RankupTransactions.economy_failed_to_apply_player_rankup_cost ); + } + double balanceFinal = rankPlayer.getBalance( targetRank.getCurrency() ); + results.addTransaction( RankupTransactions.player_balance_final ); + results.setBalanceFinal( balanceFinal ); + // Check to ensure the player's balance is correct.. - if ( balanceFinal != balanceTargetFinal ) { + if ( !success || balanceFinal != balanceTargetFinal ) { results.addTransaction( RankupStatus.RANKUP_FAILURE_ECONOMY_FAILED, RankupTransactions.economy_failed_to_update_player_balance ); return; } - results.addTransaction( RankupTransactions.player_balance_final ); - results.setBalanceFinal( balanceFinal ); - - } else { + } + else { results.addTransaction( RankupTransactions.zero_cost_to_player ); } // Actually apply the new rank here: rankPlayer.addRank(targetRank); + + // Validate that the player's rank was actually changed: + PlayerRank newRank = rankPlayer.getPlayerRank( ladderName ); + if ( newRank.equals( originalRank ) || + !targetRank.equals( newRank.getRank() ) ) { + + results.setUnexpectedRank( newRank.getRank() ); + + results.addTransaction( RankupStatus.RANKUP_FAILURE_UNABLE_TO_ASSIGN_RANK, + RankupTransactions.failed_rankup_validation__target_rank_is_not_expected ); + + boolean success = false; + + // Refund charges and payments: + if ( pForceCharge == PromoteForceCharge.charge_player) { + + results.addTransaction( RankupTransactions.player_balance_refund_increased); + success = rankPlayer.addBalanceBypassCache( results.getOriginalRank().getCurrency(), currentRankCost ); + } + else if ( pForceCharge == PromoteForceCharge.refund_player) { + + results.addTransaction( RankupTransactions.player_balance_refund_decreased ); + success = rankPlayer.removeBalanceBypassCache( targetRank.getCurrency(), nextRankCost ); + } else { + // Should never hit this code!! + } + + if ( !success ) { + // unable to reverse rankup costs or refunds + results.addTransaction( RankupTransactions.economy_failed_to_reverse_player_rankup_cost ); + } + + return; + } + + + + if ( !savePlayerRank( results, rankPlayer ) ) { return; } @@ -885,6 +940,8 @@ private void logTransactionResults( RankupResults results ) break; + case failed_rankup_validation__target_rank_is_not_expected: + default: break; } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankupResults.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankupResults.java index 92cc3a811..1d72a165b 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankupResults.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankupResults.java @@ -29,6 +29,7 @@ public class RankupResults { private PlayerRank playerRankTarget; private Rank originalRank; private Rank targetRank; + private Rank unexpectedRank; private String message; private List transactions; @@ -192,6 +193,14 @@ public void setOriginalRank( Rank originalRank ) { public Rank getTargetRank() { return targetRank; } + + public Rank getUnexpectedRank() { + return unexpectedRank; + } + public void setUnexpectedRank( Rank unexpectedRank ) { + this.unexpectedRank = unexpectedRank; + } + public void setTargetRank( Rank targetRank ) { this.targetRank = targetRank; } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommandMessages.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommandMessages.java index 895a1f578..217e7394c 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommandMessages.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommandMessages.java @@ -286,6 +286,13 @@ protected void ranksRankupFailureUnableToAssignRankMsg( CommandSender sender ) { .sendTo( sender ); } + protected void ranksRankupFailureUnableToAssignRankWithRefundMsg( CommandSender sender ) { + + PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "ranks_rankup__rankup_failed_to_assign_rank_with_refund" ) + .sendTo( sender ); + } + protected void ranksRankupFailureCouldNotSavePlayerFileMsg( CommandSender sender ) { PrisonRanks.getInstance().getRanksMessages() From 35ae0ddf2d25e587844a696f7d495e4b35b8a5f0 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sat, 5 Mar 2022 22:17:51 -0500 Subject: [PATCH 150/297] Small adjustments to the MineReset handing of the targetBlock collections. Prevent their instantiation in the constructor since they are being lazy loaded. Also synchronizing on the adding of target block, since there was one report on an issue with that not being synchronized. --- docs/changelog_v3.3.x.md | 4 ++++ .../mcprison/prison/mines/data/MineReset.java | 22 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 711a1f14a..77779e719 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9b 2022-03-05 +* **Small adjustments to the MineReset handing of the targetBlock collections.** +Prevent their instantiation in the constructor since they are being lazy loaded. Also synchronizing on the adding of target block, since there was one report on an issue with that not being synchronized. + + * **Added more validation checks and reporting on rankups and demotes.** So if something goes wrong, it can hopefully identified and tracked. If rank change failed, or if a refund failed, it will now better report these conditions. diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java index f86ec9c97..04fc997af 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java @@ -92,8 +92,8 @@ public abstract class MineReset public static final long MINE_RESET__AIR_COUNT_BASE_DELAY = 30000L; // 30 seconds - private List mineTargetPrisonBlocks; - private TreeMap mineTargetPrisonBlocksMap; + private List mineTargetPrisonBlocks = null; + private TreeMap mineTargetPrisonBlocksMap = null; private MineJob currentJob; @@ -133,8 +133,8 @@ public abstract class MineReset public MineReset() { super(); - this.mineTargetPrisonBlocks = new ArrayList<>(); - this.mineTargetPrisonBlocksMap = new TreeMap<>(); +// this.mineTargetPrisonBlocks = new ArrayList<>(); +// this.mineTargetPrisonBlocksMap = new TreeMap<>(); this.statsMineSweeperTaskMs = new ArrayList<>(); @@ -1877,8 +1877,11 @@ private void addMineTargetPrisonBlock( PrisonBlockStatusData block, Location tar targetBlock.getBlockX(), targetBlock.getBlockY(), targetBlock.getBlockZ(), targetBlock.isEdge() ); - getMineTargetPrisonBlocks().add( mtpb ); - getMineTargetPrisonBlocksMap().put( mtpb.getBlockKey(), mtpb ); + synchronized ( getMineStateMutex() ) { + + getMineTargetPrisonBlocks().add( mtpb ); + getMineTargetPrisonBlocksMap().put( mtpb.getBlockKey(), mtpb ); + } } // private void addMineTargetPrisonBlock( PrisonBlockStatusData block, int x, int y, int z, boolean isEdge ) { @@ -1895,8 +1898,11 @@ private void clearMineTargetPrisonBlocks() { // other reference exist, they will be able to continue to use them // until the release the references. - mineTargetPrisonBlocks = null; - mineTargetPrisonBlocksMap = null; + synchronized ( getMineStateMutex() ) { + + mineTargetPrisonBlocks = null; + mineTargetPrisonBlocksMap = null; + } // getMineTargetPrisonBlocks().clear(); // getMineTargetPrisonBlocksMap().clear(); From 043f2785160f985f4be2ff37f12ad4bc712456f2 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 6 Mar 2022 01:00:20 -0500 Subject: [PATCH 151/297] Enable the ability to split messages in to multiple lines by using the placeholder `{br}`. --- docs/changelog_v3.3.x.md | 3 + .../tech/mcprison/prison/output/Output.java | 3 +- .../prison/spigot/SpigotPlatform.java | 35 ++-- .../spigot/game/SpigotCommandSender.java | 22 ++- .../prison/spigot/game/SpigotPlayer.java | 157 +++++++++--------- 5 files changed, 125 insertions(+), 95 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 77779e719..bfa9cf79d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9b 2022-03-05 +* **Enable the ability to split messages in to multiple lines by using the placeholder `{br}`.** + + * **Small adjustments to the MineReset handing of the targetBlock collections.** Prevent their instantiation in the constructor since they are being lazy loaded. Also synchronizing on the adding of target block, since there was one report on an issue with that not being synchronized. diff --git a/prison-core/src/main/java/tech/mcprison/prison/output/Output.java b/prison-core/src/main/java/tech/mcprison/prison/output/Output.java index c1c06f954..9694787c5 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/output/Output.java +++ b/prison-core/src/main/java/tech/mcprison/prison/output/Output.java @@ -224,7 +224,8 @@ else if ( Prison.get() == null || Prison.get().getPlatform() == null ) { System.err.println( errorMessage + " message: [" + message + "] params: " + sb.toString() ); - } else { + } + else { try { Prison.get().getPlatform().log( prefixTemplatePrison + " " + 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 a42851b58..2a5c27945 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 @@ -577,12 +577,20 @@ public void log(String message, Object... format) { @Override public void logCore( String message ) { - ConsoleCommandSender sender = Bukkit.getConsoleSender(); - if (sender == null) { - Bukkit.getLogger().info(ChatColor.stripColor(message)); - } else { - sender.sendMessage(message); - } + ConsoleCommandSender sender = Bukkit.getConsoleSender(); + + String[] msgs = message.split( "\\{br\\}" ); + + for ( String msg : msgs ) { + + if (sender == null) { + Bukkit.getLogger().info(ChatColor.stripColor(msg)); + } + else { + sender.sendMessage(msg); + } + } + } /** @@ -592,10 +600,17 @@ public void logCore( String message ) public void logPlain( String message ) { ConsoleCommandSender sender = Bukkit.getConsoleSender(); - if (sender == null) { - Bukkit.getLogger().info(message); - } else { - sender.sendMessage(message); + + String[] msgs = message.split( "\\{br\\}" ); + + for ( String msg : msgs ) { + + if (sender == null) { + Bukkit.getLogger().info(msg); + } + else { + sender.sendMessage(msg); + } } } 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 455b3d0e4..26bbb66d4 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 @@ -69,13 +69,25 @@ public String getName() { return (this instanceof ConsoleCommandSender) && Bukkit.getConsoleSender() != null; } - @Override public void sendMessage(String message) { - bukkitSender.sendMessage(Text.translateAmpColorCodes(message)); + @Override + public void sendMessage(String message) { + + String[] msgs = Text.translateAmpColorCodes(message).split( "\\{br\\}" ); + + for ( String msg : msgs ) { + bukkitSender.sendMessage(msg); + } } - @Override public void sendMessage(String[] messages) { - for (String s : messages) { - sendMessage(s); + @Override + public void sendMessage(String[] messages) { + for (String message : messages) { + + String[] msgs = Text.translateAmpColorCodes(message).split( "\\{br\\}" ); + for ( String msg : msgs ) { + + sendMessage(msg); + } } } 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 3f9051cd0..b3bdfcdfa 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 @@ -43,7 +43,6 @@ import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; -import tech.mcprison.prison.spigot.compat.SpigotNMSPlayer; import tech.mcprison.prison.spigot.inventory.SpigotPlayerInventory; import tech.mcprison.prison.spigot.scoreboard.SpigotScoreboard; import tech.mcprison.prison.spigot.utils.tasks.PlayerMessagingTask; @@ -399,86 +398,86 @@ public String toString() { // // } - @SuppressWarnings( "deprecation" ) - public void printDebugInventoryInformationToConsole() { - - try { - printDebugInfo( bukkitPlayer.getInventory().getContents(), "Inventory Contents"); - } - catch ( java.lang.NoSuchMethodError | Exception e ) { - // Ignore: Not supported with that version of spigot: - } - - try { - printDebugInfo( bukkitPlayer.getInventory().getExtraContents(), "Inventory Extra Contents"); - } - catch ( java.lang.NoSuchMethodError | Exception e ) { - // Ignore: Not supported with that version of spigot: - } - - try { - printDebugInfo( bukkitPlayer.getInventory().getArmorContents(), "Inventory Armor Contents"); - } - catch ( java.lang.NoSuchMethodError | Exception e ) { - // Ignore: Not supported with that version of spigot: - } - try { - printDebugInfo( bukkitPlayer.getInventory().getStorageContents(), "Inventory Storage Contents"); - } - catch ( java.lang.NoSuchMethodError | Exception e ) { - // Ignore: Not supported with that version of spigot: - } - - try { - printDebugInfo( bukkitPlayer.getInventory().getItemInHand(), "Inventory Item In Hand (pre 1.13)"); - } - catch ( java.lang.NoSuchMethodError | Exception e ) { - // Ignore: Not supported with that version of spigot: - } - - try { - printDebugInfo( bukkitPlayer.getInventory().getItemInMainHand(), "Inventory Item in Main Hand"); - } - catch ( java.lang.NoSuchMethodError | Exception e ) { - // Ignore: Not supported with that version of spigot: - } - - try { - printDebugInfo( bukkitPlayer.getInventory().getItemInOffHand(), "Inventory Item in Off Hand"); - } - catch ( java.lang.NoSuchMethodError | Exception e ) { - // Ignore: Not supported with that version of spigot: - } - } +// @SuppressWarnings( "deprecation" ) +// public void printDebugInventoryInformationToConsole() { +// +// try { +// printDebugInfo( bukkitPlayer.getInventory().getContents(), "Inventory Contents"); +// } +// catch ( java.lang.NoSuchMethodError | Exception e ) { +// // Ignore: Not supported with that version of spigot: +// } +// +// try { +// printDebugInfo( bukkitPlayer.getInventory().getExtraContents(), "Inventory Extra Contents"); +// } +// catch ( java.lang.NoSuchMethodError | Exception e ) { +// // Ignore: Not supported with that version of spigot: +// } +// +// try { +// printDebugInfo( bukkitPlayer.getInventory().getArmorContents(), "Inventory Armor Contents"); +// } +// catch ( java.lang.NoSuchMethodError | Exception e ) { +// // Ignore: Not supported with that version of spigot: +// } +// try { +// printDebugInfo( bukkitPlayer.getInventory().getStorageContents(), "Inventory Storage Contents"); +// } +// catch ( java.lang.NoSuchMethodError | Exception e ) { +// // Ignore: Not supported with that version of spigot: +// } +// +// try { +// printDebugInfo( bukkitPlayer.getInventory().getItemInHand(), "Inventory Item In Hand (pre 1.13)"); +// } +// catch ( java.lang.NoSuchMethodError | Exception e ) { +// // Ignore: Not supported with that version of spigot: +// } +// +// try { +// printDebugInfo( bukkitPlayer.getInventory().getItemInMainHand(), "Inventory Item in Main Hand"); +// } +// catch ( java.lang.NoSuchMethodError | Exception e ) { +// // Ignore: Not supported with that version of spigot: +// } +// +// try { +// printDebugInfo( bukkitPlayer.getInventory().getItemInOffHand(), "Inventory Item in Off Hand"); +// } +// catch ( java.lang.NoSuchMethodError | Exception e ) { +// // Ignore: Not supported with that version of spigot: +// } +// } - private void printDebugInfo( org.bukkit.inventory.ItemStack[] iStacks, String title ) { - - Output.get().logInfo( "&7%s:", title ); - for ( int i = 0; i < iStacks.length; i++ ) { - org.bukkit.inventory.ItemStack iStack = iStacks[i]; - - if ( iStack != null ) { - - ItemStack pItemStack = SpigotUtil.bukkitItemStackToPrison(iStack); - - Output.get().logInfo( " i=%d &3%s &3%d &a[&3%s&a]", - i, iStack.getType().name(), iStack.getAmount(), - (pItemStack == null ? "" : - (pItemStack.getDisplayName() == null ? "" : - pItemStack.getDisplayName())) ); - } - } - } +// private void printDebugInfo( org.bukkit.inventory.ItemStack[] iStacks, String title ) { +// +// Output.get().logInfo( "&7%s:", title ); +// for ( int i = 0; i < iStacks.length; i++ ) { +// org.bukkit.inventory.ItemStack iStack = iStacks[i]; +// +// if ( iStack != null ) { +// +// ItemStack pItemStack = SpigotUtil.bukkitItemStackToPrison(iStack); +// +// Output.get().logInfo( " i=%d &3%s &3%d &a[&3%s&a]", +// i, iStack.getType().name(), iStack.getAmount(), +// (pItemStack == null ? "" : +// (pItemStack.getDisplayName() == null ? "" : +// pItemStack.getDisplayName())) ); +// } +// } +// } - private void printDebugInfo( org.bukkit.inventory.ItemStack iStack, String title ) { - - Output.get().logInfo( "&7%s:", title ); - if ( iStack != null ) { - - Output.get().logInfo( " &3%s &3%d", - iStack.getType().name(), iStack.getAmount() ); - } - } +// private void printDebugInfo( org.bukkit.inventory.ItemStack iStack, String title ) { +// +// Output.get().logInfo( "&7%s:", title ); +// if ( iStack != null ) { +// +// Output.get().logInfo( " &3%s &3%d", +// iStack.getType().name(), iStack.getAmount() ); +// } +// } public void giveExp( int xp ) { From 59561f6be0e1d8d882960c715b81d9ba60ed16bd Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Sun, 6 Mar 2022 13:27:05 -0500 Subject: [PATCH 152/297] v3.3.0-alpha.9c --- 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 bfa9cf79d..4d7c667fe 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9b 2022-03-05 +# 3.3.0-alpha.9c 2022-03-06 + + +* **v3.3.0-alpha.9c 2022-03-06** * **Enable the ability to split messages in to multiple lines by using the placeholder `{br}`.** diff --git a/gradle.properties b/gradle.properties index 854f767c1..8bd84bc7d 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.9b +version=3.3.0-alpha.9c #version=3.3.0-alpha.7 From 17dc2af860b1871e08ea898e231d9d37978656d5 Mon Sep 17 00:00:00 2001 From: RoyalBlueRanger <665978+rbluer@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:45:39 -0500 Subject: [PATCH 153/297] Update docs --- docs/knownissues_v3.3.x.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index 591c4b500..c1926a38e 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -8,11 +8,23 @@ # TODO Items for v3.3.0-alpha.8 +* Add a preformatted sellall multiplier +* {prison_player_sellall_mutiplier::nFormat:#,##0.0000} + + +- GUI forces admins to run auto configure. Review and remove? + + +* messages - split on \n character to multiple lines + - player messages + - console messages + + * Mine bombs: - - prison reload bombs - - validate mine bombs when initially loading... + - DONE: prison reload bombs + - DONE: validate mine bombs when initially loading... - bomb name cannot have spaces or color formatting - - mineBombId should not have spaces in the name + - initial validation added - glowing effect (enchantment) - give madog24 stone{Enchantments:[{}]} - ItemMeta.addFlags(ItemFlag.HIDE_ENCHANTMENTS) @@ -25,7 +37,7 @@ * DONE: Works for me. HiPriority: Inventory full not producing any messages. alexaille -* HiPriority: NPCs are generating a lot of errors. Real_Ganster +* DONE: HiPriority: NPCs are generating a lot of errors. Real_Ganster - Citizens running command `mines` as player ` Prison | VaultEconomyWrapper.getBalance(): Error: Cannot get economy for player vote so returning a value of 0. Failed to get an bukkit offline player.` - https://pastebin.com/JusySWDs From c2925aa4e7f2d23b3129985c5b12980994b54362 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Mar 2022 22:19:35 -0500 Subject: [PATCH 154/297] Changed the development environment and updated the java 1.8 to the latest release. --- docs/changelog_v3.3.x.md | 5 ++++- gradlew8.bat | 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 4d7c667fe..c7c8303c9 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9c 2022-03-06 +# 3.3.0-alpha.9c 2022-03-08 + + +* **Changed the development environment and updated the java 1.8 to the latest release.** * **v3.3.0-alpha.9c 2022-03-06** diff --git a/gradlew8.bat b/gradlew8.bat index 83ac1e6c3..009240f46 100644 --- a/gradlew8.bat +++ b/gradlew8.bat @@ -1 +1 @@ -./gradlew build -Dorg.gradle.java.home="C:\Program Files\Java\jdk1.8.0_291" --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 145245b14293f8da92e9588fbc666b9446cbd4c3 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Mar 2022 22:21:43 -0500 Subject: [PATCH 155/297] Update CustomItems API from v4.1.3 to v4.1.15. This update adds support for prison to get the drops from the CustomItem blocks. --- docs/changelog_v3.3.x.md | 4 ++++ .../lib/CustomItemsAPI_v4.1.15.jar.jar | Bin 0 -> 14976 bytes prison-spigot/lib/CustomItems_v4.1.3_api.jar | Bin 14678 -> 0 bytes 3 files changed, 4 insertions(+) create mode 100644 prison-spigot/lib/CustomItemsAPI_v4.1.15.jar.jar delete mode 100644 prison-spigot/lib/CustomItems_v4.1.3_api.jar diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c7c8303c9..d69fed309 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-08 +* **Update CustomItems API from v4.1.3 to v4.1.15.** +This update adds support for prison to get the drops from the CustomItem blocks. + + * **Changed the development environment and updated the java 1.8 to the latest release.** diff --git a/prison-spigot/lib/CustomItemsAPI_v4.1.15.jar.jar b/prison-spigot/lib/CustomItemsAPI_v4.1.15.jar.jar new file mode 100644 index 0000000000000000000000000000000000000000..094a7687e06c7026c6e261bff79613f261285dd6 GIT binary patch literal 14976 zcmb7rbC74vlJ>N1bEa*Z)3$BfHl}UcwvB1qHh*pRw2g0OcW>OgZ|uHzzdZlci4*x$ zor;RcCoA)jlLP@p{Q?OI`Nf#jOzF$N80hb@p{+F?$QLKpM)mt__KZ=^>R6VD1fofy7M?hV@X)B!@3z z(_x6mp+noO5nFq77fG)#oRC<1W?H-+4tJtE4|+ui`dkkmYIpdj`kmHBi&=h`Mcb8oXg2D(%G z%u{keZtiLbGC3oF!mt0-Svu<%lOJ@bxL>+nZ)<(-5zKcF;whEg{`xs<;9dZcO}>AC z;Lo`jEG!-l%e5Hv+I5f9*b;6MzzhoTN66-bQ-ZPLRV1G%gVYUnT9XpS>U`QXbcfs* zF{k=g&osC|RCBfg zJVbDOn0}M1$|zc7_ePIOly~dsMPjPf?2P~7ydSNDoTG~vk(~OYG%1W>)nRV{OIM19 zgo8>b(XmxjyOzwv&4aTuH9gISb;!2z4lZgkvXgtu=i+?gAbN^vZ~0KS&EB4a!O7gI zzQvuBVBN6%$1%)`SL#5b(rd}rGsrF?N*Iw>>f!^vCtOo|UCQ3@B!m-jYa?@ek@3hu zQ*`E4SqhdeI~JLTj+Uq*ldj-B^VcmLNg87%YrYh=iib{O$`qkg~O{Iw_8)XxSQ)OGGLS~-$NIzy1QTUreG3w~n$LiO^i z83HKP6iw54TvK)t%b7G|3|fL=95>nSIO#maSAr4Ss=mz304 zVu9I0H{wss-ms>5Pe#=2o+)KpVLkgtTnds-Cs}oc*@`dQ-a4m>!5xb~XDJe;?pBq5Y^I*Z#9`Nv`br={F0i$Bf0@AseFP7AlEZ8lx#N*hJC5U_RGJ9bZ<^Yb0EhT{h#c;A zdA;-i=rI=ef-cCUS9}t@Ic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gWY(T?HI&YDffw(&4S3rg zy0w8heiGbuKzM=8$&<&vnhflTaRK^B)DV#(dej&iMU;cK8p?L6^&&{0qce33hKy9m zP3{YEdcT-4om%I8ZKct%kiB~FXaI5yB7Ju?3xVHT(vFgHG{k1#o71SkHdVH00|a73 zH3{z3Gc5L{ReAN@>Zh;O5B<orC1&Ykuy~2PcTt z)2i8lxmDv%PlPy$$u^YX@nZbo$a*l&{1yKCRy)I2YDjfZy>}4>|MjByzN+X@8hhLh z{7s85^d;Ae_P3jCrg&&Sd+Oc+HpS<1r}m|IX4+;ywA@tGmsHgsRitFgff+|X0{dOX zCqGR(b;J2gXLJazK-^PiR62+!b|{qm%4 zZ#;&V*VqUhYYhlI4~{#!$T1ab5cQ5ZhR}URsaju3;9953+z5w&^E3}|mm}99A zS*ay=0=-l7BWmp+MTG#7Y+{i|sVog=f-Il;-n^*O=LTs>K*)twY4h@n%a=u8 zIJ)u;H=hD6I(r4GRuv~b(^WUNZp>4o5wv1eq1v*#h3495v23)D()OebeuvmMz%6`P z{QdEoZ)r6>JbTy7*f*)`%e9lK{L%4qgHNQUT-FR{3zKT1}uBAbMb$*j;H`Qmlw&PL} zXgcee7oBiD<&(NV2yqU|FM|*5fKj6L_-5-Dy>+bM0!47PO9%~-F{_fgXi@%5|0fx? ziGUTIiT~TcKL0b)|4VcB zcl5vZ?EWjdAoTx${{NUs|2z6$%kMvZzkeIu@0apVZ{hda|JDWkJN946)1LzV-_}F< zzrz0S%K5+l&|f#^A1?N9)BD}%{9pWu|6peFQsBRL_oq+Lzpwe^|&!_(b)Hj#Z From b879d75250581a41b797abfebe4be7cd0c15b7b8 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 8 Mar 2022 22:33:13 -0500 Subject: [PATCH 156/297] Upgrade XSeries from v8.5.0.1 to v8.6.2. --- docs/changelog_v3.3.x.md | 3 +++ prison-spigot/build.gradle | 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 d69fed309..50b68211a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-08 +* **Upgrade XSeries from v8.5.0.1 to v8.6.2.** + + * **Update CustomItems API from v4.1.3 to v4.1.15.** This update adds support for prison to get the drops from the CustomItem blocks. diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index 062c9d0c1..2606accbd 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -106,7 +106,7 @@ dependencies { // implementation 'com.github.cryptomorin:xseries:b95d195482' // https://mvnrepository.com/artifact/com.github.cryptomorin/XSeries - implementation 'com.github.cryptomorin:XSeries:8.5.0.1' + implementation 'com.github.cryptomorin:XSeries:8.6.2' From 74fe549e2420a07a32b09e610e6e3809930e9f42 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 9 Mar 2022 23:25:47 -0500 Subject: [PATCH 157/297] Update some of the gradle settings and fix the new custom items api. --- .gitignore | 1 + docs/changelog_v3.3.x.md | 5 ++++- prison-spigot/build.gradle | 2 +- ...I_v4.1.15.jar.jar => CustomItemsAPI_v4.1.15.jar} | Bin 4 files changed, 6 insertions(+), 2 deletions(-) rename prison-spigot/lib/{CustomItemsAPI_v4.1.15.jar.jar => CustomItemsAPI_v4.1.15.jar} (100%) diff --git a/.gitignore b/.gitignore index bf301f4be..d1cddf832 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,4 @@ gradle-app.setting # gradle/wrapper/gradle-wrapper.properties build.gradle.deploy +prison-spigot/lib/old/ diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 50b68211a..a5e0def1e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9c 2022-03-08 +# 3.3.0-alpha.9c 2022-03-09 + + +* **Update some of the gradle settings and fix the new custom items api.** * **Upgrade XSeries from v8.5.0.1 to v8.6.2.** diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index 2606accbd..c0a96b5ab 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -188,7 +188,7 @@ shadowJar { include(dependency('me.clip:placeholderapi:2.10.9')) - include(dependency('com.github.cryptomorin:XSeries:8.5.0.1')) + include(dependency('com.github.cryptomorin:XSeries:8.6.2')) //include(dependency('org.inventivetalent.spiget-update:bukkit:1.4.2-SNAPSHOT')) //include(dependency('me.badbones69:crazyenchantments-plugin:1.8-Dev-Build-v8')) diff --git a/prison-spigot/lib/CustomItemsAPI_v4.1.15.jar.jar b/prison-spigot/lib/CustomItemsAPI_v4.1.15.jar similarity index 100% rename from prison-spigot/lib/CustomItemsAPI_v4.1.15.jar.jar rename to prison-spigot/lib/CustomItemsAPI_v4.1.15.jar From 827c9932769414d30991416d1b0b9ac4015465bd Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 9 Mar 2022 23:29:18 -0500 Subject: [PATCH 158/297] CustomItems custom blocks: Hook up the new drops for CustomItems plugin. --- docs/changelog_v3.3.x.md | 3 + .../integration/CustomBlockIntegration.java | 4 +- .../events/PrisonDebugBlockInspector.java | 9 +-- .../spigot/block/OnBlockBreakEventCore.java | 4 +- .../spigot/block/OnBlockBreakMines.java | 7 +- .../spigot/customblock/CustomItems.java | 30 +++++--- .../customblock/CustomItemsWrapper.java | 72 ++++++++++++++++--- .../spigot/customblock/HeadsCustomBlocks.java | 13 +++- 8 files changed, 111 insertions(+), 31 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a5e0def1e..a1a9537ff 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-09 +* **CustomItems custom blocks: Hook up the new drops for CustomItems plugin.** + + * **Update some of the gradle settings and fix the new custom items api.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/integration/CustomBlockIntegration.java b/prison-core/src/main/java/tech/mcprison/prison/integration/CustomBlockIntegration.java index 10d6800a9..8c6a015fb 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/integration/CustomBlockIntegration.java +++ b/prison-core/src/main/java/tech/mcprison/prison/integration/CustomBlockIntegration.java @@ -3,6 +3,7 @@ import java.util.List; import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.block.Block; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; @@ -49,7 +50,8 @@ public CustomBlockIntegration( String keyName, String providerName, public abstract void setCustomBlockIdAsync( PrisonBlock prisonBlock, Location location ); - public abstract List getDrops( PrisonBlock prisonBlock ); + public abstract List getDrops( Player player, PrisonBlock prisonBlock, ItemStack tool ); +// public abstract List getDrops( PrisonBlock prisonBlock ); public abstract List getCustomBlockList(); 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 b6fa4f288..54d44d88a 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 @@ -249,7 +249,7 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTa ) ); - printEventStatus( bbe, "-initial-", "", checkBlock, targetBlock, tool, output ); + printEventStatus( bbe, "-initial-", "", checkBlock, targetBlock, tool, output, player ); for ( RegisteredListener listener : bbe.getHandlers().getRegisteredListeners() ) { @@ -266,7 +266,8 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTa } printEventStatus( bbe, - listener.getPlugin().getName(), listener.getPriority().name(), checkBlock, targetBlock, tool, output ); + listener.getPlugin().getName(), listener.getPriority().name(), checkBlock, targetBlock, + tool, output, player ); } @@ -309,7 +310,7 @@ private void printEventStatus( BlockBreakEvent bbe, String plugin, String priority, SpigotBlock sBlock, MineTargetPrisonBlock targetBlock, SpigotItemStack tool, - List output ) { + List output, SpigotPlayer player ) { StringBuilder sb = new StringBuilder(); sb.append( " " ); @@ -320,7 +321,7 @@ private void printEventStatus( BlockBreakEvent bbe, SpigotBlock sBlk = (SpigotBlock) sBlock.getLocation().getBlockAt(); List bukkitDrops = new ArrayList<>(); - obbMines.collectBukkitDrops( bukkitDrops, targetBlock, tool, sBlk ); + obbMines.collectBukkitDrops( bukkitDrops, targetBlock, tool, sBlk, player ); bukkitDrops = obbMines.mergeDrops( bukkitDrops ); sb.append( " &3Plugin: &7" ).append( plugin ).append( " " ) 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 8eb66d7b4..48d6ad1cf 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 @@ -671,7 +671,7 @@ private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder if ( pbBlockHit != null && matchedBlocks ) { // Confirmed the block is correct... so get the drops... - collectBukkitDrops( pmEvent.getBukkitDrops(), targetBlock, pmEvent.getItemInHand(), sBlockHit ); + collectBukkitDrops( pmEvent.getBukkitDrops(), targetBlock, pmEvent.getItemInHand(), sBlockHit, pmEvent.getSpigotPlayer() ); // If a chain reaction on explosions, this will prevent the same block from // being processed more than once: @@ -820,7 +820,7 @@ else if ( targetExplodedBlock.isMined() ) { if ( pBlockMined!= null && matchedExplodedBlocks ) { // Confirmed the block is correct... so get the drops... - collectBukkitDrops( pmEvent.getBukkitDrops(), targetExplodedBlock, pmEvent.getItemInHand(), sBlockMined ); + collectBukkitDrops( pmEvent.getBukkitDrops(), targetExplodedBlock, pmEvent.getItemInHand(), sBlockMined, pmEvent.getSpigotPlayer() ); // If a chain reaction on explosions, this will prevent the same block from // being processed more than once: diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java index b5bf98c7d..674d6df52 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java @@ -15,12 +15,11 @@ import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock; -import tech.mcprison.prison.internal.block.PrisonBlockStatusData; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; +import tech.mcprison.prison.internal.block.PrisonBlockStatusData; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.modules.Module; -import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent; import tech.mcprison.prison.spigot.game.SpigotPlayer; @@ -306,7 +305,7 @@ public boolean isBlockAMatch( MineTargetPrisonBlock targetBlock, PrisonBlock pbB * @return */ public boolean collectBukkitDrops( List bukkitDrops, MineTargetPrisonBlock targetBlock, - SpigotItemStack itemInHand, SpigotBlock sBlockMined ) + SpigotItemStack itemInHand, SpigotBlock sBlockMined, SpigotPlayer player ) { boolean results = false; @@ -317,7 +316,7 @@ public boolean collectBukkitDrops( List bukkitDrops, MineTarget for ( CustomBlockIntegration customBlock : cbIntegrations ) { - List drops = customBlock.getDrops( sBlockMined ); + List drops = customBlock.getDrops( player, sBlockMined, itemInHand ); for ( ItemStack drop : drops ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java index 16dde472f..24a03b551 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java @@ -7,12 +7,14 @@ import tech.mcprison.prison.integration.CustomBlockIntegration; import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.block.Block; 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.spigot.SpigotPrison; import tech.mcprison.prison.spigot.block.SpigotItemStack; +import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.spiget.BluesSpigetSemVerComparator; import tech.mcprison.prison.util.Location; @@ -50,6 +52,19 @@ public void integrate() { Output.get().logInfo( "#### Custom Block: " + block.toString() ); } } + + String message = String.format( + "Enabling CustomItems v%s: Drops are ", + getVersion() ); + + if ( semVer.compareTo( getVersion(), "4.1.15" ) >= 0 ) { + this.customItemsWrapper.setSupportsDrops( true ); + + Output.get().logInfo( message + " enabled." ); + } + else { + Output.get().logInfo( message + "not enabled." ); + } } else { Output.get().logWarn( @@ -130,17 +145,14 @@ public void setCustomBlockIdAsync( PrisonBlock prisonBlock, Location location ) } @Override - public List getDrops( PrisonBlock prisonBlock ) { - List results = customItemsWrapper.getDrops( prisonBlock ); + public List getDrops( Player player, PrisonBlock prisonBlock, ItemStack tool ) { + SpigotPlayer sPlayer = player != null && player instanceof SpigotPlayer ? + (SpigotPlayer) player : null; + SpigotItemStack sTool = tool != null && tool instanceof SpigotItemStack ? + (SpigotItemStack) tool : null; -// PrisonBlock ciPBlock = getCustomBlock( prisonBlock ); -// -// if ( ciPBlock != null ) { -// -// results.add( new ItemStack( 1, ciPBlock ) ); -// -// } + List results = customItemsWrapper.getDrops( prisonBlock, sPlayer, sTool ); return results; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java index 970d2d04c..4dbb9e82d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java @@ -1,8 +1,10 @@ package tech.mcprison.prison.spigot.customblock; +import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; import java.util.List; +import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import com.jojodmo.customitems.api.CustomItemsAPI; @@ -12,10 +14,13 @@ import tech.mcprison.prison.spigot.SpigotPrison; 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.util.Location; public class CustomItemsWrapper { + + private boolean supportsDrops = false; private final SpigotPrison plugin; @@ -95,20 +100,62 @@ public void run() { * with that future version. *

* + * + * CustomItemsAPI.breakCustomItemBlockWithoutDrops(): + * Break the given block, and return the drops instead of dropping them normally + * @param block - the block that should be broken + * @param player - the player that broke the block + * @param overrideItemUsed - what item should CustomItems pretend the user broke this block with? This should probably be the item in their main hand, but there are other special use cases where you might want to use a different ItemStack + * @param doBlockUpdate - whether or not this should trigger a block update + * @param override - false by default. Set this to true if you want to override CustomItem's decision to cancel the block break + * @return + * {@code null} if the block is not a custom block, and a two-element entry otherwise: + * The first entry is false if CustomItems cancelled the block break, and true if the block was broken. This will always be true if you set override to true. + * The second entry is also a two-element entry: + * The first entry is overrideItemUsed after being modified by any actions. You should most likely replace whatever overrideItemUsed is in the player's inventory with this item stack. + * The second entry is a list of the items that the block would have normally dropped. This will be empty if the first entry is false + * + * * @param prisonBlock * @return */ - public List getDrops( PrisonBlock prisonBlock ) { + public List getDrops( PrisonBlock prisonBlock, SpigotPlayer player, SpigotItemStack tool ) { List results = new ArrayList<>(); - org.bukkit.inventory.ItemStack bItemStack = CustomItemsAPI.getCustomItem( prisonBlock.getBlockName() ); - - SpigotItemStack sItemStack = new SpigotItemStack( bItemStack ); - - // Fix itemStack's displayName and set to the correct BlockType: - sItemStack.setPrisonBlock( prisonBlock ); - - results.add( sItemStack ); + if ( isSupportsDrops() && prisonBlock instanceof SpigotBlock ) { + + SpigotBlock sBlock = (SpigotBlock) prisonBlock; + + SimpleEntry>> cuiDropResults = + CustomItemsAPI.breakCustomItemBlockWithoutDrops( + sBlock.getWrapper(), player.getWrapper(), tool.getBukkitStack(), false, true ); + + if ( cuiDropResults != null ) { + + Boolean cuiCanceled = cuiDropResults.getKey(); + ItemStack toolOverridden = cuiDropResults.getValue().getKey(); + List cuiDrops = cuiDropResults.getValue().getValue(); + + if ( cuiCanceled && cuiDrops != null && cuiDrops.size() > 0 ) { + + for (ItemStack itemStack : cuiDrops) { + results.add( new SpigotItemStack( itemStack ) ); + } + } + } + + } + else { + + org.bukkit.inventory.ItemStack bItemStack = CustomItemsAPI.getCustomItem( prisonBlock.getBlockName() ); + + SpigotItemStack sItemStack = new SpigotItemStack( bItemStack ); + + // Fix itemStack's displayName and set to the correct BlockType: + sItemStack.setPrisonBlock( prisonBlock ); + + results.add( sItemStack ); + } return results; } @@ -120,4 +167,11 @@ public List getCustomBlockList() { public SpigotPrison getPlugin() { return plugin; } + + public boolean isSupportsDrops() { + return supportsDrops; + } + public void setSupportsDrops(boolean supportsDrops) { + this.supportsDrops = supportsDrops; + } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/HeadsCustomBlocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/HeadsCustomBlocks.java index ace0613be..2cec5e494 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/HeadsCustomBlocks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/HeadsCustomBlocks.java @@ -5,6 +5,7 @@ import tech.mcprison.prison.integration.CustomBlockIntegration; import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.block.Block; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; @@ -63,9 +64,17 @@ public List getCustomBlockList() } +// @Override +// public List getDrops( PrisonBlock prisonBlock ) +// { +// List results = new ArrayList<>(); +// +// return results; +// } + + @Override - public List getDrops( PrisonBlock prisonBlock ) - { + public List getDrops(Player player, PrisonBlock prisonBlock, ItemStack tool) { List results = new ArrayList<>(); return results; From 61dd602c0bc2bdd610d3f195b580a076e7f9f3d8 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 9 Mar 2022 23:30:40 -0500 Subject: [PATCH 159/297] Fixed an issue when checking if a block is unbreakable... it should not have been null, so this is a temp fix to prevent an error. --- docs/changelog_v3.3.x.md | 3 +++ .../tech/mcprison/prison/spigot/utils/BlockUtils.java | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a1a9537ff..c692ceffa 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-09 +* **Fixed an issue when checking if a block is unbreakable... it should not have been null, so this is a temp fix to prevent an error.** + + * **CustomItems custom blocks: Hook up the new drops for CustomItems plugin.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/BlockUtils.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/BlockUtils.java index 0bcdc31a6..b6c9e880e 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/BlockUtils.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/BlockUtils.java @@ -38,8 +38,12 @@ public static BlockUtils getInstance() { public boolean isUnbreakable( SpigotBlock block ) { - PrisonBlock pBlock = block.getPrisonBlock(); - return isUnbreakable( pBlock ); + boolean results = false; + if ( block != null ) { + PrisonBlock pBlock = block.getPrisonBlock(); + results = isUnbreakable( pBlock ); + } + return results; } public boolean isUnbreakable( PrisonBlock block ) { From 329f72400faf4fc80583f116059045dfe0a2199f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Thu, 10 Mar 2022 08:43:29 -0500 Subject: [PATCH 160/297] For unbreakable blocks, reinforce that the location, which is the key, will not be null. The block sometimes can be null, so by having the seperate location will not cause a failure if the block is null. --- docs/changelog_v3.3.x.md | 6 +++++- .../mcprison/prison/spigot/utils/BlockUtils.java | 16 +++++++++++++--- .../prison/spigot/utils/PrisonUtilsDecay.java | 6 +++--- .../spigot/utils/UnbreakableBlockData.java | 15 ++++++++++++--- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c692ceffa..75a9c9088 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9c 2022-03-09 +# 3.3.0-alpha.9c 2022-03-10 + + +* **For unbreakable blocks, reinforce that the location, which is the key, will not be null.** +The block sometimes can be null, so by having the seperate location will not cause a failure if the block is null. * **Fixed an issue when checking if a block is unbreakable... it should not have been null, so this is a temp fix to prevent an error.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/BlockUtils.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/BlockUtils.java index b6c9e880e..34969030e 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/BlockUtils.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/BlockUtils.java @@ -53,11 +53,21 @@ public boolean isUnbreakable( PrisonBlock block ) { } - public UnbreakableBlockData addUnbreakable( PrisonBlock block, Mine mine ) { + /** + *

Adds an unbreakable block at the given location. The block itself can be null, but the location + * cannot be null since it's used as the key value. + *

+ * + * @param location + * @param block + * @param mine + * @return + */ + public UnbreakableBlockData addUnbreakable( Location location, PrisonBlock block, Mine mine ) { UnbreakableBlockData data = null; - if ( block.getLocation() != null ) { - data = new UnbreakableBlockData( block, mine ); + if ( location != null ) { + data = new UnbreakableBlockData( location, block, mine ); getUnbreakableBlocks().put( data.getKey(), data ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsDecay.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsDecay.java index 8a6558dbd..810d05dfc 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsDecay.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsDecay.java @@ -117,7 +117,7 @@ else if ( decayTimeTicks > 6000 ) { Mine mine = spigotApi.findMineLocation( sourceBlock ); - UnbreakableBlockData data = BlockUtils.getInstance().addUnbreakable( sourceBlock, mine ); + UnbreakableBlockData data = BlockUtils.getInstance().addUnbreakable( sourceBlock.getLocation(), sourceBlock, mine ); data.setTargetBlock( targetBlock ); data.setDecayTimeTicks( decayTimeTicks ); @@ -215,7 +215,7 @@ else if ( decayTimeTicks > 6000 ) { Mine mine = spigotApi.findMineLocation( sourceBlock ); - UnbreakableBlockData data = BlockUtils.getInstance().addUnbreakable( sourceBlock, mine ); + UnbreakableBlockData data = BlockUtils.getInstance().addUnbreakable( sourceBlock.getLocation(), sourceBlock, mine ); data.setTargetBlock( targetBlock ); data.setDecayTimeTicks( decayTimeTicks ); @@ -319,7 +319,7 @@ else if ( decayTimeTicks > 6000 ) { Mine mine = spigotApi.findMineLocation( sourceBlock ); - UnbreakableBlockData data = BlockUtils.getInstance().addUnbreakable( sourceBlock, mine ); + UnbreakableBlockData data = BlockUtils.getInstance().addUnbreakable( sourceBlock.getLocation(), sourceBlock, mine ); data.setTargetBlock( targetBlock ); data.setDecayTimeTicks( decayTimeTicks ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/UnbreakableBlockData.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/UnbreakableBlockData.java index 7cad9c337..480c9989e 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/UnbreakableBlockData.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/UnbreakableBlockData.java @@ -15,6 +15,15 @@ public class UnbreakableBlockData private int taskId; + /** + *

The location is the key to the unbreakable block. Since it is required, + * it is supplied outside of the block, which may be nullable, or without a + * valid location. + *

+ * @param key + * @param block + * @param mine + */ public UnbreakableBlockData( Location key, PrisonBlock block, Mine mine ) { super(); @@ -28,9 +37,9 @@ public UnbreakableBlockData( Location key, PrisonBlock block, Mine mine ) { this.taskId = 0; } - public UnbreakableBlockData( PrisonBlock block, Mine mine ) { - this( block.getLocation(), block, mine ); - } +// public UnbreakableBlockData( PrisonBlock block, Mine mine ) { +// this( block.getLocation(), block, mine ); +// } public Location getKey() { return key; From 6ec61265c8c15b37c118d5e63ef88f9837abaa2a Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Thu, 10 Mar 2022 08:48:40 -0500 Subject: [PATCH 161/297] Within the SpigotBlock, now has hooks to load CustomItems blocks when trying to convert an org.bukkit.Block to a SpigotBlock. --- docs/changelog_v3.3.x.md | 3 ++ .../prison/spigot/block/SpigotBlock.java | 21 +++++++++++++- .../spigot/customblock/CustomItems.java | 28 +++++++++++++++++++ .../customblock/CustomItemsWrapper.java | 5 ++++ .../prison/spigot/game/SpigotPlayer.java | 1 - 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 75a9c9088..44e13a680 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-10 +* **Within the SpigotBlock, now has hooks to load CustomItems blocks when trying to convert an org.bukkit.Block to a SpigotBlock.** + + * **For unbreakable blocks, reinforce that the location, which is the key, will not be null.** The block sometimes can be null, so by having the seperate location will not cause a failure if the block is null. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java index 0b4271406..077d0b292 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java @@ -25,6 +25,7 @@ import com.cryptomorin.xseries.XMaterial; +import tech.mcprison.prison.Prison; import tech.mcprison.prison.PrisonAPI; import tech.mcprison.prison.integration.CustomBlockIntegration; import tech.mcprison.prison.internal.ItemStack; @@ -35,6 +36,7 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; +import tech.mcprison.prison.spigot.customblock.CustomItems; import tech.mcprison.prison.util.Location; /** @@ -72,8 +74,25 @@ public static SpigotBlock getSpigotBlock( org.bukkit.block.Block bukkitBlock) { SpigotBlock sBlock = null; XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( bukkitBlock ); + + if ( xMat == null ) { + for ( CustomBlockIntegration custIntegration : Prison.get().getIntegrationManager().getCustomBlockIntegrations() ) { + + if ( custIntegration.isRegistered() ) { + + if ( custIntegration instanceof CustomItems ) { + CustomItems cItems = (CustomItems) custIntegration; + + String blockId = cItems.getCustomBlockId(bukkitBlock); + + sBlock = new SpigotBlock( blockId, bukkitBlock ); + } + } + } + + } - if ( xMat != null ) { + else if ( xMat != null ) { sBlock = new SpigotBlock( xMat.name(), bukkitBlock ); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java index 24a03b551..b3d1eca00 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java @@ -95,6 +95,12 @@ public String getCustomBlockId( Block block ) { return customItemsWrapper.getCustomBlockId( block ); } + + public String getCustomBlockId( org.bukkit.block.Block spigotBlock ) { + + return customItemsWrapper.getCustomBlockId( spigotBlock ); + } + /** *

This function is supposed to identify if the given block is a custom block, and * if it is a custom block, then this function will return the correct PrisonBlock @@ -133,6 +139,28 @@ public PrisonBlock getCustomBlock( Block block ) { return results; } +// public PrisonBlock getCustomBlock( org.bukkit.block.Block spigotBlock ) { +// PrisonBlock results = null; +// +// String customBlockId = getCustomBlockId( spigotBlock ); +// +// if ( customBlockId != null ) { +// results = SpigotPrison.getInstance().getPrisonBlockTypes() +// .getBlockTypesByName( customBlockId ); +// +// if ( results != null ) { +// Location loc = SpigotUtil.bukkitLocationToPrison( spigotBlock.getLocation() ); +// +// results.setLocation( loc ); +// } +// +// SpigotBlock sBlock = new SpigotBlock(); +// } +// +// return results; +// } + + @Override public Block setCustomBlockId( Block block, String customId, boolean doBlockUpdate ) { return customItemsWrapper.setCustomBlockId( block, customId, doBlockUpdate ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java index 4dbb9e82d..3f2aed674 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java @@ -33,6 +33,11 @@ public String getCustomBlockId( Block block ) { org.bukkit.block.Block spigotBlock = ((SpigotBlock) block).getWrapper(); return CustomItemsAPI.getCustomItemIDAtBlock( spigotBlock ); } + + public String getCustomBlockId( org.bukkit.block.Block spigotBlock ) { + + return CustomItemsAPI.getCustomItemIDAtBlock( spigotBlock ); + } /** *

This should only be called when running in the bukkit synchronous thread. 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 b3bdfcdfa..e1ae7bff2 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 @@ -37,7 +37,6 @@ import tech.mcprison.prison.internal.inventory.Inventory; import tech.mcprison.prison.internal.scoreboard.Scoreboard; import tech.mcprison.prison.mines.data.Mine; -import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.data.RankPlayer; import tech.mcprison.prison.spigot.SpigotUtil; From b440bd489230ac7d1d68c35e60f5c621a89f3b42 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Mar 2022 14:40:29 -0500 Subject: [PATCH 162/297] v3.3.0-alpha.9d (forgot to commit on 2022-03-10) --- docs/changelog_v3.3.x.md | 3 +++ gradle.properties | 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 44e13a680..f85c100b3 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-10 +* **v3.3.0-alpha.9d 2022-03-10** + + * **Within the SpigotBlock, now has hooks to load CustomItems blocks when trying to convert an org.bukkit.Block to a SpigotBlock.** diff --git a/gradle.properties b/gradle.properties index 8bd84bc7d..72f1ac13d 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.9c +version=3.3.0-alpha.9d #version=3.3.0-alpha.7 From ec7954d710864b17aff79c69b0e993096f45b140 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Mar 2022 14:42:35 -0500 Subject: [PATCH 163/297] Report that bedrock users are not getting their tokens. When in debug mode, if their balance is not correctly updated it will report it in the console. --- docs/changelog_v3.3.x.md | 6 +++++- .../java/tech/mcprison/prison/PrisonCommand.java | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index f85c100b3..d02f05a99 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9c 2022-03-10 +# 3.3.0-alpha.9c 2022-03-12 + + +* **Report that bedrock users are not getting their tokens.** +When in debug mode, if their balance is not correctly updated it will report it in the console. * **v3.3.0-alpha.9d 2022-03-10** 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 d12504d62..40bbbb779 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -35,6 +35,7 @@ import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper; +import tech.mcprison.prison.cache.PlayerCachePlayerData; import tech.mcprison.prison.commands.Arg; import tech.mcprison.prison.commands.Command; import tech.mcprison.prison.commands.CommandPagedData; @@ -1712,21 +1713,30 @@ public void tokensAdd( CommandSender sender, } Player player = getPlayer( playerName ); + PlayerCachePlayerData pCache = player.getPlayerCachePlayerData(); + + long tokenBal = pCache.getTokens(); if ( forcePlayer ) { - player.getPlayerCachePlayerData().addTokens( amount ); + pCache.addTokens( amount ); } else { - player.getPlayerCachePlayerData().addTokensAdmin( amount ); + pCache.addTokensAdmin( amount ); } + if ( pCache.getTokens() != tokenBal + amount && Output.get().isDebug() ) { + Output.get().logError( + String.format( + "AddTokens failure: player: %s Tokens: %d Should have been: %d", + player.getName(), pCache.getTokens(), tokenBal + amount )); + } if ( !silent ) { String message = coreTokensAddedAmountMsg( player.getName(), - player.getPlayerCachePlayerData().getTokens(), amount ); + pCache.getTokens(), amount ); // String tokens = dFmt.format( player.getPlayerCachePlayerData().getTokens() ); // From f8f0c2119ccf914b8992d5f63596de8288462e41 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Mar 2022 14:47:39 -0500 Subject: [PATCH 164/297] CustomItems integration: Adding support for getDrops() from CUI. This integrates custom blocks in to getting the SpigotBlock (an internal prison block). It's not yet functional due to issues within CUI, but this is the initial setup. --- .../prison/spigot/block/SpigotBlock.java | 61 ++++++++++++------- .../spigot/customblock/CustomItems.java | 4 +- .../customblock/CustomItemsWrapper.java | 57 +++++++++++++---- 3 files changed, 86 insertions(+), 36 deletions(-) diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java index 077d0b292..8422f5e28 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlock.java @@ -56,7 +56,7 @@ public class SpigotBlock * is a custom block type. */ private transient Set prisonBlockTypes; - + private SpigotBlock( String blockName, org.bukkit.block.Block bBlock ) { super( blockName ); @@ -66,6 +66,15 @@ private SpigotBlock( String blockName, org.bukkit.block.Block bBlock ) { } + private SpigotBlock( PrisonBlockType blockType, String blockName, org.bukkit.block.Block bBlock ) { + super( blockType, blockName ); + + this.bBlock = bBlock; + + this.prisonBlockTypes = new HashSet<>(); + + } + public SpigotBlock( org.bukkit.block.Block bBlock, PrisonBlock targetBlockType ) { this( targetBlockType.getBlockName(), bBlock ); } @@ -73,28 +82,34 @@ public SpigotBlock( org.bukkit.block.Block bBlock, PrisonBlock targetBlockType ) public static SpigotBlock getSpigotBlock( org.bukkit.block.Block bukkitBlock) { SpigotBlock sBlock = null; - XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( bukkitBlock ); - - if ( xMat == null ) { - for ( CustomBlockIntegration custIntegration : Prison.get().getIntegrationManager().getCustomBlockIntegrations() ) { - - if ( custIntegration.isRegistered() ) { - - if ( custIntegration instanceof CustomItems ) { - CustomItems cItems = (CustomItems) custIntegration; - - String blockId = cItems.getCustomBlockId(bukkitBlock); - - sBlock = new SpigotBlock( blockId, bukkitBlock ); - } - } - } - - } - - else if ( xMat != null ) { - sBlock = new SpigotBlock( xMat.name(), bukkitBlock ); - } + if (bukkitBlock != null ) { + + XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( bukkitBlock ); + + if ( xMat == null ) { + for ( CustomBlockIntegration custIntegration : Prison.get().getIntegrationManager().getCustomBlockIntegrations() ) { + + if ( custIntegration.isRegistered() ) { + + if ( custIntegration instanceof CustomItems ) { + CustomItems cItems = (CustomItems) custIntegration; + + String blockId = cItems.getCustomBlockId(bukkitBlock); + + if ( blockId != null ) { + + sBlock = new SpigotBlock( cItems.getBlockType(), blockId, bukkitBlock ); + } + } + } + } + + } + + else if ( xMat != null ) { + sBlock = new SpigotBlock( xMat.name(), bukkitBlock ); + } + } // SpigotBlock sBlock = SpigotCompatibility.getInstance().getPrisonBlock( bBlock ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java index b3d1eca00..689756d4a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItems.java @@ -60,10 +60,10 @@ public void integrate() { if ( semVer.compareTo( getVersion(), "4.1.15" ) >= 0 ) { this.customItemsWrapper.setSupportsDrops( true ); - Output.get().logInfo( message + " enabled." ); + Output.get().logInfo( "&7" + message + "enabled." ); } else { - Output.get().logInfo( message + "not enabled." ); + Output.get().logInfo( "&c" + message + "not enabled. &3Upgrade to v4.1.15 or newer." ); } } else { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java index 3f2aed674..543985f86 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java @@ -4,13 +4,17 @@ import java.util.ArrayList; import java.util.List; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import com.jojodmo.customitems.api.CustomItemsAPI; +import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper; +import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.internal.block.Block; import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; @@ -127,27 +131,58 @@ public void run() { public List getDrops( PrisonBlock prisonBlock, SpigotPlayer player, SpigotItemStack tool ) { List results = new ArrayList<>(); - if ( isSupportsDrops() && prisonBlock instanceof SpigotBlock ) { + if ( isSupportsDrops() && + prisonBlock instanceof SpigotBlock ) { SpigotBlock sBlock = (SpigotBlock) prisonBlock; - SimpleEntry>> cuiDropResults = - CustomItemsAPI.breakCustomItemBlockWithoutDrops( - sBlock.getWrapper(), player.getWrapper(), tool.getBukkitStack(), false, true ); + org.bukkit.block.Block bBlock = sBlock.getWrapper(); + Player bPlayer = player.getWrapper(); + ItemStack bTool = tool.getBukkitStack(); - if ( cuiDropResults != null ) { + if ( bBlock != null && bPlayer != null && bTool != null ) { - Boolean cuiCanceled = cuiDropResults.getKey(); - ItemStack toolOverridden = cuiDropResults.getValue().getKey(); - List cuiDrops = cuiDropResults.getValue().getValue(); - if ( cuiCanceled && cuiDrops != null && cuiDrops.size() > 0 ) { + SimpleEntry>> cuiDropResults = null; + + try { + cuiDropResults = + CustomItemsAPI.breakCustomItemBlockWithoutDrops( + bBlock, bPlayer, bTool, false, true ); + } + catch (Exception e) { + Output.get().logError( "Failed: CustomItemsWrapper.getDrops: breakCustomItemBlockWithoutDrops: ", + e ); +// e.printStackTrace(); + } + + if ( cuiDropResults != null ) { + + Boolean cuiCanceled = cuiDropResults.getKey(); + ItemStack toolOverridden = cuiDropResults.getValue().getKey(); + List cuiDrops = cuiDropResults.getValue().getValue(); - for (ItemStack itemStack : cuiDrops) { - results.add( new SpigotItemStack( itemStack ) ); + if ( cuiDrops != null && cuiDrops.size() > 0 ) { + + for (ItemStack itemStack : cuiDrops) { + results.add( new SpigotItemStack( itemStack ) ); + } } } } + else { + if ( Output.get().isDebug() ) { + String message = String.format( + "CustomItems.getDrops(): failed to provide non-null inputs. " + + "block: %s player: %s tool: %s", + bBlock == null ? "null" : prisonBlock.getBlockName(), + bPlayer == null ? "null" : player.getName(), + bTool == null ? "null" : tool.getName() + ); + + Output.get().logDebug( message ); + } + } } else { From ca67d0d6b65286d95e13524fb40de7959bf2b1d4 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Mar 2022 14:50:51 -0500 Subject: [PATCH 165/297] Added an autoFeatures to enable/disable the use of CustomItems' getDrops(). --- docs/changelog_v3.3.x.md | 8 ++++++++ .../prison/autofeatures/AutoFeaturesFileConfig.java | 4 ++++ .../prison/spigot/customblock/CustomItemsWrapper.java | 1 + 3 files changed, 13 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d02f05a99..40ca0edb0 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,14 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-12 +* **Added an autoFeatures to enable/disable the use of CustomItems' getDrops().** + + +* **CustomItems integration: Adding support for getDrops() from CUI.** +This integrates custom blocks in to getting the SpigotBlock (an internal prison block). +It's not yet functional due to issues within CUI, but this is the initial setup. + + * **Report that bedrock users are not getting their tokens.** When in debug mode, if their balance is not correctly updated it will report it in the console. 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 d4eec8a29..16e2c33c7 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 @@ -75,6 +75,10 @@ public enum AutoFeatures { "NOTE: If you are using spigot v1.12.0 or higher, then do not use these " + "'forced' settings, instead adjust both 'cancelAllBlockBreakEvents' and " + "'cancelAllBlockEventBlockDrops' since that will help ensure it works better."), + + + isUseCustomBlocksCustomItemsGetDrops( otherPlugins, true ), + blockBreakEvents(options), diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java index 543985f86..dd09050b1 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java @@ -132,6 +132,7 @@ public List getDrops( PrisonBlock prisonBlock, SpigotPlayer pla List results = new ArrayList<>(); if ( isSupportsDrops() && + AutoFeaturesWrapper.getInstance().isBoolean( AutoFeatures.isUseCustomBlocksCustomItemsGetDrops ) && prisonBlock instanceof SpigotBlock ) { SpigotBlock sBlock = (SpigotBlock) prisonBlock; From 127306345ef6214dde8a29733da2b5e6422cecd2 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Mar 2022 14:55:22 -0500 Subject: [PATCH 166/297] BugFix: Prevent a possible NPE when blocks are null when calculating gravity effected blocks, and ensuring there is a location when trying to place blocks. Both of these should never be an issue, but based upon different conditions, they can become an issue. --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/internal/block/PrisonBlockStatusData.java | 7 +++++-- .../mcprison/prison/spigot/game/SpigotWorld.java | 12 ++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 40ca0edb0..0e36a62c1 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-12 +* **BugFix: Prevent a possible NPE when blocks are null when calculating gravity effected blocks, and ensuring there is a location when trying to place blocks.** +Both of these should never be an issue, but based upon different conditions, they can become an issue. + + * **Added an autoFeatures to enable/disable the use of CustomItems' getDrops().** diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockStatusData.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockStatusData.java index dce71ce66..d92a4def0 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockStatusData.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockStatusData.java @@ -341,8 +341,10 @@ private boolean checkGravityAffects( String blockName ) { boolean results = false; - switch ( blockName ) - { + if ( blockName != null ) { + + switch ( blockName ) + { case "sand": case "red_sand": case "gravel": @@ -374,6 +376,7 @@ private boolean checkGravityAffects( String blockName ) { results = true; } + } } return results; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java index ed2ae7e75..895ab4d6f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java @@ -233,7 +233,7 @@ public void run() { { current = tBlock; - if ( tBlock != null ) { + if ( tBlock != null && tBlock.getLocation() != null ) { final PrisonBlock pBlock = tBlock.getPrisonBlock( resetType ); @@ -259,15 +259,15 @@ public void run() { String resetTypeBlockName = pBlock == null ? "null" : pBlock.getBlockName(); Output.get().logError( - String.format( "SpigotWorld.setBlocksSynchronously: %s resetType: %s %s", - blkName, resetType.name(), resetTypeBlockName ), e ); + String.format( "SpigotWorld.setBlocksSynchronously Exception: %s resetType: %s %s :: %s", + blkName, resetType.name(), resetTypeBlockName, e.getMessage() ), e ); } else { Output.get().logError( - String.format( "SpigotWorld.setBlocksSynchronously: --noBlock-- resetType: %s " + - "[unable to set 'current']", - resetType.name() ), e ); + String.format( "SpigotWorld.setBlocksSynchronously Exception: --noBlock-- resetType: %s " + + "[unable to set 'current'] :: %s", + resetType.name(), e.getMessage() ), e ); } } From db1c4db4004630bf6f0aea84af5a911d59b5840a Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 12 Mar 2022 22:25:54 -0500 Subject: [PATCH 167/297] Upgrade bstats to v3.0.0, was at v2.2.1. Hoping this will better report the proper usage. Added more custom details on the graphs: player count, defaultRankCount, prestigesRankCount, otherRankCounts. Set api version to v3.3. --- docs/changelog_v3.3.x.md | 6 +++++ .../java/tech/mcprison/prison/Prison.java | 1 + .../mcprison/prison/ranks/PrisonRanks.java | 22 +++++++++++++++- prison-spigot/build.gradle | 10 ++++--- .../mcprison/prison/spigot/SpigotPrison.java | 26 +++++++++++++++++-- 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0e36a62c1..26fc4cad7 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,12 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-12 +* **Upgrade bstats to v3.0.0, was at v2.2.1.** +Hoping this will better report the proper usage. +Added more custom details on the graphs: player count, defaultRankCount, prestigesRankCount, otherRankCounts. +Set api version to v3.3. + + * **BugFix: Prevent a possible NPE when blocks are null when calculating gravity effected blocks, and ensuring there is a location when trying to place blocks.** Both of these should never be an issue, but based upon different conditions, they can become an issue. diff --git a/prison-core/src/main/java/tech/mcprison/prison/Prison.java b/prison-core/src/main/java/tech/mcprison/prison/Prison.java index 0d0456986..396216ca1 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/Prison.java +++ b/prison-core/src/main/java/tech/mcprison/prison/Prison.java @@ -74,6 +74,7 @@ public class Prison private static Prison instance = null; public static final int API_LEVEL = 3; + public static final int API_LEVEL_MINOR = 3; private String minecraftVersion; private List versionMajMin; diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java index ece133112..a438541a7 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java @@ -451,10 +451,30 @@ public Database getDatabase() { public int getRankCount() { int rankCount = getRankManager() == null ||getRankManager().getRanks() == null ? 0 : - getRankManager().getRanks().size(); + getRankManager().getRanks().size(); return rankCount; } + private int getLadderRankCount( String ladderName ) { + int rankCount = 0; + + if ( getLadderManager() != null && getLadderManager().getLadders() != null ) { + RankLadder ladder = getLadderManager().getLadder( ladderName ); + if ( ladder != null ) { + rankCount = ladder.getRanks().size(); + } + } + return rankCount; + } + + public int getDefaultLadderRankCount() { + return getLadderRankCount( "default" ); + } + + public int getPrestigesLadderRankCount() { + return getLadderRankCount( "prestiges" ); + } + public int getladderCount() { int ladderCount = getLadderManager() == null || getLadderManager().getLadders() == null ? 0 : getLadderManager().getLadders().size(); diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index c0a96b5ab..23d64d1b8 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -82,8 +82,9 @@ dependencies { implementation project(':prison-sellall') - implementation 'org.bstats:bstats-base:2.2.1' - implementation 'org.bstats:bstats-bukkit:2.2.1' + implementation 'org.bstats:bstats-bukkit:3.0.0' +// implementation 'org.bstats:bstats-base:2.2.1' +// implementation 'org.bstats:bstats-bukkit:2.2.1' // Repo keeps going down: @@ -183,8 +184,9 @@ shadowJar { include(dependency('org.apache.commons:commons-lang3:3.12.0')) include(dependency('com.google.code.gson:gson:2.8.6')) - include(dependency('org.bstats:bstats-base:2.2.1')) - include(dependency('org.bstats:bstats-bukkit:2.2.1')) + include(dependency('org.bstats:bstats-bukkit:3.0.0')) +// include(dependency('org.bstats:bstats-base:2.2.1')) +// include(dependency('org.bstats:bstats-bukkit:2.2.1')) include(dependency('me.clip:placeholderapi:2.10.9')) 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 bda985eb5..6ed247a11 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 @@ -497,7 +497,9 @@ private void initMetrics() { if (!getConfig().getBoolean("send-metrics", true)) { return; // Don't check if they don't want it } - Metrics metrics = new Metrics( this, 657 ); + + int pluginId = 657; + Metrics metrics = new Metrics( this, pluginId ); // Report the modules being used metrics.addCustomChart(new SimpleBarChart("modules_used", () -> { @@ -510,14 +512,21 @@ private void initMetrics() { // Report the API level metrics.addCustomChart( - new SimplePie("api_level", () -> "API Level " + Prison.API_LEVEL)); + new SimplePie("api_level", () -> + "API Level " + Prison.API_LEVEL + "." + Prison.API_LEVEL_MINOR )); Optional prisonMinesOpt = Prison.get().getModuleManager().getModule( PrisonMines.MODULE_NAME ); Optional prisonRanksOpt = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); int mineCount = prisonMinesOpt.map(module -> ((PrisonMines) module).getMineManager().getMines().size()).orElse(0); int rankCount = prisonRanksOpt.map(module -> ((PrisonRanks) module).getRankCount()).orElse(0); + + int defaultRankCount = prisonRanksOpt.map(module -> ((PrisonRanks) module).getDefaultLadderRankCount()).orElse(0); + int prestigesRankCount = prisonRanksOpt.map(module -> ((PrisonRanks) module).getPrestigesLadderRankCount()).orElse(0); + int otherRankCount = rankCount - defaultRankCount - prestigesRankCount; + int ladderCount = prisonRanksOpt.map(module -> ((PrisonRanks) module).getladderCount()).orElse(0); + int playerCount = prisonRanksOpt.map(module -> ((PrisonRanks) module).getPlayersCount()).orElse(0); metrics.addCustomChart(new MultiLineChart("mines_ranks_and_ladders", new Callable>() { @Override @@ -526,9 +535,22 @@ public Map call() throws Exception { valueMap.put("mines", mineCount); valueMap.put("ranks", rankCount); valueMap.put("ladders", ladderCount); + valueMap.put("players", playerCount); return valueMap; } })); + + metrics.addCustomChart(new MultiLineChart("prison_ranks", new Callable>() { + @Override + public Map call() throws Exception { + Map valueMap = new HashMap<>(); + valueMap.put("ranks", rankCount); + valueMap.put("defaultRanks", defaultRankCount); + valueMap.put("prestigesRanks", prestigesRankCount); + valueMap.put("otherRanks", otherRankCount); + return valueMap; + } + })); } /** From 8dcaec7de04447fb1239af7b5a5cae37c160237b Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Mar 2022 15:31:56 -0400 Subject: [PATCH 168/297] Update the bstats configs for v3.0.0. Although it compiled without the bstats-base, it failed to run. I suspect my local cache for gradle was incorrectly providing objects when it shouldn't have. --- docs/changelog_v3.3.x.md | 6 ++++- prison-spigot/build.gradle | 2 ++ .../mcprison/prison/spigot/SpigotPrison.java | 22 ++++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 26fc4cad7..e880b376c 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9c 2022-03-12 +# 3.3.0-alpha.9c 2022-03-13 + + +* **Update the bstats configs for v3.0.0.** +Although it compiled without the bstats-base, it failed to run. I suspect my local cache for gradle was incorrectly providing objects when it shouldn't have. * **Upgrade bstats to v3.0.0, was at v2.2.1.** diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index 23d64d1b8..ed7500742 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -82,6 +82,7 @@ dependencies { implementation project(':prison-sellall') + implementation 'org.bstats:bstats-base:3.0.0' implementation 'org.bstats:bstats-bukkit:3.0.0' // implementation 'org.bstats:bstats-base:2.2.1' // implementation 'org.bstats:bstats-bukkit:2.2.1' @@ -184,6 +185,7 @@ shadowJar { include(dependency('org.apache.commons:commons-lang3:3.12.0')) include(dependency('com.google.code.gson:gson:2.8.6')) + include(dependency('org.bstats:bstats-base:3.0.0')) include(dependency('org.bstats:bstats-bukkit:3.0.0')) // include(dependency('org.bstats:bstats-base:2.2.1')) // include(dependency('org.bstats:bstats-bukkit:2.2.1')) 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 6ed247a11..7482c4a70 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 @@ -502,18 +502,21 @@ private void initMetrics() { Metrics metrics = new Metrics( this, pluginId ); // Report the modules being used - metrics.addCustomChart(new SimpleBarChart("modules_used", () -> { + SimpleBarChart sbcModulesUsed = new SimpleBarChart("modules_used", () -> { Map valueMap = new HashMap<>(); for (Module m : PrisonAPI.getModuleManager().getModules()) { valueMap.put(m.getName(), 1); } return valueMap; - })); + }); + metrics.addCustomChart( sbcModulesUsed ); // Report the API level - metrics.addCustomChart( + SimplePie spApiLevel = new SimplePie("api_level", () -> - "API Level " + Prison.API_LEVEL + "." + Prison.API_LEVEL_MINOR )); + "API Level " + Prison.API_LEVEL + "." + Prison.API_LEVEL_MINOR ); + metrics.addCustomChart( spApiLevel ); + Optional prisonMinesOpt = Prison.get().getModuleManager().getModule( PrisonMines.MODULE_NAME ); Optional prisonRanksOpt = Prison.get().getModuleManager().getModule( PrisonRanks.MODULE_NAME ); @@ -528,7 +531,8 @@ private void initMetrics() { int ladderCount = prisonRanksOpt.map(module -> ((PrisonRanks) module).getladderCount()).orElse(0); int playerCount = prisonRanksOpt.map(module -> ((PrisonRanks) module).getPlayersCount()).orElse(0); - metrics.addCustomChart(new MultiLineChart("mines_ranks_and_ladders", new Callable>() { + MultiLineChart mlcMinesRanksAndLadders = + new MultiLineChart("mines_ranks_and_ladders", new Callable>() { @Override public Map call() throws Exception { Map valueMap = new HashMap<>(); @@ -538,9 +542,10 @@ public Map call() throws Exception { valueMap.put("players", playerCount); return valueMap; } - })); + }); + metrics.addCustomChart( mlcMinesRanksAndLadders ); - metrics.addCustomChart(new MultiLineChart("prison_ranks", new Callable>() { + MultiLineChart mlcPrisonRanks = new MultiLineChart("prison_ranks", new Callable>() { @Override public Map call() throws Exception { Map valueMap = new HashMap<>(); @@ -550,7 +555,8 @@ public Map call() throws Exception { valueMap.put("otherRanks", otherRankCount); return valueMap; } - })); + }); + metrics.addCustomChart( mlcPrisonRanks ); } /** From e12bb5508c2c285e79c649ae78075ed3a66b28bc Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Mar 2022 18:53:45 -0400 Subject: [PATCH 169/297] Reworked how some of the registered event listeners are setup, which is needed for expanding to supporting other plugin's enchanments. --- docs/changelog_v3.3.x.md | 3 + .../prison/spigot/SpigotPlatform.java | 20 +- .../mcprison/prison/spigot/SpigotPrison.java | 13 +- .../autofeatures/AutoManagerFeatures.java | 5 +- .../events/AutoManagerBlockBreakEvents.java | 349 ++-- .../events/AutoManagerCrazyEnchants.java | 330 ++- .../events/AutoManagerEventsManager.java | 60 +- .../events/AutoManagerPrisonEnchants.java | 287 ++- ...nagerPrisonsExplosiveBlockBreakEvents.java | 307 ++- .../events/AutoManagerTokenEnchant.java | 265 ++- .../events/AutoManagerZenchantments.java | 302 ++- .../spigot/block/OnBlockBreakEventCore.java | 1788 ++++++++--------- .../block/OnBlockBreakEventListener.java | 135 +- .../block/OnBlockBreakExternalEvents.java | 4 +- .../block/OnBlockBreakPlayerManualCore.java | 10 + 15 files changed, 2343 insertions(+), 1535 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e880b376c..49726b304 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **Reworked how some of the registered event listeners are setup, which is needed for expanding to supporting other plugin's enchanments.** + + * **Update the bstats configs for v3.0.0.** Although it compiled without the bstats-base, it failed to run. I suspect my local cache for gradle was incorrectly providing objects when it shouldn't have. 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 2a5c27945..ef6e0b14b 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 @@ -2361,16 +2361,18 @@ public ChatDisplay dumpEventListenersChatDisplay( String eventType, HandlerList */ public void reloadAutoFeaturesEventListeners() { - AutoManagerBlockBreakEvents autoFeaturesEvents = new AutoManagerBlockBreakEvents(); - - // NOTE: The unregisterListeners() will remove ALL auto features events that were - // registered, no matter which listeners were enabled. - autoFeaturesEvents.unregisterListeners(); - - // NOTE: The registerEvents() will register all event listeners based upon what's - // in the auto features configuration file. - autoFeaturesEvents.registerEvents(); + SpigotPrison.getInstance().getBlockBreakEventListeners().reloadEventListeners(); +// AutoManagerBlockBreakEvents autoFeaturesEvents = new AutoManagerBlockBreakEvents(); +// +// // NOTE: The unregisterListeners() will remove ALL auto features events that were +// // registered, no matter which listeners were enabled. +// autoFeaturesEvents.unregisterListeners(); +// +// // NOTE: The registerEvents() will register all event listeners based upon what's +// // in the auto features configuration file. +// autoFeaturesEvents.registerEvents(); +// } /** 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 7482c4a70..1311b41d9 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 @@ -123,6 +123,8 @@ public class SpigotPrison private AutoManagerFeatures autoFeatures = null; // private FileConfiguration autoFeaturesConfig = null; + + private OnBlockBreakEventListener blockBreakEventListeners; private MessagesConfig messagesConfig; private GuiConfig guiConfig; @@ -309,7 +311,7 @@ public void onEnableStartup() { // The BlockBreakEvents must be registered after the mines and ranks modules have been enabled: - new OnBlockBreakEventListener().registerAllBlockBreakEvents( this ); + getBlockBreakEventListeners().registerAllBlockBreakEvents( this ); initMetrics(); @@ -403,7 +405,14 @@ public File getModuleDataFolder() { } - public FileConfiguration getGuiConfig() { + public OnBlockBreakEventListener getBlockBreakEventListeners() { + if ( blockBreakEventListeners == null ) { + this.blockBreakEventListeners = new OnBlockBreakEventListener(); + } + return blockBreakEventListeners; + } + + public FileConfiguration getGuiConfig() { if (guiConfig == null) { guiConfig = new GuiConfig(); } 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 702cf34f4..6e7aaebf3 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 @@ -54,13 +54,12 @@ * * */ -public class AutoManagerFeatures +public abstract class AutoManagerFeatures extends OnBlockBreakEventCore { - private Random random = new Random(); - + public AutoManagerFeatures() { super(); 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 9ee60360d..72cb9f566 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 @@ -1,59 +1,61 @@ package tech.mcprison.prison.spigot.autofeatures.events; +import java.util.ArrayList; +import java.util.List; + 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.Listener; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.PluginManager; import tech.mcprison.prison.Prison; 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.ChatDisplay; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.output.Output.DebugTarget; 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; +import tech.mcprison.prison.spigot.block.OnBlockBreakExternalEvents; +import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.game.SpigotHandlerList; +import tech.mcprison.prison.spigot.game.SpigotPlayer; public class AutoManagerBlockBreakEvents - extends AutoManagerEventsManager + extends AutoManagerFeatures + implements PrisonEventManager { + private BlockBreakPriority bbPriority; public AutoManagerBlockBreakEvents() { super(); } - /** - *

When a listener is registered within prison's auto manager, the events - * are tracked internally and can be unregistered later. This function does not - * make it obvious the instantiated object is "stored", but it is. - *

- * - *

For more info on the storage of these registered events, please see: - *

- * - *
SpigotPrison.getRegisteredBlockListeners()
- * - */ + + public BlockBreakPriority getBbPriority() { + return bbPriority; + } + public void setBbPriority( BlockBreakPriority bbPriority ) { + this.bbPriority = bbPriority; + } + @Override public void registerEvents() { - + initialize(); - // Prison's own internal event and listener: - new AutoManagerPrisonsExplosiveBlockBreakEvents().registerEvents(); - - new AutoManagerCrazyEnchants().registerEvents(); - new AutoManagerPrisonEnchants().registerEvents(); - new AutoManagerTokenEnchant().registerEvents(); - new AutoManagerZenchantments().registerEvents(); - - - new PrisonDebugBlockInspector().init(); } @@ -68,37 +70,23 @@ public void onBlockBreak( BlockBreakEvent e, BlockBreakPriority bbPriority ) { return; } - genericBlockEvent( e, bbPriority ); + handleBlockBreakEvent( e, bbPriority ); // genericBlockEventAutoManager( e ); } + + @Override + protected int checkBonusXp(Player player, Block block, ItemStack item) { + // TODO Auto-generated method stub + return 0; + } } -// public class OnBlockBreakEventListenerNormal -// extends OnBlockBreakEventListener -// implements Listener { -// -// @EventHandler(priority=EventPriority.NORMAL) -// public void onBlockBreak(BlockBreakEvent e) { -// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockEvent( e ); -// } -// } -// -// public class OnBlockBreakEventListenerNormalMonitor -// extends OnBlockBreakEventListener -// implements Listener { -// -// @EventHandler(priority=EventPriority.MONITOR) -// public void onBlockBreak(BlockBreakEvent e) { -// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockEventMonitor( e ); -// } -// } + @Override + public void unregisterListeners() { + + } + public void initialize() { // Check to see if the class BlockBreakEvent even exists: @@ -135,71 +123,6 @@ public void execute(Listener l, Event e) { prison.getRegisteredBlockListeners().add( autoManagerlListener ); - -// OnBlockBreakEventListenerNormalMonitor normalListenerMonitor = -// new OnBlockBreakEventListenerNormalMonitor(); - - - - -// if ( eventPriority != BlockBreakPriority.MONITOR ) { -// -// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { -// -// AutoManagerBlockBreakEventListener autoManagerlListener = -// new AutoManagerBlockBreakEventListener(); -// -// pm.registerEvent(BlockBreakEvent.class, autoManagerlListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// if ( l instanceof AutoManagerBlockBreakEventListener && -// e instanceof BlockBreakEvent ) { -// ((AutoManagerBlockBreakEventListener)l) -// .onBlockBreak((BlockBreakEvent)e); -// } -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( autoManagerlListener ); -// } -// else if ( isBoolean( AutoFeatures.normalDrop ) ) { -// -// OnBlockBreakEventListenerNormal normalListener = -// new OnBlockBreakEventListenerNormal(); -// -// pm.registerEvent(BlockBreakEvent.class, normalListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// if ( l instanceof OnBlockBreakEventListenerNormal && -// e instanceof BlockBreakEvent ) { -// ((OnBlockBreakEventListenerNormal)l) -// .onBlockBreak((BlockBreakEvent)e); -// } -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListener ); -// } - - -// } -// else { -// -// pm.registerEvent(BlockBreakEvent.class, normalListenerMonitor, EventPriority.MONITOR, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// if ( l instanceof OnBlockBreakEventListenerNormalMonitor && -// e instanceof BlockBreakEvent ) { -// ((OnBlockBreakEventListenerNormalMonitor)l) -// .onBlockBreak((BlockBreakEvent)e); -// } -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); -// } - - } } @@ -209,21 +132,21 @@ public void execute(Listener l, Event e) { } - /** - *

If one BlockBreak related event needs to be unregistered, then this function will - * unregisters all of them that has been registered through the auto features. If - * this function is called by different functions, the results will be the same. If - * they are ran back-to-back, then only the first call will remove all the Listeners - * and the other calls will do nothing since the source ArrayList will be emptied - * and there would be nothing to remove. - *

- * - */ - @Override - public void unregisterListeners() { - - super.unregisterListeners(); - } +// /** +// *

If one BlockBreak related event needs to be unregistered, then this function will +// * unregisters all of them that has been registered through the auto features. If +// * this function is called by different functions, the results will be the same. If +// * they are ran back-to-back, then only the first call will remove all the Listeners +// * and the other calls will do nothing since the source ArrayList will be emptied +// * and there would be nothing to remove. +// *

+// * +// */ +// @Override +// public void unregisterListeners() { +// +//// super.unregisterListeners(); +// } @Override @@ -271,4 +194,170 @@ public void dumpEventListeners( StringBuilder sb ) { } } + + /** + *

This genericBlockEvent handles the basics of a BlockBreakEvent to see if it has happened + * within a mine or not. If it is happening within a mine, then we process it with the doAction() + * function. + *

+ * + * @param e + * @param montior Identifies that a monitor event called this function. A monitor should only record + * block break counts. + */ + private void handleBlockBreakEvent( BlockBreakEvent e, BlockBreakPriority bbPriority ) { + +// boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { + + if ( e instanceof PrisonMinesBlockBreakEvent ) { + return; + } + + long start = System.nanoTime(); + + if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { + return; + } + + + // Register all external events such as mcMMO and EZBlocks: + OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); + + StringBuilder debugInfo = new StringBuilder(); + + debugInfo.append( String.format( "### ** genericBlockEvent ** ### " + + "(event: BlockBreakEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { + + // Need to wrap in a Prison block so it can be used with the mines: + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); + SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); + + BlockEventType eventType = BlockEventType.blockBreak; + String triggered = null; + + PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), + sBlock, sPlayer, bbPriority, eventType, triggered ); + + if ( !validateEvent( pmEvent, debugInfo ) ) { + + // 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 ); + } + } + + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { + // Stop here, and prevent additional processing. Monitors should never process the event beyond this. + } + + // This is where the processing actually happens: + else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && + !isBoolean( AutoFeatures.pickupLimitToMines ) ) { + debugInfo.append( "(normal processing initiating) " ); + + // Set the mine's PrisonBlockTypes for the block. Used to identify custom blocks. + // Needed since processing of the block will lose track of which mine it came from. + if ( pmEvent.getMine() != null ) { + sBlock.setPrisonBlockTypes( pmEvent.getMine().getPrisonBlockTypes() ); + } + + // check all external events such as mcMMO and EZBlocks: + debugInfo.append( + OnBlockBreakExternalEvents.getInstance().checkAllExternalEvents( e ) ); + + List explodedBlocks = new ArrayList<>(); + pmEvent.setExplodedBlocks( explodedBlocks ); +// String triggered = null; + +// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), +// pmEvent.getMine(), sBlock, explodedBlocks, BlockEventType.blockBreak, triggered ); + Bukkit.getServer().getPluginManager().callEvent( pmEvent ); + if ( pmEvent.isCancelled() ) { + debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); + } + else { + + // Cancel drops if so configured: + if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { + + try + { + e.setDropItems( false ); + } + 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 ); + } + } + + // doAction returns a boolean that indicates if the event should be canceled or not: + if ( doAction( pmEvent, debugInfo ) ) { +// if ( doAction( sBlock, pmEvent.getMine(), pmEvent.getPlayer(), debugInfo ) ) { + + if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { + e.setCancelled( true ); + } + else { + + debugInfo.append( "(event was not canceled) " ); + } + + finalizeBreakTheBlocks( pmEvent ); + + doBlockEvents( pmEvent ); + + } + else { + + debugInfo.append( "(doAction failed without details) " ); + } + + } + + + debugInfo.append( "(normal processing completed) " ); + } + else { + + debugInfo.append( "(logic bypass) " ); + } + + } + + if ( debugInfo.length() > 0 ) { + + long stop = System.nanoTime(); + debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); + + Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); + } + } + + 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/AutoManagerCrazyEnchants.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java index 67a1ed727..37a587746 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 @@ -1,28 +1,53 @@ 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.Listener; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.PluginManager; import me.badbones69.crazyenchantments.api.events.BlastUseEvent; import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; +import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType; import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.output.Output.DebugTarget; 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; +import tech.mcprison.prison.spigot.block.OnBlockBreakExternalEvents; +import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.game.SpigotHandlerList; +import tech.mcprison.prison.spigot.game.SpigotPlayer; +import tech.mcprison.prison.spigot.integrations.IntegrationCrazyEnchantmentsPickaxes; public class AutoManagerCrazyEnchants - extends AutoManagerEventsManager + extends AutoManagerFeatures + implements PrisonEventManager { + private BlockBreakPriority bbPriority; + + private Boolean crazyEnchantEnabled; public AutoManagerCrazyEnchants() { super(); + + this.crazyEnchantEnabled = null; + } + + + public BlockBreakPriority getBbPriority() { + return bbPriority; + } + public void setBbPriority( BlockBreakPriority bbPriority ) { + this.bbPriority = bbPriority; } @Override @@ -44,35 +69,9 @@ public void onCrazyEnchantsBlockExplode( BlastUseEvent e, BlockBreakPriority bbP return; } - genericBlastUseEvent( e, bbPriority ); + handleBlastUseEvent( e, bbPriority ); } } - -// public class OnBlockBreakBlastUseEventListener -// extends AutoManagerCrazyEnchants -// implements Listener { -// -// @EventHandler(priority=EventPriority.NORMAL) -// public void onCrazyEnchantsBlockExplode(BlastUseEvent e) { -// if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockExplodeEvent( e ); -// } -// } -// -// public class OnBlockBreakBlastUseEventListenerMonitor -// extends AutoManagerCrazyEnchants -// implements Listener { -// -// @EventHandler(priority=EventPriority.MONITOR) -// public void onCrazyEnchantsBlockExplode(BlastUseEvent e) { -// if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockExplodeEventMonitor( e ); -// } -// } @Override @@ -119,77 +118,6 @@ public void execute(Listener l, Event e) { prison.getRegisteredBlockListeners().add( autoManagerlListener ); - - - - -// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); - -// if ( eventPriority != BlockBreakPriority.DISABLED ) { -// -// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); -// -// -// OnBlockBreakBlastUseEventListenerMonitor normalListenerMonitor = -// new OnBlockBreakBlastUseEventListenerMonitor(); - -// if ( eventPriority != BlockBreakPriority.MONITOR ) { - -// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { -// -// AutoManagerBlastUseEventListener autoManagerlListener = -// new AutoManagerBlastUseEventListener(); -// -// pm.registerEvent(BlastUseEvent.class, autoManagerlListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((AutoManagerBlastUseEventListener)l) -// .onCrazyEnchantsBlockExplode((BlastUseEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( autoManagerlListener ); -// } -// else if ( isBoolean( AutoFeatures.normalDrop ) ) { -// -// OnBlockBreakBlastUseEventListener normalListener = -// new OnBlockBreakBlastUseEventListener(); -// -// pm.registerEvent(BlastUseEvent.class, normalListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((OnBlockBreakBlastUseEventListener)l) -// .onCrazyEnchantsBlockExplode((BlastUseEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListener ); -// } - -// } -// else { -// -// pm.registerEvent(BlastUseEvent.class, normalListenerMonitor, EventPriority.MONITOR, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((OnBlockBreakBlastUseEventListenerMonitor)l) -// .onCrazyEnchantsBlockExplode((BlastUseEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); -// } - -// } - - // The following is paper code: -// var executor = EventExecutor -// .create( AutoManagerBlastUseEventListener.class -// .getDeclaredMethod( "onCrazyEnchantsBlockExplode", BlastUseEvent.class ), -// BlastUseEvent.class ); -// -// Bukkit.getServer().getPluginManager() -// .register( BlastUseEvent.class, this, EventPriority.LOW, executor, SpigotPrison.getInstance() ); } catch ( ClassNotFoundException e ) { // CrazyEnchants is not loaded... so ignore. @@ -204,8 +132,7 @@ public void execute(Listener l, Event e) { @Override public void unregisterListeners() { - super.unregisterListeners(); - +// super.unregisterListeners(); } @Override @@ -267,4 +194,205 @@ public void dumpEventListeners( StringBuilder sb ) { } } + /** + *

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 handleBlastUseEvent( BlastUseEvent e, BlockBreakPriority bbPriority ) { + +// boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { + + long start = System.nanoTime(); + + if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlockList().get( 0 )) ) { + return; + } + + + // Register all external events such as mcMMO and EZBlocks: + OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); + + StringBuilder debugInfo = new StringBuilder(); + + debugInfo.append( String.format( "### ** genericBlastUseEvent ** ### " + + "(event: BlastUseEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + // NOTE that check for auto manager has happened prior to accessing this function. + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR && + e.getBlockList().size() > 0 ) { + + + String eP = getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority ); + boolean isCEBlockExplodeEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + + + Block bukkitBlock = e.getBlockList().get( 0 ); + + // Need to wrap in a Prison block so it can be used with the mines: + SpigotBlock sBlock = SpigotBlock.getSpigotBlock( bukkitBlock ); + SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); + + BlockEventType eventType = BlockEventType.CEXplosion; + String triggered = null; + + + PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( bukkitBlock, e.getPlayer(), + sBlock, sPlayer, bbPriority, eventType, triggered ); + + + for ( int i = 1; i < e.getBlockList().size(); i++ ) { + pmEvent.getUnprocessedRawBlocks().add( e.getBlockList().get( i ) ); + } + + + if ( !validateEvent( pmEvent, debugInfo ) ) { + + // 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 ); + } + } + + + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { + // Stop here, and prevent additional processing. Monitors should never process the event beyond this. + } + + + + // now process all blocks (non-monitor): + else if ( isCEBlockExplodeEnabled && + ( pmEvent.getMine() != null || pmEvent.getMine() == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { + + + if ( pmEvent.getExplodedBlocks().size() > 0 ) { + +// String triggered = null; + + + // Warning: BlastUseEvent does not identify the block the player actually hit, so the dummyBlock + // is just a random first block from the explodedBlocks list and may not be the block + // that initiated the explosion event. +// SpigotBlock dummyBlock = explodedBlocks.get( 0 ); + +// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), +// mine, dummyBlock, explodedBlocks, BlockEventType.CEXplosion, triggered ); + Bukkit.getServer().getPluginManager().callEvent(pmEvent); + if ( pmEvent.isCancelled() ) { + debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); + } + else { + +// // Cancel drops if so configured: +// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { +// +// try +// { +// e.setDropItems( false ); +// } +// catch ( NoSuchMethodError e1 ) +// { +// String message = String.format( +// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + +// "is not valid for this version of Spigot. Modify the config settings and set " + +// "this value to `false`. [%s]", +// e1.getMessage() ); +// Output.get().logWarn( message ); +// } +// } + + if ( doAction( pmEvent, debugInfo ) ) { + + if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { + + e.setCancelled( true ); + } + else { + + debugInfo.append( "(event was not canceled) " ); + } + + finalizeBreakTheBlocks( pmEvent ); + + doBlockEvents( pmEvent ); + + } + + else { + + debugInfo.append( "(doAction failed without details) " ); + } + + } + } + + + debugInfo.append( "(normal processing) " ); + } + else { + + debugInfo.append( "(logic bypass) " ); + } + + } + + if ( debugInfo.length() > 0 ) { + + long stop = System.nanoTime(); + debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); + + Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); + } + } + + @Override + protected int checkBonusXp( Player player, Block block, ItemStack item ) { + int bonusXp = 0; + + try { + if ( isCrazyEnchantEnabled() == null ) { + Class.forName( + "tech.mcprison.prison.spigot.integrations.IntegrationCrazyEnchantmentsPickaxes", false, + this.getClass().getClassLoader() ); + setCrazyEnchantEnabled( Boolean.TRUE ); + } + + if ( isCrazyEnchantEnabled() != null && isCrazyEnchantEnabled().booleanValue() && + item != null && IntegrationCrazyEnchantmentsPickaxes.getInstance().isEnabled() ) { + + bonusXp = IntegrationCrazyEnchantmentsPickaxes.getInstance() + .getPickaxeEnchantmentExperienceBonus( player, block, item ); + } + } + catch ( NoClassDefFoundError | Exception e ) { + setCrazyEnchantEnabled( Boolean.FALSE ); + } + + return bonusXp; + } + + public Boolean isCrazyEnchantEnabled() { + return crazyEnchantEnabled; + } + public void setCrazyEnchantEnabled( Boolean crazyEnchantEnabled ) { + this.crazyEnchantEnabled = crazyEnchantEnabled; + } + } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerEventsManager.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerEventsManager.java index d2ac3cc9f..d08af5abc 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerEventsManager.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerEventsManager.java @@ -1,64 +1,30 @@ package tech.mcprison.prison.spigot.autofeatures.events; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; - -import tech.mcprison.prison.Prison; -import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures; -import tech.mcprison.prison.spigot.block.BlockBreakPriority; public abstract class AutoManagerEventsManager extends AutoManagerFeatures - implements PrisonEventManager +// implements PrisonEventManager { - private BlockBreakPriority bbPriority; +// private BlockBreakPriority bbPriority; public AutoManagerEventsManager() { super(); } - public boolean isDisabled( String worldName ) { - return Prison.get().getPlatform().isWorldExcluded( worldName ); - } +// public boolean isDisabled( String worldName ) { +// return Prison.get().getPlatform().isWorldExcluded( worldName ); +// } - /** - *

If one BlockBreak related event needs to be unregistered, then this function will - * unregisters all of them that has been registered through the auto features. If - * this function is called by different functions, the results will be the same. If - * they are ran back-to-back, then only the first call will remove all the Listeners - * and the other calls will do nothing since the source ArrayList will be emptied - * and there would be nothing to remove. - *

- * - */ - @Override - public void unregisterListeners() { - - SpigotPrison prison = SpigotPrison.getInstance(); - - int count = 0; - while ( prison.getRegisteredBlockListeners().size() > 0 ) { - Listener listener = prison.getRegisteredBlockListeners().remove( 0 ); - - if ( listener != null ) { - - HandlerList.unregisterAll( listener ); - count++; - } - } - - Output.get().logInfo( "AutoManagerEventsManager: unregistered a total of %d event listeners.", - count ); - } - public BlockBreakPriority getBbPriority() { - return bbPriority; - } - public void setBbPriority( BlockBreakPriority bbPriority ) { - this.bbPriority = bbPriority; - } + +// public BlockBreakPriority getBbPriority() { +// return bbPriority; +// } +// public void setBbPriority( BlockBreakPriority bbPriority ) { +// this.bbPriority = bbPriority; +// } + } 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 f84b9a152..8b7986bac 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 @@ -1,30 +1,50 @@ 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.Listener; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.PluginManager; import me.pulsi_.prisonenchants.events.PEExplosionEvent; import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; +import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType; import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.output.Output.DebugTarget; 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; +import tech.mcprison.prison.spigot.block.OnBlockBreakExternalEvents; +import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.game.SpigotHandlerList; +import tech.mcprison.prison.spigot.game.SpigotPlayer; public class AutoManagerPrisonEnchants - extends AutoManagerEventsManager { - + extends AutoManagerFeatures + implements PrisonEventManager { + + private BlockBreakPriority bbPriority; + public AutoManagerPrisonEnchants() { super(); } - + + public BlockBreakPriority getBbPriority() { + return bbPriority; + } + public void setBbPriority( BlockBreakPriority bbPriority ) { + this.bbPriority = bbPriority; + } + @Override public void registerEvents() { @@ -37,7 +57,7 @@ public void registerEvents() { * */ public class AutoManagerPEExplosiveEventListener - extends AutoManagerBlockBreakEvents + extends AutoManagerPrisonEnchants implements Listener { @EventHandler(priority=EventPriority.NORMAL) @@ -50,37 +70,12 @@ public void onPrisonEnchantsExplosiveEvent( PEExplosionEvent e, BlockBreakPriori // me.pulsi_.prisonenchants.events.PEExplosionEvent - genericExplosiveEvent( e, bbPriority ); + handlePEExplosionEvent( e, bbPriority ); // genericBlockExplodeEventAutoManager( e ); } } -// public class OnBlockBreakPEExplosiveEventListener -// extends OnBlockBreakEventListener -// implements Listener { -// -// @EventHandler(priority=EventPriority.NORMAL) -// public void onPrisonEnchantsExplosiveEvent(PEExplosionEvent e) { -// if ( isDisabled( e.getBlockBroken().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockExplodeEvent( e ); -// } -// } -// -// public class OnBlockBreakPEExplosiveEventListenerMonitor -// extends OnBlockBreakEventListener -// implements Listener { -// -// @EventHandler(priority=EventPriority.MONITOR) -// public void onPrisonEnchantsExplosiveEvent(PEExplosionEvent e) { -// if ( isDisabled( e.getBlockBroken().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockExplodeEventMonitor( e ); -// } -// } @Override public void initialize() { @@ -128,73 +123,6 @@ public void execute(Listener l, Event e) { - - -// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); -// -// if ( eventPriority != BlockBreakPriority.DISABLED ) { -// -// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); -// -// -// OnBlockBreakPEExplosiveEventListenerMonitor normalListenerMonitor = -// new OnBlockBreakPEExplosiveEventListenerMonitor(); -// - - - - -// if ( eventPriority != BlockBreakPriority.MONITOR ) { -// -// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { -// -// AutoManagerPEExplosiveEventListener autoManagerlListener = -// new AutoManagerPEExplosiveEventListener(); -// -// pm.registerEvent(PEExplosionEvent.class, autoManagerlListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((AutoManagerPEExplosiveEventListener)l) -// .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( autoManagerlListener ); -// } -// else if ( isBoolean( AutoFeatures.normalDrop ) ) { -// -// OnBlockBreakPEExplosiveEventListener normalListener = -// new OnBlockBreakPEExplosiveEventListener(); -// -// pm.registerEvent(PEExplosionEvent.class, normalListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((OnBlockBreakPEExplosiveEventListener)l) -// .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListener ); -// } - -// } -// else { -// -// pm.registerEvent(PEExplosionEvent.class, normalListenerMonitor, EventPriority.MONITOR, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((OnBlockBreakPEExplosiveEventListenerMonitor)l) -// .onPrisonEnchantsExplosiveEvent((PEExplosionEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); -// } - - - -// } - } catch ( ClassNotFoundException e ) { // PrisonEnchants is not loaded... so ignore. @@ -210,8 +138,7 @@ public void execute(Listener l, Event e) { @Override public void unregisterListeners() { - super.unregisterListeners(); - +// super.unregisterListeners(); } @Override @@ -272,5 +199,167 @@ public void dumpEventListeners( StringBuilder sb ) { } } + /** + *

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 handlePEExplosionEvent( PEExplosionEvent e, BlockBreakPriority bbPriority) { + + +// , boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { + long start = System.nanoTime(); + + if ( e.isCancelled() || processMinesBlockBreakEvent( e, e.getPlayer(), e.getBlockBroken()) ) { + return; + } + + + // Register all external events such as mcMMO and EZBlocks: + OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); + + StringBuilder debugInfo = new StringBuilder(); + + + debugInfo.append( String.format( "### ** genericExplosiveEvent (Pulsi) ** ### " + + "(event: PEExplosionEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { + + + + String eP = getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority ); + boolean isPEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + + + // Need to wrap in a Prison block so it can be used with the mines: + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlockBroken()); + SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); + + BlockEventType eventType = BlockEventType.PEExplosive; + String triggered = null; // e.getTriggeredBy(); + + PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlockBroken(), e.getPlayer(), + sBlock, sPlayer, bbPriority, eventType, triggered ); + + pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); + + + if ( !validateEvent( pmEvent, debugInfo ) ) { + + // 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 ); + } + } + + + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { + // Stop here, and prevent additional processing. Monitors should never process the event beyond this. + } + + + + // now process all blocks (non-monitor): + else if ( isPEExplosiveEnabled && + ( pmEvent.getMine() != null || pmEvent.getMine() == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { + if ( pmEvent.getExplodedBlocks().size() > 0 ) { + +// String triggered = null; + + +// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), +// mine, dummyBlock, explodedBlocks, BlockEventType.PEExplosive, triggered ); + Bukkit.getServer().getPluginManager().callEvent(pmEvent); + if ( pmEvent.isCancelled() ) { + debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); + } + else { + +// // Cancel drops if so configured: +// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { +// +// try +// { +// e.setDropItems( false ); +// } +// catch ( NoSuchMethodError e1 ) +// { +// String message = String.format( +// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + +// "is not valid for this version of Spigot. Modify the config settings and set " + +// "this value to `false`. [%s]", +// e1.getMessage() ); +// Output.get().logWarn( message ); +// } +// } + + if ( doAction( pmEvent, debugInfo ) ) { + + if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { + + e.setCancelled( true ); + } + else { + + debugInfo.append( "(event was not canceled) " ); + } + + finalizeBreakTheBlocks( pmEvent ); + + doBlockEvents( pmEvent ); + + } + + else { + + debugInfo.append( "(doAction failed without details) " ); + } + + } + } + + + debugInfo.append( "(normal processing) " ); + } + else { + + debugInfo.append( "(logic bypass) " ); + } + + } + + if ( debugInfo.length() > 0 ) { + + long stop = System.nanoTime(); + debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); + + Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); + } + + } + + @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/AutoManagerPrisonsExplosiveBlockBreakEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java index c63c370e3..f540887ec 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 @@ -1,30 +1,50 @@ 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.Listener; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.PluginManager; import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; +import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType; import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.output.Output.DebugTarget; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.api.ExplosiveBlockBreakEvent; +import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent; +import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures; import tech.mcprison.prison.spigot.block.BlockBreakPriority; +import tech.mcprison.prison.spigot.block.OnBlockBreakExternalEvents; +import tech.mcprison.prison.spigot.block.SpigotBlock; +import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.spigot.game.SpigotHandlerList; +import tech.mcprison.prison.spigot.game.SpigotPlayer; public class AutoManagerPrisonsExplosiveBlockBreakEvents - extends AutoManagerEventsManager { - + extends AutoManagerFeatures + implements PrisonEventManager { + private BlockBreakPriority bbPriority; + public AutoManagerPrisonsExplosiveBlockBreakEvents() { super(); } + + public BlockBreakPriority getBbPriority() { + return bbPriority; + } + public void setBbPriority( BlockBreakPriority bbPriority ) { + this.bbPriority = bbPriority; + } @Override public void registerEvents() { @@ -35,7 +55,7 @@ public void registerEvents() { public class AutoManagerExplosiveBlockBreakEventListener - extends AutoManagerBlockBreakEvents + extends AutoManagerPrisonsExplosiveBlockBreakEvents implements Listener { @EventHandler(priority=EventPriority.NORMAL) @@ -45,37 +65,10 @@ public void onPrisonsExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e, Block return; } - genericExplosiveEvent( e, bbPriority ); - -// genericBlockExplodeEventAutoManager( e ); + handleExplosiveBlockBreakEvent( e, bbPriority ); } } - -// public class OnBlockBreakExplosiveBlockBreakEventListener -// extends OnBlockBreakEventListener -// implements Listener { -// -// @EventHandler(priority=EventPriority.NORMAL) -// public void onPrisonExplosiveBlockBreakEvent(ExplosiveBlockBreakEvent e) { -// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockExplodeEvent( e ); -// } -// } -// -// public class OnBlockBreakExplosiveBlockBreakEventListenerMonitor -// extends OnBlockBreakEventListener -// implements Listener { -// -// @EventHandler(priority=EventPriority.MONITOR) -// public void onPrisonExplosiveBlockBreakEventMonitor(ExplosiveBlockBreakEvent e) { -// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockExplodeEventMonitor( e ); -// } -// } + @Override public void initialize() { @@ -116,75 +109,6 @@ public void execute(Listener l, Event e) { prison.getRegisteredBlockListeners().add( autoManagerlListener ); - - - - -// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); -// -// if ( eventPriority != BlockBreakPriority.DISABLED ) { -// -// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); -// -// -// OnBlockBreakExplosiveBlockBreakEventListenerMonitor normalListenerMonitor = -// new OnBlockBreakExplosiveBlockBreakEventListenerMonitor(); -// -// -// -// -// -// if ( eventPriority != BlockBreakPriority.MONITOR ) { -// -// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { -// -// AutoManagerExplosiveBlockBreakEventListener autoManagerlListener = -// new AutoManagerExplosiveBlockBreakEventListener(); -// -// pm.registerEvent(ExplosiveBlockBreakEvent.class, autoManagerlListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((AutoManagerExplosiveBlockBreakEventListener)l) -// .onPrisonsExplosiveBlockBreakEvent((ExplosiveBlockBreakEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( autoManagerlListener ); -// } -// else if ( isBoolean( AutoFeatures.normalDrop ) ) { -// -// OnBlockBreakExplosiveBlockBreakEventListener normalListener = -// new OnBlockBreakExplosiveBlockBreakEventListener(); -// -// pm.registerEvent(ExplosiveBlockBreakEvent.class, normalListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((OnBlockBreakExplosiveBlockBreakEventListener)l) -// .onPrisonExplosiveBlockBreakEvent((ExplosiveBlockBreakEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListener ); -// } - -// } -// else { -// -// pm.registerEvent(ExplosiveBlockBreakEvent.class, normalListenerMonitor, EventPriority.MONITOR, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// ((OnBlockBreakExplosiveBlockBreakEventListenerMonitor)l) -// .onPrisonExplosiveBlockBreakEventMonitor((ExplosiveBlockBreakEvent)e); -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); -// -// } - - -// } - } catch ( Exception e ) { Output.get().logInfo( "AutoManager: Prison's own ExplosiveBlockBreakEvent failed to load. [%s]", e.getMessage() ); @@ -196,8 +120,7 @@ public void execute(Listener l, Event e) { @Override public void unregisterListeners() { - super.unregisterListeners(); - +// super.unregisterListeners(); } @Override @@ -253,4 +176,182 @@ public void dumpEventListeners( StringBuilder sb ) { } } + protected void handleExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e, BlockBreakPriority bbPriority ) { + +// boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { + + long start = System.nanoTime(); + + if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { + return; + } + + + // Register all external events such as mcMMO and EZBlocks: + OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); + + StringBuilder debugInfo = new StringBuilder(); + + + debugInfo.append( String.format( "### ** genericExplosiveEvent (Prisons's bombs) ** ### " + + "(event: ExplosiveBlockBreakEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { + + + String eP = getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority ); + boolean isPPrisonExplosiveBlockBreakEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + + + // Need to wrap in a Prison block so it can be used with the mines: + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); + SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); + + BlockEventType eventType = BlockEventType.PrisonExplosion; + String triggered = e.getTriggeredBy(); + + PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), + sBlock, sPlayer, bbPriority, eventType, triggered ); + + + // If this event is fired, but yet there are no exploded blocks, then do not set + // forceIfAirBlock to true so this event is skipped. + if ( e.getExplodedBlocks() != null && e.getExplodedBlocks().size() > 0 ) { + + pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); + pmEvent.setForceIfAirBlock( e.isForceIfAirBlock() ); + } + + + + // Warning: toolInHand really needs to be defined in the event if the source is a + // Mine Bomb, otherwise auto features will detect the player is holding + // a mine bomb which is not a pickaxe so the drops will be ZERO. If they + // used their last mine bomb, then auto features will detect only AIR + // in their hand. + if ( e.getToolInHand() != null ) { + pmEvent.setItemInHand( (SpigotItemStack) e.getToolInHand() ); + + } + + // Note: If the mineBomb is set, then the bomb itself uses a pseudo + // tool in hand, so need to disable durability calculations since + // if the pseudo tool breaks, it will clear the player's in-hand + // inventory stack, which will be more mine bombs if they had more + // than one. + if ( e.getMineBomb() != null ) { + pmEvent.setCalculateDurability( false ); + } + + if ( !validateEvent( pmEvent, debugInfo ) ) { + + // 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 ); + } + } + + + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { + // Stop here, and prevent additional processing. Monitors should never process the event beyond this. + } + + + + // now process all blocks (non-monitor): + else if ( isPPrisonExplosiveBlockBreakEnabled && + ( pmEvent.getMine() != null || pmEvent.getMine() == null && + !isBoolean( AutoFeatures.pickupLimitToMines )) ) { + + if ( pmEvent.getExplodedBlocks().size() > 0 ) { + + // String triggered = null; + + + // PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), + // mine, dummyBlock, explodedBlocks, BlockEventType.PEExplosive, triggered ); + Bukkit.getServer().getPluginManager().callEvent(pmEvent); + if ( pmEvent.isCancelled() ) { + debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); + } + else { + + // Cancel drops if so configured: + if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { + + try + { + e.setDropItems( false ); + } + catch ( NoSuchMethodError e1 ) + { + String message = String.format( + "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + + "is not valid for this version of Spigot. Modify the config settings and set " + + "this value to `false`. [%s]", + e1.getMessage() ); + Output.get().logWarn( message ); + } + } + + if ( doAction( pmEvent, debugInfo ) ) { + + if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { + + e.setCancelled( true ); + } + else { + + debugInfo.append( "(event was not canceled) " ); + } + + finalizeBreakTheBlocks( pmEvent ); + + doBlockEvents( pmEvent ); + + } + + else { + + debugInfo.append( "(doAction failed without details) " ); + } + + } + } + + + debugInfo.append( "(normal processing) " ); + } + else { + + debugInfo.append( "(logic bypass) " ); + } + + } + + if ( debugInfo.length() > 0 ) { + + long stop = System.nanoTime(); + debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); + + Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); + } + + } + + @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/AutoManagerTokenEnchant.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java index 03a26276e..7bb9ed080 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 @@ -1,10 +1,13 @@ 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.Listener; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.PluginManager; @@ -12,26 +15,45 @@ import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; +import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType; import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.output.Output.DebugTarget; 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; +import tech.mcprison.prison.spigot.block.OnBlockBreakExternalEvents; +import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.game.SpigotHandlerList; +import tech.mcprison.prison.spigot.game.SpigotPlayer; public class AutoManagerTokenEnchant - extends AutoManagerEventsManager { + extends AutoManagerFeatures + implements PrisonEventManager { + + private BlockBreakPriority bbPriority; + + private boolean teExplosionTriggerEnabled; public AutoManagerTokenEnchant() { super(); + this.teExplosionTriggerEnabled = true; } + public BlockBreakPriority getBbPriority() { + return bbPriority; + } + public void setBbPriority( BlockBreakPriority bbPriority ) { + this.bbPriority = bbPriority; + } + @Override public void registerEvents() { initialize(); - } @@ -45,36 +67,11 @@ public void onTEBlockExplode( TEBlockExplodeEvent e, BlockBreakPriority bbPriori return; } - genericBlockExplodeEvent( e, bbPriority ); + handleTEBlockExplodeEvent( e, bbPriority ); // genericBlockExplodeEventAutoManager( e ); } } -// public class OnBlockBreakEventTokenEnchantEventListener -// extends AutoManagerTokenEnchant -// implements Listener { -// -// @EventHandler(priority=EventPriority.NORMAL) -// public void onTEBlockExplode(TEBlockExplodeEvent e) { -// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockExplodeEvent( e ); -// } -// } -// -// public class OnBlockBreakEventTokenEnchantEventListenerMonitor -// extends AutoManagerTokenEnchant -// implements Listener { -// -// @EventHandler(priority=EventPriority.MONITOR) -// public void onTEBlockExplode(TEBlockExplodeEvent e) { -// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockExplodeEventMonitor( e ); -// } -// } @Override public void initialize() { @@ -196,8 +193,7 @@ public void execute(Listener l, Event e) { @Override public void unregisterListeners() { - super.unregisterListeners(); - +// super.unregisterListeners(); } @@ -259,5 +255,214 @@ public void dumpEventListeners( StringBuilder sb ) { } } + /** + *

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 handleTEBlockExplodeEvent( TEBlockExplodeEvent e, BlockBreakPriority bbPriority ) { +// , boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { + + long start = System.nanoTime(); + + if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { + return; + } + + + // Register all external events such as mcMMO and EZBlocks: + OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); + + StringBuilder debugInfo = new StringBuilder(); + + + debugInfo.append( String.format( "### ** genericBlockExplodeEvent ** ### " + + "(event: TEBlockExplodeEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { + + + + + String eP = getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority ); + boolean isTEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); + + + // Need to wrap in a Prison block so it can be used with the mines: + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); + SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); + + BlockEventType eventType = BlockEventType.TEXplosion; + String triggered = checkCEExplosionTriggered( e ); + + PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), + sBlock, sPlayer, bbPriority, eventType, triggered ); + + // NOTE: Token Enchant will pass the event's block to prison, but that block may + // have already been processed by prison. Therefore the PrisonMinesBlockBreakEvent + // must enable the feature setForceIfAirBlock( true ). That block will not be used a + // second time, but it will allow the explosion event to be processed. + pmEvent.setForceIfAirBlock( true ); + + pmEvent.setUnprocessedRawBlocks( e.blockList() ); + + if ( !validateEvent( pmEvent, debugInfo ) ) { + + // 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 ); + } + } + + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { + // Stop here, and prevent additional processing. Monitors should never process the event beyond this. + } + + + + // now process all blocks (non-monitor): + else if ( isTEExplosiveEnabled && + ( pmEvent.getMine() != null || pmEvent.getMine() == null && + !isBoolean( AutoFeatures.pickupLimitToMines )) ) { + + + if ( pmEvent.getExplodedBlocks().size() > 0 ) { + +// String triggered = checkCEExplosionTriggered( e ); +// +// +// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), +// mine, block, explodedBlocks, BlockEventType.TEXplosion, triggered ); + Bukkit.getServer().getPluginManager().callEvent( pmEvent ); + if ( pmEvent.isCancelled() ) { + debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); + } + else { + + // Cancel drops if so configured: + if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { + + try + { + e.setYield( 0 ); +// e.setDropItems( false ); + } + catch ( NoSuchMethodError e1 ) + { + String message = String.format( + "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + + "is not valid for this version of Spigot. Modify the config settings and set " + + "this value to `false`. [%s]", + e1.getMessage() ); + Output.get().logWarn( message ); + } + } + + // This is where the processing actually happens: + if ( doAction( pmEvent, debugInfo ) ) { + + if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { + + e.setCancelled( true ); + } + else { + + debugInfo.append( "(event was not canceled) " ); + } + + finalizeBreakTheBlocks( pmEvent ); + + doBlockEvents( pmEvent ); + + } + + else { + + debugInfo.append( "(doAction failed without details) " ); + } + + } + + } + + + debugInfo.append( "(normal processing) " ); + } + else { + + debugInfo.append( "(logic bypass) " ); + } + + } + + if ( debugInfo.length() > 0 ) { + + long stop = System.nanoTime(); + debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); + + Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); + } + } + + private String checkCEExplosionTriggered( TEBlockExplodeEvent e ) + { + String triggered = null; + + // Please be aware: This function is named the same as the auto features setting, but this is + // not related. This is only trying to get the name of the enchantment that triggered the event. + if ( isTeExplosionTriggerEnabled() ) { + + try { + triggered = e.getTrigger(); + } + catch ( Exception | NoSuchMethodError ex ) { + // Only print the error the first time, then suppress the error: + String error = ex.getMessage(); + + Output.get().logError( "Error: Trying to access the TEBlockExplodeEvent.getTrigger() " + + "function. Make sure you are using TokenEnchant v18.11.0 or newer. The new " + + "getTrigger() function returns the TE Plugin that is firing the TEBlockExplodeEvent. " + + "The Prison BlockEvents can be filtered by this triggered value. " + + error ); + + // Disable collecting the trigger. + setTeExplosionTriggerEnabled( false ); + + } + } + + return triggered; + } + + protected int checkBonusXp( Player player, Block block, ItemStack item ) { + int bonusXp = 0; + + return bonusXp; + } + + private boolean isTeExplosionTriggerEnabled() { + return teExplosionTriggerEnabled; + } + + private void setTeExplosionTriggerEnabled( boolean teExplosionTriggerEnabled ) { + this.teExplosionTriggerEnabled = teExplosionTriggerEnabled; + } } 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 c195cc7c7..7340c5eb9 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 @@ -1,30 +1,55 @@ package tech.mcprison.prison.spigot.autofeatures.events; +import java.util.ArrayList; +import java.util.List; + 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.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.PluginManager; import tech.mcprison.prison.Prison; 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.ChatDisplay; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.output.Output.DebugTarget; 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; +import tech.mcprison.prison.spigot.block.OnBlockBreakExternalEvents; +import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.game.SpigotHandlerList; +import tech.mcprison.prison.spigot.game.SpigotPlayer; import zedly.zenchantments.BlockShredEvent; public class AutoManagerZenchantments - extends AutoManagerEventsManager { + extends AutoManagerFeatures + implements PrisonEventManager { + private BlockBreakPriority bbPriority; + public AutoManagerZenchantments() { super(); } + public BlockBreakPriority getBbPriority() { + return bbPriority; + } + public void setBbPriority( BlockBreakPriority bbPriority ) { + this.bbPriority = bbPriority; + } + @Override public void registerEvents() { @@ -34,7 +59,7 @@ public void registerEvents() { public class AutoManagerBlockShredEventListener - extends AutoManagerBlockBreakEvents + extends AutoManagerZenchantments implements Listener { @EventHandler(priority=EventPriority.NORMAL) @@ -44,37 +69,12 @@ public void onBlockShredBreak( BlockShredEvent e, BlockBreakPriority bbPriority return; } - genericBlockEvent( e, bbPriority ); + handleZenchantmentsBlockBreakEvent( e, bbPriority ); // genericBlockEventAutoManager( e ); } } -// public class OnBlockBreakBlockShredEventListener -// extends OnBlockBreakEventListener -// implements Listener { -// -// @EventHandler(priority=EventPriority.NORMAL) -// public void onBlockShredBreak(BlockShredEvent e) { -// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockEvent( e ); -// } -// } -// -// public class OnBlockBreakBlockShredEventListenerMonitor -// extends OnBlockBreakEventListener -// implements Listener { -// -// @EventHandler(priority=EventPriority.MONITOR) -// public void onBlockShredBreakMonitor(BlockShredEvent e) { -// if ( isDisabled( e.getBlock().getLocation().getWorld().getName() ) ) { -// return; -// } -// genericBlockEventMonitor( e ); -// } -// } @Override @@ -123,85 +123,6 @@ public void execute(Listener l, Event e) { prison.getRegisteredBlockListeners().add( autoManagerlListener ); - - - -// BlockBreakPriority eventPriority = BlockBreakPriority.fromString( eP ); - -// if ( eventPriority != BlockBreakPriority.DISABLED ) { - -// EventPriority ePriority = EventPriority.valueOf( eventPriority.name().toUpperCase() ); - - -// OnBlockBreakBlockShredEventListenerMonitor normalListenerMonitor = -// new OnBlockBreakBlockShredEventListenerMonitor(); - - - -// if ( eventPriority != BlockBreakPriority.MONITOR ) { - -// if ( isBoolean( AutoFeatures.isAutoFeaturesEnabled )) { -// -// AutoManagerBlockShredEventListener autoManagerlListener = -// new AutoManagerBlockShredEventListener(); -// -// pm.registerEvent(BlockShredEvent.class, autoManagerlListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && -// e instanceof BlockShredEvent ) { -// OnBlockBreakBlockShredEventListenerMonitor lmon = -// (OnBlockBreakBlockShredEventListenerMonitor) l; -// BlockShredEvent event = (BlockShredEvent) e; -// lmon.onBlockShredBreakMonitor( event ); -// } -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( autoManagerlListener ); -// } -// else if ( isBoolean( AutoFeatures.normalDrop ) ) { -// -// OnBlockBreakBlockShredEventListener normalListener = -// new OnBlockBreakBlockShredEventListener(); -// -// pm.registerEvent(BlockShredEvent.class, normalListener, ePriority, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && -// e instanceof BlockShredEvent ) { -// OnBlockBreakBlockShredEventListenerMonitor lmon = -// (OnBlockBreakBlockShredEventListenerMonitor) l; -// BlockShredEvent event = (BlockShredEvent) e; -// lmon.onBlockShredBreakMonitor( event ); -// } -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListener ); -// } - -// } -// else { -// -// pm.registerEvent(BlockShredEvent.class, normalListenerMonitor, EventPriority.MONITOR, -// new EventExecutor() { -// public void execute(Listener l, Event e) { -// if ( l instanceof OnBlockBreakBlockShredEventListenerMonitor && -// e instanceof BlockShredEvent ) { -// OnBlockBreakBlockShredEventListenerMonitor lmon = -// (OnBlockBreakBlockShredEventListenerMonitor) l; -// BlockShredEvent event = (BlockShredEvent) e; -// lmon.onBlockShredBreakMonitor( event ); -// } -// } -// }, -// prison); -// prison.getRegisteredBlockListeners().add( normalListenerMonitor ); -// } - -// } - } catch ( ClassNotFoundException e ) { // Zenchantments is not loaded... so ignore. @@ -215,8 +136,7 @@ public void execute(Listener l, Event e) { @Override public void unregisterListeners() { - super.unregisterListeners(); - +// super.unregisterListeners(); } @Override @@ -280,4 +200,168 @@ public void dumpEventListeners( StringBuilder sb ) { } } + /** + *

This genericBlockEvent handles the basics of a BlockBreakEvent to see if it has happened + * within a mine or not. If it is happening within a mine, then we process it with the doAction() + * function. + *

+ * + * @param e + * @param montior Identifies that a monitor event called this function. A monitor should only record + * block break counts. + */ + private void handleZenchantmentsBlockBreakEvent( BlockBreakEvent e, BlockBreakPriority bbPriority ) { + +// boolean monitor, boolean blockEventsOnly, +// boolean autoManager ) { + + if ( e instanceof PrisonMinesBlockBreakEvent ) { + return; + } + + long start = System.nanoTime(); + + if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { + return; + } + + + // Register all external events such as mcMMO and EZBlocks: + OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); + + StringBuilder debugInfo = new StringBuilder(); + + debugInfo.append( String.format( "### ** genericBlockEvent ** ### " + + "(event: BlockBreakEvent, config: %s, priority: %s, canceled: %s) ", + bbPriority.name(), + bbPriority.getBukkitEventPriority().name(), + (e.isCancelled() ? "TRUE " : "FALSE") + ) ); + + + if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { + + // Need to wrap in a Prison block so it can be used with the mines: + SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); + SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); + + BlockEventType eventType = BlockEventType.blockBreak; + String triggered = null; + + PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), + sBlock, sPlayer, bbPriority, eventType, triggered ); + + if ( !validateEvent( pmEvent, debugInfo ) ) { + + // 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 ); + } + } + + else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { + // Stop here, and prevent additional processing. Monitors should never process the event beyond this. + } + + // This is where the processing actually happens: + else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && + !isBoolean( AutoFeatures.pickupLimitToMines ) ) { + debugInfo.append( "(normal processing initiating) " ); + + // Set the mine's PrisonBlockTypes for the block. Used to identify custom blocks. + // Needed since processing of the block will lose track of which mine it came from. + if ( pmEvent.getMine() != null ) { + sBlock.setPrisonBlockTypes( pmEvent.getMine().getPrisonBlockTypes() ); + } + + // check all external events such as mcMMO and EZBlocks: + debugInfo.append( + OnBlockBreakExternalEvents.getInstance().checkAllExternalEvents( e ) ); + + List explodedBlocks = new ArrayList<>(); + pmEvent.setExplodedBlocks( explodedBlocks ); +// String triggered = null; + +// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), +// pmEvent.getMine(), sBlock, explodedBlocks, BlockEventType.blockBreak, triggered ); + Bukkit.getServer().getPluginManager().callEvent( pmEvent ); + if ( pmEvent.isCancelled() ) { + debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); + } + else { + + // Cancel drops if so configured: + if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { + + try + { + e.setDropItems( false ); + } + 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 ); + } + } + + // doAction returns a boolean that indicates if the event should be canceled or not: + if ( doAction( pmEvent, debugInfo ) ) { +// if ( doAction( sBlock, pmEvent.getMine(), pmEvent.getPlayer(), debugInfo ) ) { + + if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { + e.setCancelled( true ); + } + else { + + debugInfo.append( "(event was not canceled) " ); + } + + finalizeBreakTheBlocks( pmEvent ); + + doBlockEvents( pmEvent ); + + } + else { + + debugInfo.append( "(doAction failed without details) " ); + } + + } + + + debugInfo.append( "(normal processing completed) " ); + } + else { + + debugInfo.append( "(logic bypass) " ); + } + + } + + if ( debugInfo.length() > 0 ) { + + long stop = System.nanoTime(); + debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); + + Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); + } + } + + @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/block/OnBlockBreakEventCore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java index 48d6ad1cf..0e8b15094 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 @@ -2,22 +2,16 @@ import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.Random; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; -import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import com.vk2gpz.tokenenchant.event.TEBlockExplodeEvent; - -import me.badbones69.crazyenchantments.api.events.BlastUseEvent; import me.pulsi_.prisonenchants.events.PEExplosionEvent; import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; @@ -27,25 +21,21 @@ import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlockStatusData; -import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType; -import tech.mcprison.prison.modules.Module; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.output.Output.DebugTarget; import tech.mcprison.prison.spigot.SpigotPrison; -import tech.mcprison.prison.spigot.api.ExplosiveBlockBreakEvent; import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent; import tech.mcprison.prison.spigot.autofeatures.AutoManagerBreakBlockTask; import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures; import tech.mcprison.prison.spigot.compat.Compatibility; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; import tech.mcprison.prison.spigot.game.SpigotPlayer; -import tech.mcprison.prison.spigot.integrations.IntegrationCrazyEnchantmentsPickaxes; import tech.mcprison.prison.spigot.utils.BlockUtils; import tech.mcprison.prison.util.Text; -public class OnBlockBreakEventCore +public abstract class OnBlockBreakEventCore extends OnBlockBreakMines { @@ -53,12 +43,12 @@ public class OnBlockBreakEventCore private int uses = 0; private long usesElapsedTimeNano = 0L; - private boolean teExplosionTriggerEnabled; +// private boolean teExplosionTriggerEnabled; private AutoFeaturesWrapper autoFeatureWrapper = null; - private Boolean crazyEnchantEnabled; +// private Boolean crazyEnchantEnabled; private Random random = new Random(); @@ -70,9 +60,9 @@ public OnBlockBreakEventCore() { - this.teExplosionTriggerEnabled = true; +// this.teExplosionTriggerEnabled = true; - this.crazyEnchantEnabled = null; +// this.crazyEnchantEnabled = null; } @@ -83,29 +73,32 @@ public enum EventDetails { ; } - - /** - *

The Prison Mines module must be enabled, or these BlockBreakEvents should - * not be enabled since they are geared to work with the prison mines. - *

- * - *

At this time, prison's block handling is not supported outside of the mines. - *

- * - * @return - */ - public boolean isEnabled() { - boolean results = false; - - Optional mmOptional = Prison.get().getModuleManager().getModule( PrisonMines.MODULE_NAME ); - if ( mmOptional.isPresent() && mmOptional.get().isEnabled() ) { - PrisonMines prisonMines = (PrisonMines) mmOptional.get(); - - results = prisonMines != null; - } - - return results; + public boolean isDisabled( String worldName ) { + return Prison.get().getPlatform().isWorldExcluded( worldName ); } + +// /** +// *

The Prison Mines module must be enabled, or these BlockBreakEvents should +// * not be enabled since they are geared to work with the prison mines. +// *

+// * +// *

At this time, prison's block handling is not supported outside of the mines. +// *

+// * +// * @return +// */ +// public boolean isEnabled() { +// boolean results = false; +// +// Optional mmOptional = Prison.get().getModuleManager().getModule( PrisonMines.MODULE_NAME ); +// if ( mmOptional.isPresent() && mmOptional.get().isEnabled() ) { +// PrisonMines prisonMines = (PrisonMines) mmOptional.get(); +// +// results = prisonMines != null; +// } +// +// return results; +// } public AutoFeaturesFileConfig getAutoFeaturesConfig() { return autoFeatureWrapper.getAutoFeaturesConfig(); @@ -314,163 +307,163 @@ public enum ItemLoreEnablers { // return processEvent; // } - /** - *

This genericBlockEvent handles the basics of a BlockBreakEvent to see if it has happened - * within a mine or not. If it is happening within a mine, then we process it with the doAction() - * function. - *

- * - * @param e - * @param montior Identifies that a monitor event called this function. A monitor should only record - * block break counts. - */ - public void genericBlockEvent( BlockBreakEvent e, BlockBreakPriority bbPriority ) { - -// boolean monitor, boolean blockEventsOnly, -// boolean autoManager ) { - - if ( e instanceof PrisonMinesBlockBreakEvent ) { - return; - } - - long start = System.nanoTime(); - - if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { - return; - } - - - // Register all external events such as mcMMO and EZBlocks: - OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); - - StringBuilder debugInfo = new StringBuilder(); - - debugInfo.append( String.format( "### ** genericBlockEvent ** ### " + - "(event: BlockBreakEvent, config: %s, priority: %s, canceled: %s) ", - bbPriority.name(), - bbPriority.getBukkitEventPriority().name(), - (e.isCancelled() ? "TRUE " : "FALSE") - ) ); - - - if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { - - // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); - SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); - - BlockEventType eventType = BlockEventType.blockBreak; - String triggered = null; - - PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), - sBlock, sPlayer, bbPriority, eventType, triggered ); - - if ( !validateEvent( pmEvent, debugInfo ) ) { - - // 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 ); - } - } - - else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { - // Stop here, and prevent additional processing. Monitors should never process the event beyond this. - } - - // This is where the processing actually happens: - else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && - !isBoolean( AutoFeatures.pickupLimitToMines ) ) { - debugInfo.append( "(normal processing initiating) " ); - - // Set the mine's PrisonBlockTypes for the block. Used to identify custom blocks. - // Needed since processing of the block will lose track of which mine it came from. - if ( pmEvent.getMine() != null ) { - sBlock.setPrisonBlockTypes( pmEvent.getMine().getPrisonBlockTypes() ); - } - - // check all external events such as mcMMO and EZBlocks: - debugInfo.append( - OnBlockBreakExternalEvents.getInstance().checkAllExternalEvents( e ) ); - - List explodedBlocks = new ArrayList<>(); - pmEvent.setExplodedBlocks( explodedBlocks ); -// String triggered = null; - -// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), -// pmEvent.getMine(), sBlock, explodedBlocks, BlockEventType.blockBreak, triggered ); - Bukkit.getServer().getPluginManager().callEvent( pmEvent ); - if ( pmEvent.isCancelled() ) { - debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); - } - else { - - // Cancel drops if so configured: - if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { - - try - { - e.setDropItems( false ); - } - 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 ); - } - } - - // doAction returns a boolean that indicates if the event should be canceled or not: - if ( doAction( pmEvent, debugInfo ) ) { -// if ( doAction( sBlock, pmEvent.getMine(), pmEvent.getPlayer(), debugInfo ) ) { - - if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { - e.setCancelled( true ); - } - else { - - debugInfo.append( "(event was not canceled) " ); - } - - finalizeBreakTheBlocks( pmEvent ); - - doBlockEvents( pmEvent ); - - } - else { - - debugInfo.append( "(doAction failed without details) " ); - } - - } - - - debugInfo.append( "(normal processing completed) " ); - } - else { - - debugInfo.append( "(logic bypass) " ); - } - - } - - if ( debugInfo.length() > 0 ) { - - long stop = System.nanoTime(); - debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); - - Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); - } - } +// /** +// *

This genericBlockEvent handles the basics of a BlockBreakEvent to see if it has happened +// * within a mine or not. If it is happening within a mine, then we process it with the doAction() +// * function. +// *

+// * +// * @param e +// * @param montior Identifies that a monitor event called this function. A monitor should only record +// * block break counts. +// */ +// public void genericBlockEvent( BlockBreakEvent e, BlockBreakPriority bbPriority ) { +// +//// boolean monitor, boolean blockEventsOnly, +//// boolean autoManager ) { +// +// if ( e instanceof PrisonMinesBlockBreakEvent ) { +// return; +// } +// +// long start = System.nanoTime(); +// +// if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { +// return; +// } +// +// +// // Register all external events such as mcMMO and EZBlocks: +// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); +// +// StringBuilder debugInfo = new StringBuilder(); +// +// debugInfo.append( String.format( "### ** genericBlockEvent ** ### " + +// "(event: BlockBreakEvent, config: %s, priority: %s, canceled: %s) ", +// bbPriority.name(), +// bbPriority.getBukkitEventPriority().name(), +// (e.isCancelled() ? "TRUE " : "FALSE") +// ) ); +// +// +// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { +// +// // Need to wrap in a Prison block so it can be used with the mines: +// SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); +// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); +// +// BlockEventType eventType = BlockEventType.blockBreak; +// String triggered = null; +// +// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), +// sBlock, sPlayer, bbPriority, eventType, triggered ); +// +// if ( !validateEvent( pmEvent, debugInfo ) ) { +// +// // 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 ); +// } +// } +// +// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { +// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. +// } +// +// // This is where the processing actually happens: +// else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && +// !isBoolean( AutoFeatures.pickupLimitToMines ) ) { +// debugInfo.append( "(normal processing initiating) " ); +// +// // Set the mine's PrisonBlockTypes for the block. Used to identify custom blocks. +// // Needed since processing of the block will lose track of which mine it came from. +// if ( pmEvent.getMine() != null ) { +// sBlock.setPrisonBlockTypes( pmEvent.getMine().getPrisonBlockTypes() ); +// } +// +// // check all external events such as mcMMO and EZBlocks: +// debugInfo.append( +// OnBlockBreakExternalEvents.getInstance().checkAllExternalEvents( e ) ); +// +// List explodedBlocks = new ArrayList<>(); +// pmEvent.setExplodedBlocks( explodedBlocks ); +//// String triggered = null; +// +//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), +//// pmEvent.getMine(), sBlock, explodedBlocks, BlockEventType.blockBreak, triggered ); +// Bukkit.getServer().getPluginManager().callEvent( pmEvent ); +// if ( pmEvent.isCancelled() ) { +// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); +// } +// else { +// +// // Cancel drops if so configured: +// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { +// +// try +// { +// e.setDropItems( false ); +// } +// 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 ); +// } +// } +// +// // doAction returns a boolean that indicates if the event should be canceled or not: +// if ( doAction( pmEvent, debugInfo ) ) { +//// if ( doAction( sBlock, pmEvent.getMine(), pmEvent.getPlayer(), debugInfo ) ) { +// +// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { +// e.setCancelled( true ); +// } +// else { +// +// debugInfo.append( "(event was not canceled) " ); +// } +// +// finalizeBreakTheBlocks( pmEvent ); +// +// doBlockEvents( pmEvent ); +// +// } +// else { +// +// debugInfo.append( "(doAction failed without details) " ); +// } +// +// } +// +// +// debugInfo.append( "(normal processing completed) " ); +// } +// else { +// +// debugInfo.append( "(logic bypass) " ); +// } +// +// } +// +// if ( debugInfo.length() > 0 ) { +// +// long stop = System.nanoTime(); +// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); +// +// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); +// } +// } protected boolean ignoreMinesBlockBreakEvent( Cancellable event, Player player, Block block ) { @@ -502,7 +495,7 @@ protected boolean processMinesBlockBreakEvent( PEExplosionEvent event, Player pl * * @param pmEvent */ - private void doBlockEvents( PrisonMinesBlockBreakEvent pmEvent ) + protected void doBlockEvents( PrisonMinesBlockBreakEvent pmEvent ) { if ( pmEvent.getMine() != null ) { @@ -520,7 +513,7 @@ private void doBlockEvents( PrisonMinesBlockBreakEvent pmEvent ) } } - private void finalizeBreakTheBlocks( PrisonMinesBlockBreakEvent pmEvent ) + protected void finalizeBreakTheBlocks( PrisonMinesBlockBreakEvent pmEvent ) { List blocks = finalizeBreakTheBlocksCollectEm( pmEvent ); @@ -601,7 +594,7 @@ private List finalizeBreakTheBlocksCollectEm( PrisonMinesBlockBreak * @param debugInfo * @return */ - private boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder debugInfo ) + protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuilder debugInfo ) { boolean results = true; @@ -1142,319 +1135,115 @@ else if ( results && pmEvent.getBbPriority() == BlockBreakPriority.MONITOR && mi // return new ArrayList<>( results.values() ); // } - /** - *

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 genericBlockExplodeEvent( TEBlockExplodeEvent e, BlockBreakPriority bbPriority ) { - -// , boolean monitor, boolean blockEventsOnly, -// boolean autoManager ) { - - long start = System.nanoTime(); - - if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { - return; - } - - - // Register all external events such as mcMMO and EZBlocks: - OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); - - StringBuilder debugInfo = new StringBuilder(); - - - debugInfo.append( String.format( "### ** genericBlockExplodeEvent ** ### " + - "(event: TEBlockExplodeEvent, config: %s, priority: %s, canceled: %s) ", - bbPriority.name(), - bbPriority.getBukkitEventPriority().name(), - (e.isCancelled() ? "TRUE " : "FALSE") - ) ); - - - - if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { - - - - - String eP = getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority ); - boolean isTEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - - - // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); - SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); - - BlockEventType eventType = BlockEventType.TEXplosion; - String triggered = checkCEExplosionTriggered( e ); - - PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), - sBlock, sPlayer, bbPriority, eventType, triggered ); - - // NOTE: Token Enchant will pass the event's block to prison, but that block may - // have already been processed by prison. Therefore the PrisonMinesBlockBreakEvent - // must enable the feature setForceIfAirBlock( true ). That block will not be used a - // second time, but it will allow the explosion event to be processed. - pmEvent.setForceIfAirBlock( true ); - - pmEvent.setUnprocessedRawBlocks( e.blockList() ); - - if ( !validateEvent( pmEvent, debugInfo ) ) { - - // 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 ); - } - } - - else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { - // Stop here, and prevent additional processing. Monitors should never process the event beyond this. - } - - - - // now process all blocks (non-monitor): - else if ( isTEExplosiveEnabled && - ( pmEvent.getMine() != null || pmEvent.getMine() == null && - !isBoolean( AutoFeatures.pickupLimitToMines )) ) { - - - if ( pmEvent.getExplodedBlocks().size() > 0 ) { - -// String triggered = checkCEExplosionTriggered( e ); -// +// /** +// *

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 handleTEBlockExplodeEvent( TEBlockExplodeEvent e, BlockBreakPriority bbPriority ) { +// +//// , boolean monitor, boolean blockEventsOnly, +//// boolean autoManager ) { // -// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), -// mine, block, explodedBlocks, BlockEventType.TEXplosion, triggered ); - Bukkit.getServer().getPluginManager().callEvent( pmEvent ); - if ( pmEvent.isCancelled() ) { - debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); - } - else { - - // Cancel drops if so configured: - if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { - - try - { - e.setYield( 0 ); -// e.setDropItems( false ); - } - catch ( NoSuchMethodError e1 ) - { - String message = String.format( - "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + - "is not valid for this version of Spigot. Modify the config settings and set " + - "this value to `false`. [%s]", - e1.getMessage() ); - Output.get().logWarn( message ); - } - } - - // This is where the processing actually happens: - if ( doAction( pmEvent, debugInfo ) ) { - - if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { - - e.setCancelled( true ); - } - else { - - debugInfo.append( "(event was not canceled) " ); - } - - finalizeBreakTheBlocks( pmEvent ); - - doBlockEvents( pmEvent ); - - } - - else { - - debugInfo.append( "(doAction failed without details) " ); - } - - } - - } - - - debugInfo.append( "(normal processing) " ); - } - else { - - debugInfo.append( "(logic bypass) " ); - } - - } - - if ( debugInfo.length() > 0 ) { - - long stop = System.nanoTime(); - debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); - - Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); - } - } - - - - private String checkCEExplosionTriggered( TEBlockExplodeEvent e ) - { - String triggered = null; - - // Please be aware: This function is named the same as the auto features setting, but this is - // not related. This is only trying to get the name of the enchantment that triggered the event. - if ( isTeExplosionTriggerEnabled() ) { - - try { - triggered = e.getTrigger(); - } - catch ( Exception | NoSuchMethodError ex ) { - // Only print the error the first time, then suppress the error: - String error = ex.getMessage(); - - Output.get().logError( "Error: Trying to access the TEBlockExplodeEvent.getTrigger() " + - "function. Make sure you are using TokenEnchant v18.11.0 or newer. The new " + - "getTrigger() function returns the TE Plugin that is firing the TEBlockExplodeEvent. " + - "The Prison BlockEvents can be filtered by this triggered value. " + - error ); - - // Disable collecting the trigger. - setTeExplosionTriggerEnabled( false ); - - } - } - - return triggered; - } - - - - /** - *

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 genericBlastUseEvent( BlastUseEvent e, BlockBreakPriority bbPriority ) { - -// boolean monitor, boolean blockEventsOnly, -// boolean autoManager ) { - - long start = System.nanoTime(); - - if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlockList().get( 0 )) ) { - return; - } - - - // Register all external events such as mcMMO and EZBlocks: - OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); - - StringBuilder debugInfo = new StringBuilder(); - - debugInfo.append( String.format( "### ** genericBlastUseEvent ** ### " + - "(event: BlastUseEvent, config: %s, priority: %s, canceled: %s) ", - bbPriority.name(), - bbPriority.getBukkitEventPriority().name(), - (e.isCancelled() ? "TRUE " : "FALSE") - ) ); - - - // NOTE that check for auto manager has happened prior to accessing this function. - if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR && - e.getBlockList().size() > 0 ) { - - - String eP = getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority ); - boolean isCEBlockExplodeEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - - - Block bukkitBlock = e.getBlockList().get( 0 ); - - // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = SpigotBlock.getSpigotBlock( bukkitBlock ); - SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); - - BlockEventType eventType = BlockEventType.CEXplosion; - String triggered = null; - - - PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( bukkitBlock, e.getPlayer(), - sBlock, sPlayer, bbPriority, eventType, triggered ); - - - for ( int i = 1; i < e.getBlockList().size(); i++ ) { - pmEvent.getUnprocessedRawBlocks().add( e.getBlockList().get( i ) ); - } - - - if ( !validateEvent( pmEvent, debugInfo ) ) { - - // 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 ); - } - } - - - else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { - // Stop here, and prevent additional processing. Monitors should never process the event beyond this. - } - - - - // now process all blocks (non-monitor): - else if ( isCEBlockExplodeEnabled && - ( pmEvent.getMine() != null || pmEvent.getMine() == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { - - - if ( pmEvent.getExplodedBlocks().size() > 0 ) { - -// String triggered = null; - - - // Warning: BlastUseEvent does not identify the block the player actually hit, so the dummyBlock - // is just a random first block from the explodedBlocks list and may not be the block - // that initiated the explosion event. -// SpigotBlock dummyBlock = explodedBlocks.get( 0 ); - -// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), -// mine, dummyBlock, explodedBlocks, BlockEventType.CEXplosion, triggered ); - Bukkit.getServer().getPluginManager().callEvent(pmEvent); - if ( pmEvent.isCancelled() ) { - debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); - } - else { - +// long start = System.nanoTime(); +// +// if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { +// return; +// } +// +// +// // Register all external events such as mcMMO and EZBlocks: +// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); +// +// StringBuilder debugInfo = new StringBuilder(); +// +// +// debugInfo.append( String.format( "### ** genericBlockExplodeEvent ** ### " + +// "(event: TEBlockExplodeEvent, config: %s, priority: %s, canceled: %s) ", +// bbPriority.name(), +// bbPriority.getBukkitEventPriority().name(), +// (e.isCancelled() ? "TRUE " : "FALSE") +// ) ); +// +// +// +// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { +// +// +// +// +// String eP = getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority ); +// boolean isTEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); +// +// +// // Need to wrap in a Prison block so it can be used with the mines: +// SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); +// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); +// +// BlockEventType eventType = BlockEventType.TEXplosion; +// String triggered = checkCEExplosionTriggered( e ); +// +// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), +// sBlock, sPlayer, bbPriority, eventType, triggered ); +// +// // NOTE: Token Enchant will pass the event's block to prison, but that block may +// // have already been processed by prison. Therefore the PrisonMinesBlockBreakEvent +// // must enable the feature setForceIfAirBlock( true ). That block will not be used a +// // second time, but it will allow the explosion event to be processed. +// pmEvent.setForceIfAirBlock( true ); +// +// pmEvent.setUnprocessedRawBlocks( e.blockList() ); +// +// if ( !validateEvent( pmEvent, debugInfo ) ) { +// +// // 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 ); +// } +// } +// +// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { +// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. +// } +// +// +// +// // now process all blocks (non-monitor): +// else if ( isTEExplosiveEnabled && +// ( pmEvent.getMine() != null || pmEvent.getMine() == null && +// !isBoolean( AutoFeatures.pickupLimitToMines )) ) { +// +// +// if ( pmEvent.getExplodedBlocks().size() > 0 ) { +// +//// String triggered = checkCEExplosionTriggered( e ); +//// +//// +//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), +//// mine, block, explodedBlocks, BlockEventType.TEXplosion, triggered ); +// Bukkit.getServer().getPluginManager().callEvent( pmEvent ); +// if ( pmEvent.isCancelled() ) { +// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); +// } +// else { +// // // Cancel drops if so configured: // if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { // // try // { -// e.setDropItems( false ); +// e.setYield( 0 ); +//// e.setDropItems( false ); // } // catch ( NoSuchMethodError e1 ) // { @@ -1466,147 +1255,523 @@ else if ( isCEBlockExplodeEnabled && // Output.get().logWarn( message ); // } // } - - if ( doAction( pmEvent, debugInfo ) ) { - - if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { - - e.setCancelled( true ); - } - else { - - debugInfo.append( "(event was not canceled) " ); - } - - finalizeBreakTheBlocks( pmEvent ); - - doBlockEvents( pmEvent ); - - } - - else { - - debugInfo.append( "(doAction failed without details) " ); - } - - } - } - +// +// // This is where the processing actually happens: +// if ( doAction( pmEvent, debugInfo ) ) { +// +// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { +// +// e.setCancelled( true ); +// } +// else { +// +// debugInfo.append( "(event was not canceled) " ); +// } +// +// finalizeBreakTheBlocks( pmEvent ); +// +// doBlockEvents( pmEvent ); +// +// } +// +// else { +// +// debugInfo.append( "(doAction failed without details) " ); +// } +// +// } +// +// } +// +// +// debugInfo.append( "(normal processing) " ); +// } +// else { +// +// debugInfo.append( "(logic bypass) " ); +// } +// +// } +// +// if ( debugInfo.length() > 0 ) { +// +// long stop = System.nanoTime(); +// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); +// +// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); +// } +// } +// - debugInfo.append( "(normal processing) " ); - } - else { - - debugInfo.append( "(logic bypass) " ); - } - } - - if ( debugInfo.length() > 0 ) { - - long stop = System.nanoTime(); - debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); - - Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); - } - } - +// private String checkCEExplosionTriggered( TEBlockExplodeEvent e ) +// { +// String triggered = null; +// +// // Please be aware: This function is named the same as the auto features setting, but this is +// // not related. This is only trying to get the name of the enchantment that triggered the event. +// if ( isTeExplosionTriggerEnabled() ) { +// +// try { +// triggered = e.getTrigger(); +// } +// catch ( Exception | NoSuchMethodError ex ) { +// // Only print the error the first time, then suppress the error: +// String error = ex.getMessage(); +// +// Output.get().logError( "Error: Trying to access the TEBlockExplodeEvent.getTrigger() " + +// "function. Make sure you are using TokenEnchant v18.11.0 or newer. The new " + +// "getTrigger() function returns the TE Plugin that is firing the TEBlockExplodeEvent. " + +// "The Prison BlockEvents can be filtered by this triggered value. " + +// error ); +// +// // Disable collecting the trigger. +// setTeExplosionTriggerEnabled( false ); +// +// } +// } +// +// return triggered; +// } - /** - *

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 genericExplosiveEvent( PEExplosionEvent e, BlockBreakPriority bbPriority) { - - -// , boolean monitor, boolean blockEventsOnly, -// boolean autoManager ) { - - long start = System.nanoTime(); - - if ( e.isCancelled() || processMinesBlockBreakEvent( e, e.getPlayer(), e.getBlockBroken()) ) { - return; - } - - - // Register all external events such as mcMMO and EZBlocks: - OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); - - StringBuilder debugInfo = new StringBuilder(); - - - debugInfo.append( String.format( "### ** genericExplosiveEvent (Pulsi) ** ### " + - "(event: PEExplosionEvent, config: %s, priority: %s, canceled: %s) ", - bbPriority.name(), - bbPriority.getBukkitEventPriority().name(), - (e.isCancelled() ? "TRUE " : "FALSE") - ) ); - - - if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { - - - - String eP = getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority ); - boolean isPEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - - - // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlockBroken()); - SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); - - BlockEventType eventType = BlockEventType.PEExplosive; - String triggered = null; // e.getTriggeredBy(); - - PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlockBroken(), e.getPlayer(), - sBlock, sPlayer, bbPriority, eventType, triggered ); - - pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); - - - if ( !validateEvent( pmEvent, debugInfo ) ) { - - // 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 ); - } - } - - - else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { - // Stop here, and prevent additional processing. Monitors should never process the event beyond this. - } - - + +// /** +// *

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 handleBlastUseEvent( BlastUseEvent e, BlockBreakPriority bbPriority ) { +// +//// boolean monitor, boolean blockEventsOnly, +//// boolean autoManager ) { +// +// long start = System.nanoTime(); +// +// if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlockList().get( 0 )) ) { +// return; +// } +// +// +// // Register all external events such as mcMMO and EZBlocks: +// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); +// +// StringBuilder debugInfo = new StringBuilder(); +// +// debugInfo.append( String.format( "### ** genericBlastUseEvent ** ### " + +// "(event: BlastUseEvent, config: %s, priority: %s, canceled: %s) ", +// bbPriority.name(), +// bbPriority.getBukkitEventPriority().name(), +// (e.isCancelled() ? "TRUE " : "FALSE") +// ) ); +// +// +// // NOTE that check for auto manager has happened prior to accessing this function. +// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR && +// e.getBlockList().size() > 0 ) { +// +// +// String eP = getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority ); +// boolean isCEBlockExplodeEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); +// +// +// Block bukkitBlock = e.getBlockList().get( 0 ); +// +// // Need to wrap in a Prison block so it can be used with the mines: +// SpigotBlock sBlock = SpigotBlock.getSpigotBlock( bukkitBlock ); +// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); +// +// BlockEventType eventType = BlockEventType.CEXplosion; +// String triggered = null; +// +// +// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( bukkitBlock, e.getPlayer(), +// sBlock, sPlayer, bbPriority, eventType, triggered ); +// +// +// for ( int i = 1; i < e.getBlockList().size(); i++ ) { +// pmEvent.getUnprocessedRawBlocks().add( e.getBlockList().get( i ) ); +// } +// +// +// if ( !validateEvent( pmEvent, debugInfo ) ) { +// +// // 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 ); +// } +// } +// +// +// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { +// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. +// } +// +// +// +// // now process all blocks (non-monitor): +// else if ( isCEBlockExplodeEnabled && +// ( pmEvent.getMine() != null || pmEvent.getMine() == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { +// +// +// if ( pmEvent.getExplodedBlocks().size() > 0 ) { +// +//// String triggered = null; +// +// +// // Warning: BlastUseEvent does not identify the block the player actually hit, so the dummyBlock +// // is just a random first block from the explodedBlocks list and may not be the block +// // that initiated the explosion event. +//// SpigotBlock dummyBlock = explodedBlocks.get( 0 ); +// +//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), +//// mine, dummyBlock, explodedBlocks, BlockEventType.CEXplosion, triggered ); +// Bukkit.getServer().getPluginManager().callEvent(pmEvent); +// if ( pmEvent.isCancelled() ) { +// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); +// } +// else { +// +//// // Cancel drops if so configured: +//// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { +//// +//// try +//// { +//// e.setDropItems( false ); +//// } +//// catch ( NoSuchMethodError e1 ) +//// { +//// String message = String.format( +//// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + +//// "is not valid for this version of Spigot. Modify the config settings and set " + +//// "this value to `false`. [%s]", +//// e1.getMessage() ); +//// Output.get().logWarn( message ); +//// } +//// } +// +// if ( doAction( pmEvent, debugInfo ) ) { +// +// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { +// +// e.setCancelled( true ); +// } +// else { +// +// debugInfo.append( "(event was not canceled) " ); +// } +// +// finalizeBreakTheBlocks( pmEvent ); +// +// doBlockEvents( pmEvent ); +// +// } +// +// else { +// +// debugInfo.append( "(doAction failed without details) " ); +// } +// +// } +// } +// +// +// debugInfo.append( "(normal processing) " ); +// } +// else { +// +// debugInfo.append( "(logic bypass) " ); +// } +// +// } +// +// if ( debugInfo.length() > 0 ) { +// +// long stop = System.nanoTime(); +// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); +// +// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); +// } +// } + - // now process all blocks (non-monitor): - else if ( isPEExplosiveEnabled && - ( pmEvent.getMine() != null || pmEvent.getMine() == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { - if ( pmEvent.getExplodedBlocks().size() > 0 ) { - -// String triggered = null; - - -// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), -// mine, dummyBlock, explodedBlocks, BlockEventType.PEExplosive, triggered ); - Bukkit.getServer().getPluginManager().callEvent(pmEvent); - if ( pmEvent.isCancelled() ) { - debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); - } - else { - + +// /** +// *

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 handlePEExplosionEvent( PEExplosionEvent e, BlockBreakPriority bbPriority) { +// +// +//// , boolean monitor, boolean blockEventsOnly, +//// boolean autoManager ) { +// +// long start = System.nanoTime(); +// +// if ( e.isCancelled() || processMinesBlockBreakEvent( e, e.getPlayer(), e.getBlockBroken()) ) { +// return; +// } +// +// +// // Register all external events such as mcMMO and EZBlocks: +// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); +// +// StringBuilder debugInfo = new StringBuilder(); +// +// +// debugInfo.append( String.format( "### ** genericExplosiveEvent (Pulsi) ** ### " + +// "(event: PEExplosionEvent, config: %s, priority: %s, canceled: %s) ", +// bbPriority.name(), +// bbPriority.getBukkitEventPriority().name(), +// (e.isCancelled() ? "TRUE " : "FALSE") +// ) ); +// +// +// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { +// +// +// +// String eP = getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority ); +// boolean isPEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); +// +// +// // Need to wrap in a Prison block so it can be used with the mines: +// SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlockBroken()); +// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); +// +// BlockEventType eventType = BlockEventType.PEExplosive; +// String triggered = null; // e.getTriggeredBy(); +// +// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlockBroken(), e.getPlayer(), +// sBlock, sPlayer, bbPriority, eventType, triggered ); +// +// pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); +// +// +// if ( !validateEvent( pmEvent, debugInfo ) ) { +// +// // 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 ); +// } +// } +// +// +// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { +// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. +// } +// +// +// +// // now process all blocks (non-monitor): +// else if ( isPEExplosiveEnabled && +// ( pmEvent.getMine() != null || pmEvent.getMine() == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { +// if ( pmEvent.getExplodedBlocks().size() > 0 ) { +// +//// String triggered = null; +// +// +//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), +//// mine, dummyBlock, explodedBlocks, BlockEventType.PEExplosive, triggered ); +// Bukkit.getServer().getPluginManager().callEvent(pmEvent); +// if ( pmEvent.isCancelled() ) { +// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); +// } +// else { +// +//// // Cancel drops if so configured: +//// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { +//// +//// try +//// { +//// e.setDropItems( false ); +//// } +//// catch ( NoSuchMethodError e1 ) +//// { +//// String message = String.format( +//// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + +//// "is not valid for this version of Spigot. Modify the config settings and set " + +//// "this value to `false`. [%s]", +//// e1.getMessage() ); +//// Output.get().logWarn( message ); +//// } +//// } +// +// if ( doAction( pmEvent, debugInfo ) ) { +// +// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { +// +// e.setCancelled( true ); +// } +// else { +// +// debugInfo.append( "(event was not canceled) " ); +// } +// +// finalizeBreakTheBlocks( pmEvent ); +// +// doBlockEvents( pmEvent ); +// +// } +// +// else { +// +// debugInfo.append( "(doAction failed without details) " ); +// } +// +// } +// } +// +// +// debugInfo.append( "(normal processing) " ); +// } +// else { +// +// debugInfo.append( "(logic bypass) " ); +// } +// +// } +// +// if ( debugInfo.length() > 0 ) { +// +// long stop = System.nanoTime(); +// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); +// +// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); +// } +// +// } + +// protected void handleExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e, BlockBreakPriority bbPriority ) { +// +//// boolean monitor, boolean blockEventsOnly, +//// boolean autoManager ) { +// +// long start = System.nanoTime(); +// +// if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { +// return; +// } +// +// +// // Register all external events such as mcMMO and EZBlocks: +// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); +// +// StringBuilder debugInfo = new StringBuilder(); +// +// +// debugInfo.append( String.format( "### ** genericExplosiveEvent (Prisons's bombs) ** ### " + +// "(event: ExplosiveBlockBreakEvent, config: %s, priority: %s, canceled: %s) ", +// bbPriority.name(), +// bbPriority.getBukkitEventPriority().name(), +// (e.isCancelled() ? "TRUE " : "FALSE") +// ) ); +// +// +// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { +// +// +// String eP = getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority ); +// boolean isPPrisonExplosiveBlockBreakEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); +// +// +// // Need to wrap in a Prison block so it can be used with the mines: +// SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); +// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); +// +// BlockEventType eventType = BlockEventType.PrisonExplosion; +// String triggered = e.getTriggeredBy(); +// +// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), +// sBlock, sPlayer, bbPriority, eventType, triggered ); +// +// +// // If this event is fired, but yet there are no exploded blocks, then do not set +// // forceIfAirBlock to true so this event is skipped. +// if ( e.getExplodedBlocks() != null && e.getExplodedBlocks().size() > 0 ) { +// +// pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); +// pmEvent.setForceIfAirBlock( e.isForceIfAirBlock() ); +// } +// +// +// +// // Warning: toolInHand really needs to be defined in the event if the source is a +// // Mine Bomb, otherwise auto features will detect the player is holding +// // a mine bomb which is not a pickaxe so the drops will be ZERO. If they +// // used their last mine bomb, then auto features will detect only AIR +// // in their hand. +// if ( e.getToolInHand() != null ) { +// pmEvent.setItemInHand( (SpigotItemStack) e.getToolInHand() ); +// +// } +// +// // Note: If the mineBomb is set, then the bomb itself uses a pseudo +// // tool in hand, so need to disable durability calculations since +// // if the pseudo tool breaks, it will clear the player's in-hand +// // inventory stack, which will be more mine bombs if they had more +// // than one. +// if ( e.getMineBomb() != null ) { +// pmEvent.setCalculateDurability( false ); +// } +// +// if ( !validateEvent( pmEvent, debugInfo ) ) { +// +// // 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 ); +// } +// } +// +// +// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { +// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. +// } +// +// +// +// // now process all blocks (non-monitor): +// else if ( isPPrisonExplosiveBlockBreakEnabled && +// ( pmEvent.getMine() != null || pmEvent.getMine() == null && +// !isBoolean( AutoFeatures.pickupLimitToMines )) ) { +// +// if ( pmEvent.getExplodedBlocks().size() > 0 ) { +// +//// String triggered = null; +// +// +//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), +//// mine, dummyBlock, explodedBlocks, BlockEventType.PEExplosive, triggered ); +// Bukkit.getServer().getPluginManager().callEvent(pmEvent); +// if ( pmEvent.isCancelled() ) { +// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); +// } +// else { +// // // Cancel drops if so configured: // if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { // @@ -1624,223 +1789,51 @@ else if ( isPEExplosiveEnabled && // Output.get().logWarn( message ); // } // } - - if ( doAction( pmEvent, debugInfo ) ) { - - if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { - - e.setCancelled( true ); - } - else { - - debugInfo.append( "(event was not canceled) " ); - } - - finalizeBreakTheBlocks( pmEvent ); - - doBlockEvents( pmEvent ); - - } - - else { - - debugInfo.append( "(doAction failed without details) " ); - } - - } - } - - - debugInfo.append( "(normal processing) " ); - } - else { - - debugInfo.append( "(logic bypass) " ); - } - - } - - if ( debugInfo.length() > 0 ) { - - long stop = System.nanoTime(); - debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); - - Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); - } - - } - - protected void genericExplosiveEvent( ExplosiveBlockBreakEvent e, BlockBreakPriority bbPriority ) { - -// boolean monitor, boolean blockEventsOnly, -// boolean autoManager ) { - - long start = System.nanoTime(); - - if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { - return; - } - - - // Register all external events such as mcMMO and EZBlocks: - OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); - - StringBuilder debugInfo = new StringBuilder(); - - - debugInfo.append( String.format( "### ** genericExplosiveEvent (Prisons's bombs) ** ### " + - "(event: ExplosiveBlockBreakEvent, config: %s, priority: %s, canceled: %s) ", - bbPriority.name(), - bbPriority.getBukkitEventPriority().name(), - (e.isCancelled() ? "TRUE " : "FALSE") - ) ); - - - if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { - - - String eP = getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority ); - boolean isPPrisonExplosiveBlockBreakEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); - - - // Need to wrap in a Prison block so it can be used with the mines: - SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); - SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); - - BlockEventType eventType = BlockEventType.PrisonExplosion; - String triggered = e.getTriggeredBy(); - - PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), - sBlock, sPlayer, bbPriority, eventType, triggered ); - - - // If this event is fired, but yet there are no exploded blocks, then do not set - // forceIfAirBlock to true so this event is skipped. - if ( e.getExplodedBlocks() != null && e.getExplodedBlocks().size() > 0 ) { - - pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); - pmEvent.setForceIfAirBlock( e.isForceIfAirBlock() ); - } - - - - // Warning: toolInHand really needs to be defined in the event if the source is a - // Mine Bomb, otherwise auto features will detect the player is holding - // a mine bomb which is not a pickaxe so the drops will be ZERO. If they - // used their last mine bomb, then auto features will detect only AIR - // in their hand. - if ( e.getToolInHand() != null ) { - pmEvent.setItemInHand( (SpigotItemStack) e.getToolInHand() ); - - } - - // Note: If the mineBomb is set, then the bomb itself uses a pseudo - // tool in hand, so need to disable durability calculations since - // if the pseudo tool breaks, it will clear the player's in-hand - // inventory stack, which will be more mine bombs if they had more - // than one. - if ( e.getMineBomb() != null ) { - pmEvent.setCalculateDurability( false ); - } - - if ( !validateEvent( pmEvent, debugInfo ) ) { - - // 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 ); - } - } - - - else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { - // Stop here, and prevent additional processing. Monitors should never process the event beyond this. - } - - - - // now process all blocks (non-monitor): - else if ( isPPrisonExplosiveBlockBreakEnabled && - ( pmEvent.getMine() != null || pmEvent.getMine() == null && - !isBoolean( AutoFeatures.pickupLimitToMines )) ) { - - if ( pmEvent.getExplodedBlocks().size() > 0 ) { - -// String triggered = null; - - -// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), -// mine, dummyBlock, explodedBlocks, BlockEventType.PEExplosive, triggered ); - Bukkit.getServer().getPluginManager().callEvent(pmEvent); - if ( pmEvent.isCancelled() ) { - debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); - } - else { - - // Cancel drops if so configured: - if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { - - try - { - e.setDropItems( false ); - } - catch ( NoSuchMethodError e1 ) - { - String message = String.format( - "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + - "is not valid for this version of Spigot. Modify the config settings and set " + - "this value to `false`. [%s]", - e1.getMessage() ); - Output.get().logWarn( message ); - } - } - - if ( doAction( pmEvent, debugInfo ) ) { - - if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { - - e.setCancelled( true ); - } - else { - - debugInfo.append( "(event was not canceled) " ); - } - - finalizeBreakTheBlocks( pmEvent ); - - doBlockEvents( pmEvent ); - - } - - else { - - debugInfo.append( "(doAction failed without details) " ); - } - - } - } - - - debugInfo.append( "(normal processing) " ); - } - else { - - debugInfo.append( "(logic bypass) " ); - } - - } - - if ( debugInfo.length() > 0 ) { - - long stop = System.nanoTime(); - debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); - - Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); - } - - } +// +// if ( doAction( pmEvent, debugInfo ) ) { +// +// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { +// +// e.setCancelled( true ); +// } +// else { +// +// debugInfo.append( "(event was not canceled) " ); +// } +// +// finalizeBreakTheBlocks( pmEvent ); +// +// doBlockEvents( pmEvent ); +// +// } +// +// else { +// +// debugInfo.append( "(doAction failed without details) " ); +// } +// +// } +// } +// +// +// debugInfo.append( "(normal processing) " ); +// } +// else { +// +// debugInfo.append( "(logic bypass) " ); +// } +// +// } +// +// if ( debugInfo.length() > 0 ) { +// +// long stop = System.nanoTime(); +// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); +// +// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); +// } +// +// } @@ -2274,12 +2267,13 @@ private int xpCalculateBonusXP( MineTargetPrisonBlock targetBlock, SpigotPlayer SpigotBlock sBlock = ((SpigotBlock) targetBlock.getMinedBlock()); // Bonus XP: - xp = checkCrazyEnchant( player.getWrapper(), sBlock.getWrapper(), itemInHand ); + xp = checkBonusXp( player.getWrapper(), sBlock.getWrapper(), itemInHand ); } return xp; } + protected abstract int checkBonusXp( Player player, Block block, ItemStack item ); /** *

Gives XP to the player, either as Orbs or directly. @@ -2786,31 +2780,31 @@ protected void itemLoreCounter( SpigotItemStack itemInHand, String itemLore, int - private int checkCrazyEnchant( Player player, Block block, ItemStack item ) { - int bonusXp = 0; - - try { - if ( isCrazyEnchantEnabled() == null ) { - Class.forName( - "tech.mcprison.prison.spigot.integrations.IntegrationCrazyEnchantmentsPickaxes", false, - this.getClass().getClassLoader() ); - setCrazyEnchantEnabled( Boolean.TRUE ); - } - - if ( isCrazyEnchantEnabled() != null && isCrazyEnchantEnabled().booleanValue() && - item != null && IntegrationCrazyEnchantmentsPickaxes.getInstance().isEnabled() ) { - - bonusXp = IntegrationCrazyEnchantmentsPickaxes.getInstance() - .getPickaxeEnchantmentExperienceBonus( player, block, item ); - } - } - catch ( NoClassDefFoundError | Exception e ) { - setCrazyEnchantEnabled( Boolean.FALSE ); - } - - return bonusXp; - } - +// private int checkCrazyEnchant( Player player, Block block, ItemStack item ) { +// int bonusXp = 0; +// +// try { +// if ( isCrazyEnchantEnabled() == null ) { +// Class.forName( +// "tech.mcprison.prison.spigot.integrations.IntegrationCrazyEnchantmentsPickaxes", false, +// this.getClass().getClassLoader() ); +// setCrazyEnchantEnabled( Boolean.TRUE ); +// } +// +// if ( isCrazyEnchantEnabled() != null && isCrazyEnchantEnabled().booleanValue() && +// item != null && IntegrationCrazyEnchantmentsPickaxes.getInstance().isEnabled() ) { +// +// bonusXp = IntegrationCrazyEnchantmentsPickaxes.getInstance() +// .getPickaxeEnchantmentExperienceBonus( player, block, item ); +// } +// } +// catch ( NoClassDefFoundError | Exception e ) { +// setCrazyEnchantEnabled( Boolean.FALSE ); +// } +// +// return bonusXp; +// } +// @@ -2832,25 +2826,25 @@ private synchronized String incrementUses(Long elapsedNano) { } return message; } - - private boolean isTeExplosionTriggerEnabled() { - return teExplosionTriggerEnabled; - } - - private void setTeExplosionTriggerEnabled( boolean teExplosionTriggerEnabled ) { - this.teExplosionTriggerEnabled = teExplosionTriggerEnabled; - } +// +// private boolean isTeExplosionTriggerEnabled() { +// return teExplosionTriggerEnabled; +// } +// +// private void setTeExplosionTriggerEnabled( boolean teExplosionTriggerEnabled ) { +// this.teExplosionTriggerEnabled = teExplosionTriggerEnabled; +// } public Random getRandom() { return random; } - public Boolean isCrazyEnchantEnabled() { - return crazyEnchantEnabled; - } - public void setCrazyEnchantEnabled( Boolean crazyEnchantEnabled ) { - this.crazyEnchantEnabled = crazyEnchantEnabled; - } +// public Boolean isCrazyEnchantEnabled() { +// return crazyEnchantEnabled; +// } +// public void setCrazyEnchantEnabled( Boolean crazyEnchantEnabled ) { +// this.crazyEnchantEnabled = crazyEnchantEnabled; +// } } 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 b57718218..080a3e22a 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 @@ -1,9 +1,25 @@ package tech.mcprison.prison.spigot.block; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; +import tech.mcprison.prison.mines.PrisonMines; +import tech.mcprison.prison.modules.Module; + +import java.util.Optional; + +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import tech.mcprison.prison.Prison; +import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerBlockBreakEvents; +import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerCrazyEnchants; +import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerPrisonEnchants; +import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerPrisonsExplosiveBlockBreakEvents; +import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerTokenEnchant; +import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerZenchantments; +import tech.mcprison.prison.spigot.autofeatures.events.PrisonDebugBlockInspector; /** *

This is a pivotal class that "monitors" onBlockBreak events so it can @@ -82,20 +98,54 @@ * */ public class OnBlockBreakEventListener - extends OnBlockBreakEventCore { +// extends OnBlockBreakEventCore + { + private AutoManagerBlockBreakEvents bbEvents; + private AutoManagerPrisonsExplosiveBlockBreakEvents pebbEvents; + private AutoManagerCrazyEnchants ceEvents; + + private AutoManagerPrisonEnchants peEvents; + private AutoManagerTokenEnchant teEvents; + private AutoManagerZenchantments zcEvents; + + private PrisonDebugBlockInspector pdBlockInspector; + public OnBlockBreakEventListener() { super(); } + /** + *

The Prison Mines module must be enabled, or these BlockBreakEvents should + * not be enabled since they are geared to work with the prison mines. + *

+ * + *

At this time, prison's block handling is not supported outside of the mines. + *

+ * + * @return + */ + public boolean isEnabled() { + boolean results = false; + + Optional mmOptional = Prison.get().getModuleManager().getModule( PrisonMines.MODULE_NAME ); + if ( mmOptional.isPresent() && mmOptional.get().isEnabled() ) { + PrisonMines prisonMines = (PrisonMines) mmOptional.get(); + + results = prisonMines != null; + } + + return results; + } + public void registerAllBlockBreakEvents(SpigotPrison spigotPrison ) { // Only register these event listeners if these are enabled. // In order to be enabled, the prison mines module must be enabled. - if ( !isBoolean(AutoFeatures.isAutoManagerEnabled) ) { + if ( !AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) { Output.get().logWarn( "AutoMager: AutoFeatures is dsabled. " + "No block break listeners are registered. " + @@ -114,7 +164,7 @@ public void registerAllBlockBreakEvents(SpigotPrison spigotPrison ) { // This will register all events that should be enabled, for both // auto manager and the normal events too. - new AutoManagerBlockBreakEvents().registerEvents(); + registerEvents(); } @@ -125,6 +175,85 @@ public void registerAllBlockBreakEvents(SpigotPrison spigotPrison ) { } } + + public void reloadEventListeners() { + + // NOTE: The unregisterListeners() will remove ALL auto features events that were + // registered, no matter which listeners were enabled. + unregisterListeners(); + + // NOTE: The registerEvents() will register all event listeners based upon what's + // in the auto features configuration file. + registerEvents(); + + + } + + /** + *

When a listener is registered within prison's auto manager, the events + * are tracked internally and can be unregistered later. This function does not + * make it obvious the instantiated object is "stored", but it is. + *

+ * + *

For more info on the storage of these registered events, please see: + *

+ * + *
SpigotPrison.getRegisteredBlockListeners()
+ * + */ + private void registerEvents() { + + bbEvents = new AutoManagerBlockBreakEvents(); + bbEvents.registerEvents(); + + // Prison's own internal event and listener: + pebbEvents = new AutoManagerPrisonsExplosiveBlockBreakEvents(); + pebbEvents.registerEvents(); + + ceEvents = new AutoManagerCrazyEnchants(); + ceEvents.registerEvents(); + + peEvents = new AutoManagerPrisonEnchants(); + peEvents.registerEvents(); + + teEvents = new AutoManagerTokenEnchant(); + teEvents.registerEvents(); + + zcEvents = new AutoManagerZenchantments(); + zcEvents.registerEvents(); + + pdBlockInspector = new PrisonDebugBlockInspector(); + pdBlockInspector.init(); + } + + /** + *

If one BlockBreak related event needs to be unregistered, then this function will + * unregisters all of them that has been registered through the auto features. If + * this function is called by different functions, the results will be the same. If + * they are ran back-to-back, then only the first call will remove all the Listeners + * and the other calls will do nothing since the source ArrayList will be emptied + * and there would be nothing to remove. + *

+ * + */ + public void unregisterListeners() { + + SpigotPrison prison = SpigotPrison.getInstance(); + + int count = 0; + while ( prison.getRegisteredBlockListeners().size() > 0 ) { + Listener listener = prison.getRegisteredBlockListeners().remove( 0 ); + + if ( listener != null ) { + + HandlerList.unregisterAll( listener ); + count++; + } + } + + Output.get().logInfo( "AutoManagerEventsManager: unregistered a total of %d event listeners.", + count ); + } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java index 95dbcdd8a..5bed7545c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakExternalEvents.java @@ -91,7 +91,7 @@ protected List getListString( AutoFeatures feature ) { } - protected void registerAllExternalEvents() { + public void registerAllExternalEvents() { if ( !setup ) { setup = true; @@ -167,7 +167,7 @@ protected void registerAllExternalEvents() { // //handlers.get // } - protected StringBuilder checkAllExternalEvents( BlockBreakEvent e ) { + public StringBuilder checkAllExternalEvents( BlockBreakEvent e ) { // check mcmmo StringBuilder sb = checkMCMMO( e ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java index 2f6eae52a..4ea130819 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java @@ -4,7 +4,9 @@ import java.util.HashMap; import java.util.List; +import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import com.cryptomorin.xseries.XMaterial; @@ -289,4 +291,12 @@ protected void autoBlock( boolean autoBlock, XMaterial source, XMaterial target, } } + + + @Override + protected int checkBonusXp( Player player, Block block, ItemStack item ) { + int bonusXp = 0; + + return bonusXp; + } } From 79ea4c1188e0e98505d4bd9ffb63dba2317aa4ff Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Mar 2022 19:54:19 -0400 Subject: [PATCH 170/297] Mine bombs: Fix an issue with the generated mine bomb tool not being enchanted with the specified fortune, which also was effecting the durability and dig_speed too. --- docs/changelog_v3.3.x.md | 3 +++ .../events/AutoManagerPrisonsExplosiveBlockBreakEvents.java | 5 +++-- .../prison/spigot/utils/PrisonUtilsMineBombsTasks.java | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 49726b304..cf3f29853 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **Mine bombs: Fix an issue with the generated mine bomb tool not being enchanted with the specified fortune, which also was effecting the durability and dig_speed too.** + + * **Reworked how some of the registered event listeners are setup, which is needed for expanding to supporting other plugin's enchanments.** 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 f540887ec..2f15e72e6 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 @@ -235,11 +235,12 @@ protected void handleExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e, Block // a mine bomb which is not a pickaxe so the drops will be ZERO. If they // used their last mine bomb, then auto features will detect only AIR // in their hand. - if ( e.getToolInHand() != null ) { + if ( e.getToolInHand() != null && e.getToolInHand() instanceof SpigotItemStack ) { pmEvent.setItemInHand( (SpigotItemStack) e.getToolInHand() ); - } + + // Note: If the mineBomb is set, then the bomb itself uses a pseudo // tool in hand, so need to disable durability calculations since // if the pseudo tool breaks, it will clear the player's in-hand diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java index 1d0ee5ddd..faec43e67 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java @@ -59,7 +59,7 @@ protected Boolean initialize() protected void setFortune( SpigotItemStack itemInHand, int fortuneLevel ) { - if ( itemInHand != null && itemInHand.getBukkitStack() != null && itemInHand.getBukkitStack().hasItemMeta() ) { + if ( itemInHand != null && itemInHand.getBukkitStack() != null ) { itemInHand.getBukkitStack().addUnsafeEnchantment( Enchantment.LOOT_BONUS_BLOCKS, fortuneLevel ); @@ -72,7 +72,7 @@ protected void setFortune( SpigotItemStack itemInHand, int fortuneLevel ) { protected void setUnbreaking( SpigotItemStack itemInHand, int durabilityLevel ) { - if ( itemInHand != null && itemInHand.getBukkitStack() != null && itemInHand.getBukkitStack().hasItemMeta() ) { + if ( itemInHand != null && itemInHand.getBukkitStack() != null ) { itemInHand.getBukkitStack().addUnsafeEnchantment( Enchantment.DURABILITY, durabilityLevel ); } @@ -80,7 +80,7 @@ protected void setUnbreaking( SpigotItemStack itemInHand, int durabilityLevel ) protected void setDigSpeed( SpigotItemStack itemInHand, int digSpeedLevel ) { - if ( itemInHand != null && itemInHand.getBukkitStack() != null && itemInHand.getBukkitStack().hasItemMeta() ) { + if ( itemInHand != null && itemInHand.getBukkitStack() != null ) { itemInHand.getBukkitStack().addUnsafeEnchantment( Enchantment.DIG_SPEED, digSpeedLevel ); } From 5957a1b96e49456c820c6a632befcbebc3e20962 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Mar 2022 21:48:17 -0400 Subject: [PATCH 171/297] PlayerCache earningsPerMinute: Sychronize to prevent an issue with concurrent mods. --- docs/changelog_v3.3.x.md | 3 ++ .../prison/cache/PlayerCachePlayerData.java | 43 +++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index cf3f29853..25438d0b5 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **PlayerCache earningsPerMinute: Sychronize to prevent an issue with concurrent mods.** + + * **Mine bombs: Fix an issue with the generated mine bomb tool not being enchanted with the specified fortune, which also was effecting the durability and dig_speed too.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCachePlayerData.java b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCachePlayerData.java index 676fb8674..cf33074ca 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCachePlayerData.java +++ b/prison-core/src/main/java/tech/mcprison/prison/cache/PlayerCachePlayerData.java @@ -438,15 +438,18 @@ public void addEarnings( double earnings, String mineName ) { double earningsPM = earnings; - if ( getEarningsPerMinute().containsKey( key ) ) { - earningsPM += getEarningsPerMinute().get( key ); - } - getEarningsPerMinute().put( key, earningsPM ); - - if ( getEarningsPerMinute().size() > 5 ) { - getEarningsPerMinute().remove( - getEarningsPerMinute().firstEntry().getKey() ); + synchronized (earningsPerMinute) { + if ( getEarningsPerMinute().containsKey( key ) ) { + earningsPM += getEarningsPerMinute().get( key ); + } + getEarningsPerMinute().put( key, earningsPM ); + + + if ( getEarningsPerMinute().size() > 5 ) { + getEarningsPerMinute().remove( + getEarningsPerMinute().firstEntry().getKey() ); + } } if ( mineName != null && sessionType != SessionType.mining ) { @@ -478,9 +481,12 @@ public double getAverageEarningsPerMinute() { double results = 0; int size = 0; - for ( double value : earningsPerMinute.values() ) { - results += value; - size++; + + synchronized (earningsPerMinute) { + for ( double value : earningsPerMinute.values() ) { + results += value; + size++; + } } return ( size == 0 ? 0 : ( results / size )); @@ -678,9 +684,15 @@ public String toString() { sb.append( getPlayerName() ) .append( " " ) .append( isOnline() ? "online" : "OFFLINE" ) - .append( " avg earnings/min: " ) - .append( getAverageEarningsPerMinute() ) + .append( " avg earnings/min: " ); + synchronized (earningsPerMinute) { + + sb + .append( getAverageEarningsPerMinute() ); + } + + sb .append( " TotalOnlineTime: " ) .append( totalTime ) .append( " MiningTime: " ) @@ -764,7 +776,10 @@ public TreeMap getEarningsPerMinute() { return earningsPerMinute; } public void setEarningsPerMinute( TreeMap earningsPerMinute ) { - this.earningsPerMinute = earningsPerMinute; + + synchronized (earningsPerMinute) { + this.earningsPerMinute = earningsPerMinute; + } } public long getOnlineTimeTotal() { From 69b95ad7a4c7ba558a264d62caad1fb5bfde6385 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Mar 2022 23:50:42 -0400 Subject: [PATCH 172/297] Sellall: prevent selling with custom name items. --- docs/changelog_v3.3.x.md | 3 + .../prison/spigot/sellall/SellAllUtil.java | 73 +++++++++++++------ 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 25438d0b5..b75ce6869 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **Sellall: prevent selling with custom name items.** + + * **PlayerCache earningsPerMinute: Sychronize to prevent an issue with concurrent mods.** 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 568d9a8a3..1a3889f51 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 @@ -26,6 +26,7 @@ import tech.mcprison.prison.PrisonAPI; 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; @@ -173,18 +174,38 @@ public ArrayList getItemTriggerXMaterials(){ * @return XMaterial. * */ private XMaterial getXMaterialOrLapis(ItemStack itemStack) { - if (itemStack.isSimilar(lapisLazuli)) { - return XMaterial.LAPIS_LAZULI; - } - XMaterial results = null; - try - { - results = XMaterial.matchXMaterial(itemStack); - } - catch ( Exception e ) - { - // ignore... it is not normal matertial so it cannot be sold - } + XMaterial results = null; + + String altName = null; + + if ( itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() ) { + altName = itemStack.getItemMeta().getDisplayName(); + } + + if ( altName == null ) { + 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; } @@ -455,18 +476,26 @@ private double getSellMoney( Player p, SpigotItemStack itemStack ) { double results = 0d; - HashMap xMaterialIntegerHashMap = new HashMap<>(); - - PrisonBlock pBlock = itemStack.getMaterial(); - - XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( pBlock ); - - if ( xMat != null ) { - xMaterialIntegerHashMap.put( xMat, itemStack.getAmount() ); + // 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 ( itemStack.getMaterial().getBlockType() == null || + itemStack.getMaterial().getBlockType() == PrisonBlockType.minecraft ) { - results = getSellMoney( p, xMaterialIntegerHashMap ); + 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 ); + } } + return results; } @@ -993,7 +1022,7 @@ public boolean canPlayerSell(Player p, boolean isUsingSign){ * */ public boolean editPrice(XMaterial xMaterial, double value){ - if (!sellAllBlocks.containsKey(xMaterial)){ + if (!sellAllBlocks.containsKey(xMaterial) && sellAllBlocks.get(xMaterial) != value ){ return false; } From e8cca47f819ebd75184182134dfc4719a100994e Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Mar 2022 23:52:23 -0400 Subject: [PATCH 173/297] CustomItems drops: If custom items do not produce a drop, then default to dropping the block itself. --- docs/changelog_v3.3.x.md | 3 +++ .../mcprison/prison/spigot/customblock/CustomItemsWrapper.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index b75ce6869..e5838132b 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **CustomItems drops: If custom items do not produce a drop, then default to dropping the block itself.** + + * **Sellall: prevent selling with custom name items.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java index dd09050b1..eeec73bb5 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java @@ -186,7 +186,8 @@ public List getDrops( PrisonBlock prisonBlock, SpigotPlayer pla } } - else { + + if ( results.size() == 0 ) { org.bukkit.inventory.ItemStack bItemStack = CustomItemsAPI.getCustomItem( prisonBlock.getBlockName() ); From 6f442d711f6ad12346f518154c91144033693213 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Mar 2022 23:54:46 -0400 Subject: [PATCH 174/297] Mine bombs getting a replacement blocks from the player's location. --- docs/changelog_v3.3.x.md | 3 +++ .../mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e5838132b..e4acc7b0c 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **Mine bombs getting a replacement blocks from the player's location.** + + * **CustomItems drops: If custom items do not produce a drop, then default to dropping the block itself.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index 0c3969b37..0257a751c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -751,7 +751,11 @@ else if ( bomb != null ) { if ( bombs != null ) { - SpigotBlock bombBlock = sBlock != null ? sBlock : (SpigotBlock) player.getLocation().getBlock(); + if ( sBlock == null ) { + sBlock = (SpigotBlock) sPlayer.getLocation().getBlockAt(); + } + + SpigotBlock bombBlock = sBlock; // // If the clicked on block is empty, then the player probably clicked on air. From b0d86be18a6bdf5201533f96847b6d36d58c2ccf Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 13 Mar 2022 23:56:17 -0400 Subject: [PATCH 175/297] Removed some old code... --- docs/changelog_v3.3.x.md | 2 + .../spigot/block/OnBlockBreakEventCore.java | 1016 +---------------- 2 files changed, 3 insertions(+), 1015 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e4acc7b0c..98ad41773 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,8 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **Removed some old code from block event processing...** + * **Mine bombs getting a replacement blocks from the player's location.** 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 0e8b15094..e6a57dcc1 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 @@ -43,13 +43,9 @@ public abstract class OnBlockBreakEventCore private int uses = 0; private long usesElapsedTimeNano = 0L; -// private boolean teExplosionTriggerEnabled; - private AutoFeaturesWrapper autoFeatureWrapper = null; -// private Boolean crazyEnchantEnabled; - private Random random = new Random(); @@ -58,11 +54,6 @@ public OnBlockBreakEventCore() { this.autoFeatureWrapper = AutoFeaturesWrapper.getInstance(); - - -// this.teExplosionTriggerEnabled = true; - -// this.crazyEnchantEnabled = null; } @@ -155,316 +146,10 @@ public enum ItemLoreEnablers { } - - -// protected void genericBlockEventMonitor( BlockBreakEvent e ) { -// genericBlockEvent( e, true, false, false ); -// } -// -// protected void genericBlockEvent( BlockBreakEvent e ) { -// genericBlockEvent( e, false, false, false ); -// } - -// protected void genericBlockEventAutoManager( BlockBreakEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericBlockEvent( e, false, blockEventsOnly, true ); -// } - - -// protected void genericBlockExplodeEventMonitor( TEBlockExplodeEvent e ) { -// genericBlockExplodeEvent( e, true, false, false ); -// } -// -// protected void genericBlockExplodeEvent( TEBlockExplodeEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericBlockExplodeEvent( e, false, blockEventsOnly, false ); -// } + -// protected void genericBlockExplodeEventAutoManager( TEBlockExplodeEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericBlockExplodeEvent( e, false, blockEventsOnly, true ); -// } -// protected void genericBlockExplodeEventMonitor( BlastUseEvent e ) { -// genericBlastUseEvent( e, true, false, false ); -// } -// -// protected void genericBlockExplodeEvent( BlastUseEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericBlastUseEvent( e, false, blockEventsOnly, false ); -// } - -// protected void genericBlockExplodeEventAutoManager( BlastUseEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericBlastUseEvent( e, false, blockEventsOnly, true ); -// } - - -// /** -// * For Pulsi_'s PrisonEnchants plugin: -// * -// * @param e -// */ -// protected void genericBlockExplodeEventMonitor( PEExplosionEvent e ) { -// genericExplosiveEvent( e, true, false, false ); -// } -// -// /** -// * For Pulsi_'s PrisonEnchants plugin: -// * -// * @param e -// */ -// protected void genericBlockExplodeEvent( PEExplosionEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericExplosiveEvent( e, false, blockEventsOnly, false ); -// } - -// /** -// * For Pulsi_'s PrisonEnchants plugin: -// * -// * @param e -// */ -// protected void genericBlockExplodeEventAutoManager( PEExplosionEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericExplosiveEvent( e, false, blockEventsOnly, true ); -// } - - - - -// /** -// * For Prison's very own ExplosiveBlockBreakEvent: -// * -// * @param e -// */ -// protected void genericBlockExplodeEventMonitor( ExplosiveBlockBreakEvent e ) { -// genericExplosiveEvent( e, true, false, false ); -// } -// -// /** -// * For Prison's very own ExplosiveBlockBreakEvent: -// * -// * @param e -// */ -// protected void genericBlockExplodeEvent( ExplosiveBlockBreakEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericExplosiveEvent( e, false, blockEventsOnly, false ); -// } - -// /** -// * For Prison's very own ExplosiveBlockBreakEvent: -// * -// * @param e -// */ -// protected void genericBlockExplodeEventAutoManager( ExplosiveBlockBreakEvent e ) { -// // NOTE: If autoManager is turned off, then process only the blockEvents: -// boolean blockEventsOnly = !isBoolean(AutoFeatures.isAutoManagerEnabled); -// genericExplosiveEvent( e, false, blockEventsOnly, true ); -// } - -// protected boolean processMinesBlockBreakEvent( Cancellable event, Player player, Block block ) { -// boolean processEvent = true; -// -// SpigotBlock sBlock = new SpigotBlock( block ); -// if ( BlockUtils.getInstance().isUnbreakable( sBlock ) ) { -// event.setCancelled( true ); -// processEvent = false; -// } -// -// Mine mine = findMine( player, sBlock, null, null ); -// -// if ( mine == null ) { -// // Prison is unable to process blocks outside of mines right now, so exit: -// processEvent = false; -// } -// -// // If not minable, then display message and exit. -// if ( !mine.getMineStateMutex().isMinable() ) { -// -// SpigotPlayer sPlayer = new SpigotPlayer( player ); -// sPlayer.setActionBar( "Mine " + mine.getTag() + " is being reset... please wait." ); -// event.setCancelled( true ); -// processEvent = false; -// } -// MineTargetPrisonBlock targetBlock = mine.getTargetPrisonBlock( sBlock ); -// -// // If ignore all block events, then exit this function without logging anything: -// if ( targetBlock.isIgnoreAllBlockEvents() ) { -// event.setCancelled( true ); -// processEvent = false; -// } -// -// -// return processEvent; -// } - -// /** -// *

This genericBlockEvent handles the basics of a BlockBreakEvent to see if it has happened -// * within a mine or not. If it is happening within a mine, then we process it with the doAction() -// * function. -// *

-// * -// * @param e -// * @param montior Identifies that a monitor event called this function. A monitor should only record -// * block break counts. -// */ -// public void genericBlockEvent( BlockBreakEvent e, BlockBreakPriority bbPriority ) { -// -//// boolean monitor, boolean blockEventsOnly, -//// boolean autoManager ) { -// -// if ( e instanceof PrisonMinesBlockBreakEvent ) { -// return; -// } -// -// long start = System.nanoTime(); -// -// if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { -// return; -// } -// -// -// // Register all external events such as mcMMO and EZBlocks: -// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); -// -// StringBuilder debugInfo = new StringBuilder(); -// -// debugInfo.append( String.format( "### ** genericBlockEvent ** ### " + -// "(event: BlockBreakEvent, config: %s, priority: %s, canceled: %s) ", -// bbPriority.name(), -// bbPriority.getBukkitEventPriority().name(), -// (e.isCancelled() ? "TRUE " : "FALSE") -// ) ); -// -// -// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { -// -// // Need to wrap in a Prison block so it can be used with the mines: -// SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); -// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); -// -// BlockEventType eventType = BlockEventType.blockBreak; -// String triggered = null; -// -// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), -// sBlock, sPlayer, bbPriority, eventType, triggered ); -// -// if ( !validateEvent( pmEvent, debugInfo ) ) { -// -// // 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 ); -// } -// } -// -// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { -// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. -// } -// -// // This is where the processing actually happens: -// else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && -// !isBoolean( AutoFeatures.pickupLimitToMines ) ) { -// debugInfo.append( "(normal processing initiating) " ); -// -// // Set the mine's PrisonBlockTypes for the block. Used to identify custom blocks. -// // Needed since processing of the block will lose track of which mine it came from. -// if ( pmEvent.getMine() != null ) { -// sBlock.setPrisonBlockTypes( pmEvent.getMine().getPrisonBlockTypes() ); -// } -// -// // check all external events such as mcMMO and EZBlocks: -// debugInfo.append( -// OnBlockBreakExternalEvents.getInstance().checkAllExternalEvents( e ) ); -// -// List explodedBlocks = new ArrayList<>(); -// pmEvent.setExplodedBlocks( explodedBlocks ); -//// String triggered = null; -// -//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), -//// pmEvent.getMine(), sBlock, explodedBlocks, BlockEventType.blockBreak, triggered ); -// Bukkit.getServer().getPluginManager().callEvent( pmEvent ); -// if ( pmEvent.isCancelled() ) { -// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); -// } -// else { -// -// // Cancel drops if so configured: -// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { -// -// try -// { -// e.setDropItems( false ); -// } -// 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 ); -// } -// } -// -// // doAction returns a boolean that indicates if the event should be canceled or not: -// if ( doAction( pmEvent, debugInfo ) ) { -//// if ( doAction( sBlock, pmEvent.getMine(), pmEvent.getPlayer(), debugInfo ) ) { -// -// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { -// e.setCancelled( true ); -// } -// else { -// -// debugInfo.append( "(event was not canceled) " ); -// } -// -// finalizeBreakTheBlocks( pmEvent ); -// -// doBlockEvents( pmEvent ); -// -// } -// else { -// -// debugInfo.append( "(doAction failed without details) " ); -// } -// -// } -// -// -// debugInfo.append( "(normal processing completed) " ); -// } -// else { -// -// debugInfo.append( "(logic bypass) " ); -// } -// -// } -// -// if ( debugInfo.length() > 0 ) { -// -// long stop = System.nanoTime(); -// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); -// -// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); -// } -// } - protected boolean ignoreMinesBlockBreakEvent( Cancellable event, Player player, Block block ) { MinesEventResults eventResults = ignoreMinesBlockBreakEvent( player, block ); @@ -1135,706 +820,7 @@ else if ( results && pmEvent.getBbPriority() == BlockBreakPriority.MONITOR && mi // return new ArrayList<>( results.values() ); // } -// /** -// *

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 handleTEBlockExplodeEvent( TEBlockExplodeEvent e, BlockBreakPriority bbPriority ) { -// -//// , boolean monitor, boolean blockEventsOnly, -//// boolean autoManager ) { -// -// long start = System.nanoTime(); -// -// if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { -// return; -// } -// -// -// // Register all external events such as mcMMO and EZBlocks: -// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); -// -// StringBuilder debugInfo = new StringBuilder(); -// -// -// debugInfo.append( String.format( "### ** genericBlockExplodeEvent ** ### " + -// "(event: TEBlockExplodeEvent, config: %s, priority: %s, canceled: %s) ", -// bbPriority.name(), -// bbPriority.getBukkitEventPriority().name(), -// (e.isCancelled() ? "TRUE " : "FALSE") -// ) ); -// -// -// -// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { -// -// -// -// -// String eP = getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority ); -// boolean isTEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); -// -// -// // Need to wrap in a Prison block so it can be used with the mines: -// SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); -// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); -// -// BlockEventType eventType = BlockEventType.TEXplosion; -// String triggered = checkCEExplosionTriggered( e ); -// -// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), -// sBlock, sPlayer, bbPriority, eventType, triggered ); -// -// // NOTE: Token Enchant will pass the event's block to prison, but that block may -// // have already been processed by prison. Therefore the PrisonMinesBlockBreakEvent -// // must enable the feature setForceIfAirBlock( true ). That block will not be used a -// // second time, but it will allow the explosion event to be processed. -// pmEvent.setForceIfAirBlock( true ); -// -// pmEvent.setUnprocessedRawBlocks( e.blockList() ); -// -// if ( !validateEvent( pmEvent, debugInfo ) ) { -// -// // 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 ); -// } -// } -// -// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { -// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. -// } -// -// -// -// // now process all blocks (non-monitor): -// else if ( isTEExplosiveEnabled && -// ( pmEvent.getMine() != null || pmEvent.getMine() == null && -// !isBoolean( AutoFeatures.pickupLimitToMines )) ) { -// -// -// if ( pmEvent.getExplodedBlocks().size() > 0 ) { -// -//// String triggered = checkCEExplosionTriggered( e ); -//// -//// -//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), -//// mine, block, explodedBlocks, BlockEventType.TEXplosion, triggered ); -// Bukkit.getServer().getPluginManager().callEvent( pmEvent ); -// if ( pmEvent.isCancelled() ) { -// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); -// } -// else { -// -// // Cancel drops if so configured: -// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { -// -// try -// { -// e.setYield( 0 ); -//// e.setDropItems( false ); -// } -// catch ( NoSuchMethodError e1 ) -// { -// String message = String.format( -// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + -// "is not valid for this version of Spigot. Modify the config settings and set " + -// "this value to `false`. [%s]", -// e1.getMessage() ); -// Output.get().logWarn( message ); -// } -// } -// -// // This is where the processing actually happens: -// if ( doAction( pmEvent, debugInfo ) ) { -// -// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { -// -// e.setCancelled( true ); -// } -// else { -// -// debugInfo.append( "(event was not canceled) " ); -// } -// -// finalizeBreakTheBlocks( pmEvent ); -// -// doBlockEvents( pmEvent ); -// -// } -// -// else { -// -// debugInfo.append( "(doAction failed without details) " ); -// } -// -// } -// -// } -// -// -// debugInfo.append( "(normal processing) " ); -// } -// else { -// -// debugInfo.append( "(logic bypass) " ); -// } -// -// } -// -// if ( debugInfo.length() > 0 ) { -// -// long stop = System.nanoTime(); -// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); -// -// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); -// } -// } -// - -// private String checkCEExplosionTriggered( TEBlockExplodeEvent e ) -// { -// String triggered = null; -// -// // Please be aware: This function is named the same as the auto features setting, but this is -// // not related. This is only trying to get the name of the enchantment that triggered the event. -// if ( isTeExplosionTriggerEnabled() ) { -// -// try { -// triggered = e.getTrigger(); -// } -// catch ( Exception | NoSuchMethodError ex ) { -// // Only print the error the first time, then suppress the error: -// String error = ex.getMessage(); -// -// Output.get().logError( "Error: Trying to access the TEBlockExplodeEvent.getTrigger() " + -// "function. Make sure you are using TokenEnchant v18.11.0 or newer. The new " + -// "getTrigger() function returns the TE Plugin that is firing the TEBlockExplodeEvent. " + -// "The Prison BlockEvents can be filtered by this triggered value. " + -// error ); -// -// // Disable collecting the trigger. -// setTeExplosionTriggerEnabled( false ); -// -// } -// } -// -// return triggered; -// } - - - -// /** -// *

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 handleBlastUseEvent( BlastUseEvent e, BlockBreakPriority bbPriority ) { -// -//// boolean monitor, boolean blockEventsOnly, -//// boolean autoManager ) { -// -// long start = System.nanoTime(); -// -// if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlockList().get( 0 )) ) { -// return; -// } -// -// -// // Register all external events such as mcMMO and EZBlocks: -// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); -// -// StringBuilder debugInfo = new StringBuilder(); -// -// debugInfo.append( String.format( "### ** genericBlastUseEvent ** ### " + -// "(event: BlastUseEvent, config: %s, priority: %s, canceled: %s) ", -// bbPriority.name(), -// bbPriority.getBukkitEventPriority().name(), -// (e.isCancelled() ? "TRUE " : "FALSE") -// ) ); -// -// -// // NOTE that check for auto manager has happened prior to accessing this function. -// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR && -// e.getBlockList().size() > 0 ) { -// -// -// String eP = getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority ); -// boolean isCEBlockExplodeEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); -// -// -// Block bukkitBlock = e.getBlockList().get( 0 ); -// -// // Need to wrap in a Prison block so it can be used with the mines: -// SpigotBlock sBlock = SpigotBlock.getSpigotBlock( bukkitBlock ); -// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); -// -// BlockEventType eventType = BlockEventType.CEXplosion; -// String triggered = null; -// -// -// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( bukkitBlock, e.getPlayer(), -// sBlock, sPlayer, bbPriority, eventType, triggered ); -// -// -// for ( int i = 1; i < e.getBlockList().size(); i++ ) { -// pmEvent.getUnprocessedRawBlocks().add( e.getBlockList().get( i ) ); -// } -// -// -// if ( !validateEvent( pmEvent, debugInfo ) ) { -// -// // 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 ); -// } -// } -// -// -// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { -// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. -// } -// -// -// -// // now process all blocks (non-monitor): -// else if ( isCEBlockExplodeEnabled && -// ( pmEvent.getMine() != null || pmEvent.getMine() == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { -// -// -// if ( pmEvent.getExplodedBlocks().size() > 0 ) { -// -//// String triggered = null; -// -// -// // Warning: BlastUseEvent does not identify the block the player actually hit, so the dummyBlock -// // is just a random first block from the explodedBlocks list and may not be the block -// // that initiated the explosion event. -//// SpigotBlock dummyBlock = explodedBlocks.get( 0 ); -// -//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), -//// mine, dummyBlock, explodedBlocks, BlockEventType.CEXplosion, triggered ); -// Bukkit.getServer().getPluginManager().callEvent(pmEvent); -// if ( pmEvent.isCancelled() ) { -// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); -// } -// else { -// -//// // Cancel drops if so configured: -//// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { -//// -//// try -//// { -//// e.setDropItems( false ); -//// } -//// catch ( NoSuchMethodError e1 ) -//// { -//// String message = String.format( -//// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + -//// "is not valid for this version of Spigot. Modify the config settings and set " + -//// "this value to `false`. [%s]", -//// e1.getMessage() ); -//// Output.get().logWarn( message ); -//// } -//// } -// -// if ( doAction( pmEvent, debugInfo ) ) { -// -// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { -// -// e.setCancelled( true ); -// } -// else { -// -// debugInfo.append( "(event was not canceled) " ); -// } -// -// finalizeBreakTheBlocks( pmEvent ); -// -// doBlockEvents( pmEvent ); -// -// } -// -// else { -// -// debugInfo.append( "(doAction failed without details) " ); -// } -// -// } -// } -// -// -// debugInfo.append( "(normal processing) " ); -// } -// else { -// -// debugInfo.append( "(logic bypass) " ); -// } -// -// } -// -// if ( debugInfo.length() > 0 ) { -// -// long stop = System.nanoTime(); -// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); -// -// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); -// } -// } - - - -// /** -// *

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 handlePEExplosionEvent( PEExplosionEvent e, BlockBreakPriority bbPriority) { -// -// -//// , boolean monitor, boolean blockEventsOnly, -//// boolean autoManager ) { -// -// long start = System.nanoTime(); -// -// if ( e.isCancelled() || processMinesBlockBreakEvent( e, e.getPlayer(), e.getBlockBroken()) ) { -// return; -// } -// -// -// // Register all external events such as mcMMO and EZBlocks: -// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); -// -// StringBuilder debugInfo = new StringBuilder(); -// -// -// debugInfo.append( String.format( "### ** genericExplosiveEvent (Pulsi) ** ### " + -// "(event: PEExplosionEvent, config: %s, priority: %s, canceled: %s) ", -// bbPriority.name(), -// bbPriority.getBukkitEventPriority().name(), -// (e.isCancelled() ? "TRUE " : "FALSE") -// ) ); -// -// -// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { -// -// -// -// String eP = getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority ); -// boolean isPEExplosiveEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); -// -// -// // Need to wrap in a Prison block so it can be used with the mines: -// SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlockBroken()); -// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); -// -// BlockEventType eventType = BlockEventType.PEExplosive; -// String triggered = null; // e.getTriggeredBy(); -// -// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlockBroken(), e.getPlayer(), -// sBlock, sPlayer, bbPriority, eventType, triggered ); -// -// pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); -// -// -// if ( !validateEvent( pmEvent, debugInfo ) ) { -// -// // 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 ); -// } -// } -// -// -// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { -// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. -// } -// -// -// -// // now process all blocks (non-monitor): -// else if ( isPEExplosiveEnabled && -// ( pmEvent.getMine() != null || pmEvent.getMine() == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { -// if ( pmEvent.getExplodedBlocks().size() > 0 ) { -// -//// String triggered = null; -// -// -//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), -//// mine, dummyBlock, explodedBlocks, BlockEventType.PEExplosive, triggered ); -// Bukkit.getServer().getPluginManager().callEvent(pmEvent); -// if ( pmEvent.isCancelled() ) { -// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); -// } -// else { -// -//// // Cancel drops if so configured: -//// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { -//// -//// try -//// { -//// e.setDropItems( false ); -//// } -//// catch ( NoSuchMethodError e1 ) -//// { -//// String message = String.format( -//// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + -//// "is not valid for this version of Spigot. Modify the config settings and set " + -//// "this value to `false`. [%s]", -//// e1.getMessage() ); -//// Output.get().logWarn( message ); -//// } -//// } -// -// if ( doAction( pmEvent, debugInfo ) ) { -// -// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { -// -// e.setCancelled( true ); -// } -// else { -// -// debugInfo.append( "(event was not canceled) " ); -// } -// -// finalizeBreakTheBlocks( pmEvent ); -// -// doBlockEvents( pmEvent ); -// -// } -// -// else { -// -// debugInfo.append( "(doAction failed without details) " ); -// } -// -// } -// } -// -// -// debugInfo.append( "(normal processing) " ); -// } -// else { -// -// debugInfo.append( "(logic bypass) " ); -// } -// -// } -// -// if ( debugInfo.length() > 0 ) { -// -// long stop = System.nanoTime(); -// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); -// -// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); -// } -// -// } - -// protected void handleExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e, BlockBreakPriority bbPriority ) { -// -//// boolean monitor, boolean blockEventsOnly, -//// boolean autoManager ) { -// -// long start = System.nanoTime(); -// -// if ( e.isCancelled() || ignoreMinesBlockBreakEvent( e, e.getPlayer(), e.getBlock()) ) { -// return; -// } -// -// -// // Register all external events such as mcMMO and EZBlocks: -// OnBlockBreakExternalEvents.getInstance().registerAllExternalEvents(); -// -// StringBuilder debugInfo = new StringBuilder(); -// -// -// debugInfo.append( String.format( "### ** genericExplosiveEvent (Prisons's bombs) ** ### " + -// "(event: ExplosiveBlockBreakEvent, config: %s, priority: %s, canceled: %s) ", -// bbPriority.name(), -// bbPriority.getBukkitEventPriority().name(), -// (e.isCancelled() ? "TRUE " : "FALSE") -// ) ); -// -// -// if ( bbPriority != BlockBreakPriority.MONITOR && !e.isCancelled() || bbPriority == BlockBreakPriority.MONITOR ) { -// -// -// String eP = getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority ); -// boolean isPPrisonExplosiveBlockBreakEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP ); -// -// -// // Need to wrap in a Prison block so it can be used with the mines: -// SpigotBlock sBlock = SpigotBlock.getSpigotBlock(e.getBlock()); -// SpigotPlayer sPlayer = new SpigotPlayer(e.getPlayer()); -// -// BlockEventType eventType = BlockEventType.PrisonExplosion; -// String triggered = e.getTriggeredBy(); -// -// PrisonMinesBlockBreakEvent pmEvent = new PrisonMinesBlockBreakEvent( e.getBlock(), e.getPlayer(), -// sBlock, sPlayer, bbPriority, eventType, triggered ); -// -// -// // If this event is fired, but yet there are no exploded blocks, then do not set -// // forceIfAirBlock to true so this event is skipped. -// if ( e.getExplodedBlocks() != null && e.getExplodedBlocks().size() > 0 ) { -// -// pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() ); -// pmEvent.setForceIfAirBlock( e.isForceIfAirBlock() ); -// } -// -// -// -// // Warning: toolInHand really needs to be defined in the event if the source is a -// // Mine Bomb, otherwise auto features will detect the player is holding -// // a mine bomb which is not a pickaxe so the drops will be ZERO. If they -// // used their last mine bomb, then auto features will detect only AIR -// // in their hand. -// if ( e.getToolInHand() != null ) { -// pmEvent.setItemInHand( (SpigotItemStack) e.getToolInHand() ); -// -// } -// -// // Note: If the mineBomb is set, then the bomb itself uses a pseudo -// // tool in hand, so need to disable durability calculations since -// // if the pseudo tool breaks, it will clear the player's in-hand -// // inventory stack, which will be more mine bombs if they had more -// // than one. -// if ( e.getMineBomb() != null ) { -// pmEvent.setCalculateDurability( false ); -// } -// -// if ( !validateEvent( pmEvent, debugInfo ) ) { -// -// // 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 ); -// } -// } -// -// -// else if ( pmEvent.getBbPriority() == BlockBreakPriority.MONITOR ) { -// // Stop here, and prevent additional processing. Monitors should never process the event beyond this. -// } -// -// -// -// // now process all blocks (non-monitor): -// else if ( isPPrisonExplosiveBlockBreakEnabled && -// ( pmEvent.getMine() != null || pmEvent.getMine() == null && -// !isBoolean( AutoFeatures.pickupLimitToMines )) ) { -// -// if ( pmEvent.getExplodedBlocks().size() > 0 ) { -// -//// String triggered = null; -// -// -//// PrisonMinesBlockBreakEvent pmbbEvent = new PrisonMinesBlockBreakEvent( dummyBlock.getWrapper(), e.getPlayer(), -//// mine, dummyBlock, explodedBlocks, BlockEventType.PEExplosive, triggered ); -// Bukkit.getServer().getPluginManager().callEvent(pmEvent); -// if ( pmEvent.isCancelled() ) { -// debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); -// } -// else { -// -// // Cancel drops if so configured: -// if ( isBoolean( AutoFeatures.cancelAllBlockEventBlockDrops ) ) { -// -// try -// { -// e.setDropItems( false ); -// } -// catch ( NoSuchMethodError e1 ) -// { -// String message = String.format( -// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " + -// "is not valid for this version of Spigot. Modify the config settings and set " + -// "this value to `false`. [%s]", -// e1.getMessage() ); -// Output.get().logWarn( message ); -// } -// } -// -// if ( doAction( pmEvent, debugInfo ) ) { -// -// if ( isBoolean( AutoFeatures.cancelAllBlockBreakEvents ) ) { -// -// e.setCancelled( true ); -// } -// else { -// -// debugInfo.append( "(event was not canceled) " ); -// } -// -// finalizeBreakTheBlocks( pmEvent ); -// -// doBlockEvents( pmEvent ); -// -// } -// -// else { -// -// debugInfo.append( "(doAction failed without details) " ); -// } -// -// } -// } -// -// -// debugInfo.append( "(normal processing) " ); -// } -// else { -// -// debugInfo.append( "(logic bypass) " ); -// } -// -// } -// -// if ( debugInfo.length() > 0 ) { -// -// long stop = System.nanoTime(); -// debugInfo.append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" ); -// -// Output.get().logDebug( DebugTarget.blockBreak, debugInfo.toString() ); -// } -// -// } - public void doActionMonitor( SpigotBlock block, Mine mine ) { From dcc17b213ec7aca57a3fe061bbd8e444a70b032f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Mar 2022 02:36:27 -0400 Subject: [PATCH 176/297] Prison version: including more information on ranks and add the ladder rank listing to the prison version command. --- docs/changelog_v3.3.x.md | 4 +++ .../prison/modules/ModuleManager.java | 22 ++++++++++--- .../resources/lang/ranks/en_US.properties | 4 +-- .../resources/lang/ranks/zh_TW.properties | 5 +-- .../mcprison/prison/ranks/PrisonRanks.java | 20 +++++++++--- .../prison/ranks/PrisonRanksMessages.java | 13 +++++--- .../prison/ranks/managers/RankManager.java | 31 ++++++++++++++----- .../prison/spigot/SpigotPlatform.java | 31 +++++++++++++++++++ 8 files changed, 106 insertions(+), 24 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 98ad41773..24ee3be8e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,8 +16,12 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **Prison version: including more information on ranks and add the ladder rank listing to the prison version command.** + + * **Removed some old code from block event processing...** + * **Mine bombs getting a replacement blocks from the player's location.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/modules/ModuleManager.java b/prison-core/src/main/java/tech/mcprison/prison/modules/ModuleManager.java index d88a57f7e..a56e5b6e9 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/modules/ModuleManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/modules/ModuleManager.java @@ -18,15 +18,16 @@ package tech.mcprison.prison.modules; -import tech.mcprison.prison.Prison; -import tech.mcprison.prison.PrisonAPI; -import tech.mcprison.prison.output.Output; - import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import tech.mcprison.prison.Prison; +import tech.mcprison.prison.PrisonAPI; +import tech.mcprison.prison.modules.ModuleStatus.Status; +import tech.mcprison.prison.output.Output; + /** * Keeps track of each module and each module's status. * @@ -206,4 +207,17 @@ public File getModuleRoot() { } + public boolean isModuleActive(String moduleName) { + boolean results = false; + + if ( moduleName != null ) { + + Module module = getModule(moduleName).orElse(null); + if ( module != null ) { + results = module.getStatus().getStatus() == Status.ENABLED; + } + } + + return results; + } } diff --git a/prison-core/src/main/resources/lang/ranks/en_US.properties b/prison-core/src/main/resources/lang/ranks/en_US.properties index 0616441d5..b0b22b070 100644 --- a/prison-core/src/main/resources/lang/ranks/en_US.properties +++ b/prison-core/src/main/resources/lang/ranks/en_US.properties @@ -50,7 +50,7 @@ ## -messages__version=23 +messages__version=24 messages__auto_refresh=true ranks_rankup__rankup_no_player_name=You have @@ -120,7 +120,7 @@ ranks_prisonRanks__failure_loading_players=A player file failed to load. %1 ranks_prisonRanks__failed_loading_players=&cFailed Loading Players: %1 ranks_prisonRanks__failed_to_load_player_file=A player file failed to load. %1 -ranks_prisonRanks__status_loaded_ranks=Loaded %1 ranks. +ranks_prisonRanks__status_loaded_ranks=Loaded %1 total ranks. default ranks: %2 prestige ranks: %3 other ranks: %4 ranks_prisonRanks__status_loaded_ladders=Loaded %1 ladders. ranks_prisonRanks__status_loaded_players=Loaded %1 players. diff --git a/prison-core/src/main/resources/lang/ranks/zh_TW.properties b/prison-core/src/main/resources/lang/ranks/zh_TW.properties index 4271e2b12..a76592fe1 100644 --- a/prison-core/src/main/resources/lang/ranks/zh_TW.properties +++ b/prison-core/src/main/resources/lang/ranks/zh_TW.properties @@ -50,7 +50,7 @@ ## -messages__version=4 +messages__version=5 messages__auto_refresh=true ranks_rankup__rankup_no_player_name=您已經 @@ -114,7 +114,8 @@ ranks_prisonRanks__failure_loading_players=玩家資料資料失敗. %1 ranks_prisonRanks__failed_loading_players=&c無法載入玩家: %1 ranks_prisonRanks__failed_to_load_player_file=玩家資料載入失敗. %1 -ranks_prisonRanks__status_loaded_ranks=載入 %1 階級 +ranks_prisonRanks__status_loaded_ranks=載入 %1 éšŽç´ default ranks: %2 prestige ranks: %3 other ranks: %4 +š ranks_prisonRanks__status_loaded_ladders=載入 %1 階 ranks_prisonRanks__status_loaded_players=載入 %1 玩家 diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java index a438541a7..5d77ab6c2 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java @@ -43,7 +43,7 @@ import tech.mcprison.prison.ranks.managers.LadderManager; import tech.mcprison.prison.ranks.managers.PlayerManager; import tech.mcprison.prison.ranks.managers.RankManager; -import tech.mcprison.prison.ranks.managers.RankManager.RanksByLadderOptions; +import tech.mcprison.prison.ranks.tasks.RanksStartupPlayerValidationsAsyncTask; import tech.mcprison.prison.store.Collection; import tech.mcprison.prison.store.Database; @@ -238,18 +238,28 @@ public void enable() { ConversionManager.getInstance().registerConversionAgent(new RankConversionAgent()); - logStartupMessage( prisonRanksStatusLoadedRanksMsg( getRankCount() ) ); - logStartupMessage( prisonRanksStatusLoadedLaddersMsg( getladderCount() ) ); + int totalRanks = getRankCount(); + int defaultRanks = getDefaultLadderRankCount(); + int prestigesRanks = getPrestigesLadderRankCount(); + int otherRanks = totalRanks - defaultRanks - prestigesRanks; + + logStartupMessage( prisonRanksStatusLoadedRanksMsg( + totalRanks, defaultRanks, prestigesRanks, otherRanks ) ); + logStartupMessage( prisonRanksStatusLoadedPlayersMsg( getPlayersCount() ) ); // Display all Ranks in each ladder: - PrisonRanks.getInstance().getRankManager().ranksByLadders( RanksByLadderOptions.allRanks ); + List rankDetails = PrisonRanks.getInstance().getRankManager().ranksByLadders(); + for (String msg : rankDetails) { + Output.get().logInfo(msg); + } // boolean includeAll = true; // PrisonRanks.getInstance().getRankManager().ranksByLadders( includeAll ); + } @@ -322,6 +332,8 @@ public void checkAllPlayersForJoin() Output.get().logInfo( prisonRankAddedAndFixedPlayers( addedPlayers, fixedPlayers ) ); } } + + Output.get().logInfo( "Ranks: Finished First Join Checks." ); } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanksMessages.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanksMessages.java index 899447ab9..579db0592 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanksMessages.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanksMessages.java @@ -99,16 +99,21 @@ protected String prisonRanksFailedToLoadPlayFileMsg( String errorMessage ) { .localize(); } - protected String prisonRanksStatusLoadedRanksMsg( int rankCount ) { + public String prisonRanksStatusLoadedRanksMsg( int totalRanksCount, + int defaultRanks, int prestigesRanks, int otherRanks ) { return PrisonRanks.getInstance().getRanksMessages() .getLocalizable( "ranks_prisonRanks__status_loaded_ranks" ) .withReplacements( - Integer.toString( rankCount ) ) + Integer.toString( totalRanksCount ), + Integer.toString( defaultRanks ), + Integer.toString( prestigesRanks ), + Integer.toString( otherRanks ) + ) .localize(); } - protected String prisonRanksStatusLoadedLaddersMsg( int ladderCount ) { + public String prisonRanksStatusLoadedLaddersMsg( int ladderCount ) { return PrisonRanks.getInstance().getRanksMessages() .getLocalizable( "ranks_prisonRanks__status_loaded_ladders" ) @@ -117,7 +122,7 @@ protected String prisonRanksStatusLoadedLaddersMsg( int ladderCount ) { .localize(); } - protected String prisonRanksStatusLoadedPlayersMsg( int playerCount ) { + public String prisonRanksStatusLoadedPlayersMsg( int playerCount ) { return PrisonRanks.getInstance().getRanksMessages() .getLocalizable( "ranks_prisonRanks__status_loaded_players" ) 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 9c4019b91..39648ee43 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 @@ -555,7 +555,7 @@ public String listAllRanks( String ladderName, List ranks, RanksByLadderOp sb.append( ", " ); if ( count >= 10 && (count - 1) % 15 == 0 ) { - sb.append( "\n " ); + sb.append( "{br} " ); } } @@ -600,20 +600,33 @@ public String listAllRanks( String ladderName, List ranks, RanksByLadderOp * * @param includeAll If true then includes all ranks, otherwise just ranks within one more players */ - public void ranksByLadders( RanksByLadderOptions option ) { - ranksByLadders( null, "all", option ); + public List ranksByLadders() { + return ranksByLadders( "all", RanksByLadderOptions.allRanks ); } public void ranksByLadders( CommandSender sender, RanksByLadderOptions option ) { - ranksByLadders( sender, "all", option ); + List results = ranksByLadders( "all", option ); + for (String msg : results) { + rankByLadderOutput( sender, msg ); + } } public void ranksByLadders( CommandSender sender, String ladderName, RanksByLadderOptions option ) { + List results = ranksByLadders( ladderName, option ); + for (String msg : results) { + rankByLadderOutput( sender, msg ); + } + } + + private List ranksByLadders( String ladderName, RanksByLadderOptions option ) { + List results = new ArrayList<>(); + + Localizable localManagerLog = PrisonRanks.getInstance().getRanksMessages() .getLocalizable( "ranks_rankManager__ranks_by_ladders" ); - rankByLadderOutput( sender, localManagerLog.localize() ); + results.add( localManagerLog.localize() ); // Track which ranks were included in the ladders listed: List ranksIncluded = new ArrayList<>(); @@ -626,7 +639,7 @@ public void ranksByLadders( CommandSender sender, String ladderName, RanksByLadd String ranksByLadder = listAllRanks( ladder.getName(), ladderRanks, option ); - rankByLadderOutput( sender, ranksByLadder ); + results.add( ranksByLadder ); } } @@ -641,10 +654,12 @@ public void ranksByLadders( CommandSender sender, String ladderName, RanksByLadd // so enable "true" for includeAll to list all ranks that are not tied to ladders // since player count will always be zero. // Update: Set the RanksByLadderOptions to full - String ranksByLadder = listAllRanks( "none", ranksExcluded, RanksByLadderOptions.full ); + String ranksByLadder = listAllRanks( "(*no-ladder*)", ranksExcluded, RanksByLadderOptions.full ); - rankByLadderOutput( sender, ranksByLadder ); + results.add( ranksByLadder ); } + + return results; } private void rankByLadderOutput( CommandSender sender, String ranksByLadder ) { 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 ef6e0b14b..66dc11a53 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 @@ -91,6 +91,7 @@ import tech.mcprison.prison.ranks.data.RankPlayerFactory; import tech.mcprison.prison.ranks.managers.PlayerManager; import tech.mcprison.prison.ranks.managers.RankManager; +import tech.mcprison.prison.ranks.managers.RankManager.RanksByLadderOptions; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerBlockBreakEvents; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerCrazyEnchants; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerPrisonEnchants; @@ -1973,6 +1974,36 @@ public List getActiveFeatures() { List results = new ArrayList<>(); + // Log rank related items first: + if ( Prison.get().getModuleManager().isModuleActive( PrisonRanks.MODULE_NAME ) ) { + + PrisonRanks pRanks = PrisonRanks.getInstance(); + + results.add( + pRanks.prisonRanksStatusLoadedLaddersMsg( + pRanks.getladderCount() ) ); + + int totalRanks = pRanks.getRankCount(); + int defaultRanks = pRanks.getDefaultLadderRankCount(); + int prestigesRanks = pRanks.getPrestigesLadderRankCount(); + int otherRanks = totalRanks - defaultRanks - prestigesRanks; + + results.add( + pRanks.prisonRanksStatusLoadedRanksMsg( + totalRanks, defaultRanks, prestigesRanks, otherRanks ) ); + + results.add( + pRanks.prisonRanksStatusLoadedPlayersMsg( + pRanks.getPlayersCount() ) ); + + + // Display all Ranks in each ladder: + results.addAll( + PrisonRanks.getInstance().getRankManager().ranksByLadders() ); + + results.add( " " ); + } + AutoFeaturesWrapper afw = AutoFeaturesWrapper.getInstance(); From badd6a622cbe806df4c5344f8cea056edef34acd Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Mar 2022 02:54:45 -0400 Subject: [PATCH 177/297] Prison startup performance fix: On large servers with many players, the process of getting the player's balance from the economy plugin can cause significant delays if that plugin is not able to handle the load... so the validation of the players and the sorting of the top-n list is now ran in an async thread so it will not cause lag or delays on startup. --- docs/changelog_v3.3.x.md | 4 ++ .../mcprison/prison/ranks/PrisonRanks.java | 10 +++-- .../prison/ranks/managers/PlayerManager.java | 10 ++++- ...anksStartupPlayerValidationsAsyncTask.java | 38 +++++++++++++++++++ 4 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 prison-ranks/src/main/java/tech/mcprison/prison/ranks/tasks/RanksStartupPlayerValidationsAsyncTask.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 24ee3be8e..638996b67 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -16,6 +16,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9c 2022-03-13 +* **Prison startup performance fix: On large servers with many players, the process of getting the player's balance from the economy plugin can cause significant delays if that plugin is not able to handle the load...** +so the validation of the players and the sorting of the top-n list is now ran in an async thread so it will not cause lag or delays on startup. + + * **Prison version: including more information on ranks and add the ladder rank listing to the prison version command.** diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java index 5d77ab6c2..732c3e872 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java @@ -225,10 +225,6 @@ public void enable() { Output.get().logInfo( "Ranks: Finished registering Rank Commands." ); - // Check all players to see if any need to join: - checkAllPlayersForJoin(); - - Output.get().logInfo( "Ranks: Finished First Join Checks." ); // Load up all else @@ -260,6 +256,12 @@ public void enable() { // PrisonRanks.getInstance().getRankManager().ranksByLadders( includeAll ); + + // Check all players to see if any need to join: + RanksStartupPlayerValidationsAsyncTask.submitTaskSync( this ); +// checkAllPlayersForJoin(); + + } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index cdf6d5fd7..bc2c1a9ec 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -152,8 +152,9 @@ public void loadPlayers() throws IOException { } - - Collections.sort( playersByTop, sorterTopN ); + // NOTE: The following is very expensive operation if the players balance + // needs to be retrieved: + // sortPlayerByTopRanked(); // players.forEach( @@ -161,6 +162,11 @@ public void loadPlayers() throws IOException { // this.players.add( // rankPlayerFactory.createRankPlayer(document) )); } + + public void sortPlayerByTopRanked() { + + Collections.sort( playersByTop, sorterTopN ); + } /** * Saves a {@link RankPlayer} to disk. diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/tasks/RanksStartupPlayerValidationsAsyncTask.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/tasks/RanksStartupPlayerValidationsAsyncTask.java new file mode 100644 index 000000000..be2d02fae --- /dev/null +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/tasks/RanksStartupPlayerValidationsAsyncTask.java @@ -0,0 +1,38 @@ +package tech.mcprison.prison.ranks.tasks; + +import tech.mcprison.prison.ranks.PrisonRanks; +import tech.mcprison.prison.tasks.PrisonRunnable; +import tech.mcprison.prison.tasks.PrisonTaskSubmitter; + +public class RanksStartupPlayerValidationsAsyncTask + implements PrisonRunnable { + + private PrisonRanks pRanks; + + public RanksStartupPlayerValidationsAsyncTask( PrisonRanks pRanks ) { + super(); + + this.pRanks = pRanks; + } + + public static void submitTaskSync( PrisonRanks pRanks ) { + + RanksStartupPlayerValidationsAsyncTask rspvaTask = + new RanksStartupPlayerValidationsAsyncTask( pRanks ); + + PrisonTaskSubmitter.runTaskLaterAsync( rspvaTask, 0 ); + } + + @Override + public void run() { + + pRanks.checkAllPlayersForJoin(); + + + // The following can take awhile to run if there are a lot of players + // and if they need to load their balance. This is impacted moreso if + // there is a high cost to get the balance. + pRanks.getPlayerManager().sortPlayerByTopRanked(); + + } +} From f1a3702266bfb6ac9e7291577716d45d6446ae2f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Mar 2022 04:50:19 -0400 Subject: [PATCH 178/297] Top-n: More work to enable. Now supports /ranks topn. The rank-score and penalty is not yet enabled. Placeholders will be enabled after the command is fully functional. --- docs/changelog_v3.3.x.md | 6 +- .../prison/ranks/commands/RanksCommands.java | 94 +++++++++++++++++++ .../prison/ranks/managers/PlayerManager.java | 4 + .../RankPlayerSortOrderTopRanked.java | 18 ++-- 4 files changed, 112 insertions(+), 10 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 638996b67..5998bf762 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,11 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9c 2022-03-13 +# 3.3.0-alpha.9c 2022-03-14 + + +* **Top-n: More work to enable. Now supports /ranks topn, with alias /topn.** +The rank-score and penalty is not yet enabled. Placeholders will be enabled after the command is fully functional. * **Prison startup performance fix: On large servers with many players, the process of getting the player's balance from the economy plugin can cause significant delays if that plugin is not able to handle the load...** 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 4c14db41d..a6b6b7f7b 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 @@ -2033,6 +2033,100 @@ public void rankPlayers(CommandSender sender, + @Command(identifier = "ranks topn", description = "Shows the top-n ranked players on the server. " + + "The rankings are calculated by prestiges ladder, default ladder, and then by the " + + "player's balance which is used to generate a rank-score. If enabled, players who " + + "do not rankup when they can, will be penalized with their excessive balance. ", + onlyPlayers = false, aliases="topn") + public void rankTopN(CommandSender sender, + @Arg(name = "page", def = "1", + description = "Page number [1]") String pageNumber, + @Arg(name = "pageSize", def = "10", + description = "Page size [10]") String pageSizeNumber){ + + int page = 1; + int pageSize = 10; + + + try { + page = Integer.parseInt(pageNumber); + } + catch (NumberFormatException e ) { + // Ignore: will use defaults + } + try { + pageSize = Integer.parseInt(pageSizeNumber); + } + catch (NumberFormatException e ) { + // Ignore: will use defaults + } + + if ( page <= 0 ) { + page = 1; + } + if ( pageSize <= 0 ) { + pageSize = 10; + } + + int totalPlayers = PrisonRanks.getInstance().getPlayerManager().getPlayers().size(); + int totalPages = (totalPlayers / pageSize) + (totalPlayers % pageSize == 0 ? 0 : 1); + + if ( page > totalPages ) { + page = totalPages; + } + + int posStart = (page - 1) * pageSize; + int posEnd = posStart + pageSize; + + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); + + List topN = PrisonRanks.getInstance().getPlayerManager().getPlayersByTop(); + + String header = String.format( + "Ranking %-14s %-9s %-6s %-7s %-7s", + "Player", + "Prestiges", + "Rank", + "Rank-Score", + "Penalty" + + ); + sender.sendMessage(header); + + for ( int i = posStart; i < posEnd && i < topN.size(); i++ ) { + RankPlayer rPlayer = topN.get(i); + + PlayerRank prestRank = rPlayer.getPlayerRankPrestiges(); + PlayerRank defRank = rPlayer.getPlayerRankDefault(); + + String prestRankTag = prestRank == null ? "---" : prestRank.getRank().getTag(); + String defRankTag = defRank == null ? "---" : defRank.getRank().getTag(); + + String prestRankTagNc = Text.stripColor(prestRankTag); + String defRankTagNc = Text.stripColor(defRankTag); + + String message = String.format( + " %-3d %-18s %-7s %-7s %7s %7s", + i + 1, + rPlayer.getName(), + prestRankTagNc, + defRankTagNc, + dFmt.format( rPlayer.getRankScore() ), + dFmt.format( rPlayer.getRankScorePenalty() ) + ); + + message = message + .replace(prestRankTagNc, prestRankTag + "&r") + .replace(defRankTagNc, defRankTag + "&r"); + sender.sendMessage(message); + } + + + + } + + + // /** // * This function is just an arbitrary test to access the various components. // * diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index bc2c1a9ec..822a84a15 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -252,6 +252,10 @@ public TreeMap getPlayersByName() { return playersByName; } + public List getPlayersByTop() { + return playersByTop; + } + public Set getPlayerErrors() { return playerErrors; } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankPlayerSortOrderTopRanked.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankPlayerSortOrderTopRanked.java index 0e8a2a907..a11570c67 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankPlayerSortOrderTopRanked.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankPlayerSortOrderTopRanked.java @@ -51,15 +51,15 @@ private int compareLadderPrestiges( RankPlayer rp1, RankPlayer rp2 ) { if ( rp1.getPlayerRankPrestiges() == null && rp2.getPlayerRankPrestiges() == null ) { results = 0; } -// else if ( rp2.getPlayerRankPrestiges() == null ) { -// Handled when comparing PlayerRanks... -// results = -1; -// } + else if ( rp2.getPlayerRankPrestiges() == null ) { +// Handled when comparing PlayerRanks... ?? + results = -1; + } else if ( rp1.getPlayerRankPrestiges() == null ) { results = 1; } else { - results = rp1.getPlayerRankPrestiges().compareTo( rp2.getPlayerRankPrestiges() ); + results = rp2.getPlayerRankPrestiges().compareTo( rp1.getPlayerRankPrestiges() ); } return results; @@ -71,15 +71,15 @@ private int compareLadderDefault( RankPlayer rp1, RankPlayer rp2 ) { if ( rp1.getPlayerRankDefault() == null && rp2.getPlayerRankDefault() == null ) { results = 0; } -// else if ( rp2.getPlayerRankDefault() == null ) { + else if ( rp2.getPlayerRankDefault() == null ) { // Handled when comparing PlayerRanks... -// results = -1; -// } + results = -1; + } else if ( rp1.getPlayerRankDefault() == null ) { results = 1; } else { - results = rp1.getPlayerRankDefault().compareTo( rp2.getPlayerRankDefault() ); + results = rp2.getPlayerRankDefault().compareTo( rp1.getPlayerRankDefault() ); } return results; From ce1127909d745b35c4ca15d4851b51da9b487ebe Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 14 Mar 2022 04:59:33 -0400 Subject: [PATCH 179/297] v3.3.0-alpha.9d --- 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 5998bf762..edb10fffe 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,7 +13,10 @@ These build logs represent the work that has been going on within prison. *Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* -# 3.3.0-alpha.9c 2022-03-14 +# 3.3.0-alpha.9e 2022-03-14 + + +* **3.3.0-alpha.9e 2022-03-14** * **Top-n: More work to enable. Now supports /ranks topn, with alias /topn.** diff --git a/gradle.properties b/gradle.properties index 72f1ac13d..fc3d15229 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.9d +version=3.3.0-alpha.9e #version=3.3.0-alpha.7 From 2db9f4da724bf701ba92f6ea226702d10b9f576e Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 16 Mar 2022 02:04:59 -0400 Subject: [PATCH 180/297] Fixed issue where ranking does not which rank is associated with each rank. Now the ranks will properly track the players at their ranks. --- docs/changelog_v3.3.x.md | 6 ++++-- .../mcprison/prison/ranks/data/RankPlayer.java | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index edb10fffe..5a5338a01 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -10,10 +10,12 @@ These build logs represent the work that has been going on within prison. -*Will continue as v3.3.0-alpha.7 2021-06-?? in the near future.* +# 3.3.0-alpha.9e 2022-03-16 -# 3.3.0-alpha.9e 2022-03-14 + +* **Fixed issue where ranking does not which rank is associated with each rank.** +Now the ranks will properly track the players at their ranks. * **3.3.0-alpha.9e 2022-03-14** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index 63bb7bf58..210d80246 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -361,6 +361,11 @@ public void addRank( Rank rank) { } if ( ladderRanks.containsKey( rank.getLadder() ) ) { + + // Remove the player from the old rank: + PlayerRank oldRank = ladderRanks.get( rank.getLadder() ); + oldRank.getRank().getPlayers().remove( this ); + ladderRanks.remove( rank.getLadder() ); } @@ -370,6 +375,10 @@ public void addRank( Rank rank) { ladderRanks.put( rank.getLadder(), pRank ); + // Add the player to the new rank: + rank.getPlayers().add( this ); + + // Calculate and apply the rank multipliers: recalculateRankMultipliers(); } @@ -1285,9 +1294,10 @@ private void checkRecalculateRankScore() { double currentBalance = getBalance( getRankScoreCurrency() ); - if ( currentBalance == getRankScoreBalance() || + if ( getRankScoreBalance() != 0 && ( + currentBalance == getRankScoreBalance() || currentBalance >= (getRankScoreBalance() - getRankScoreBalanceThreshold()) || - currentBalance <= (getRankScoreBalance() + getRankScoreBalanceThreshold() ) ) { + currentBalance <= (getRankScoreBalance() + getRankScoreBalanceThreshold() ) )) { // increment the cooldown since the balance is either the same, or still // within the threshold range: From 12d89c6b514db8048595f34cd80b38db415cdde2 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 18 Mar 2022 23:54:40 -0400 Subject: [PATCH 181/297] When validating the success of a rankup transaction's abiliity for the rankup cost to be applied, the validation is now checking to see if it's within a plus/minus of 1.0 from the target final balance of the player. This covers the inability of floats and doubles not being able to accurately repesent base 10 numbers all of the time, which the accuracy may be off by a small value such as 0.000001, but that will prevent an equality check from passing. By checking that it's within a range of plus/minus one will help prevent false failures. --- docs/changelog_v3.3.x.md | 7 ++++++- .../java/tech/mcprison/prison/ranks/RankUtil.java | 15 ++++++++++++++- .../tech/mcprison/prison/ranks/RankupResults.java | 8 ++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5a5338a01..9ba84eff9 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,12 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9e 2022-03-16 +# 3.3.0-alpha.9e 2022-03-19 + + +* **When validating the success of a rankup transaction's abiliity for the rankup cost to be applied, the validation is now checking to see if it's within a plus/minus of 1.0 from the target final balance of the player.** +This covers the inability of floats and doubles not being able to accurately repesent base 10 numbers all of the time, which the accuracy may be off by a small value such as 0.000001, but that will prevent an equality check from passing. +By checking that it's within a range of plus/minus one will help prevent false failures. * **Fixed issue where ranking does not which rank is associated with each rank.** diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java index 1fe7395e6..f3259b521 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java @@ -147,6 +147,8 @@ public enum RankupTransactions { economy_failed_to_update_player_balance, economy_failed_to_reverse_player_rankup_cost, economy_failed_to_apply_player_rankup_cost, + accuracy_out_of_range, + attempting_to_delete_ladder_from_player, @@ -545,7 +547,11 @@ else if ( pForceCharge == PromoteForceCharge.refund_player) { results.setBalanceFinal( balanceFinal ); // Check to ensure the player's balance is correct.. - if ( !success || balanceFinal != balanceTargetFinal ) { + double finalAccuracy = Math.abs( balanceTargetFinal - balanceFinal ); + if ( !success || finalAccuracy > 1.0 ) { + + results.addTransaction( RankupTransactions.accuracy_out_of_range ); + results.setRankupCostFinalAccuracy( finalAccuracy ); results.addTransaction( RankupStatus.RANKUP_FAILURE_ECONOMY_FAILED, RankupTransactions.economy_failed_to_update_player_balance ); @@ -928,6 +934,13 @@ private void logTransactionResults( RankupResults results ) break; + case accuracy_out_of_range: + sb.append( "=" ); + DecimalFormat sFmt = new DecimalFormat("#,##0.00000000"); + sb.append( sFmt.format( results.getRankupCostFinalAccuracy() ) ); + + break; + case rankupCommandsStart: sb.append( "=" ); sb.append( iFmt.format( results.getRankupCommandsAvailable() ) ); diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankupResults.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankupResults.java index 1d72a165b..4a6b703ff 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankupResults.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankupResults.java @@ -37,6 +37,7 @@ public class RankupResults { private double balanceInitial; private double balanceFinal; private String currency; + private double rankupCostFinalAccuracy; private int rankupCommandsAvailable = 0; private int rankupCommandsExecuted = 0; @@ -267,5 +268,12 @@ public long getTimestampStop() { public void setTimestampStop( long timestampStop ) { this.timestampStop = timestampStop; } + + public double getRankupCostFinalAccuracy() { + return rankupCostFinalAccuracy; + } + public void setRankupCostFinalAccuracy(double rankupCostFinalAccuracy) { + this.rankupCostFinalAccuracy = rankupCostFinalAccuracy; + } } From 330bd40d5cdd00551278007b19d7481c4afe6933 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 19 Mar 2022 00:19:52 -0400 Subject: [PATCH 182/297] Updated the rankup accuracy to be greater than or equal to 1.0. And conditionally only report the accuracy_out_of_range if >= 1.0. --- docs/changelog_v3.3.x.md | 4 ++++ .../main/java/tech/mcprison/prison/ranks/RankUtil.java | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9ba84eff9..5507c5bd8 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-19 +* **Updated the rankup accuracy to be greater than or equal to 1.0.** +And conditionally only report the accuracy_out_of_range if >= 1.0. + + * **When validating the success of a rankup transaction's abiliity for the rankup cost to be applied, the validation is now checking to see if it's within a plus/minus of 1.0 from the target final balance of the player.** This covers the inability of floats and doubles not being able to accurately repesent base 10 numbers all of the time, which the accuracy may be off by a small value such as 0.000001, but that will prevent an equality check from passing. By checking that it's within a range of plus/minus one will help prevent false failures. diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java index f3259b521..a692f3e43 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/RankUtil.java @@ -548,10 +548,13 @@ else if ( pForceCharge == PromoteForceCharge.refund_player) { // Check to ensure the player's balance is correct.. double finalAccuracy = Math.abs( balanceTargetFinal - balanceFinal ); - if ( !success || finalAccuracy > 1.0 ) { + if ( !success || finalAccuracy >= 1.0 ) { - results.addTransaction( RankupTransactions.accuracy_out_of_range ); - results.setRankupCostFinalAccuracy( finalAccuracy ); + if ( finalAccuracy >= 1.0 ) { + + results.addTransaction( RankupTransactions.accuracy_out_of_range ); + results.setRankupCostFinalAccuracy( finalAccuracy ); + } results.addTransaction( RankupStatus.RANKUP_FAILURE_ECONOMY_FAILED, RankupTransactions.economy_failed_to_update_player_balance ); From 65d83d1f4dabe0f357028d91c7f188f56bb253d2 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 21 Mar 2022 10:00:33 -0400 Subject: [PATCH 183/297] Slight update on how the top-n players are printed... simplifies and also cleans it up the formatting. --- docs/changelog_v3.3.x.md | 5 +- .../prison/ranks/data/RankPlayer.java | 51 +++++++++++++++++++ .../prison/ranks/commands/RanksCommands.java | 35 ++----------- 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5507c5bd8..210e82f53 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9e 2022-03-19 +# 3.3.0-alpha.9e 2022-03-21 + + +* **Slight update on how the top-n players are printed... simplifies and also cleans it up the formatting.** * **Updated the rankup accuracy to be greater than or equal to 1.0.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index 210d80246..60721c7c3 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -17,6 +17,7 @@ package tech.mcprison.prison.ranks.data; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -37,8 +38,10 @@ import tech.mcprison.prison.internal.inventory.Inventory; import tech.mcprison.prison.internal.scoreboard.Scoreboard; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.placeholders.PlaceholdersUtil; import tech.mcprison.prison.util.Gamemode; import tech.mcprison.prison.util.Location; +import tech.mcprison.prison.util.Text; /** * Represents a player with ranks. @@ -1309,6 +1312,54 @@ private void checkRecalculateRankScore() { } } + public static String printRankScoreLineHeader() { + String header = String.format( + "Ranking %-14s %-9s %-6s %-9s %-9s %-9s", + "Player", + "Prestiges", + "Rank", + "Balance", + "Rank-Score", + "Penalty" + + ); + return header; + } + + public String printRankScoreLine( int rankPostion ) { + + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); + + PlayerRank prestRank = getPlayerRankPrestiges(); + PlayerRank defRank = getPlayerRankDefault(); + + String prestRankTag = prestRank == null ? "---" : prestRank.getRank().getTag(); + String defRankTag = defRank == null ? "---" : defRank.getRank().getTag(); + + String prestRankTagNc = Text.stripColor(prestRankTag); + String defRankTagNc = Text.stripColor(defRankTag); + + String balanceStr = PlaceholdersUtil.formattedKmbtSISize( getBalance(), dFmt, " " ); + String sPenaltyStr = PlaceholdersUtil.formattedKmbtSISize( getRankScorePenalty(), dFmt, " " ); + + String message = String.format( + " %-3d %-18s %-7s %-7s %9s %9s %9s", + (rankPostion > 0 ? rankPostion : ""), + getName(), + prestRankTagNc, + defRankTagNc, + balanceStr, + dFmt.format( getRankScore() ), + sPenaltyStr + ); + + message = message + .replace(prestRankTagNc, prestRankTag + "&r") + .replace(defRankTagNc, defRankTag + "&r"); + + return message; + } + public boolean isHesitancyDelayPenaltyEnabled() { return Prison.get().getPlatform() .getConfigBooleanTrue( "top-stats.rank-players.hesitancy-delay-penalty" ); 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 a6b6b7f7b..33895ed59 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 @@ -2078,46 +2078,17 @@ public void rankTopN(CommandSender sender, int posStart = (page - 1) * pageSize; int posEnd = posStart + pageSize; - DecimalFormat dFmt = new DecimalFormat("#,##0.00"); +// DecimalFormat dFmt = new DecimalFormat("#,##0.00"); List topN = PrisonRanks.getInstance().getPlayerManager().getPlayersByTop(); - String header = String.format( - "Ranking %-14s %-9s %-6s %-7s %-7s", - "Player", - "Prestiges", - "Rank", - "Rank-Score", - "Penalty" - - ); - sender.sendMessage(header); + sender.sendMessage( RankPlayer.printRankScoreLineHeader() ); for ( int i = posStart; i < posEnd && i < topN.size(); i++ ) { RankPlayer rPlayer = topN.get(i); - PlayerRank prestRank = rPlayer.getPlayerRankPrestiges(); - PlayerRank defRank = rPlayer.getPlayerRankDefault(); - - String prestRankTag = prestRank == null ? "---" : prestRank.getRank().getTag(); - String defRankTag = defRank == null ? "---" : defRank.getRank().getTag(); - - String prestRankTagNc = Text.stripColor(prestRankTag); - String defRankTagNc = Text.stripColor(defRankTag); - - String message = String.format( - " %-3d %-18s %-7s %-7s %7s %7s", - i + 1, - rPlayer.getName(), - prestRankTagNc, - defRankTagNc, - dFmt.format( rPlayer.getRankScore() ), - dFmt.format( rPlayer.getRankScorePenalty() ) - ); + String message = rPlayer.printRankScoreLine( i + 1 ); - message = message - .replace(prestRankTagNc, prestRankTag + "&r") - .replace(defRankTagNc, defRankTag + "&r"); sender.sendMessage(message); } From 5ba2c330df86c89d4df6925c7ef53f4cb28036ca Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 21 Mar 2022 10:07:00 -0400 Subject: [PATCH 184/297] Prepare for the handling of STATSPLAYERS placeholders, which will be the ones that provides the placeholders for the top-n players. This handles the workflow on handling the placeholders. --- docs/changelog_v3.3.x.md | 4 ++ .../placeholders/PlaceholderManager.java | 1 + .../prison/ranks/managers/RankManager.java | 66 +++++++++++++++++-- .../placeholder/SpigotPlaceholders.java | 8 ++- 4 files changed, 70 insertions(+), 9 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 210e82f53..1723d9691 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-21 +* **Prepare for the handling of STATSPLAYERS placeholders, which will be the ones that provides the placeholders for the top-n players.** +This handles the workflow on handling the placeholders. + + * **Slight update on how the top-n players are printed... simplifies and also cleans it up the formatting.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java index 41c4ce01e..90cf2de77 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java @@ -43,6 +43,7 @@ public enum PlaceholderFlags { STATSMINES( true ), STATSRANKS( true ), + STATSPLAYERS( true ), SUPRESS, 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 39648ee43..3cda93f1e 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 @@ -736,11 +736,14 @@ public String getTranslateRanksPlaceHolder( String identifier ) { //PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { + +// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); + if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { //Mine mine = getMine( placeHolderKey.getData() ); - results = getTranslateRanksPlaceHolder( placeHolderKey, identifier ); + results = getTranslateRanksPlaceHolder( placeHolderKey, identifier, 0 ); break; } } @@ -748,7 +751,8 @@ public String getTranslateRanksPlaceHolder( String identifier ) { return results; } - public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, String identifier ) { + public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, + String identifier, int numericSequence ) { String results = null; if ( identifier == null ) { @@ -767,11 +771,20 @@ public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, Strin PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - String rankName = placeHolderKey.getData(); - Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); - + if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { + + results = getTranslateRanksPlaceHolderTopPlayer( placeHolderKey, attribute, numericSequence ); + } + else { + + String rankName = placeHolderKey.getData(); + Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); + + + results = getTranslateRanksPlaceHolder( placeHolderKey, rank, attribute ); + } + - results = getTranslateRanksPlaceHolder( placeHolderKey, rank, attribute ); } return results; @@ -928,6 +941,31 @@ public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, } + public String getTranslateRanksPlaceHolderTopPlayer( PlaceHolderKey placeHolderKey, + PlaceholderAttribute attribute, int numericSequence ) { + String results = null; + + PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); + +// DecimalFormat dFmt = new DecimalFormat("#,##0"); + + switch ( placeHolder ) { + +// case prison_tpl1_nnn_tp: +// case prison_top_player_line1_headers_nnn_tp: +// { +//// placeHolderKey.get +// +// } + + default: + break; + + } + + return results; + } + public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerName, PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute) { String results = null; @@ -1156,6 +1194,22 @@ public List getTranslatedPlaceHolderKeys() { } } + + + // This generates all the placeholders for all ranks: + List placeHolders2 = PrisonPlaceHolders.getTypes( PlaceholderFlags.STATSPLAYERS ); + + for ( PrisonPlaceHolders ph : placeHolders2 ) { + String key = ph.name(); + + PlaceHolderKey placeholder = new PlaceHolderKey(key, ph ); + if ( ph.getAlias() != null ) { + String aliasName = ph.getAlias().name(); + placeholder.setAliasName( aliasName ); + } + translatedPlaceHolderKeys.add( placeholder ); + } + } return translatedPlaceHolderKeys; 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 18fb1597c..6b79a70f7 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 @@ -264,7 +264,8 @@ public String placeholderTranslateText( String text) { if ( results != null && identifier != null && identifier.hasResults() ) { results = placeholderReplace( results, identifier.getEscapedIdentifier(), - rm.getTranslateRanksPlaceHolder( placeHolderKey, identifier.getIdentifier() ) ); + rm.getTranslateRanksPlaceHolder( placeHolderKey, identifier.getIdentifier(), + identifier.getNumericSequence()) ); } } @@ -444,10 +445,11 @@ else if ( pm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFla value = pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, null ); } else if ( rm != null && placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) ) { - value = rm.getTranslateRanksPlaceHolder( placeHolderKey, null ); + value = rm.getTranslateRanksPlaceHolder( placeHolderKey, null, 0 ); } else if ( rm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS )) ) { + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) ) { value = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeHolderKey, null ); } From 4111a8f97e698c857dc383b07e903f125343ab24 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 21 Mar 2022 10:09:47 -0400 Subject: [PATCH 185/297] AutoFeatures debugging: Some color change in the logging details for failures so they are easier to see. --- docs/changelog_v3.3.x.md | 3 +++ .../autofeatures/events/AutoManagerBlockBreakEvents.java | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 1723d9691..9176f5025 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-21 +* **AutoFeatures debugging: Some color change in the logging details for failures so they are easier to see.** + + * **Prepare for the handling of STATSPLAYERS placeholders, which will be the ones that provides the placeholders for the top-n players.** This handles the workflow on handling the placeholders. 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 72cb9f566..075b84026 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 @@ -226,7 +226,7 @@ private void handleBlockBreakEvent( BlockBreakEvent e, BlockBreakPriority bbPrio StringBuilder debugInfo = new StringBuilder(); - debugInfo.append( String.format( "### ** genericBlockEvent ** ### " + + debugInfo.append( String.format( "&9### ** genericBlockEvent ** ### " + "(event: BlockBreakEvent, config: %s, priority: %s, canceled: %s) ", bbPriority.name(), bbPriority.getBukkitEventPriority().name(), @@ -284,7 +284,7 @@ else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && // pmEvent.getMine(), sBlock, explodedBlocks, BlockEventType.blockBreak, triggered ); Bukkit.getServer().getPluginManager().callEvent( pmEvent ); if ( pmEvent.isCancelled() ) { - debugInfo.append( "(normal processing: PrisonMinesBlockBreakEvent was canceled) " ); + debugInfo.append( "(normal processing: &6PrisonMinesBlockBreakEvent was canceled&9) " ); } else { @@ -322,14 +322,16 @@ else if ( pmEvent.getMine() != null || pmEvent.getMine() == null && debugInfo.append( "(event was not canceled) " ); } + // Break the blocks finalizeBreakTheBlocks( pmEvent ); + // Block counts and blockEvents doBlockEvents( pmEvent ); } else { - debugInfo.append( "(doAction failed without details) " ); + debugInfo.append( "&c(doAction failed without details)&9 " ); } } From ce257e50d1e9ca679ba78362b147aacc993ae7be Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 23 Mar 2022 03:05:54 -0400 Subject: [PATCH 186/297] Placeholder Bar Attributes: Now supports a non-positional keyword "reverse" which will take any bar graph and reverse it. --- docs/changelog_v3.3.x.md | 5 ++++- docs/prison_docs_310_guide_placeholders.md | 8 ++++++-- .../placeholders/PlaceholderAttributeBar.java | 3 +++ .../placeholders/PlaceholderManager.java | 5 +++++ .../PlaceholderProgressBarConfig.java | 20 +++++++++++++++---- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9176f5025..f021d9252 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9e 2022-03-21 +# 3.3.0-alpha.9e 2022-03-23 + + +* **Placeholder Bar Attributes: Now supports a non-positional keyword "reverse" which will take any bar graph and reverse it.** * **AutoFeatures debugging: Some color change in the logging details for failures so they are easier to see.** diff --git a/docs/prison_docs_310_guide_placeholders.md b/docs/prison_docs_310_guide_placeholders.md index 0b4a04f28..d77a90ddb 100644 --- a/docs/prison_docs_310_guide_placeholders.md +++ b/docs/prison_docs_310_guide_placeholders.md @@ -298,7 +298,7 @@ The bar placeholder attribute only works with placeholders with the word bar in Example of this attribute's usage is as follows, using descriptions for each parameter. -`::bar:size:posColor:posSeg:negColor:negSeg:hex:hex2:debug` +`::bar:size:posColor:posSeg:negColor:negSeg:reverse:hex:hex2:debug` @@ -312,7 +312,11 @@ Example of this attribute's usage is as follows, using descriptions for each par Color codes should start with an &. - **Negative Segment**: The value that will be used for the negative segment. - + + +- **reverse**: **Optional.** Case sensitive. Non-positional; can be placed anywhere. + When enabled, this will reverse the bar graph. + - **hex**: **Optional.** Case sensitive. Non-positional; can be placed anywhere. Only valid value is "hex". When enabled it will translate diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeBar.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeBar.java index ec04895ef..181066644 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeBar.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeBar.java @@ -74,6 +74,8 @@ public PlaceholderAttributeBar(ArrayList parts, this.hex = parts.remove( "hex" ); this.hex2 = parts.remove( "hex2" ); this.debug = parts.remove( "debug" ); + + boolean isReversed = parts.remove( "reverse" ); int len = 1; @@ -121,6 +123,7 @@ else if ( isHex() ) { this.barConfig = new PlaceholderProgressBarConfig( seg, pCol, pSeg, nCol, nSeg ); + this.barConfig.setReverse(isReversed); // // Debug: // String debugStr = parts.length > len ? parts[len++] : null; diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java index 90cf2de77..c1fcf276b 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java @@ -1012,6 +1012,11 @@ else if ( value < 0 ) { } } + + if ( barConfig.isReverse() ) { + sb.reverse(); + } + return sb.toString(); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderProgressBarConfig.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderProgressBarConfig.java index aa9c6aa57..59ab03d17 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderProgressBarConfig.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderProgressBarConfig.java @@ -10,10 +10,12 @@ public class PlaceholderProgressBarConfig { private String negativeColor; private String negativeSegment; + private boolean reverse; + public PlaceholderProgressBarConfig() { super(); - + this.reverse = false; } public PlaceholderProgressBarConfig( int segments, @@ -28,6 +30,8 @@ public PlaceholderProgressBarConfig( int segments, this.negativeColor = negativeColor; this.negativeSegment = negativeSegment; + + this.reverse = false; } @Override @@ -42,9 +46,12 @@ public String toString() { .append(" Neg: \\Q" ).append( getNegativeColor() ) .append( "\\E [" ).append( getNegativeColor() ) - .append( getNegativeSegment()).append( "&7]" ) - ; + .append( getNegativeSegment()).append( "&7]" ); + if ( isReverse() ) { + sb.append(" (Reversed)"); + } + return sb.toString(); } @@ -83,6 +90,11 @@ public void setNegativeSegment( String negativeSegment ) { this.negativeSegment = negativeSegment; } - + public boolean isReverse() { + return reverse; + } + public void setReverse(boolean reverse) { + this.reverse = reverse; + } } From 644de9ad308837c78e240c89edfb138f5a50bac9 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 23 Mar 2022 04:11:13 -0400 Subject: [PATCH 187/297] Top-n players listing: added an alternative line. --- docs/changelog_v3.3.x.md | 3 ++ .../prison/ranks/data/RankPlayer.java | 51 +++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index f021d9252..0d7cf5435 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-23 +* **Top-n players listing: added an alternative line.** + + * **Placeholder Bar Attributes: Now supports a non-positional keyword "reverse" which will take any bar graph and reverse it.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index 60721c7c3..8a97d8702 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -1312,9 +1312,9 @@ private void checkRecalculateRankScore() { } } - public static String printRankScoreLineHeader() { + public static String printRankScoreLine1Header() { String header = String.format( - "Ranking %-14s %-9s %-6s %-9s %-9s %-9s", + "Rank %-16s %-9s %-6s %-9s %-9s %-9s", "Player", "Prestiges", "Rank", @@ -1326,7 +1326,7 @@ public static String printRankScoreLineHeader() { return header; } - public String printRankScoreLine( int rankPostion ) { + public String printRankScoreLine1( int rankPostion ) { DecimalFormat dFmt = new DecimalFormat("#,##0.00"); @@ -1360,6 +1360,51 @@ public String printRankScoreLine( int rankPostion ) { return message; } + public static String printRankScoreLine2Header() { + String header = String.format( + "Rank %s %s %-15s %9s", + "Ranks", + "Rank-Score", + "Player", + "Balance" + + ); + return header; + } + + public String printRankScoreLine2( int rankPostion ) { + + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); + + PlayerRank prestRank = getPlayerRankPrestiges(); + PlayerRank defRank = getPlayerRankDefault(); + + String prestRankTag = prestRank == null ? "---" : prestRank.getRank().getTag(); + String defRankTag = defRank == null ? "---" : defRank.getRank().getTag(); + + String prestRankTagNc = Text.stripColor(prestRankTag); + String defRankTagNc = Text.stripColor(defRankTag); + + String balanceStr = PlaceholdersUtil.formattedKmbtSISize( getBalance(), dFmt, " " ); +// String sPenaltyStr = PlaceholdersUtil.formattedKmbtSISize( getRankScorePenalty(), dFmt, " " ); + + String ranks = prestRankTagNc + defRankTagNc; + String message = String.format( + " %-3d %-9s %6s %-17s %9s", + (rankPostion > 0 ? rankPostion : ""), + ranks, + dFmt.format( getRankScore() ), + getName(), + balanceStr + ); + + message = message + .replace(prestRankTagNc, prestRankTag + "&r") + .replace(defRankTagNc, defRankTag + "&r"); + + return message; + } + public boolean isHesitancyDelayPenaltyEnabled() { return Prison.get().getPlatform() .getConfigBooleanTrue( "top-stats.rank-players.hesitancy-delay-penalty" ); From 43b7eb8df39b416bc6fd71f15648d2068bbdff7a Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 23 Mar 2022 04:12:36 -0400 Subject: [PATCH 188/297] Top-n players listing: added an alternative line. --- .../prison/ranks/commands/RanksCommands.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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 33895ed59..0a9429a88 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 @@ -2042,11 +2042,20 @@ public void rankTopN(CommandSender sender, @Arg(name = "page", def = "1", description = "Page number [1]") String pageNumber, @Arg(name = "pageSize", def = "10", - description = "Page size [10]") String pageSizeNumber){ + description = "Page size [10]") String pageSizeNumber, + @Arg(name = "options", def = ".", + description = "Options: 'alt' displays a shorter format. [alt]") String options ){ int page = 1; int pageSize = 10; + boolean alt = false; + if ( pageNumber.toLowerCase().contains("alt") || + pageSizeNumber.toLowerCase().contains("alt") || + options.toLowerCase().contains("alt") ) { + alt = true; + } + try { page = Integer.parseInt(pageNumber); @@ -2082,12 +2091,17 @@ public void rankTopN(CommandSender sender, List topN = PrisonRanks.getInstance().getPlayerManager().getPlayersByTop(); - sender.sendMessage( RankPlayer.printRankScoreLineHeader() ); + String header = alt ? + RankPlayer.printRankScoreLine2Header() : + RankPlayer.printRankScoreLine1Header(); + sender.sendMessage( header ); for ( int i = posStart; i < posEnd && i < topN.size(); i++ ) { RankPlayer rPlayer = topN.get(i); - String message = rPlayer.printRankScoreLine( i + 1 ); + String message = alt ? + rPlayer.printRankScoreLine2( i + 1 ) : + rPlayer.printRankScoreLine1( i + 1 ); sender.sendMessage(message); } From 1d9b6d2d5d1dfc49f109aaced4bc48829d2ff4f1 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 23 Mar 2022 04:25:08 -0400 Subject: [PATCH 189/297] Placeholders top player: added new placeholders based upon the _nnn_ pattern to identify the player. --- docs/changelog_v3.3.x.md | 3 + .../prison/placeholders/PlaceHolderKey.java | 2 +- .../placeholders/PlaceholderManager.java | 36 ++ .../placeholders/PlaceholderResults.java | 18 +- .../prison/ranks/managers/RankManager.java | 367 ++++++++++++++++-- .../placeholder/SpigotPlaceholders.java | 16 +- 6 files changed, 399 insertions(+), 43 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0d7cf5435..0d41d5b0e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-23 +* **Placeholders top player: added new placeholders based upon the _nnn_ pattern to identify the player.** + + * **Top-n players listing: added an alternative line.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java index f33d83961..c5ca5ca9e 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java @@ -46,7 +46,7 @@ public PlaceHolderKey( String key, PrisonPlaceHolders placeholder, String data, * @return */ public PlaceholderResults getIdentifier( String text ) { - PlaceholderResults results = new PlaceholderResults(this); + PlaceholderResults results = new PlaceholderResults(this, text); String textLowercase = text.toLowerCase(); diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java index c1fcf276b..d17bf78e6 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java @@ -570,6 +570,42 @@ public enum PrisonPlaceHolders { prison_top_rank_balance_balance_nnn_rankname( prison_trbb_nnn_rankname, PlaceholderFlags.STATSRANKS ), + + + prison_tpl1_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpl2_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpl1h_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpl2h_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + + prison_tpn_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tprp_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tprd_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpb_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpbf_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpbr_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tprs_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tprsb_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpp_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tppf_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tppr_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + + prison_top_player_line1_nnn_tp( prison_tpl1_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_line2_nnn_tp( prison_tpl2_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_line1_headers_nnn_tp( prison_tpl1h_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_line2_headers_nnn_tp( prison_tpl2h_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + + prison_top_player_name_nnn_tp( prison_tpn_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_rank_prestiges_nnn_tp( prison_tprp_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_rank_default_nnn_tp( prison_tprd_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_balance_nnn_tp( prison_tpb_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_balance_formatted_nnn_tp( prison_tpbf_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_balance_raw_nnn_tp( prison_tpbr_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_rank_score_nnn_tp( prison_tprs_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_rank_score_bar_nnn_tp( prison_tprsb_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_penalty_nnn_tp( prison_tpp_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_penalty_formatted_nnn_tp( prison_tppf_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_penalty_raw_nnn_tp( prison_tppr_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + ; diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java index 7b236ea3c..ad8d805d1 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java @@ -11,12 +11,19 @@ public class PlaceholderResults private String identifier; - + private String text; - public PlaceholderResults( PlaceHolderKey placeholder ) { +// public PlaceholderResults( PlaceHolderKey placeholder ) { +// super(); +// +// this.placeholder = placeholder; +// this.text = null; +// } + public PlaceholderResults( PlaceHolderKey placeholder, String text ) { super(); this.placeholder = placeholder; + this.text = text; } @Override @@ -60,6 +67,13 @@ public void setPlaceholder( PlaceHolderKey placeholder ) { this.placeholder = placeholder; } + public String getText() { + return text; + } + public void setText(String text) { + this.text = text; + } + public String getIdentifier() { return identifier; } 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 3cda93f1e..ccd4015f8 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 @@ -38,6 +38,7 @@ import tech.mcprison.prison.placeholders.PlaceholderAttributeNumberFormat; import tech.mcprison.prison.placeholders.PlaceholderAttributeText; import tech.mcprison.prison.placeholders.PlaceholderManager; +import tech.mcprison.prison.placeholders.PlaceholderResults; import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags; import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; import tech.mcprison.prison.placeholders.PlaceholdersUtil; @@ -315,7 +316,7 @@ public Optional getRankOptional(String name) { * @return */ public Rank getRank(String name) { - return getRanksByName().get( name.toLowerCase() ); + return name == null ? null : getRanksByName().get( name.toLowerCase() ); } @@ -692,15 +693,44 @@ else if ( formatted ) { return resultsx; } + public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, String identifier ) { + String results = null; + + // placeholder Attributes: + PlaceholderManager pman = Prison.get().getPlaceholderManager(); + String placeholder = pman.extractPlaceholderString( identifier ); + + List placeHolderKeys = getTranslatedPlaceHolderKeys(); + + PlaceHolderKey placeholderKey = null; + for ( PlaceHolderKey phk : placeHolderKeys ) { + + if ( phk.getKey().equalsIgnoreCase( placeholder )) { + placeholderKey = phk; + break; + } + } + + if ( placeholderKey != null ) { + + PlaceholderResults placeholderResults = placeholderKey.getIdentifier(identifier); + + results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeholderResults ); + } + + return results; + } - public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, String identifier ) { + public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, + PlaceholderResults placeholderResults ) { String results = null; - if ( playerUuid != null && identifier != null ) { + if ( playerUuid != null && placeholderResults != null ) { - List placeHolderKeys = getTranslatedPlaceHolderKeys(); +// List placeHolderKeys = getTranslatedPlaceHolderKeys(); + + String identifier = placeholderResults.getIdentifier().toLowerCase(); - identifier = identifier.toLowerCase(); if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; @@ -708,15 +738,22 @@ public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String player // placeholder Attributes: PlaceholderManager pman = Prison.get().getPlaceholderManager(); - String placeholder = pman.extractPlaceholderString( identifier ); +// String placeholder = pman.extractPlaceholderString( identifier ); PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { - if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { - results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeHolderKey, attribute ); - break; - } - } + PlaceHolderKey placeHolderKey = placeholderResults.getPlaceholder(); + + results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, + placeHolderKey, attribute, placeholderResults ); + +// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { +// +// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { +// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, +// placeHolderKey, attribute, placeholderResults ); +// break; +// } +// } } return results; @@ -773,9 +810,17 @@ public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { - results = getTranslateRanksPlaceHolderTopPlayer( placeHolderKey, attribute, numericSequence ); + UUID playerUuid = null; + String playerName = null; + + PlaceholderResults placeholderResults = placeHolderKey.getIdentifier(identifier); + + results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, + placeHolderKey, attribute, placeholderResults ); + } - else { + else + { String rankName = placeHolderKey.getData(); Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); @@ -941,33 +986,34 @@ public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, } - public String getTranslateRanksPlaceHolderTopPlayer( PlaceHolderKey placeHolderKey, - PlaceholderAttribute attribute, int numericSequence ) { - String results = null; - - PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); - -// DecimalFormat dFmt = new DecimalFormat("#,##0"); - - switch ( placeHolder ) { - +// public String getTranslateRanksPlaceHolderTopPlayer( PlaceHolderKey placeHolderKey, +// PlaceholderAttribute attribute, int numericSequence ) { +// String results = null; +// +// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); +// +//// DecimalFormat dFmt = new DecimalFormat("#,##0"); +// +// switch ( placeHolder ) { +// // case prison_tpl1_nnn_tp: -// case prison_top_player_line1_headers_nnn_tp: +// case prison_top_player_line1_nnn_tp: // { //// placeHolderKey.get +// lll // // } - - default: - break; - - } - - return results; - } +// +// default: +// break; +// +// } +// +// return results; +// } public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerName, - PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute) { + PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, PlaceholderResults placeholderResults ) { String results = null; PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); @@ -981,7 +1027,8 @@ public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerN DecimalFormat dFmt = new DecimalFormat("#,##0"); - if ( rank != null && rankPlayer != null ) { + if ( !placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) && + rank != null && rankPlayer != null ) { switch ( placeHolder ) { @@ -1102,6 +1149,239 @@ public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerN break; + + default: + break; + } + } + + else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { + + switch ( placeHolder ) { + + case prison_top_player_line1_headers_nnn_tp: + case prison_tpl1h_nnn_tp: + { + results = RankPlayer.printRankScoreLine1Header(); + } + break; + + case prison_tpl1_nnn_tp: + case prison_top_player_line1_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + results = topRankPlayer.printRankScoreLine1( placeholderResults.getNumericSequence() ); + } + else { + results = ""; + } + } + break; + + case prison_top_player_line2_headers_nnn_tp: + case prison_tpl2h_nnn_tp: + { + results = RankPlayer.printRankScoreLine2Header(); + } + break; + + case prison_top_player_line2_nnn_tp: + case prison_tpl2_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + results = topRankPlayer.printRankScoreLine2( placeholderResults.getNumericSequence() ); + } + else { + results = ""; + } + } + break; + + case prison_top_player_name_nnn_tp: + case prison_tpn_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + results = topRankPlayer.getName(); + } + else { + results = ""; + } + } + break; + + case prison_top_player_rank_prestiges_nnn_tp: + case prison_tprp_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + results = topRankPlayer.getPlayerRankPrestiges().getRank().getTag(); + } + else { + results = ""; + } + } + break; + + case prison_top_player_rank_default_nnn_tp: + case prison_tprd_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + results = topRankPlayer.getPlayerRankDefault().getRank().getTag(); + } + else { + results = ""; + } + } + break; + + case prison_top_player_balance_nnn_tp: + case prison_tpb_nnn_tp: + case prison_top_player_balance_formatted_nnn_tp: + case prison_tpbf_nnn_tp: + case prison_top_player_balance_raw_nnn_tp: + case prison_tpbr_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + double bal = topRankPlayer.getBalance(); + + if ( bal < 0 ) { + bal = 0; + } + + if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { + PlaceholderAttributeNumberFormat attributeNF = + (PlaceholderAttributeNumberFormat) attribute; + results = attributeNF.format( bal ); + } + else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_formatted_nnn_tp || + placeHolder == PrisonPlaceHolders.prison_tpbf_nnn_tp ) { + + results = PlaceholdersUtil.formattedMetricSISize( bal ); + } + else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_raw_nnn_tp || + placeHolder == PrisonPlaceHolders.prison_tpbr_nnn_tp ) { + + results = Double.toString(bal); + } + else { + results = dFmt.format(bal); + } + + } + else { + results = ""; + } + } + break; + + + + case prison_top_player_rank_score_nnn_tp: + case prison_tprs_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + double rankScore = topRankPlayer.getRankScore(); + + if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { + PlaceholderAttributeNumberFormat attributeNF = + (PlaceholderAttributeNumberFormat) attribute; + results = attributeNF.format( rankScore ); + } + else { + results = dFmt.format(rankScore); + } + } + else { + results = ""; + } + } + break; + + + case prison_top_player_rank_score_bar_nnn_tp: + case prison_tprsb_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + double rankScore = topRankPlayer.getRankScore(); + + results = Prison.get().getPlaceholderManager(). + getProgressBar( rankScore, 100.0d, false, attribute ); + } + else { + results = ""; + } + } + break; + + case prison_top_player_penalty_nnn_tp: + case prison_tpp_nnn_tp: + case prison_top_player_penalty_formatted_nnn_tp: + case prison_tppf_nnn_tp: + case prison_top_player_penalty_raw_nnn_tp: + case prison_tppr_nnn_tp: + { + RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + + if ( topRankPlayer != null ) { + + double rsPenalty = topRankPlayer.getRankScorePenalty(); + + if ( rsPenalty < 0 ) { + rsPenalty = 0; + } + + if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { + PlaceholderAttributeNumberFormat attributeNF = + (PlaceholderAttributeNumberFormat) attribute; + results = attributeNF.format( rsPenalty ); + } + else if ( placeHolder == PrisonPlaceHolders.prison_top_player_penalty_formatted_nnn_tp || + placeHolder == PrisonPlaceHolders.prison_tppf_nnn_tp ) { + + results = PlaceholdersUtil.formattedMetricSISize( rsPenalty ); + } + else if ( placeHolder == PrisonPlaceHolders.prison_top_player_penalty_raw_nnn_tp || + placeHolder == PrisonPlaceHolders.prison_tppr_nnn_tp ) { + + results = Double.toString(rsPenalty); + } + else { + results = dFmt.format(rsPenalty); + } + + } + else { + results = ""; + } + } + break; + + + + default: break; } @@ -1115,6 +1395,23 @@ public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerN return results; } + + private RankPlayer getTopNRankPlayer( PlaceholderResults placeholderResults ) { + RankPlayer topRankPlayer = null; + + if ( placeholderResults != null ) { + + int rankPosition = placeholderResults.getNumericSequence(); + + PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); + if ( rankPosition >= 0 && rankPosition < pm.getPlayersByTop().size() ) { + + topRankPlayer = pm.getPlayersByTop().get(rankPosition); + } + } + + return topRankPlayer; + } private double calculateRankCost( RankPlayer rankPlayer, Rank rank ) { 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 6b79a70f7..906787895 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 @@ -187,6 +187,7 @@ public String placeholderTranslate(UUID playerUuid, String playerName, String id results = rm.getTranslateRanksPlaceHolder( identifier ); if ( results == null ) { + results = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, identifier ); } } @@ -335,13 +336,13 @@ public String placeholderTranslateText( UUID playerUuid, String playerName, Stri for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { - PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); + PlaceholderResults pResults = placeHolderKey.getIdentifier( results ); - if ( results != null && identifier != null && identifier.hasResults() ) { + if ( results != null && pResults != null && pResults.hasResults() ) { - results = placeholderReplace( results, identifier.getEscapedIdentifier(), - rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, identifier.getIdentifier() ) ); + results = placeholderReplace( results, pResults.getEscapedIdentifier(), + rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, pResults ) ); } } } @@ -450,7 +451,12 @@ else if ( rm != null && placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlag else if ( rm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) ) { - value = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeHolderKey, null ); + + String searchPatterns = String.join("_", patterns); + + PlaceholderResults pResults = placeHolderKey.getIdentifier( searchPatterns ); + + value = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeHolderKey, null, pResults ); } String placeholderAlias = ( placeHolderKey.getAliasName() == null ? null : From 1638fb4a527ff9b56ca63666f5c14641b55f22ec Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 26 Mar 2022 05:51:26 -0400 Subject: [PATCH 190/297] v3.3.0-alpha.9f 2022-03-26 --- 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 0d41d5b0e..9e180f0ff 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9e 2022-03-23 +# 3.3.0-alpha.9e 2022-03-25 + + +* **v3.3.0-alpha.9f 2022-03-25** * **Placeholders top player: added new placeholders based upon the _nnn_ pattern to identify the player.** diff --git a/gradle.properties b/gradle.properties index fc3d15229..d7e60faae 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.9e +version=3.3.0-alpha.9f #version=3.3.0-alpha.7 From a00bd8bc88ff576f51f28d499d8a31562079584c Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 26 Mar 2022 05:54:54 -0400 Subject: [PATCH 191/297] topn fix: If next rank is null, then try to use the next prestige rank for the cost. --- docs/changelog_v3.3.x.md | 5 ++++- .../prison/ranks/data/RankPlayer.java | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9e180f0ff..6a1a8ea99 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9e 2022-03-25 +# 3.3.0-alpha.9e 2022-03-26 + + +* **topn fix: If next rank is null, then try to use the next prestige rank for the cost.** * **v3.3.0-alpha.9f 2022-03-25** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index 8a97d8702..adfb78919 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -1254,7 +1254,24 @@ private void calculateRankScore() { PlayerRank rankCurrent = getPlayerRankDefault(); Rank nRank = rankCurrent.getRank().getRankNext(); - String rankNextCurrency = nRank.getCurrency(); + + // If player does not have a next rank, then try to use the next prestige rank: + if ( nRank == null ) { + PlayerRank prestigeRankCurrent = getPlayerRankPrestiges(); + + // if they don't have a current prestige rank, then use the lowest rank: + if ( prestigeRankCurrent == null ) { + RankLadder rLadder = getRankLadder( "prestiges" ); + nRank = rLadder.getLowestRank().orElse(null); + } + + if ( prestigeRankCurrent != null ) { + nRank = prestigeRankCurrent.getRank().getRankNext(); + } + + } + + String rankNextCurrency = nRank == null ? "" : nRank.getCurrency(); PlayerRank pRankNext = rankCurrent.getTargetPlayerRankForPlayer( this, nRank ); From a9df240c11019499a025e5126460f282bc9db233 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 26 Mar 2022 06:32:54 -0400 Subject: [PATCH 192/297] auto features autosell when inventory is full when using the priority BLOCKEVENTS. --- docs/changelog_v3.3.x.md | 3 +++ .../autofeatures/AutoFeaturesFileConfig.java | 3 +++ .../spigot/block/OnBlockBreakEventCore.java | 22 +++++++++++++++++++ .../prison/spigot/game/SpigotPlayer.java | 14 ++++++++++++ 4 files changed, 42 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 6a1a8ea99..f0486706d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-26 +* **auto features autosell when inventory is full when using the priority BLOCKEVENTS.** + + * **topn fix: If next rank is null, then try to use the next prestige rank for the cost.** 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 16e2c33c7..e4de85d6d 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 @@ -157,6 +157,9 @@ public enum AutoFeatures { isAutoSellIfInventoryIsFull(inventory, true), + isAutoSellIfInventoryIsFullForBLOCKEVENTSPriority(inventory, false), + + dropItemsIfInventoryIsFull(inventory, true), playSoundIfInventoryIsFull(inventory, true), 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 e6a57dcc1..8a3aad6e1 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 @@ -1,5 +1,6 @@ package tech.mcprison.prison.spigot.block; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -32,6 +33,7 @@ import tech.mcprison.prison.spigot.compat.Compatibility; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; import tech.mcprison.prison.spigot.game.SpigotPlayer; +import tech.mcprison.prison.spigot.sellall.SellAllUtil; import tech.mcprison.prison.spigot.utils.BlockUtils; import tech.mcprison.prison.util.Text; @@ -655,6 +657,26 @@ else if ( targetExplodedBlock.isMined() ) { if ( results && pmEvent.getBbPriority() == BlockBreakPriority.BLOCKEVENTS ) { + + // AutoSell on full inventory when using BLOCKEVENTS: + if ( isBoolean( AutoFeatures.isAutoSellIfInventoryIsFullForBLOCKEVENTSPriority ) && + Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) && + SellAllUtil.get() != null && + pmEvent.getSpigotPlayer().isInventoryFull() ) { + + + final long nanoStart = System.nanoTime(); + boolean success = SellAllUtil.get().sellAllSell( pmEvent.getPlayer(), + false, false, false, true, true, false); + final long nanoStop = System.nanoTime(); + double milliTime = (nanoStop - nanoStart) / 1000000d; + + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); + debugInfo.append( "(autosell: " + (success ? "success" : "failed") + + " ms: " + dFmt.format( milliTime ) + ") "); + + } + String triggered = null; doActionBlockEventOnly( sBlockHit, mine, pmEvent.getPlayer(), 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 e1ae7bff2..929741a8a 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 @@ -702,5 +702,19 @@ public boolean isSneaking() { } return sneaking; } + + public boolean isInventoryFull() { + boolean results = false; + + if ( getWrapper() != null ) { + org.bukkit.entity.Player bukkitPlayer = getWrapper(); + + int firstEmpty = bukkitPlayer.getInventory().firstEmpty(); + + results = (firstEmpty == -1); + } + + return results; + } } From 3c4468e2417964e76650402972db7dac01bf4b82 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Mar 2022 10:39:42 -0400 Subject: [PATCH 193/297] Fixed a NPE on the topn calculations. --- docs/changelog_v3.3.x.md | 5 ++++- .../java/tech/mcprison/prison/ranks/data/RankPlayer.java | 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 f0486706d..025235a4d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9e 2022-03-26 +# 3.3.0-alpha.9e 2022-03-27 + + +* **Fixed a NPE on the topn calculations.** * **auto features autosell when inventory is full when using the priority BLOCKEVENTS.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index adfb78919..1fa8550b8 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -1275,7 +1275,7 @@ private void calculateRankScore() { PlayerRank pRankNext = rankCurrent.getTargetPlayerRankForPlayer( this, nRank ); - double cost = pRankNext.getRankCost(); + double cost = pRankNext == null ? 0d : pRankNext.getRankCost(); double balance = getBalance( rankNextCurrency ); double score = balance; From 848eb68831f4d3636787b3772475ee3877e5d4c4 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Mar 2022 10:44:50 -0400 Subject: [PATCH 194/297] Fixed an NPE issue with checking to see if a block exists within a mine. This issue was impacting spigot versions less than 1.13. The problem is with data values being abnormal and out of the standard range. --- docs/changelog_v3.3.x.md | 4 ++++ .../tech/mcprison/prison/spigot/block/OnBlockBreakMines.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 025235a4d..a64014d7f 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-27 +* **Fixed an NPE issue with checking to see if a block exists within a mine.** +This issue was impacting spigot versions less than 1.13. The problem is with data values being abnormal and out of the standard range. + + * **Fixed a NPE on the topn calculations.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java index 674d6df52..d7561a2e0 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java @@ -426,7 +426,7 @@ public List mergeDrops( List drops ) private Mine findMineLocation( SpigotBlock block ) { - return getPrisonMineManager() == null ? + return getPrisonMineManager() == null || block == null || block.getLocation() == null ? null : getPrisonMineManager().findMineLocationExact( block.getLocation() ); } From cdc8519e8310a1ba364f668059d53351b22829c9 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Mar 2022 14:12:47 -0400 Subject: [PATCH 195/297] Enabled a sellall feature to enable the old functionality where sellall ignores the Display Name or is not a valid prison block type. --- docs/changelog_v3.3.x.md | 3 + .../prison/spigot/configs/SellAllConfig.java | 2 + .../prison/spigot/sellall/SellAllUtil.java | 103 ++++++++++++------ 3 files changed, 77 insertions(+), 31 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a64014d7f..606e50125 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-27 +* **Enabled a sellall feature to enable the old functionality where sellall ignores the Display Name or is not a valid prison block type.** + + * **Fixed an NPE issue with checking to see if a block exists within a mine.** This issue was impacting spigot versions less than 1.13. The problem is with data values being abnormal and out of the standard range. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/SellAllConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/SellAllConfig.java index 46ac1ee81..f12eb6823 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/SellAllConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/SellAllConfig.java @@ -92,6 +92,8 @@ private void values(){ dataConfig("Options.SellAll_Sign_Notify", false); dataConfig("Options.SellAll_Sign_Visible_Tag", "&7[&3SellAll&7]"); dataConfig("Options.SellAll_Hand_Enabled", true); + dataConfig("Options.SellAll_ignoreCustomNames", false); + dataConfig("Options.Player_GUI_Enabled", true); dataConfig("Options.Player_GUI_Permission_Enabled",false); dataConfig("Options.Player_GUI_Permission","prison.sellall.playergui"); 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 1a3889f51..26821bfcf 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 @@ -107,6 +107,8 @@ public class SellAllUtil { public boolean isSellAllBackpackItemsEnabled; public boolean isSellAllMinesBackpacksPluginEnabled; public boolean isSellAllHandEnabled; + + public boolean isSellAllIgnoreCustomNames = false; /** * Get cached instance of SellAllUtil, if present, if not then Initialize it, if SellAll is disabled return null. @@ -129,7 +131,7 @@ public static SellAllUtil get() { * * @return boolean. * */ - public static boolean getBoolean(String string) { + private static boolean getBoolean(String string) { return string != null && string.equalsIgnoreCase("true"); } @@ -182,7 +184,7 @@ private XMaterial getXMaterialOrLapis(ItemStack itemStack) { altName = itemStack.getItemMeta().getDisplayName(); } - if ( altName == null ) { + if ( altName == null || isSellAllIgnoreCustomNames ) { XMaterial xMat = null; if (itemStack.isSimilar(lapisLazuli)) { @@ -476,10 +478,14 @@ private double getSellMoney( Player p, SpigotItemStack itemStack ) { double results = 0d; + // 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 ( itemStack.getMaterial().getBlockType() == null || + if ( isSellAllIgnoreCustomNames || + itemStack.getMaterial().getBlockType() == null || itemStack.getMaterial().getBlockType() == PrisonBlockType.minecraft ) { HashMap xMaterialIntegerHashMap = new HashMap<>(); @@ -554,7 +560,7 @@ public boolean isPlayerAutoSellEnabled(Player p){ return true; } - return getBoolean(sellAllConfig.getString("Users." + p.getUniqueId() + ".isEnabled")); + return getBooleanValue("Users." + p.getUniqueId() + ".isEnabled"); } /** @@ -637,31 +643,65 @@ private void initCachedData() { 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 = getBoolean(sellAllConfig.getString("Options.Sell_Per_Block_Permission_Enabled")); - isAutoSellEnabled = getBoolean(sellAllConfig.getString("Options.Full_Inv_AutoSell")); - isAutoSellNotificationEnabled = getBoolean(sellAllConfig.getString("Options.Full_Inv_AutoSell_Notification")); - isAutoSellEarningNotificationDelayEnabled = getBoolean(sellAllConfig.getString("Options.Full_Inv_AutoSell_EarnedMoneyNotificationDelay_Enabled")); - isAutoSellPerUserToggleable = getBoolean(sellAllConfig.getString("Options.Full_Inv_AutoSell_perUserToggleable")); - isAutoSellPerUserToggleablePermEnabled = getBoolean(sellAllConfig.getString("Options.Full_Inv_AutoSell_perUserToggleable_Need_Perm")); - isSellAllNotificationEnabled = getBoolean(sellAllConfig.getString("Options.Sell_Notify_Enabled")); - isSellAllSoundEnabled = getBoolean(sellAllConfig.getString("Options.Sell_Sound_Enabled")); - isSellAllBackpackItemsEnabled = getBoolean(sellAllConfig.getString("Options.Sell_Prison_BackPack_Items")); - isSellAllMinesBackpacksPluginEnabled = getBoolean(sellAllConfig.getString("Options.Sell_MinesBackPacks_Plugin_Backpack")); - isSellAllDelayEnabled = getBoolean(sellAllConfig.getString("Options.Sell_Delay_Enabled")); - isSellAllSellPermissionEnabled = getBoolean(sellAllConfig.getString("Options.Sell_Permission_Enabled")); - isSellAllItemTriggerEnabled = getBoolean(sellAllConfig.getString("Options.ShiftAndRightClickSellAll.Enabled")); - isSellAllItemTriggerPermissionEnabled = getBoolean(sellAllConfig.getString("Options.ShiftAndRightClickSellAll.PermissionEnabled")); - isSellAllGUIEnabled = getBoolean(sellAllConfig.getString("Options.GUI_Enabled")); - isSellAllPlayerGUIEnabled = getBoolean(sellAllConfig.getString("Options.Player_GUI_Enabled")); - isSellAllGUIPermissionEnabled = getBoolean(sellAllConfig.getString("Options.GUI_Permission_Enabled")); - isSellAllPlayerGUIPermissionEnabled = getBoolean(sellAllConfig.getString("Options.Player_GUI_Permission_Enabled")); - isSellAllMultiplierEnabled = getBoolean(sellAllConfig.getString("Options.Multiplier_Enabled")); - isSellAllPermissionMultiplierOnlyHigherEnabled = getBoolean(sellAllConfig.getString("Options.Multiplier_Permission_Only_Higher")); - isSellAllSignEnabled = getBoolean(sellAllConfig.getString("Options.SellAll_Sign_Enabled")); - isSellAllSignNotifyEnabled = getBoolean(sellAllConfig.getString("Options.SellAll_Sign_Notify")); - isSellAllSignPermissionToUseEnabled = getBoolean(sellAllConfig.getString("Options.SellAll_Sign_Use_Permission_Enabled")); - isSellAllBySignOnlyEnabled = getBoolean(sellAllConfig.getString("Options.SellAll_By_Sign_Only")); - isSellAllHandEnabled = getBoolean(sellAllConfig.getString("Options.SellAll_Hand_Enabled")); + 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 false; } /** @@ -768,7 +808,7 @@ public boolean addSellAllBlock(XMaterial xMaterial, double value){ FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile); conf.set("Items." + xMaterial.name() + ".ITEM_ID", xMaterial.name()); conf.set("Items." + xMaterial.name() + ".ITEM_VALUE", value); - if (getBoolean(sellAllConfig.getString("Options.Sell_Per_Block_Permission_Enabled"))) { + if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) { conf.set("Items." + xMaterial.name() + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + xMaterial.name()); } conf.save(sellAllFile); @@ -1022,6 +1062,7 @@ public boolean canPlayerSell(Player p, boolean isUsingSign){ * */ public boolean editPrice(XMaterial xMaterial, double value){ + // 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 ){ return false; } @@ -1031,7 +1072,7 @@ public boolean editPrice(XMaterial xMaterial, double value){ FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile); conf.set("Items." + xMaterial.name() + ".ITEM_ID", xMaterial.name()); conf.set("Items." + xMaterial.name() + ".ITEM_VALUE", value); - if (getBoolean(sellAllConfig.getString("Options.Sell_Per_Block_Permission_Enabled"))) { + if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) { conf.set("Items." + xMaterial + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + xMaterial.name()); } conf.save(sellAllFile); From da4709790c07d333e9400e49b723f086d614b627 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:43:53 -0400 Subject: [PATCH 196/297] Topn calculations: handle a null being returned for the prestige ladder. --- docs/changelog_v3.3.x.md | 3 +++ .../tech/mcprison/prison/ranks/data/RankLadder.java | 8 ++++++-- .../tech/mcprison/prison/ranks/data/RankPlayer.java | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 606e50125..b33b8ab85 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-27 +* **Topn calculations: handle a null being returned for the prestige ladder.** + + * **Enabled a sellall feature to enable the old functionality where sellall ignores the Display Name or is not a valid prison block type.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java index 9e6329920..b9ef21843 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankLadder.java @@ -35,6 +35,10 @@ public class RankLadder implements PrisonSortable, Comparable { + public static final String DEFAULT = "default"; + public static final String PRESTIGES = "prestiges"; + + private int id; private String name; private List ranks; @@ -72,11 +76,11 @@ public RankLadder( int id, String name ) { public boolean isDefault() { - return getName().equalsIgnoreCase( "default" ); + return getName().equalsIgnoreCase( DEFAULT ); } public boolean isPrestiges() { - return getName().equalsIgnoreCase( "prestiges" ); + return getName().equalsIgnoreCase( PRESTIGES ); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java index 1fa8550b8..b80cf1403 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java @@ -574,6 +574,7 @@ private RankLadder getRankLadder( String ladderName ) { for ( RankLadder rLadder : getLadderRanks().keySet() ) { if ( rLadder.getName().equalsIgnoreCase( ladderName ) ) { results = rLadder; + break; } } @@ -1261,12 +1262,13 @@ private void calculateRankScore() { // if they don't have a current prestige rank, then use the lowest rank: if ( prestigeRankCurrent == null ) { - RankLadder rLadder = getRankLadder( "prestiges" ); - nRank = rLadder.getLowestRank().orElse(null); + RankLadder rLadder = getRankLadder( RankLadder.PRESTIGES ); + nRank = rLadder == null ? null : rLadder.getLowestRank().orElse(null); } if ( prestigeRankCurrent != null ) { - nRank = prestigeRankCurrent.getRank().getRankNext(); + nRank = prestigeRankCurrent.getRank() == null ? + null : prestigeRankCurrent.getRank().getRankNext(); } } @@ -1282,7 +1284,7 @@ private void calculateRankScore() { double penalty = 0d; // Do not apply the penalty if cost is zero: - if ( isHesitancyDelayPenaltyEnabled() && cost > 0 ) { + if ( cost > 0 && isHesitancyDelayPenaltyEnabled() ) { score = balance > cost ? cost : score; double excess = balance > cost ? balance - cost : 0d; From ddd35179ac71d43df5c84fbc531bd462c697f75e Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 27 Mar 2022 19:26:59 -0400 Subject: [PATCH 197/297] Update debug info in auto features to properly show it's within the BLOCKEVENTS priority processing. --- docs/changelog_v3.3.x.md | 2 ++ .../mcprison/prison/spigot/block/OnBlockBreakEventCore.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index b33b8ab85..914025bfe 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,6 +13,8 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-27 +* **Update debug info in auto features to properly show it's within the BLOCKEVENTS priority processing.** + * **Topn calculations: handle a null being returned for the prestige ladder.** 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 8a3aad6e1..7a8fa2a42 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 @@ -672,7 +672,7 @@ else if ( targetExplodedBlock.isMined() ) { double milliTime = (nanoStop - nanoStart) / 1000000d; DecimalFormat dFmt = new DecimalFormat("#,##0.00"); - debugInfo.append( "(autosell: " + (success ? "success" : "failed") + + debugInfo.append( "(autosellBLOCKEVENTS: " + (success ? "success" : "failed") + " ms: " + dFmt.format( milliTime ) + ") "); } From bb70104c256dbd8d63e6261de9082e455b5ef4b0 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 29 Mar 2022 01:52:13 -0400 Subject: [PATCH 198/297] Auto features bug fix: was paying the player, instead of just reporting the value when in debug mode. --- .../prison/spigot/autofeatures/AutoManagerFeatures.java | 2 +- .../java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java | 2 +- 2 files changed, 2 insertions(+), 2 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 6e7aaebf3..1905682d3 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 @@ -548,7 +548,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, if ( Output.get().isDebug() && Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) ) { // Just get the calculated value for the drops... do not sell: - double amount = SellAllUtil.get().sellAllSell( player, itemStack, true, false, false ); + double amount = SellAllUtil.get().getSellMoney( player, itemStack ); autosellTotal += amount; debugInfo.append( "(Debug-unsold-value-check: " + itemStack.getName() + 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 26821bfcf..a587d5371 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 @@ -474,7 +474,7 @@ public double getSellMoney(Player p){ * @param itemStack * @return */ - private double getSellMoney( Player p, SpigotItemStack itemStack ) + public double getSellMoney( Player p, SpigotItemStack itemStack ) { double results = 0d; From e356c949a65656e1f4ad626fc017c1096ec05160 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 29 Mar 2022 01:54:28 -0400 Subject: [PATCH 199/297] Sellall bug fix on calculation boolean config values; it was not returning the correct value. --- docs/changelog_v3.3.x.md | 13 ++++++++++++- .../mcprison/prison/spigot/sellall/SellAllUtil.java | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 914025bfe..6084f0a95 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,18 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9e 2022-03-27 +# 3.3.0-alpha.9e 2022-03-29 + + +* **Sellall bug fix on calculation boolean config values; it was not returning the correct value.** +This was found by a report that `/sellall hand` was not working. + + +* **Auto features bug fix: was paying the player, instead of just reporting the value when in debug mode.** + + +* **Auto features bug fix: was paying the player, instead of just reporting the value when in debug mode.** + * **Update debug info in auto features to properly show it's within the BLOCKEVENTS priority processing.** 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 a587d5371..dc1a94723 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 @@ -701,7 +701,7 @@ else if ( sellAllConfig.isBoolean(configName) ) { } } - return false; + return results; } /** From f5f0f776ff8d28c85d3f8bc54ef8a150143bde62 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 29 Mar 2022 01:59:59 -0400 Subject: [PATCH 200/297] Doc update on how to setup debuging in eclipse. --- ...rison_docs_012_setting_up_prison_basics.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/prison_docs_012_setting_up_prison_basics.md b/docs/prison_docs_012_setting_up_prison_basics.md index b0fa49a4d..5d4d0940f 100644 --- a/docs/prison_docs_012_setting_up_prison_basics.md +++ b/docs/prison_docs_012_setting_up_prison_basics.md @@ -273,6 +273,25 @@ Note: The use of `--log-strip-color` may or may not work within your environment +
+ +# Setting up an Eclipse Debugging Session + +To go along with the above settings for debugging on port 5005, you need to setup in Eclipse the correct remote debug configuration using a Remote Java Application. + +Detailed settings can be found here: + + +[https://www.spigotmc.org/wiki/eclipse-debug-your-plugin/](https://www.spigotmc.org/wiki/eclipse-debug-your-plugin/) + + +Basically, under "Debug Configurations...", add a new "Remote Java Application". Select a name, such as "Spigot Debugger - Local", with port `5005`, and `localhost` for the host. + +With the spigot server already running, then set a break point in the code, then start the debugger. + +If the Eclipse debugger breaks on the selected breakpoint, but yet does not show any source, click on the button in the empty source window to select the correct source. From the popup window, then choose to select an existing Java Project, then select all listed projects associated with your plugin(s), including all sub-projects. The debugger should then select the correct source. + +
From 50560a3d6ada011cf15b1df3c338f91e11fee29f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 29 Mar 2022 02:05:09 -0400 Subject: [PATCH 201/297] Sellall - added debug logging on the calculation of sell prices. --- docs/changelog_v3.3.x.md | 3 ++ .../prison/spigot/sellall/SellAllUtil.java | 41 ++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 6084f0a95..9c6dbd082 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-29 +* **Sellall - added debug logging on the calculation of sell prices.** + + * **Sellall bug fix on calculation boolean config values; it was not returning the correct value.** This was found by a report that `/sellall hand` was not working. 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 dc1a94723..c4db8ea93 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 @@ -398,6 +398,8 @@ public double getPlayerMultiplier(Player p){ * @return double. * */ public double getSellMoney(Player p, HashMap xMaterialIntegerHashMap){ + StringBuilder sb = new StringBuilder(); + boolean debug = Output.get().isDebug(); if (sellAllBlocks.isEmpty()){ return 0; @@ -407,18 +409,45 @@ public double getSellMoney(Player p, HashMap xMaterialIntege double earned = 0; - for (HashMap.Entry xMaterialIntegerEntry : xMaterialIntegerHashMap.entrySet()){ - if (sellAllBlocks.containsKey(xMaterialIntegerEntry.getKey())){ + 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 + xMaterialIntegerEntry.getKey().name())){ + if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMatEntry.getKey().name())){ // Nothing will change. - } else { - earned += xMaterialIntegerEntry.getValue() * sellAllBlocks.get(xMaterialIntegerEntry.getKey()); + } + 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; } } } - return earned * multiplier; + double total = earned * multiplier; + + if ( debug ) { + DecimalFormat dFmt = new DecimalFormat( "#,##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; } /** From b4315cc5bd62c1701a677e892d0e0a29225ffe69 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 29 Mar 2022 02:56:04 -0400 Subject: [PATCH 202/297] Mine bombs cooldown - ran in to a null value in the cooldown timers. Handles this situation now. --- docs/changelog_v3.3.x.md | 3 +++ .../prison/spigot/utils/PrisonUtilsMineBombsTasks.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9c6dbd082..2bf241df5 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-29 +* **Mine bombs cooldown - ran in to a null value in the cooldown timers. Handles this situation now. ** + + * **Sellall - added debug logging on the calculation of sell prices.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java index faec43e67..fc96653e5 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombsTasks.java @@ -116,8 +116,10 @@ public boolean addPlayerCooldown( String playerUUID, int ticks ) @Override public void run() { + + Integer cooldownTicks = playerCooldowns.get( playerUUID ); - int ticksRemaining = playerCooldowns.get( playerUUID ) - 10; + int ticksRemaining = cooldownTicks == null ? 0 : cooldownTicks - 10; if ( ticksRemaining <= 0 ) { From 6355a7e0bc2e7a4b08d23071e815624bbfb48705 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 29 Mar 2022 03:57:29 -0400 Subject: [PATCH 203/297] sellall reload - fixed issue where the reload was not chaning any online valus or settings. --- docs/changelog_v3.3.x.md | 3 +++ .../tech/mcprison/prison/spigot/sellall/SellAllUtil.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 2bf241df5..7743417b7 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-29 +* **sellall reload - fixed issue where the reload was not chaning any online valus or settings.** + + * **Mine bombs cooldown - ran in to a null value in the cooldown timers. Handles this situation now. ** 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 c4db8ea93..1609660eb 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 @@ -644,7 +644,10 @@ public boolean isValidItem(String item){ * Update SellAll Cached config. * */ public void updateConfig(){ - sellAllConfig = SpigotPrison.getInstance().updateSellAllConfig(); + + initCachedData(); + +// sellAllConfig = SpigotPrison.getInstance().updateSellAllConfig(); } /** From 0e85347be3d9d7f614fc132d4294e8d173e1743f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 29 Mar 2022 14:01:32 -0400 Subject: [PATCH 204/297] auto features: Enable player toggle on sellall for auto feature's autosell. --- docs/changelog_v3.3.x.md | 2 ++ .../autofeatures/AutoManagerFeatures.java | 15 +++++++++++---- .../spigot/block/OnBlockBreakEventCore.java | 9 ++++++++- .../prison/spigot/sellall/SellAllUtil.java | 19 +++++++++++++++++-- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7743417b7..dfcdd9838 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,8 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9e 2022-03-29 +* **auto features: Enable player toggle on sellall for auto feature's autosell.** + * **sellall reload - fixed issue where the reload was not chaning any online valus or settings.** 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 1905682d3..3bbd7f679 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 @@ -505,13 +505,21 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent, count += itemStack.getAmount(); + // 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() ) + ; + // Try to autosell if enabled: if ( Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) && - (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) || + (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) && + isPlayerAutosellEnabled || pmEvent.isForceAutoSell() || !player.isOp() && !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) && player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) && - SellAllUtil.get() != null ) { + isPlayerAutosellEnabled ) { final long nanoStart = System.nanoTime(); double amount = SellAllUtil.get().sellAllSell( player, itemStack, false, false, true ); @@ -956,8 +964,7 @@ protected void dropExtra( HashMap extra, Player player isBoolean(AutoFeatures.isAutoSellIfInventoryIsFull) )) { - if ( !sellAllUtil.isAutoSellPerUserToggleable || - sellAllUtil.isAutoSellPerUserToggleable && sellAllUtil.isPlayerAutoSellEnabled(player) ) { + if ( sellAllUtil.checkIfPlayerAutosellIsActive(player) ) { 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 7a8fa2a42..6c6e57ddf 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 @@ -656,12 +656,19 @@ else if ( targetExplodedBlock.isMined() ) { if ( results && pmEvent.getBbPriority() == BlockBreakPriority.BLOCKEVENTS ) { + + // 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() ) + ; // AutoSell on full inventory when using BLOCKEVENTS: if ( isBoolean( AutoFeatures.isAutoSellIfInventoryIsFullForBLOCKEVENTSPriority ) && Prison.get().getPlatform().getConfigBooleanFalse( "sellall" ) && - SellAllUtil.get() != null && + isPlayerAutosellEnabled && pmEvent.getSpigotPlayer().isInventoryFull() ) { 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 1609660eb..46c120aad 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 @@ -24,6 +24,8 @@ import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack; import tech.mcprison.prison.Prison; import tech.mcprison.prison.PrisonAPI; +import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper; +import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.integration.EconomyCurrencyIntegration; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType; @@ -581,7 +583,8 @@ private HashMap getHashMapOfPlayerInventories(Player p) { * */ public boolean isPlayerAutoSellEnabled(Player p){ - if (isAutoSellPerUserToggleablePermEnabled && !p.hasPermission(permissionAutoSellPerUserToggleable)){ + if (isAutoSellPerUserToggleablePermEnabled && + !p.hasPermission(permissionAutoSellPerUserToggleable)){ return false; } @@ -591,6 +594,16 @@ public boolean isPlayerAutoSellEnabled(Player p){ return getBooleanValue("Users." + p.getUniqueId() + ".isEnabled"); } + + public boolean checkIfPlayerAutosellIsActive(Player p) { + boolean results = true; + + if ( isAutoSellPerUserToggleable ) { + results = isPlayerAutoSellEnabled(p); + } + + return results; + } /** * Check if Player is in a disabled world, where he can't use sellall sell. @@ -1552,7 +1565,9 @@ public boolean setAutoSell(Boolean isEnabled){ * @return boolean. * */ public boolean setAutoSellPlayer(Player p, boolean enable){ - if (!isAutoSellEnabled || !isAutoSellPerUserToggleable){ + if (!(isAutoSellEnabled || + AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled)) || + !isAutoSellPerUserToggleable){ return false; } From 0ba3b76558d897f9559a02d454b166fc3f35b8d6 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 2 Apr 2022 00:10:06 -0400 Subject: [PATCH 205/297] v3.3.0-alpha.9g 2022-03-29 --- docs/changelog_v3.3.x.md | 9 +++++---- gradle.properties | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index dfcdd9838..199b48119 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,11 +11,15 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9e 2022-03-29 +# 3.3.0-alpha.9g 2022-03-29 + + +* **v3.3.0-alpha.9g 2022-03-29** * **auto features: Enable player toggle on sellall for auto feature's autosell.** + * **sellall reload - fixed issue where the reload was not chaning any online valus or settings.** @@ -32,9 +36,6 @@ This was found by a report that `/sellall hand` was not working. * **Auto features bug fix: was paying the player, instead of just reporting the value when in debug mode.** -* **Auto features bug fix: was paying the player, instead of just reporting the value when in debug mode.** - - * **Update debug info in auto features to properly show it's within the BLOCKEVENTS priority processing.** diff --git a/gradle.properties b/gradle.properties index d7e60faae..ec6181753 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.9f +version=3.3.0-alpha.9g #version=3.3.0-alpha.7 From 4b024c30bfb24cea5778fa8529d1145288a7f427 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 2 Apr 2022 11:57:23 -0400 Subject: [PATCH 206/297] ChatDisplay: An internal change that controls if a chat display object (multi-lined content, such as command output) displays the title. This will be useful when integrating in to other commands and workflows, such as redesigning how the startup reporting is handled. --- docs/changelog_v3.3.x.md | 6 +++- .../mcprison/prison/output/ChatDisplay.java | 34 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 199b48119..f5b222eb9 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9g 2022-03-29 +# 3.3.0-alpha.9g 2022-04-02 + + +* **ChatDisplay: An internal change that controls if a chat display object (multi-lined content, such as command output) displays the title.** +This will be useful when integrating in to other commands and workflows, such as redesigning how the startup reporting is handled. * **v3.3.0-alpha.9g 2022-03-29** 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 ac0eb2bd8..05e938e08 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 @@ -38,6 +38,8 @@ public class ChatDisplay { private String title; private LinkedList displayComponents; + + private boolean showTitle = true; /* * Constructor @@ -69,21 +71,30 @@ public ChatDisplay addEmptyLine() { } public void send(CommandSender sender) { - sender.sendMessage(title); + if ( isShowTitle() ) { + sender.sendMessage(title); + } + for (DisplayComponent component : displayComponents) { component.send(sender); } } public void toLog(LogLevel logLevel) { - Output.get().log( title, logLevel ); + if ( isShowTitle() ) { + Output.get().log( title, logLevel ); + } + for (DisplayComponent component : displayComponents) { Output.get().log( component.text(), logLevel ); } } public void sendtoOutputLogInfo() { - Output.get().logInfo( title ); + if ( isShowTitle() ) { + Output.get().logInfo( title ); + } + for (DisplayComponent component : displayComponents) { Output.get().logInfo( component.text() ); } @@ -92,7 +103,10 @@ public void sendtoOutputLogInfo() { public StringBuilder toStringBuilder() { StringBuilder sb = new StringBuilder(); - sb.append( title ).append( "\n" ); + if ( isShowTitle() ) { + sb.append( title ).append( "\n" ); + } + for (DisplayComponent component : displayComponents) { sb.append( component.text() ).append( "\n" ); } @@ -103,7 +117,10 @@ public StringBuilder toStringBuilder() { public StringBuilder toStringBuilderEscaped() { StringBuilder sb = new StringBuilder(); - sb.append( title ).append( "\\n" ); + if ( isShowTitle() ) { + sb.append( title ).append( "\\n" ); + } + for (DisplayComponent component : displayComponents) { sb.append( component.text() ).append( "\\n" ); } @@ -128,5 +145,12 @@ protected String getTitle() { protected LinkedList getDisplayComponents() { return displayComponents; } + + public boolean isShowTitle() { + return showTitle; + } + public void setShowTitle(boolean showTitle) { + this.showTitle = showTitle; + } } From ac873efcfa482bbb3b0011a070a1050679375752 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 2 Apr 2022 12:04:44 -0400 Subject: [PATCH 207/297] Change to prison startup details reporting to elminate duplication. Near the end of the prison startup process, prison would run the `/prison version` command to provide additional information in the logs. This was duplicating some of the information that was already printed during the actual startup process. Changes were made to only add the information that was missing so the whole command does not need to re reran. Overall this is a small impact, but a useful one. It does shift where these functions live and ran from. --- docs/changelog_v3.3.x.md | 5 + .../tech/mcprison/prison/PrisonCommand.java | 296 +++++++++--------- .../prison/internal/platform/Platform.java | 5 +- .../tech/mcprison/prison/TestPlatform.java | 9 +- .../prison/spigot/SpigotPlatform.java | 235 ++++++++++++-- .../mcprison/prison/spigot/SpigotPrison.java | 15 +- 6 files changed, 388 insertions(+), 177 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index f5b222eb9..4139197c8 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9g 2022-04-02 +* **Change to prison startup details reporting to elminate duplication.** +Near the end of the prison startup process, prison would run the `/prison version` command to provide additional information in the logs. This was duplicating some of the information that was already printed during the actual startup process. +Changes were made to only add the information that was missing so the whole command does not need to re reran. Overall this is a small impact, but a useful one. It does shift where these functions live and ran from. + + * **ChatDisplay: An internal change that controls if a chat display object (multi-lined content, such as command output) displays the title.** This will be useful when integrating in to other commands and workflows, such as redesigning how the startup reporting is handled. 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 40bbbb779..7e4def774 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -41,13 +41,10 @@ import tech.mcprison.prison.commands.CommandPagedData; import tech.mcprison.prison.commands.Wildcard; import tech.mcprison.prison.discord.PrisonPasteChat; -import tech.mcprison.prison.integration.IntegrationManager; -import tech.mcprison.prison.integration.IntegrationType; import tech.mcprison.prison.internal.CommandSender; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.localization.LocaleManager; import tech.mcprison.prison.modules.Module; -import tech.mcprison.prison.modules.ModuleStatus; import tech.mcprison.prison.output.BulletedListComponent; import tech.mcprison.prison.output.ChatDisplay; import tech.mcprison.prison.output.DisplayComponent; @@ -57,7 +54,6 @@ import tech.mcprison.prison.troubleshoot.Troubleshooter; import tech.mcprison.prison.util.JumboTextFont; import tech.mcprison.prison.util.PrisonJarReporter; -import tech.mcprison.prison.util.Text; /** * Root commands for managing the platform as a whole, in-game. @@ -275,161 +271,171 @@ public ChatDisplay displayVersion(String options) { display.addText(""); - - display.addText("&7Prison's root Command: /prison"); - - for ( Module module : Prison.get().getModuleManager().getModules() ) { - - display.addText( "&7Module: %s : %s %s", module.getName(), - module.getStatus().getStatusText(), - (module.getStatus().getStatus() == ModuleStatus.Status.FAILED ? - "[" + module.getStatus().getMessage() + "]" : "") - ); - // display.addText( ". &7Base Commands: %s", module.getBaseCommands() ); - } - - List disabledModules = Prison.get().getModuleManager().getDisabledModules(); - if ( disabledModules.size() > 0 ) { - display.addText( "&7Disabled Module%s:", (disabledModules.size() > 1 ? "s" : "")); - for ( String disabledModule : Prison.get().getModuleManager().getDisabledModules() ) { - display.addText( ". &cDisabled Module:&7 %s. Related commands and placeholders are non-functional. ", - disabledModule ); - } - } - - - List features = Prison.get().getPlatform().getActiveFeatures(); - if ( features.size() > 0 ) { - - display.addText(""); - for ( String feature : features ) { - - if ( !feature.startsWith( "+" ) ) { - - display.addText( feature ); - } - else if ( !isBasic ) { - - display.addText( feature.substring( 1 ) ); - } - } - } - - - display.addText(""); - display.addText("&7Integrations:"); - - IntegrationManager im = Prison.get().getIntegrationManager(); - String permissions = - (im.hasForType(IntegrationType.PERMISSION) ? - " " + im.getForType(IntegrationType.PERMISSION).get().getDisplayName() : - "None"); - display.addText(". . &7Permissions: " + permissions); - String economy = - (im.hasForType(IntegrationType.ECONOMY) ? - " " + im.getForType(IntegrationType.ECONOMY).get().getDisplayName() : - "None"); + // This generates the module listing, the autoFeatures overview, + // the integrations listings, and the plugins listings. + boolean showLaddersAndRanks = true; + Prison.get().getPlatform().prisonVersionFeatures( display, isBasic, showLaddersAndRanks ); - display.addText(". . &7Economy: " + economy); - - - List integrationRows = im.getIntegrationComponents( isBasic ); - for ( DisplayComponent component : integrationRows ) - { - display.addComponent( component ); - } - display.addText(""); - display.addText("&7Locale Settings:"); - - for ( String localeInfo : Prison.get().getLocaleLoadInfo() ) { - display.addText( ". . " + localeInfo ); - } - - - Prison.get().getPlatform().identifyRegisteredPlugins(); - - // NOTE: This list of plugins is good enough and the detailed does not have all the info. - // Display all loaded plugins: - if ( getRegisteredPlugins().size() > 0 ) { - display.addText(""); - display.addText( "&7Registered Plugins: " ); - - List plugins = getRegisteredPlugins(); - Collections.sort( plugins ); - List plugins2Cols = Text.formatColumnsFromList( plugins, 2 ); - - for ( String rp : plugins2Cols ) { - - display.addText( rp ); - } - -// StringBuilder sb = new StringBuilder(); -// for ( String plugin : getRegisteredPlugins() ) { -// if ( sb.length() == 0) { -// sb.append( ". " ); -// sb.append( plugin ); -// } else { -// sb.append( ", " ); -// sb.append( plugin ); -// display.addText( sb.toString() ); -// sb.setLength( 0 ); -// } -// } -// if ( sb.length() > 0 ) { -// display.addText( sb.toString()); -// } - } - - // This version of plugins does not have all the registered commands: -// // The new plugin listings: -// if ( getRegisteredPluginData().size() > 0 ) { -// display.text( "&7Registered Plugins Detailed: " ); -// StringBuilder sb = new StringBuilder(); -// Set keys = getRegisteredPluginData().keySet(); +// List features = Prison.get().getPlatform().getActiveFeatures(); +// if ( features.size() > 0 ) { // -// for ( String key : keys ) { -// RegisteredPluginsData plugin = getRegisteredPluginData().get(key); +// display.addText(""); +// for ( String feature : features ) { // -// if ( sb.length() == 0) { -// sb.append( " " ); -// sb.append( plugin.formatted() ); -// } else { -// sb.append( ", " ); -// sb.append( plugin.formatted() ); -// display.text( sb.toString() ); -// sb.setLength( 0 ); +// if ( !feature.startsWith( "+" ) ) { +// +// display.addText( feature ); +// } +// else if ( !isBasic ) { +// +// display.addText( feature.substring( 1 ) ); // } // } -// if ( sb.length() > 0 ) { -// display.text( sb.toString()); +// } +// +// +// display.addText(""); +// +// // Active Modules: +// display.addText("&7Prison's root Command: &3/prison"); +// +// for ( Module module : Prison.get().getModuleManager().getModules() ) { +// +// display.addText( "&7Module: %s : %s %s", module.getName(), +// module.getStatus().getStatusText(), +// (module.getStatus().getStatus() == ModuleStatus.Status.FAILED ? +// "[" + module.getStatus().getMessage() + "]" : "") +// ); +// // display.addText( ". &7Base Commands: %s", module.getBaseCommands() ); +// } +// +// List disabledModules = Prison.get().getModuleManager().getDisabledModules(); +// if ( disabledModules.size() > 0 ) { +// display.addText( "&7Disabled Module%s:", (disabledModules.size() > 1 ? "s" : "")); +// for ( String disabledModule : Prison.get().getModuleManager().getDisabledModules() ) { +// display.addText( ". &cDisabled Module:&7 %s. Related commands and placeholders are non-functional. ", +// disabledModule ); // } // } - - -// RegisteredPluginsData plugin = getRegisteredPluginData().get( "Prison" ); -// String pluginDetails = plugin.getdetails(); // -// display.text( pluginDetails ); +// display.addText(""); +// display.addText("&7Integrations:"); +// +// IntegrationManager im = Prison.get().getIntegrationManager(); +// String permissions = +// (im.hasForType(IntegrationType.PERMISSION) ? +// " " + im.getForType(IntegrationType.PERMISSION).get().getDisplayName() : +// "None"); +// +// display.addText(". . &7Permissions: " + permissions); +// +// String economy = +// (im.hasForType(IntegrationType.ECONOMY) ? +// " " + im.getForType(IntegrationType.ECONOMY).get().getDisplayName() : +// "None"); +// +// display.addText(". . &7Economy: " + economy); +// +// +// List integrationRows = im.getIntegrationComponents( isBasic ); +// for ( DisplayComponent component : integrationRows ) +// { +// display.addComponent( component ); +// } +// +// +// display.addText(""); +// display.addText("&7Locale Settings:"); +// +// for ( String localeInfo : Prison.get().getLocaleLoadInfo() ) { +// display.addText( ". . " + localeInfo ); +// } - -// if ( !isBasic ) { -// Prison.get().getPlatform().dumpEventListenersBlockBreakEvents(); +// +// Prison.get().getPlatform().identifyRegisteredPlugins(); +// +// // NOTE: This list of plugins is good enough and the detailed does not have all the info. +// // Display all loaded plugins: +// if ( getRegisteredPlugins().size() > 0 ) { +// display.addText(""); +// display.addText( "&7Registered Plugins: " ); +// +// List plugins = getRegisteredPlugins(); +// Collections.sort( plugins ); +// List plugins2Cols = Text.formatColumnsFromList( plugins, 2 ); +// +// for ( String rp : plugins2Cols ) { +// +// display.addText( rp ); +// } +// +//// StringBuilder sb = new StringBuilder(); +//// for ( String plugin : getRegisteredPlugins() ) { +//// if ( sb.length() == 0) { +//// sb.append( ". " ); +//// sb.append( plugin ); +//// } else { +//// sb.append( ", " ); +//// sb.append( plugin ); +//// display.addText( sb.toString() ); +//// sb.setLength( 0 ); +//// } +//// } +//// if ( sb.length() > 0 ) { +//// display.addText( sb.toString()); +//// } +// } +// +// // This version of plugins does not have all the registered commands: +//// // The new plugin listings: +//// if ( getRegisteredPluginData().size() > 0 ) { +//// display.text( "&7Registered Plugins Detailed: " ); +//// StringBuilder sb = new StringBuilder(); +//// Set keys = getRegisteredPluginData().keySet(); +//// +//// for ( String key : keys ) { +//// RegisteredPluginsData plugin = getRegisteredPluginData().get(key); +//// +//// if ( sb.length() == 0) { +//// sb.append( " " ); +//// sb.append( plugin.formatted() ); +//// } else { +//// sb.append( ", " ); +//// sb.append( plugin.formatted() ); +//// display.text( sb.toString() ); +//// sb.setLength( 0 ); +//// } +//// } +//// if ( sb.length() > 0 ) { +//// display.text( sb.toString()); +//// } +//// } +// +// +//// RegisteredPluginsData plugin = getRegisteredPluginData().get( "Prison" ); +//// String pluginDetails = plugin.getdetails(); +//// +//// display.text( pluginDetails ); +// +// +//// if ( !isBasic ) { +//// Prison.get().getPlatform().dumpEventListenersBlockBreakEvents(); +//// } +// +// +// Prison.get().getPlatform().getWorldLoadErrors( display ); +// +// if ( !isBasic && getPrisonStartupDetails().size() > 0 ) { +// display.addText(""); +// +// for ( String msg : getPrisonStartupDetails() ) { +// display.addText( msg ); +// } // } - - - Prison.get().getPlatform().getWorldLoadErrors( display ); - - if ( !isBasic && getPrisonStartupDetails().size() > 0 ) { - display.addText(""); - - for ( String msg : getPrisonStartupDetails() ) { - display.addText( msg ); - } - } return display; } 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 19bd0d96e..e903aa9e8 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 @@ -351,8 +351,11 @@ public void autoCreateMineLinerAssignment( List rankMineNames, * * @return */ - public List getActiveFeatures(); + public List getActiveFeatures( boolean showLaddersAndRanks ); + + public void prisonVersionFeatures( ChatDisplay display, boolean isBasic, boolean showLaddersAndRanks ); + public String dumpEventListenersBlockBreakEvents(); 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 c0951c5a9..d8492350a 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java +++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java @@ -370,11 +370,18 @@ public void autoCreateConfigureMines() { } @Override - public List getActiveFeatures() { + public List getActiveFeatures( boolean showLaddersAndRanks ) { List results = new ArrayList<>(); return results; } + + @Override + public void prisonVersionFeatures( ChatDisplay display, boolean isBasic, boolean showLaddersAndRanks ) { + + } + + @Override public String dumpEventListenersBlockBreakEvents() { 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 66dc11a53..79b2ae35e 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 @@ -60,6 +60,8 @@ import tech.mcprison.prison.convert.ConversionResult; import tech.mcprison.prison.file.FileStorage; import tech.mcprison.prison.file.YamlFileIO; +import tech.mcprison.prison.integration.IntegrationManager; +import tech.mcprison.prison.integration.IntegrationType; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.PlayerUtil; import tech.mcprison.prison.internal.Scheduler; @@ -79,8 +81,10 @@ import tech.mcprison.prison.modules.Module; import tech.mcprison.prison.modules.ModuleElement; import tech.mcprison.prison.modules.ModuleElementType; +import tech.mcprison.prison.modules.ModuleStatus; import tech.mcprison.prison.output.BulletedListComponent; import tech.mcprison.prison.output.ChatDisplay; +import tech.mcprison.prison.output.DisplayComponent; import tech.mcprison.prison.output.LogLevel; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; @@ -91,7 +95,6 @@ import tech.mcprison.prison.ranks.data.RankPlayerFactory; import tech.mcprison.prison.ranks.managers.PlayerManager; import tech.mcprison.prison.ranks.managers.RankManager; -import tech.mcprison.prison.ranks.managers.RankManager.RanksByLadderOptions; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerBlockBreakEvents; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerCrazyEnchants; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerPrisonEnchants; @@ -1970,40 +1973,44 @@ public List buildBlockListXMaterial() { // } @Override - public List getActiveFeatures() { + public List getActiveFeatures( boolean showLaddersAndRanks ) { List results = new ArrayList<>(); - // Log rank related items first: - if ( Prison.get().getModuleManager().isModuleActive( PrisonRanks.MODULE_NAME ) ) { + if ( showLaddersAndRanks ) { - PrisonRanks pRanks = PrisonRanks.getInstance(); - - results.add( - pRanks.prisonRanksStatusLoadedLaddersMsg( - pRanks.getladderCount() ) ); - - int totalRanks = pRanks.getRankCount(); - int defaultRanks = pRanks.getDefaultLadderRankCount(); - int prestigesRanks = pRanks.getPrestigesLadderRankCount(); - int otherRanks = totalRanks - defaultRanks - prestigesRanks; - - results.add( - pRanks.prisonRanksStatusLoadedRanksMsg( - totalRanks, defaultRanks, prestigesRanks, otherRanks ) ); - - results.add( - pRanks.prisonRanksStatusLoadedPlayersMsg( - pRanks.getPlayersCount() ) ); - - - // Display all Ranks in each ladder: - results.addAll( - PrisonRanks.getInstance().getRankManager().ranksByLadders() ); - - results.add( " " ); + // Log rank related items first: + if ( Prison.get().getModuleManager().isModuleActive( PrisonRanks.MODULE_NAME ) ) { + + PrisonRanks pRanks = PrisonRanks.getInstance(); + + results.add( + pRanks.prisonRanksStatusLoadedLaddersMsg( + pRanks.getladderCount() ) ); + + int totalRanks = pRanks.getRankCount(); + int defaultRanks = pRanks.getDefaultLadderRankCount(); + int prestigesRanks = pRanks.getPrestigesLadderRankCount(); + int otherRanks = totalRanks - defaultRanks - prestigesRanks; + + results.add( + pRanks.prisonRanksStatusLoadedRanksMsg( + totalRanks, defaultRanks, prestigesRanks, otherRanks ) ); + + results.add( + pRanks.prisonRanksStatusLoadedPlayersMsg( + pRanks.getPlayersCount() ) ); + + + // Display all Ranks in each ladder: + results.addAll( + PrisonRanks.getInstance().getRankManager().ranksByLadders() ); + + results.add( " " ); + } } + AutoFeaturesWrapper afw = AutoFeaturesWrapper.getInstance(); @@ -2224,6 +2231,176 @@ public List getActiveFeatures() { } + @Override + public void prisonVersionFeatures( ChatDisplay display, boolean isBasic, + boolean showLaddersAndRanks ) { + + + + List features = getActiveFeatures( showLaddersAndRanks ); + if ( features.size() > 0 ) { + + display.addText(""); + for ( String feature : features ) { + + if ( !feature.startsWith( "+" ) ) { + + display.addText( feature ); + } + else if ( !isBasic ) { + + display.addText( feature.substring( 1 ) ); + } + } + } + + + display.addText(""); + + // Active Modules:x's root Command: &3/prison"); + + for ( Module module : Prison.get().getModuleManager().getModules() ) { + + display.addText( "&7Module: %s : %s %s", module.getName(), + module.getStatus().getStatusText(), + (module.getStatus().getStatus() == ModuleStatus.Status.FAILED ? + "[" + module.getStatus().getMessage() + "]" : "") + ); + // display.addText( ". &7Base Commands: %s", module.getBaseCommands() ); + } + + List disabledModules = Prison.get().getModuleManager().getDisabledModules(); + if ( disabledModules.size() > 0 ) { + display.addText( "&7Disabled Module%s:", (disabledModules.size() > 1 ? "s" : "")); + for ( String disabledModule : Prison.get().getModuleManager().getDisabledModules() ) { + display.addText( ". &cDisabled Module:&7 %s. Related commands and placeholders are non-functional. ", + disabledModule ); + } + } + + display.addText(""); + display.addText("&7Integrations:"); + + IntegrationManager im = Prison.get().getIntegrationManager(); + String permissions = + (im.hasForType(IntegrationType.PERMISSION) ? + " " + im.getForType(IntegrationType.PERMISSION).get().getDisplayName() : + "None"); + + display.addText(". . &7Permissions: " + permissions); + + String economy = + (im.hasForType(IntegrationType.ECONOMY) ? + " " + im.getForType(IntegrationType.ECONOMY).get().getDisplayName() : + "None"); + + display.addText(". . &7Economy: " + economy); + + + List integrationRows = im.getIntegrationComponents( isBasic ); + for ( DisplayComponent component : integrationRows ) + { + display.addComponent( component ); + } + + + display.addText(""); + display.addText("&7Locale Settings:"); + + for ( String localeInfo : Prison.get().getLocaleLoadInfo() ) { + display.addText( ". . " + localeInfo ); + } + + + identifyRegisteredPlugins(); + + List registeredPlugins = Prison.get().getPrisonCommands().getRegisteredPlugins(); + + + // NOTE: This list of plugins is good enough and the detailed does not have all the info. + // Display all loaded plugins: + if ( registeredPlugins.size() > 0 ) { + display.addText(""); + display.addText( "&7Registered Plugins: " ); + +// List plugins = getRegisteredPlugins(); + Collections.sort( registeredPlugins ); + List plugins2Cols = Text.formatColumnsFromList( registeredPlugins, 2 ); + + for ( String rp : plugins2Cols ) { + + display.addText( rp ); + } + +// StringBuilder sb = new StringBuilder(); +// for ( String plugin : getRegisteredPlugins() ) { +// if ( sb.length() == 0) { +// sb.append( ". " ); +// sb.append( plugin ); +// } else { +// sb.append( ", " ); +// sb.append( plugin ); +// display.addText( sb.toString() ); +// sb.setLength( 0 ); +// } +// } +// if ( sb.length() > 0 ) { +// display.addText( sb.toString()); +// } + } + + // This version of plugins does not have all the registered commands: +// // The new plugin listings: +// if ( getRegisteredPluginData().size() > 0 ) { +// display.text( "&7Registered Plugins Detailed: " ); +// StringBuilder sb = new StringBuilder(); +// Set keys = getRegisteredPluginData().keySet(); +// +// for ( String key : keys ) { +// RegisteredPluginsData plugin = getRegisteredPluginData().get(key); +// +// if ( sb.length() == 0) { +// sb.append( " " ); +// sb.append( plugin.formatted() ); +// } else { +// sb.append( ", " ); +// sb.append( plugin.formatted() ); +// display.text( sb.toString() ); +// sb.setLength( 0 ); +// } +// } +// if ( sb.length() > 0 ) { +// display.text( sb.toString()); +// } +// } + + +// RegisteredPluginsData plugin = getRegisteredPluginData().get( "Prison" ); +// String pluginDetails = plugin.getdetails(); +// +// display.text( pluginDetails ); + + +// if ( !isBasic ) { +// Prison.get().getPlatform().dumpEventListenersBlockBreakEvents(); +// } + + + Prison.get().getPlatform().getWorldLoadErrors( display ); + + if ( !isBasic && Prison.get().getPrisonCommands().getPrisonStartupDetails().size() > 0 ) { + display.addText(""); + + for ( String msg : Prison.get().getPrisonCommands().getPrisonStartupDetails() ) { + display.addText( msg ); + } + } + + + + } + + @Override public PlayerUtil getPlayerUtil( UUID playerUuid ) { return new SpigotPlayerUtil( playerUuid ); 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 1311b41d9..088e019d7 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 @@ -338,7 +338,20 @@ public void onEnableStartup() { // cmdVersion.getRegisteredPlugins().add( value ); // } - ChatDisplay cdVersion = cmdVersion.displayVersion("basic"); + + ChatDisplay cdVersion = new ChatDisplay("A suppressed title"); + cdVersion.setShowTitle( false ); +// ChatDisplay cdVersion = cmdVersion.displayVersion("basic"); + + + // This generates the module listing, the autoFeatures overview, + // the integrations listings, and the plugins listings. + // Used in the command: /prison version + boolean isBasic = true; + boolean showLaddersAndRanks = false; + Prison.get().getPlatform().prisonVersionFeatures( cdVersion, isBasic, showLaddersAndRanks ); + + cdVersion.toLog( LogLevel.INFO ); // Provides a startup test of blocks available for the version of spigot that being used: From 03f48141f29b4347d6e6b2b1a30be09da6017d2b Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 2 Apr 2022 12:13:54 -0400 Subject: [PATCH 208/297] Ran in to an issue with spigot versions < 1.13 where a data value outside of the normal range prevents XMaterial from mapping to a bukkit block. This change provides a better fallback which ignores the data value, which is the varient. The drawback of ignoring the varient type, which is outside the valid ranges anyway, is that it may not accurately reflect the intended block types. But at least this will prevent errors and being unable to map to any blocks. --- docs/changelog_v3.3.x.md | 4 ++++ .../mcprison/prison/spigot/compat/Spigot18Blocks.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 4139197c8..a73d9619c 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.9g 2022-04-02 +* **Ran in to an issue with spigot versions < 1.13 where a data value outside of the normal range prevents XMaterial from mapping to a bukkit block.** +This change provides a better fallback which ignores the data value, which is the varient. The drawback of ignoring the varient type, which is outside the valid ranges anyway, is that it may not accurately reflect the intended block types. But at least this will prevent errors and being unable to map to any blocks. + + * **Change to prison startup details reporting to elminate duplication.** Near the end of the prison startup process, prison would run the `/prison version` command to provide additional information in the logs. This was duplicating some of the information that was already printed during the actual startup process. Changes were made to only add the information that was missing so the whole command does not need to re reran. Overall this is a small impact, but a useful one. It does shift where these functions live and ran from. 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 4a04b41c4..ce648dfd8 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 @@ -231,6 +231,14 @@ public XMaterial getXMaterial( Block spigotBlock ) { results = XMaterial.matchXMaterial( id, data ).orElse( null ); } + if ( results == null ) { + results = XMaterial.matchXMaterial(spigotBlock.getType()); + } + + if ( results == null ) { + results = XMaterial.matchXMaterial( spigotBlock.getType().name() ).orElse( null ); + } + if ( results == null ) { // Last chance, try to match without data. If it matches, then // the cache will be setup with a data appended so as to bypass all this From 29377f8bd2ef97b2075f84c157f27c1012766153 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 9 Apr 2022 17:52:34 -0400 Subject: [PATCH 209/297] v3.3.0-alpha.10 2022-04-02 --- docs/changelog_v3.3.x.md | 25 ++++++++++++++++++++++++- gradle.properties | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a73d9619c..d7b83bf31 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,30 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.9g 2022-04-02 +# 3.3.0-alpha.10 2022-04-02 + + +** v3.3.0-alpha.10 2022-04-02** + +** Release notes for the v3.3.0-alpha.10 release as posted to spigotmc.org and polymart.org: + +v3.3.0-alpha.10 + +This alpha.10 release includes many significant performance improvements and bug fixes. Although this is an alpha release, it is proving to be stable enough to use on a production server. Please make backups and test prior to using. This v3.3.0-alpha.10 release is "still" backwards compatible with v3.2.11 so you should be able to down-grade back to v3.2.11 without major issues. The breaking changes that will be in the final v3.3.0 release have not been applied yet to these alpha releases. + +Please see our discord server for the full listing of all bug fixes and improvements, there have been more than 70 updates since the alpha.9 release. The following is just a simple short list. + +- Many bug fixes. Some that even predates the v3.2.11 release. + +- Performance improvements: startup validations moved to an async thread. Slight delay between mine validations to allow other tasks to run (needed for less powerful servers). Improvements with sellall performance. + +- Added more support for Custom Items (custom blocks) + +- Added support for top-n players and added over 30 new placeholders. Top-n support for blocks mined and tokens earned will be added shortly too. + +- Upgraded internal libraries: bstats, XSeries, gradle, custom items, and a couple others. + +- Many fixes: Mine bombs, sellall, autosell, auto features, block even listening and handling. * **Ran in to an issue with spigot versions < 1.13 where a data value outside of the normal range prevents XMaterial from mapping to a bukkit block.** diff --git a/gradle.properties b/gradle.properties index ec6181753..645605c6d 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.9g +version=3.3.0-alpha.10 #version=3.3.0-alpha.7 From 219d63587c945df01fb2dfd5ecf4710043defa08 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 10 Apr 2022 12:08:50 -0400 Subject: [PATCH 210/297] Pull out the setBlock and blockAt functions from the SpigotWorld class so that way it would properly track within Timings. --- docs/changelog_v3.3.x.md | 6 +- .../block/SpigotBlockGetAtLocation.java | 80 +++++ .../block/SpigotBlockSetAsynchronously.java | 44 +++ .../block/SpigotBlockSetSynchronously.java | 91 ++++++ .../prison/spigot/game/SpigotWorld.java | 274 +++++++++--------- 5 files changed, 355 insertions(+), 140 deletions(-) create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockGetAtLocation.java create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockSetAsynchronously.java create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockSetSynchronously.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d7b83bf31..cd3c71971 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.10 2022-04-02 +# 3.3.0-alpha.10 2022-04-10 + + +* **Pull out the setBlock and blockAt functions from the SpigotWorld class so that way it would properly track within Timings.** + ** v3.3.0-alpha.10 2022-04-02** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockGetAtLocation.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockGetAtLocation.java new file mode 100644 index 000000000..f23774b06 --- /dev/null +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockGetAtLocation.java @@ -0,0 +1,80 @@ +package tech.mcprison.prison.spigot.block; + +import java.util.List; + +import tech.mcprison.prison.PrisonAPI; +import tech.mcprison.prison.integration.CustomBlockIntegration; +import tech.mcprison.prison.internal.block.Block; +import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.spigot.compat.SpigotCompatibility; +import tech.mcprison.prison.spigot.game.SpigotWorld; +import tech.mcprison.prison.util.Location; + +public class SpigotBlockGetAtLocation { + + /** + *

This should be the ONLY usage in the whole Prison plugin that gets the + * bukkit block from the world and converts it to a SpigotBlock.. + *

+ * + *

This gets the actual block from the world, but it only reads, and does not + * update. I cannot say this is safe to run asynchronously, but so far I have + * not see any related problems when it is. + * + */ + public Block getBlockAt( Location location, boolean containsCustomBlocks, + SpigotWorld world ) { + SpigotBlock sBlock = null; + + if ( location != null ) { + + org.bukkit.Location bLocation = world.getBukkitLocation( location ); + org.bukkit.block.Block bBlock = world.getWrapper().getBlockAt( bLocation ); + + + sBlock = SpigotCompatibility.getInstance().getSpigotBlock( bBlock ); + + if ( sBlock == null ) { + + sBlock = new SpigotBlock( bBlock, PrisonBlock.AIR.clone() ); + } + + + if ( containsCustomBlocks ) { + + List cbIntegrations = + PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); + + for ( CustomBlockIntegration customBlock : cbIntegrations ) + { + PrisonBlock pBlock = customBlock.getCustomBlock( sBlock ); + + if ( pBlock != null ) { + + //if ( Output.get().isDebug() ) +// { +// +// String message = String.format( +// "SpigotWorld.getBlockAt: customBlock: %s " + +// "spigot: %s bukkit: %s", +// pBlock.getBlockName(), sBlock.getBlockName(), +// bBlock.getType().name() ); +// +// Output.get().logInfo( message ); +// } + + sBlock.setBlockName( pBlock.getBlockName() ); + sBlock.setBlockType( customBlock.getBlockType() ); + break; + } + } + } + + + } + + return sBlock; + } + + +} diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockSetAsynchronously.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockSetAsynchronously.java new file mode 100644 index 000000000..84bf8fff8 --- /dev/null +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockSetAsynchronously.java @@ -0,0 +1,44 @@ +package tech.mcprison.prison.spigot.block; + +import tech.mcprison.prison.PrisonAPI; +import tech.mcprison.prison.integration.CustomBlockIntegration; +import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.spigot.compat.SpigotCompatibility; +import tech.mcprison.prison.util.Location; + +public class SpigotBlockSetAsynchronously { + + /** + *

This function should be called from an async task, and it will + * drop down in to the synchronous thread to first get the block + * from the world, then it will change to the specified PrisonBlock type. + *

+ * + * @param prisonBlock + * @param location + */ + public void setBlockAsync( PrisonBlock prisonBlock, Location location ) { + + switch ( prisonBlock.getBlockType() ) + { + case minecraft: + + SpigotCompatibility.getInstance().updateSpigotBlockAsync( prisonBlock, location ); + + break; + + case CustomItems: + { + CustomBlockIntegration customItemsIntegration = + PrisonAPI.getIntegrationManager().getCustomBlockIntegration( prisonBlock.getBlockType() ); + + customItemsIntegration.setCustomBlockIdAsync( prisonBlock, location ); + } + + break; + + default: + break; + } + } +} diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockSetSynchronously.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockSetSynchronously.java new file mode 100644 index 000000000..dd1056e88 --- /dev/null +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotBlockSetSynchronously.java @@ -0,0 +1,91 @@ +package tech.mcprison.prison.spigot.block; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.scheduler.BukkitRunnable; + +import tech.mcprison.prison.internal.PrisonStatsElapsedTimeNanos; +import tech.mcprison.prison.internal.block.MineResetType; +import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; +import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.spigot.SpigotPrison; +import tech.mcprison.prison.spigot.game.SpigotWorld; +import tech.mcprison.prison.util.Location; + +public class SpigotBlockSetSynchronously { + + public void setBlocksSynchronously( List tBlocks, MineResetType resetType, + PrisonStatsElapsedTimeNanos nanos, SpigotWorld world ) { + + List tBlocksCloned = new ArrayList<>(); + for ( MineTargetPrisonBlock mtpb : tBlocks ) { + + tBlocksCloned.add( mtpb ); + } + + new BukkitRunnable() { + @Override + public void run() { + + long start = System.nanoTime(); + + MineTargetPrisonBlock current = null; + try + { + for ( MineTargetPrisonBlock tBlock : tBlocksCloned ) + { + current = tBlock; + + if ( tBlock != null && tBlock.getLocation() != null ) { + + final PrisonBlock pBlock = tBlock.getPrisonBlock( resetType ); + + if ( pBlock != null ) { + + Location location = tBlock.getLocation(); + + SpigotBlock sBlock = (SpigotBlock) world.getBlockAt( location ); +// SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); + + sBlock.setPrisonBlock( pBlock ); + } + } + + } + } + catch ( Exception e ) { + + if ( current != null ) { + + String blkName = current.getPrisonBlock().getBlockName(); + PrisonBlock pBlock = current.getPrisonBlock( resetType ); + String resetTypeBlockName = pBlock == null ? "null" : pBlock.getBlockName(); + + Output.get().logError( + String.format( "SpigotWorld.setBlocksSynchronously Exception: %s resetType: %s %s :: %s", + blkName, resetType.name(), resetTypeBlockName, e.getMessage() ), e ); + } + else { + + Output.get().logError( + String.format( "SpigotWorld.setBlocksSynchronously Exception: --noBlock-- resetType: %s " + + "[unable to set 'current'] :: %s", + resetType.name(), e.getMessage() ), e ); + } + } + + long elapsedNanos = System.nanoTime() - start; + + + if ( nanos != null ) { + nanos.addNanos( elapsedNanos ); + } + + } + }.runTaskLater( SpigotPrison.getInstance(), 0 ); + + } + +} diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java index 895ab4d6f..62352df0f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java @@ -18,16 +18,12 @@ package tech.mcprison.prison.spigot.game; -import java.util.ArrayList; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; import org.bukkit.Bukkit; -import org.bukkit.scheduler.BukkitRunnable; -import tech.mcprison.prison.PrisonAPI; -import tech.mcprison.prison.integration.CustomBlockIntegration; import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.PrisonStatsElapsedTimeNanos; @@ -36,10 +32,10 @@ import tech.mcprison.prison.internal.block.MineResetType; import tech.mcprison.prison.internal.block.MineTargetPrisonBlock; import tech.mcprison.prison.internal.block.PrisonBlock; -import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.SpigotUtil; -import tech.mcprison.prison.spigot.block.SpigotBlock; +import tech.mcprison.prison.spigot.block.SpigotBlockGetAtLocation; +import tech.mcprison.prison.spigot.block.SpigotBlockSetAsynchronously; +import tech.mcprison.prison.spigot.block.SpigotBlockSetSynchronously; import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; import tech.mcprison.prison.util.Location; @@ -50,6 +46,10 @@ public class SpigotWorld implements World { private org.bukkit.World bukkitWorld; + + private SpigotBlockSetAsynchronously setBlockAsync; + private SpigotBlockSetSynchronously setBlockSync; + private SpigotBlockGetAtLocation getBlockAtLocation; public SpigotWorld(org.bukkit.World bukkitWorld) { this.bukkitWorld = bukkitWorld; @@ -80,56 +80,63 @@ public SpigotWorld(org.bukkit.World bukkitWorld) { */ @Override public Block getBlockAt( Location location, boolean containsCustomBlocks ) { - SpigotBlock sBlock = null; - if ( location != null ) { - - org.bukkit.Location bLocation = getBukkitLocation( location ); - org.bukkit.block.Block bBlock = bukkitWorld.getBlockAt( bLocation ); - - - sBlock = SpigotCompatibility.getInstance().getSpigotBlock( bBlock ); - - if ( sBlock == null ) { - - sBlock = new SpigotBlock( bBlock, PrisonBlock.AIR.clone() ); - } - - - if ( containsCustomBlocks ) { - - List cbIntegrations = - PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); - - for ( CustomBlockIntegration customBlock : cbIntegrations ) - { - PrisonBlock pBlock = customBlock.getCustomBlock( sBlock ); - - if ( pBlock != null ) { - - //if ( Output.get().isDebug() ) -// { -// -// String message = String.format( -// "SpigotWorld.getBlockAt: customBlock: %s " + -// "spigot: %s bukkit: %s", -// pBlock.getBlockName(), sBlock.getBlockName(), -// bBlock.getType().name() ); -// -// Output.get().logInfo( message ); -// } - - sBlock.setBlockName( pBlock.getBlockName() ); - sBlock.setBlockType( customBlock.getBlockType() ); - break; - } - } - } - - + if ( getBlockAtLocation == null ) { + getBlockAtLocation = new SpigotBlockGetAtLocation(); } - - return sBlock; + + return getBlockAtLocation.getBlockAt(location, containsCustomBlocks, this); + +// SpigotBlock sBlock = null; +// +// if ( location != null ) { +// +// org.bukkit.Location bLocation = getBukkitLocation( location ); +// org.bukkit.block.Block bBlock = bukkitWorld.getBlockAt( bLocation ); +// +// +// sBlock = SpigotCompatibility.getInstance().getSpigotBlock( bBlock ); +// +// if ( sBlock == null ) { +// +// sBlock = new SpigotBlock( bBlock, PrisonBlock.AIR.clone() ); +// } +// +// +// if ( containsCustomBlocks ) { +// +// List cbIntegrations = +// PrisonAPI.getIntegrationManager().getCustomBlockIntegrations(); +// +// for ( CustomBlockIntegration customBlock : cbIntegrations ) +// { +// PrisonBlock pBlock = customBlock.getCustomBlock( sBlock ); +// +// if ( pBlock != null ) { +// +// //if ( Output.get().isDebug() ) +//// { +//// +//// String message = String.format( +//// "SpigotWorld.getBlockAt: customBlock: %s " + +//// "spigot: %s bukkit: %s", +//// pBlock.getBlockName(), sBlock.getBlockName(), +//// bBlock.getType().name() ); +//// +//// Output.get().logInfo( message ); +//// } +// +// sBlock.setBlockName( pBlock.getBlockName() ); +// sBlock.setBlockType( customBlock.getBlockType() ); +// break; +// } +// } +// } +// +// +// } +// +// return sBlock; } public Block getBlockAt( Location location ) { @@ -175,27 +182,11 @@ public void setBlock( PrisonBlock block, int x, int y, int z ) { */ public void setBlockAsync( PrisonBlock prisonBlock, Location location ) { - switch ( prisonBlock.getBlockType() ) - { - case minecraft: - - SpigotCompatibility.getInstance().updateSpigotBlockAsync( prisonBlock, location ); - - break; - - case CustomItems: - { - CustomBlockIntegration customItemsIntegration = - PrisonAPI.getIntegrationManager().getCustomBlockIntegration( prisonBlock.getBlockType() ); - - customItemsIntegration.setCustomBlockIdAsync( prisonBlock, location ); - } - - break; - - default: - break; + if ( setBlockAsync == null ) { + setBlockAsync = new SpigotBlockSetAsynchronously(); } + setBlockAsync.setBlockAsync(prisonBlock, location); + } @@ -214,72 +205,77 @@ public void setBlockAsync( PrisonBlock prisonBlock, Location location ) { public void setBlocksSynchronously( List tBlocks, MineResetType resetType, PrisonStatsElapsedTimeNanos nanos ) { - List tBlocksCloned = new ArrayList<>(); - for ( MineTargetPrisonBlock mtpb : tBlocks ) { - - tBlocksCloned.add( mtpb ); + if ( setBlockSync == null ) { + setBlockSync = new SpigotBlockSetSynchronously(); } + setBlockSync.setBlocksSynchronously(tBlocks, resetType, nanos, this ); - new BukkitRunnable() { - @Override - public void run() { - - long start = System.nanoTime(); - - MineTargetPrisonBlock current = null; - try - { - for ( MineTargetPrisonBlock tBlock : tBlocksCloned ) - { - current = tBlock; - - if ( tBlock != null && tBlock.getLocation() != null ) { - - final PrisonBlock pBlock = tBlock.getPrisonBlock( resetType ); - - if ( pBlock != null ) { - - Location location = tBlock.getLocation(); - - SpigotBlock sBlock = (SpigotBlock) getBlockAt( location ); -// SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); - - sBlock.setPrisonBlock( pBlock ); - } - } - - } - } - catch ( Exception e ) { - - if ( current != null ) { - - String blkName = current.getPrisonBlock().getBlockName(); - PrisonBlock pBlock = current.getPrisonBlock( resetType ); - String resetTypeBlockName = pBlock == null ? "null" : pBlock.getBlockName(); - - Output.get().logError( - String.format( "SpigotWorld.setBlocksSynchronously Exception: %s resetType: %s %s :: %s", - blkName, resetType.name(), resetTypeBlockName, e.getMessage() ), e ); - } - else { - - Output.get().logError( - String.format( "SpigotWorld.setBlocksSynchronously Exception: --noBlock-- resetType: %s " + - "[unable to set 'current'] :: %s", - resetType.name(), e.getMessage() ), e ); - } - } - - long elapsedNanos = System.nanoTime() - start; - - - if ( nanos != null ) { - nanos.addNanos( elapsedNanos ); - } - - } - }.runTaskLater( SpigotPrison.getInstance(), 0 ); +// List tBlocksCloned = new ArrayList<>(); +// for ( MineTargetPrisonBlock mtpb : tBlocks ) { +// +// tBlocksCloned.add( mtpb ); +// } +// +// new BukkitRunnable() { +// @Override +// public void run() { +// +// long start = System.nanoTime(); +// +// MineTargetPrisonBlock current = null; +// try +// { +// for ( MineTargetPrisonBlock tBlock : tBlocksCloned ) +// { +// current = tBlock; +// +// if ( tBlock != null && tBlock.getLocation() != null ) { +// +// final PrisonBlock pBlock = tBlock.getPrisonBlock( resetType ); +// +// if ( pBlock != null ) { +// +// Location location = tBlock.getLocation(); +// +// SpigotBlock sBlock = (SpigotBlock) getBlockAt( location ); +//// SpigotBlock sBlock = (SpigotBlock) location.getBlockAt(); +// +// sBlock.setPrisonBlock( pBlock ); +// } +// } +// +// } +// } +// catch ( Exception e ) { +// +// if ( current != null ) { +// +// String blkName = current.getPrisonBlock().getBlockName(); +// PrisonBlock pBlock = current.getPrisonBlock( resetType ); +// String resetTypeBlockName = pBlock == null ? "null" : pBlock.getBlockName(); +// +// Output.get().logError( +// String.format( "SpigotWorld.setBlocksSynchronously Exception: %s resetType: %s %s :: %s", +// blkName, resetType.name(), resetTypeBlockName, e.getMessage() ), e ); +// } +// else { +// +// Output.get().logError( +// String.format( "SpigotWorld.setBlocksSynchronously Exception: --noBlock-- resetType: %s " + +// "[unable to set 'current'] :: %s", +// resetType.name(), e.getMessage() ), e ); +// } +// } +// +// long elapsedNanos = System.nanoTime() - start; +// +// +// if ( nanos != null ) { +// nanos.addNanos( elapsedNanos ); +// } +// +// } +// }.runTaskLater( SpigotPrison.getInstance(), 0 ); } From 769f758384f2f0e5070d67533d001f631f407563 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 10 Apr 2022 15:45:11 -0400 Subject: [PATCH 211/297] Placeholders: prison_rankup_rank_tag (and the ladder variants) now shows the prestiges next rank when at the top rank in the default ladder. This only applies to the default ladder and only if the prestiges ladder is activated. --- docs/changelog_v3.3.x.md | 4 +++ .../prison/ranks/managers/LadderManager.java | 8 +++++ .../prison/ranks/managers/PlayerManager.java | 36 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index cd3c71971..bcc8200eb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.10 2022-04-10 +* **Placeholders: prison_rankup_rank_tag (and the ladder variants) now shows the prestiges next rank when at the top rank in the default ladder.** +This only applies to the default ladder and only if the prestiges ladder is activated. + + * **Pull out the setBlock and blockAt functions from the SpigotWorld class so that way it would properly track within Timings.** 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 821d34951..399452417 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 @@ -246,6 +246,14 @@ public boolean removeLadder(RankLadder ladder) { return true; } + public RankLadder getLadderDefault() { + return getLadder( RankLadder.DEFAULT ); + } + + public RankLadder getLadderPrestiges() { + return getLadder( RankLadder.PRESTIGES ); + } + /** * Returns the ladder with the specified name. * diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index 822a84a15..b511f44e2 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -508,6 +508,24 @@ public String getPlayerRankTag( RankPlayer rankPlayer, String ladderName ) { // sb.append(" "); // } Rank rank = entry.getValue().getRank(); + +// if ( rank.getLadder() != null && rank.getLadder().isDefault() && +// rank.getRankNext() == null ) { +// PlayerRank prestigeRank = rankPlayer.getPlayerRankPrestiges(); +// +// if ( prestigeRank == null ) { +// RankLadder prestigeLadder = PrisonRanks.getInstance() +// .getLadderManager().getLadderPrestiges(); +// if ( prestigeLadder != null ) { +// rank = prestigeLadder.getLowestRank().orElseGet( null ); +// } +// } +// else { +// rank = prestigeRank.getRank().getRankNext(); +// } +// +// } + String tag = rank.getTag(); sb.append( tag == null ? rank.getName() : tag ); } @@ -1312,6 +1330,24 @@ public String getPlayerNextRankTag( RankPlayer rankPlayer, String ladderName ) { PlayerRank pRank = rankPlayerFactory.getRank( rankPlayer, ladder ); Rank rank = pRank.getRank(); + + if ( rank.getLadder() != null && rank.getLadder().isDefault() && + rank.getRankNext() == null ) { + PlayerRank prestigeRank = rankPlayer.getPlayerRankPrestiges(); + + if ( prestigeRank == null ) { + RankLadder prestigeLadder = PrisonRanks.getInstance() + .getLadderManager().getLadderPrestiges(); + if ( prestigeLadder != null ) { + rank = prestigeLadder.getLowestRank().orElseGet( null ); + } + } + else { + rank = prestigeRank.getRank().getRankNext(); + } + + } + if ( rank != null && rank.getRankNext() != null ) { Rank nextRank = rank.getRankNext(); From 674407afb72b76fc9df6c5486e85af281f28d444 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:16:48 -0400 Subject: [PATCH 212/297] CustomItems getDrops() debug mode will list the results of the get drops. This will help track what's going on with the getDrops function since it's a complicated process. --- docs/changelog_v3.3.x.md | 4 ++++ .../customblock/CustomItemsWrapper.java | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index bcc8200eb..9548b4b17 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.10 2022-04-10 +* **CustomItems getDrops() debug mode will list the results of the get drops.** +This will help track what's going on with the getDrops function since it's a complicated process. + + * **Placeholders: prison_rankup_rank_tag (and the ladder variants) now shows the prestiges next rank when at the top rank in the default ladder.** This only applies to the default ladder and only if the prestiges ladder is activated. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java index eeec73bb5..207668d7d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/customblock/CustomItemsWrapper.java @@ -169,6 +169,30 @@ public List getDrops( PrisonBlock prisonBlock, SpigotPlayer pla results.add( new SpigotItemStack( itemStack ) ); } } + + if ( Output.get().isDebug() ) { + StringBuilder sbDrops = new StringBuilder(); + + for (SpigotItemStack sItemStack : results) { + if ( sbDrops.length() > 0 ) { + sbDrops.append(", "); + } + sbDrops.append(sItemStack.getName()).append(":").append(sItemStack.getAmount()); + } + sbDrops.insert(0, "[").append("]"); + + String message = String.format( + "CustomItems.getDrops() results for block: %s " + + "canceled: %b drops: %s player: %s tool: %s", + bBlock == null ? "null" : prisonBlock.getBlockName(), + cuiCanceled, + sbDrops.toString(), + bPlayer == null ? "null" : player.getName(), + toolOverridden == null ? "null" : toolOverridden.getType().toString() + ); + + Output.get().logDebug( message ); + } } } else { From caadc8e678dd4b0a400570fa1688b7159c0cd5ff Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:17:52 -0400 Subject: [PATCH 213/297] Update some docs... Auto Features and to do. --- docs/knownissues_v3.3.x.md | 53 ++++++- docs/prison_docs_311_guide_automanager.md | 170 ++++++++++++++++++++-- 2 files changed, 208 insertions(+), 15 deletions(-) diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index c1926a38e..d09a9ddeb 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -5,7 +5,58 @@ -# TODO Items for v3.3.0-alpha.8 +# TODO Items for v3.3.0-alpha.10 + + +- Many errors when prison hits a standard potion. - jamo + +- autofeatures BLOCKEVENTS priority - include backpacks on auto sell - Ryankayz + +- Top block and top tokens - Phoung Nguyen + +- auto features autosell - tie to sellall's player toggle - Ryankayz + +- SQL support - Six + + +- DONE: autofeatures BLOCKEVENT priority - check for full inventory and perform sellall - Ryankayz + + +- Mine Resets - Glass block not being removed - harold + +- Placeholder bar is reversed. As the player earns more money, it shrinks instead of grows. - harold + - prison_rankup_cost_bar_default + +- Archive old players - budderman18 + - archive all player files to a zip. Remove the originals. If player logs back on, then restore the archives. Prevent startup from adding these players back. + + +- DONE: Rankup - Still not working correctly. + - DONE: takes money but does not rank them up? + - DONE: rank changes does not alter the list of players at the ranks + +- Placeholders - dynamic content - + - custom placeholders based upon other primary placeholders? + + +- DONE: Top-n: hookup rank-score and penalty. + - Placeholders - hookup placeholders to support top=n players. +- DONE: Top-n balance calculations using essentials - 2 mins 31 secs - Budderman18 + - DONE: move to async thread on startup - high priority +- Top-n - phuong Nguyen +- CustomItems drops - harold +- DONE: Sellall - custom blocks/items and items that have been renamed - harold & RomainD +- DONE: sellall - no sell renamed items - RomainD +- DONE: mine bombs - fortune not using the mine bomb's pick with fortune.. always zero - RomainD + - debug is showing fortune 0 +- DONE: CustomItems - not doing drops, even when drops are set - harold +- DONE: CustomItems - Not block counting custom blocks +- DONE: Upgrade bStats to v3.0.0 +- auto features - normal drops may not be happening. May be using auto pickup code. + + + +* DONE: The function isUnbreakable could return a null for the SpigotBlock/PrisonBlock. Change it so the primary check for that function is location, then block is optional. This is failing because the bukkit block cannot be mapped to a XMaterial which should not be a factor. XMaterial will be null for custom blocks. * Add a preformatted sellall multiplier diff --git a/docs/prison_docs_311_guide_automanager.md b/docs/prison_docs_311_guide_automanager.md index 9dc450e45..debd2dc93 100644 --- a/docs/prison_docs_311_guide_automanager.md +++ b/docs/prison_docs_311_guide_automanager.md @@ -2,6 +2,115 @@ ### Prison Documentation [Prison Documents - Table of Contents](prison_docs_000_toc.md) + +See below for information on: +- Setting up TokenEnchants +- Setting up CrazyEnchants + +- Auto Manager Settings - Block Event Listener priorities and their events + + +
+ +# Auto Manager + +Other content is coming soon... + + +
+ + +# Auto Manager Event Listener Priorities + +Prison listens to a number of block break event types, and each one can be enabled or disabled. By enabling these listeners, any combination of priorities can be applied to any of the listeners. + +Valid values for the priorities are: + +- `DISABLED` - This turns off all processing for this event type. +- `LOWEST` - Allows Prison to be one of the first plugins to process the event. +- `LOW` - This generally is the suggested setting since it allows other plugins to use LOWEST if they need to. +- `NORMAL` +- `HIGH` +- `HIGHEST` +- `BLOCKEVENTS` - This priority is basically the same as MONITOR, but it will also run the Prison blockEvents within the mines. +- `MONITOR` - This priority only allows Prison to record which blocks were broken in the mines. It will update the counts for the mines and the players. This setting will NOT run any Prison blockEvents. + + +Valid event listeners are as follows, including their default values: + +- `blockBreakEventPriority: LOW` - This applies to the org.bukkit.BlockBreakEvent and is the primary way Prison deals with standard block events. There may be some situations where prison would need to DISABLE this listener. +- `ProcessPrisons_ExplosiveBlockBreakEventsPriority: LOW` - This is the event that must be enabled for Prison Mine Bombs to work. Other plugins may also use this Prison multi-block explosion event too. +- `TokenEnchantBlockExplodeEventPriority: DISABLED` - For TokenEnchant (premium) +- `CrazyEnchantsBlastUseEventPriority: DISABLED` - For CrazyEnchant (open source) +- `ZenchantmentsBlockShredEventPriority: DISABLED` - For ZenChantments (open source) +- `PrisonEnchantsExplosiveEventPriority: DISABLED` - Pulsi's Plugin - (Premium and free... not currently in active development for at this time) + + +Do not enable any event listener if you are not using that plugin. Doing so will not contribute to lag, but it will try to setup a useless event listener that could delay startup, and consume a little more memory. + + +
+ + +# Auto Manager's Canceling the Event vs. Canceling the Drops + +Prison's primary way of dealing with BlockBreakEvents, and other block events, has always been done by the canceling the event. + + +Note: Setting this behavior will effect all block break event listeners. There is no way to customize it for each event type. + + +This was the original way of handling block breaks, and is the ONLY way of dealing with block breaks for all spigot versions older than v1.12.x. Since this is a feature within Spigot (I don't think it is a bukkit feature), there is no way to provide this newer, and better way, of dealing with block breaks in the older versions. If you try to enable this on older versions of Spigot, then each time the server is started, the setting will be "forced" off and then an error message will be printed to the console too. + + +You can still cancel the events with newer versions of Spigot, but if you run in to compatibility issues with other plugins, then it may be the easiest solution. + + +**Canceling the block break Events:** + +This is the default settings for Prison's Auto Features. This is the setting that must be used on Spigot versions prior to 1.12.x (Spigot 1.8.x through 1.11.x). It can also be used on newer versions of Spigot, but it may cause compatibility issues with some other plugins that need to monitor the event, which canceling the event will cause those plugins to ignore the event. + + +The idea behind these settings, is that prison will break the block (set it to AIR) and then cancel the event. Since the event is canceled, all other plugins will ignore the event and will not perform any processing on it. + + +When the event is canceled, the drops should not be canceled. If the drops are canceled, then there may not be issues, but to be safe, make sure it's not canceled. + + +``` +options: + blockBreakEvents: + cancelAllBlockBreakEvents: true + cancelAllBlockEventBlockDrops: false +``` + + +**Canceling the block drops:** + +This setting is for Prison's Auto Features and **only** works with Spigot versions 1.12.x and higher. By canceling the drops, it allows other plugins that are listening after Prison, to be able to process the block break event too. These are generally plugins that gather stats on the block break event, without contributing to the drops. + + +The idea behind these settings, is that prison will not break the block (set it to AIR), but instead, it will set the drops to zero. Since the event is not canceled, other plugins can process it as normal. Bukkit will then break the block normally when all plugins are done listening to the event, but since the drops have been canceled (set to zero), it will not drop anything. This allows prison to provide the drops, either normally by dropping them, or through auto pickup. + + +Some of the plugins that can benefit from this behavior are: McMMO, Quests, and other plugins that may count block stats. These plugins do not modify the drops, but monitoring the events will allow them to work normally. + + +When the drops are canceled, then event must not be canceled. If the event is canceled, then the drops could be duplicated one or more times. + + +``` +options: + blockBreakEvents: + cancelAllBlockBreakEvents: false + cancelAllBlockEventBlockDrops: true +``` + + + +
+ + # Prison's Auto Manager - Setting Up and Enabling Other Plugins @@ -19,59 +128,92 @@ This document contains information on how to configure TokenEnchant and Crazy En
-# Auto Manager +# To get TokenEnchant's TEBlockExplosionEvent to work with prison, you must follow these settings: -(content coming soon) +The information presented here applies only to the latest release of Prison. There has been many changes related to Prison's auto features that it's next to impossible to cover all past versions of prison. -
+Prison's preferred choice of setting up access to the mines and the ability to TP to the mines, is through the use of the linked Ranks. Prison is able to handle all of the access details for players, without the need to setup permissions and without setting up WorldGuard regions to grant the players access. In the past, with older versions of prison, that was the only way to control mine access, unless the mines were physically isolated from each other through barriers such as void worlds. +Although prison is able to manage it's own access, Prison cannot manage access for other plugins, especially if those plugins utilize API calls directly to WorldGuard to identify what regions a player has access to. Therefore, when setting up TokenEnchant, you must also setup WorldGuard regions. -# To get TokenEnchant's TEBlockExplosionEvent to work with prison, you must follow these settings: +The following instructions will explain how to enable Prison's auto features with auto pickup, and allow Prison to handle TE's multi-block explosion events. These instructions cover the TE's plugin **TE-ExplosiveEnchant-8.x.x.jar**, but they also apply to other TE Plugins that may utilize the TE's **TEBlockExplodeEvent**. -**Please Note:** that these instructions apply to **Prison v3.2.4** and later only. +If you would like have TE handle the auto pickup, or the drops, then you will have to modify these instructions on your own. -**Please Note:** that as of Prison v3.2.5-alpha.11 some of these settings may not be required, especially in relation to WorldGuard and if you are using Mine Access Permissions. -**Please Note:** As of prison v3.2.6-alpha.1 Event priorities have been added to prison. Changing the event priorities may make it easier to get prison to work better with TE instead of having to change the event priorities on TE. If the follow directions do not work well for you, then try changing a few of the the prison's event priorities. Currently I do not have any documentation to explain how this may help. +**Please Note:** Event priorities have been added to prison. Changing the event priorities within Prison may make it easier to get prison to work better with TE instead of having to change the event priorities on TE. If the following directions do not work well for you, then try changing prison's event priorities for the events Prison is listening to. There isn't any documentation to explain how to figure out how priorities on the listeners should work, but in general, the first plugins that lisent to the events has the first chance to do something with the events, but the last plugins have the final say if they want to undo, or override something. This is just letting you know that this may be an option to play with to get things to work. + +**Notice when using Spigot Versions 1.12.x and newer:** Prison now supports drop-canceling, which is a new feature in bukkit 1.12.x and newer. This allows you to turn off Prison's event canceling, and instead, cancel the drops associated with breaking the blocks. How this will work, is that prison will provide auto-pickup on the drops, but it will set the bukkit drops to zero, and then let bukkit naturally break the block when all other plugins are done "listening" to the break. Setting it to zero will prevent bukkit from doubling the drops, and prevent other plugins from doubling the drops too. Older versions of prison did not have this feature, so it was more difficult to get prison to play-well with other plugins. + + + +

General WorldGuard global region settings

+ - **WorldGuard:** Enable the WorldGuard's setting for __global__ to prevent block breaks within the world where the mines are. - **WorldGuard:** Define a **simple region** in the mine the same size as the mine. Name it as suggested at the top of this document, such as prison_mine_c as an example. The "simple" region only includes defining the region, setting the priority to 10, and add a permission group member. Example: `prison.mines.a`. You may add the other flags if you want, as suggested at the top of this document. - **WorldGuard:** Please note: Sometimes you might have to add the WorldGuard flag **block-break** in order to get this to work. `/region flag prison_mine_ block-break allow` It may be a WG version issue. Spigot v1.8.8 requires this flag, while Spigot v1.15.2 does not appear to require it. Your success may vary. It may also be a good idea to add it either way. +

General permissions for the WorldGuard regions

+ - **Player Permissions:** You may have to first create the group within your permission plugin before you can assign it to a player. Example using LuckPerms: `lp creategroup prison.mines.a` - **Player Permissions:** The player must have the permission that is tied to the afore mentioned region. For example the group perm: `prison.mines.a` And assign it with: `/lp user RoyalBlueRanger parent set prison.mines.a` +

Configuring TokenEnchant

+ - **TokenEnchant:** TokenEnchant must be configured properly to enable Explosive enchantment. Setup TokenEnchant as you would normally. Download and place the **TE-ExplosiveEnchant-8.7.0_4.jar** in the `plugins/TokenEnchant/enchants/` directory. Start the server to have TE generate the configuration files related to that enhancement. + - **TokenEnchant:** TokenEnchant must not process the TEBlockExplosionEvent and the default settings must be turned off. TE's auto pickup is defined within TE's config file: `plugins/TokenEnchant/config.yml` at bottom with the two settings: `TEBlockExplodeEvent.process: true` and `TEBlockExplodeEvent.pickup: true` as default values. Both of these must be set to `false` for this to work with prison. + - **TokenEnchant:** In order for TEBlockExplosiveEvent to be fired, the `plugins/TokenEnchant/enchants/Exposive_config.yml` must be adjusted. First run your server to generate this file if you have not done so yet. Find `Potions.Explosive.occurrence: random` and change it to `always` for testing purposes. Then locate the setting of `Potions.Explosive.event_map.BlockBreakEvent: HIGHEST` which is the default value (HIGHEST), and change it to a value of `LOWEST`. Failure to change this setting will result in the failure of TE from being able to fire the TEBlockExplodeEvent. + - **TokenEnchant:** To create a pickaxe with an explosion enchant do the following: From within the game, give yourself a diamond pickaxe (`/give diamond_pickaxe 1` or `diamondpickaxe`) and enchant it with the command `/te enchant Explosive 1` or up to a level of 10. Run as OP, or if you need tokens to use, give yourself some from the console with `/te add 100`. -- **Prison: Auto Manager:** Within the configuration file `plugins/Prison/autoFeaturesConfig.yml` change the setting `options.isProcessTokensEnchantExplosiveEvents: true` to a value of `true`. The default value is true, but double check to ensure it set correctly. PLEASE NOTE: This setting is used even if **options.general.isAutoManagerEnabled: false** is disabled (set to false). -- **Prison: Auto Manager:** Enable **Auto Features** and **Auto Pickup** and all blocks from the explosion event will be placed in the player's inventory. +

Configuring Prison's Auto Manager

+ +- **Prison: Auto Manager:** Within the configuration file `plugins/Prison/autoFeaturesConfig.yml` change the setting `options.blockBreakEvents.TokenEnchantBlockExplodeEventPriority: LOW` to a value of `LOW`. The default value is `DISABLED`, but double check to ensure it set correctly. To disable any event listener, just set the priority to `DISABLED`. + +- **Reload Auto Manager's settings:** If you make a change to the auto manager's settings, you can reload them with `/prison reload autoFeatures`. You don't have to restart the server. + +- **Prison: Auto Manager:** Enable **Auto Features** and **Auto Pickup** and all blocks from the explosion event will be placed in the player's inventory. You can also enable the auto sell on each block break, which may improve the performance when using massive explosions (over 500+ blocks, and even over 30,000+ blocks). + - **Prison: Auto Manager:** If **Auto Features** is disabled (which means auto pickup is also disabled), then the blocks still must be processed and broken by prison to prevent blocks outside of the mine from being broken. To enable prison to drop blocks normally within the mines, while honoring the TE Explosive event, then you will have to enable the setting `isProcessNormalDropsEvents: true` (set to true). Prison will calculate the drops and will drop them where the blocks were originally (not at the player's feet). The internal calculations that prison uses for the drops are the same calculations it uses for the auto pickups. +

Testing the configurations

+ - **Testing:** Deop yourself if you are testing this so you will not break blocks outside the mine. -- **Testing:** Test with a regular pickaxe, a TE Enchanted pickaxe. Also test with Prison's auto features turned on (auto pickup) and off. Ensure the setting `isProcessNormalDropsEvents: true` is enabled when auto features is disabled. This setting can be left on even when auto features is enabled since auto features will override it. - +- **Testing:** Test with a regular pickaxe, and also a TE Enchanted pickaxe. Also test with Prison's auto features turned on (auto pickup) and off. Ensure the setting `isProcessNormalDropsEvents: true` is enabled when auto features is disabled. This setting can be left on even when auto features is enabled since auto features will override it. + +- **Enabling Prison's debug mode:** If the blocks are not breaking as expected, or you're seeing a puff of smoke and hearing an explosion, but no explosion is happening, then you may want to try some of prison's debugging features to see what is going on internally. Prison has a few that can really be beneficial, but it may help to contact our discord server to get help using them too. + + - **Prison Debug Mode - Enabling and Disabling it:** Using the command `/prison debug` will toggle the primary debug mode on and off. + + - The idea is to enable debug mode, break a few blocks, then turn it off. Prison has a "countdown" feature on debug mode, where you can tell it how many debug statements it should log, and then it will turn itself off automatically. To enable the limited debug mode, that will turn itself off, add a "count" to the end of the command such as: `/prison debug 10`. Sometimes, on a busy server, you may have to increase this value to capture the event your looking for, since other players may generate debug statements that are not relevant. + + - **Prison BlockBreak Listeners:** Sometimes the order of the blockBreak listeners in other plugins can get in the way and prevent Prison from working, or other plugins. Use this command to list all listeners in the order in which they will respond to the event. `/prison support listeners blockBreak` + + - **Block Inspection:** When prison is in debug mode, you can use the **Prison wand** (give wand with `/mines wand`) to inspect what a block's name is (left or right click the block). The wand will also set points one and two for creating a new mine too, but ignore that if you want. If you "sneak-click" a block with the wand, using the shift key, then prison will simulate a block break event, but will monitor the before and after states of the event for each plugin that is listening. This could tell you which plugin canceled the event, or processed it, or changed what it will drop. The details will be printed in the console if you do not see them ingame. + + ##### **WARNINGS:** - If anyone is OP'd then they can break blocks outside of the mine through the TE event. This is the result of WorldGuard bypassing the restrictions on the regions and has nothing to do with prison. @@ -88,8 +230,6 @@ This document contains information on how to configure TokenEnchant and Crazy En # To get Crazy Enchants' BlockExplodeEvent to work with prison, you must follow these settings: -Please note that these instructions apply to **Prison v3.2.4** and later only. - Please follow the directions for Token Enchant explosion that are listed above. @@ -98,7 +238,9 @@ But ignore everything that is listed for Token Enchant since Crazy Enchants is m To enable the processing of the Crazy Enchant BlockExplodeEvent enable this configuration: -`isProcessCrazyEnchantsBlockExplodeEvents: true` (enable by setting to true) +`CrazyEnchantsBlastUseEventPriority: LOW` + +Enable by setting to any value other than `DISABLED`. From 459b602a844414101f8de2753ca84f73cdeee337 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 15 Apr 2022 04:24:27 -0400 Subject: [PATCH 214/297] Setup placeholder formatted time values to use the language config file. This set of values will "NOT" reload when the command `/prison reload locales` is ran. The server must be restarted to reload these values. --- docs/changelog_v3.3.x.md | 6 ++- .../prison/placeholders/PlaceholdersUtil.java | 37 ++++++++++++++++--- .../placeholders/PlaceholdersUtilMessage.java | 26 +++++++++++++ .../main/resources/lang/core/de_DE.properties | 3 +- .../main/resources/lang/core/en_GB.properties | 3 +- .../main/resources/lang/core/en_US.properties | 3 +- .../main/resources/lang/core/es_ES.properties | 3 +- .../main/resources/lang/core/hu_HU.properties | 3 +- .../main/resources/lang/core/it_IT.properties | 3 +- .../main/resources/lang/core/nl_BE.properties | 3 +- .../main/resources/lang/core/nl_NL.properties | 3 +- .../main/resources/lang/core/zh_TW.properties | 3 +- 12 files changed, 81 insertions(+), 15 deletions(-) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtilMessage.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9548b4b17..10ebe2e38 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.10 2022-04-10 +# 3.3.0-alpha.10 2022-04-15 + + +* **Setup placeholder formatted time values to use the language config file.** +This set of values will "NOT" reload when the command `/prison reload locales` is ran. The server must be restarted to reload these values. * **CustomItems getDrops() debug mode will list the results of the get drops.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java index 48142f5fc..456fa97f8 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java @@ -4,7 +4,8 @@ import java.util.ArrayList; import java.util.List; -public class PlaceholdersUtil { +public class PlaceholdersUtil + extends PlaceholdersUtilMessage { public static final double TIME_SECOND = 1.0; public static final double TIME_MINUTE = TIME_SECOND * 60.0; @@ -14,6 +15,8 @@ public class PlaceholdersUtil { public static final List prefixesBinary = new ArrayList<>(); + public static final List prefixesTimeUnits = new ArrayList<>(); + static { prefixesBinary.add( "" ); prefixesBinary.add( "KB" ); @@ -24,6 +27,22 @@ public class PlaceholdersUtil { prefixesBinary.add( "EB" ); prefixesBinary.add( "ZB" ); prefixesBinary.add( "YB" ); + + List timeUnitsShort = coreOutputTextTimeUnitsShortArray(); + if ( timeUnitsShort.size() == 7 ) { + // y,m,w,d,h,m,s + prefixesTimeUnits.addAll(timeUnitsShort); + } + else { + // y,m,w,d,h,m,s + prefixesTimeUnits.add( "y" ); + prefixesTimeUnits.add( "m" ); + prefixesTimeUnits.add( "w" ); + prefixesTimeUnits.add( "d" ); + prefixesTimeUnits.add( "h" ); + prefixesTimeUnits.add( "m" ); + prefixesTimeUnits.add( "s" ); + } } @@ -42,28 +61,36 @@ public static String formattedTime( double timeSec ) { timeSec -= (days * TIME_DAY); if ( days > 0 ) { sb.append( days ); - sb.append( "d " ); + // y,m,w,d,h,m,s + sb.append( prefixesTimeUnits.get(3) ).append( " " ); +// sb.append( "d " ); } long hours = (long)(timeSec / TIME_HOUR); timeSec -= (hours * TIME_HOUR); if ( sb.length() > 0 || hours > 0 ) { sb.append( hours ); - sb.append( "h " ); + // y,m,w,d,h,m,s + sb.append( prefixesTimeUnits.get(4) ).append( " " ); +// sb.append( "h " ); } long mins = (long)(timeSec / TIME_MINUTE); timeSec -= (mins * TIME_MINUTE); if ( sb.length() > 0 || mins > 0 ) { sb.append( mins ); - sb.append( "m " ); + // y,m,w,d,h,m,s + sb.append( prefixesTimeUnits.get(5) ).append( " " ); +// sb.append( "m " ); } double secs = (double)(timeSec / TIME_SECOND); timeSec -= (secs * TIME_SECOND); DecimalFormat dFmt = new DecimalFormat("#0"); sb.append( dFmt.format( secs )); - sb.append( "s " ); + // y,m,w,d,h,m,s + sb.append( prefixesTimeUnits.get(6) ).append( " " ); +// sb.append( "s " ); return sb.toString(); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtilMessage.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtilMessage.java new file mode 100644 index 000000000..3f038d4e0 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtilMessage.java @@ -0,0 +1,26 @@ +package tech.mcprison.prison.placeholders; + +import java.util.ArrayList; +import java.util.List; + +import tech.mcprison.prison.Prison; + +public class PlaceholdersUtilMessage { + protected static List coreOutputTextTimeUnitsShortArray() { + List timeUnits = new ArrayList<>(); + + String unitsStr = Prison.get().getLocaleManager() + .getLocalizable( "core_text__time_units_short" ) + .withReplacements( "%s" ) + .setFailSilently() + .localize(); + String[] units = unitsStr.split(","); + + for (String unit : units) { + timeUnits.add( unit.trim() ); + } + + return timeUnits; + } + +} diff --git a/prison-core/src/main/resources/lang/core/de_DE.properties b/prison-core/src/main/resources/lang/core/de_DE.properties index ae61ed3f9..973ea18a2 100644 --- a/prison-core/src/main/resources/lang/core/de_DE.properties +++ b/prison-core/src/main/resources/lang/core/de_DE.properties @@ -70,7 +70,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -97,6 +97,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. diff --git a/prison-core/src/main/resources/lang/core/en_GB.properties b/prison-core/src/main/resources/lang/core/en_GB.properties index def341497..6c6dd2841 100644 --- a/prison-core/src/main/resources/lang/core/en_GB.properties +++ b/prison-core/src/main/resources/lang/core/en_GB.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -94,6 +94,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. diff --git a/prison-core/src/main/resources/lang/core/en_US.properties b/prison-core/src/main/resources/lang/core/en_US.properties index b5dd0523c..af822b085 100644 --- a/prison-core/src/main/resources/lang/core/en_US.properties +++ b/prison-core/src/main/resources/lang/core/en_US.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -94,6 +94,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. diff --git a/prison-core/src/main/resources/lang/core/es_ES.properties b/prison-core/src/main/resources/lang/core/es_ES.properties index c1a4a0714..674f968e2 100644 --- a/prison-core/src/main/resources/lang/core/es_ES.properties +++ b/prison-core/src/main/resources/lang/core/es_ES.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -94,6 +94,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. diff --git a/prison-core/src/main/resources/lang/core/hu_HU.properties b/prison-core/src/main/resources/lang/core/hu_HU.properties index c0152e48c..c0048af5b 100644 --- a/prison-core/src/main/resources/lang/core/hu_HU.properties +++ b/prison-core/src/main/resources/lang/core/hu_HU.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -94,6 +94,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. diff --git a/prison-core/src/main/resources/lang/core/it_IT.properties b/prison-core/src/main/resources/lang/core/it_IT.properties index 9b47bd634..e9683998c 100644 --- a/prison-core/src/main/resources/lang/core/it_IT.properties +++ b/prison-core/src/main/resources/lang/core/it_IT.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -94,6 +94,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. diff --git a/prison-core/src/main/resources/lang/core/nl_BE.properties b/prison-core/src/main/resources/lang/core/nl_BE.properties index 2c11e8dbf..96b319250 100644 --- a/prison-core/src/main/resources/lang/core/nl_BE.properties +++ b/prison-core/src/main/resources/lang/core/nl_BE.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -94,6 +94,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. diff --git a/prison-core/src/main/resources/lang/core/nl_NL.properties b/prison-core/src/main/resources/lang/core/nl_NL.properties index 2c11e8dbf..96b319250 100644 --- a/prison-core/src/main/resources/lang/core/nl_NL.properties +++ b/prison-core/src/main/resources/lang/core/nl_NL.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -94,6 +94,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. diff --git a/prison-core/src/main/resources/lang/core/zh_TW.properties b/prison-core/src/main/resources/lang/core/zh_TW.properties index 5962401c4..50ebe74b2 100644 --- a/prison-core/src/main/resources/lang/core/zh_TW.properties +++ b/prison-core/src/main/resources/lang/core/zh_TW.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=4 +messages__version=5 messages__auto_refresh=true @@ -94,6 +94,7 @@ core_text__from_now=from now core_text__and=and core_text__time_units_singular=year,month,week,day,hour,minute,second core_text__time_units_plural=years,months,weeks,days,hours,minutes,seconds +core_text__time_units_short=y,m,w,d,h,m,s core_tokens__name_required=Prison Tokens=A player's name is required when used from console. From 0f09f2715ce5240915a7a1b83cc2cd3af5c933c7 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 18 Apr 2022 02:36:42 -0400 Subject: [PATCH 215/297] New feature: Block Converters. Setup the initial core settings for block converters within the auto features. The core internal structure is in place and so is the ability to write the data to the file system. This has not been hooked up to anything yet. --- docs/changelog_v3.3.x.md | 7 +- .../autofeatures/AutoFeaturesFileConfig.java | 119 ++++++++++- .../prison/autofeatures/BlockConverter.java | 115 ++++++++++ .../autofeatures/BlockConverterTarget.java | 197 ++++++++++++++++++ .../autofeatures/BlockConvertersNode.java | 122 +++++++++++ .../prison/autofeatures/NullNode.java | 6 +- .../prison/autofeatures/ValueNode.java | 6 +- 7 files changed, 566 insertions(+), 6 deletions(-) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java create mode 100644 prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java create mode 100644 prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 10ebe2e38..f4d50e8dc 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,12 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.10 2022-04-15 +# 3.3.0-alpha.10 2022-04-18 + + +* **New feature: Block Converters. Setup the initial core settings for block converters within the auto features.** +The core internal structure is in place and so is the ability to write the data to the file system. +This has not been hooked up to anything yet. * **Setup placeholder formatted time values to use the language config file.** 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 e4de85d6d..4356fc892 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 @@ -6,6 +6,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.ValueNode.NodeType; @@ -319,6 +320,13 @@ public enum AutoFeatures { blockSnowBlock(blockFeature, true), blockGlowstone(blockFeature, true), blockCopperBlock(blockFeature, true), + + +// examplesOnlyNotUsed, +// exampleOfBlockConversions(examplesOnlyNotUsed), +// +// sampleBlockTransformer(exampleOfBlockConversions, NodeType.BLOCK_CONVERTER, "sample01" ) + // eventInjector(options), @@ -346,6 +354,7 @@ public enum AutoFeatures { private final boolean isLong; private final boolean isDouble; private final boolean isStringList; + private final boolean isBlockConverter; private final String path; private final String message; @@ -354,6 +363,7 @@ public enum AutoFeatures { private final Long longValue; private final Double doubleValue; private final List listValue; + private final TreeMap blockConverters; private AutoFeatures() { this.parent = null; @@ -364,6 +374,7 @@ private AutoFeatures() { this.isLong = false; this.isDouble = false; this.isStringList = false; + this.isBlockConverter = false; this.path = null; this.message = null; @@ -372,6 +383,7 @@ private AutoFeatures() { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); + this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section) { this.parent = section; @@ -382,6 +394,7 @@ private AutoFeatures(AutoFeatures section) { this.isLong = false; this.isDouble = false; this.isStringList = false; + this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -390,6 +403,7 @@ private AutoFeatures(AutoFeatures section) { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); + this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, String message) { this.parent = section; @@ -400,6 +414,7 @@ private AutoFeatures(AutoFeatures section, String message) { this.isLong = false; this.isDouble = false; this.isStringList = false; + this.isBlockConverter = false; this.path = section.getKey(); this.message = message; @@ -408,6 +423,7 @@ private AutoFeatures(AutoFeatures section, String message) { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); + this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, Boolean value) { this.parent = section; @@ -418,6 +434,7 @@ private AutoFeatures(AutoFeatures section, Boolean value) { this.isLong = false; this.isDouble = false; this.isStringList = false; + this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -426,6 +443,7 @@ private AutoFeatures(AutoFeatures section, Boolean value) { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); + this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, int value) { this.parent = section; @@ -436,6 +454,7 @@ private AutoFeatures(AutoFeatures section, int value) { this.isLong = false; this.isDouble = false; this.isStringList = false; + this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -444,6 +463,27 @@ private AutoFeatures(AutoFeatures section, int value) { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); + this.blockConverters = new TreeMap<>(); + } + private AutoFeatures(AutoFeatures section, long value) { + this.parent = section; + this.isSection = false; + this.isBoolean = false; + this.isMessage = false; + this.isInteger = false; + this.isLong = true; + this.isDouble = false; + this.isStringList = false; + this.isBlockConverter = false; + + this.path = section.getKey(); + this.message = null; + this.value = null; + this.intValue = null; + this.longValue = value; + this.doubleValue = null; + this.listValue = new ArrayList<>(); + this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, double value) { this.parent = section; @@ -454,6 +494,7 @@ private AutoFeatures(AutoFeatures section, double value) { this.isLong = false; this.isDouble = true; this.isStringList = false; + this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -462,6 +503,7 @@ private AutoFeatures(AutoFeatures section, double value) { this.longValue = null; this.doubleValue = value; this.listValue = new ArrayList<>(); + this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, NodeType nodeType, String... values ) { this.parent = section; @@ -472,6 +514,7 @@ private AutoFeatures(AutoFeatures section, NodeType nodeType, String... values ) this.isLong = false; this.isDouble = false; this.isStringList = (nodeType == NodeType.STRING_LIST); + this.isBlockConverter = (nodeType == NodeType.BLOCK_CONVERTER); this.path = section.getKey(); this.message = null; @@ -480,10 +523,17 @@ private AutoFeatures(AutoFeatures section, NodeType nodeType, String... values ) this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); + this.blockConverters = new TreeMap<>(); - if ( values != null && values.length > 0 ) { + if ( nodeType == NodeType.STRING_LIST ) { - this.listValue.addAll( Arrays.asList( values )); + if ( values != null && values.length > 0 ) { + + this.listValue.addAll( Arrays.asList( values )); + } + } + else if ( nodeType == NodeType.BLOCK_CONVERTER ) { + loadSampleBlockConverters( blockConverters, Arrays.asList( values ) ); } } @@ -511,6 +561,9 @@ public boolean isDouble() { public boolean isStringList() { return isStringList; } + public boolean isBlockConverter() { + return isBlockConverter; + } public String getPath() { return path; @@ -534,6 +587,9 @@ public Double getDoubleValue() { public List getListValue() { return listValue; } + public TreeMap getBlockConverters() { + return blockConverters; + } public String getKey() { return (path != null ? path + "." : "") + this.name(); @@ -660,6 +716,25 @@ else if ( getListValue() != null && getListValue().size() > 0 ) { } + public TreeMap getBlockConverters( Map conf ) { + TreeMap results = null; + + + if ( conf.containsKey(getKey()) && conf.get( getKey() ).isBlockConvertersNode() ) { + BlockConvertersNode blockConverters = (BlockConvertersNode) conf.get( getKey() ); + results = blockConverters.getValue(); + } +// else if ( getListValue() != null && getListValue().size() > 0 ) { +// results = getListValue(); +// } + + if ( results == null ) { + results = new BlockConvertersNode().getValue(); + } + + return results; + } + /** *

Get the children nodes to the given item. @@ -696,6 +771,17 @@ protected AutoFeaturesFileConfig() { this.config = new LinkedHashMap<>(); + + // If an AutoFeatures defines a block converter, then the actual block + // converter object, with all dependencies, needs to be stored in this + // TreeMap so it can be accessed later without having to regenerate + // everything. The enums of AutoFeatures, when they identify that the + // are of type BlockConverter, needs to store the complex data outside + // of the enum. This is it... with it being a TreeMap it will be + // fast access to it, and as many nodes as desired, can be added. + // NOTE: ONE entry in this TreeMap is related to ONE entry in the enum. +// this.blockConverters = new TreeMap<>(); + // The following is strictly not needed to ensure that the configs are // created, but this, somehow, does ensure that the order in which @@ -735,7 +821,34 @@ protected AutoFeaturesFileConfig() { } - public void reloadConfig() { + public static void loadSampleBlockConverters( + TreeMap blockConverters, List sampleSets ) { + + if ( sampleSets.contains( "sample01" ) ) { + BlockConverter bc1 = new BlockConverter( "coal_ore" ); + bc1.getTargets().add( new BlockConverterTarget( "diamond", 1 )); + + + BlockConverter bc2 = new BlockConverter( "ice_block" ); + BlockConverterTarget bc2t1 = new BlockConverterTarget( "water_bucket", 2); + BlockConverterTarget bc2t2 = new BlockConverterTarget( "gravel", 1); + BlockConverterTarget bc2t3 = new BlockConverterTarget( "pufferfish", 1, 0.15 ); + bc2t3.getPermissions().add("prison.not.used.sample.pufferfish"); + bc2t3.getPermissions().add("prison.not.used.sample.admin"); + bc2.getTargets().add( bc2t1 ); + bc2.getTargets().add( bc2t2 ); + bc2.getTargets().add( bc2t3 ); + + + + blockConverters.put( bc1.getKey(), bc1 ); + blockConverters.put( bc2.getKey(), bc2 ); + + } + } + + + public void reloadConfig() { // First clear the configs: getConfig().clear(); diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java new file mode 100644 index 000000000..bafcfccd3 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java @@ -0,0 +1,115 @@ +package tech.mcprison.prison.autofeatures; + +import java.util.ArrayList; +import java.util.List; +import java.util.TreeMap; + +public class BlockConverter { + + private String key; + + private List targets; + + public BlockConverter( String blockName ) { + super(); + + this.key = blockName; + + this.targets = new ArrayList<>(); + } + + public BlockConverter( String blockName, Object rawTarget ) { + this( blockName ); + + parseConverterTarget( rawTarget ); + } + + /** + *

The rawTarget object is an ArrayList of TreeMaps, where each + * TreeMap represents a BlockConverterTarget object. + *

+ * + * @param rawTarget + */ + private void parseConverterTarget( Object rawTargets ) { + + if ( rawTargets != null && rawTargets instanceof ArrayList ) { + + @SuppressWarnings("unchecked") + List rTargets = (List) rawTargets; + + for ( Object rTarget : rTargets) { + + BlockConverterTarget target = new BlockConverterTarget( rTarget ); + + getTargets().add( target ); + } + } + } + + /** + *

This function converts this object in to a saveable yaml object. + * It basically undoes what parseConverterTarget does. + * The big difference is that where parseConverterTarget has a + * blockName and an Object that represents an ArrayList, this + * returns a TreeMap where the key is the blockName and the object of + * the TreeMap are all of the BlockConverterTarget objects represented + * as a yaml maps. + *

+ * + *

The returned TreeMap should be added to other TreeMaps, where all of + * the keys are combined, and all of the objects are combined in to one + * TreeMap. + *

+ * + * @return + */ + public TreeMap>> toYamlMap() { + TreeMap>> results = new TreeMap<>(); + + List> targets = new ArrayList<>(); + + for ( BlockConverterTarget target : getTargets() ) { + TreeMap rawTarget = target.toYamlMap(); + + targets.add(rawTarget); + } + + results.put( getKey(), targets ); + + return results; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + sb.append( getKey() ).append( ": ["); + + List strList = new ArrayList<>(); + for (BlockConverterTarget bcTarget : targets) { + + strList.add( bcTarget.toString() ); + } + sb.append( String.join( ", ", strList ) ); + + sb.append("]"); + + return sb.toString(); + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + + public List getTargets() { + return targets; + } + public void setTargets(List targets) { + this.targets = targets; + } + +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java new file mode 100644 index 000000000..13b55d7dc --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java @@ -0,0 +1,197 @@ +package tech.mcprison.prison.autofeatures; + +import java.util.ArrayList; +import java.util.List; +import java.util.TreeMap; + +public class BlockConverterTarget { + + private String blockName; + private Integer quantity; + private Double chance; + private List permissions; + + public BlockConverterTarget( String blockName, Integer quantity ) { + super(); + + this.blockName = blockName; + this.quantity = quantity; + this.chance = null; + + this.permissions = new ArrayList<>(); + } + + public BlockConverterTarget( String blockName, Integer quantity, Double chance ) { + this( blockName, quantity ); + + this.chance = chance; + } + + /** + * + * @param rawTarget + */ + public BlockConverterTarget( Object rawTarget ) { + super(); + + this.permissions = new ArrayList<>(); + + parseConverterTarget( rawTarget ); + } + + private void parseConverterTarget( Object rawTarget ) { + + // This should be a TreeMaps of field settings. + if ( rawTarget != null && rawTarget instanceof TreeMap ) { + + @SuppressWarnings("unchecked") + TreeMap rawMaps = (TreeMap) rawTarget; + + if ( rawMaps != null ) { + if ( rawMaps.containsKey("blockName") ) { + Object raw = rawMaps.get( "blockName" ); + + if ( raw != null && raw instanceof String ) { + + setBlockName( (String) raw ); + } + } + + if ( rawMaps.containsKey("quantity") ) { + Object raw = rawMaps.get( "quantity" ); + + if ( raw != null && raw instanceof Integer ) { + + setQuantity( (Integer) raw ); + } + } + + if ( rawMaps.containsKey("chance") ) { + Object raw = rawMaps.get( "chance" ); + + if ( raw != null && raw instanceof Double ) { + + setChance( (Double) raw ); + } + } + + if ( rawMaps.containsKey("permissions") ) { + Object raw = rawMaps.get( "permissions" ); + + if ( raw != null && raw instanceof String ) { + + getPermissions().add( (String) raw ); + } + else if ( raw != null && raw instanceof ArrayList ) { + + @SuppressWarnings("unchecked") + ArrayList perms = (ArrayList) raw; + + for (String perm : perms) { + getPermissions().add(perm); + } + } + } + } + } + } + + /** + *

This function converts this object in to a saveable yaml object. + * It basically undoes what parseConverterTarget does. + *

+ * @return + */ + public TreeMap toYamlMap() { + TreeMap results = new TreeMap<>(); + + results.put( "blockName", getBlockName() ); + results.put( "quantity", getQuantity() == null ? null : getQuantity().intValue() ); + + if ( getChance() != null ) { + results.put( "chance", getChance().doubleValue() ); + } + + if ( getPermissions() != null && getPermissions().size() > 0 ) { + results.put( "permissions", getPermissions() ); + } +// +// results.put( "blockName", new TextNode( getBlockName() ).getValue() ); +// results.put( "quantity", getQuantity() == null ? +// new NullNode().getValue() : new IntegerNode( getQuantity() ).getValue() ); +// +// if ( getChance() != null ) { +// results.put( "chance", new DoubleNode( getChance() ).getValue() ); +// } +// +// if ( getPermissions() != null && getPermissions().size() > 0 ) { +// results.put( "permissions", new StringListNode( getPermissions() ).getValue() ); +// } + + return results; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + sb.append( "(" ); + sb.append( getBlockName() ).append( " "); + sb.append( getQuantity() ); + + if ( getChance() != null && getChance() != 0d ) { + sb.append( " " ).append( getChance() ); + } + + if ( getPermissions().size() > 0 ) { + StringBuilder sbp = new StringBuilder(); + sbp.append( " [" ); + + for (String perm : getPermissions() ) { + if ( sbp.length() > 2 ) { + sbp.append( ", " ); + } + sbp.append( perm ); + } + sbp.append( "]" ); + sb.append( sbp ); + } + + sb.append( ")" ); + +// sb.append( "{" ); +// sb.append( "blockName:" ).append( getBlockName() ).append( ", "); +// sb.append( "quantity:" ).append( getQuantity() ); +// sb.append( "}" ); + + return sb.toString(); + } + + public String getBlockName() { + return blockName; + } + public void setBlockName(String blockName) { + this.blockName = blockName; + } + + public Integer getQuantity() { + return quantity; + } + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Double getChance() { + return chance; + } + public void setChance(Double chance) { + this.chance = chance; + } + + public List getPermissions() { + return permissions; + } + public void setPermissions(List permissions) { + this.permissions = permissions; + } +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java new file mode 100644 index 000000000..511c371ad --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java @@ -0,0 +1,122 @@ +package tech.mcprison.prison.autofeatures; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.TreeMap; + +public class BlockConvertersNode + extends ValueNode +{ + private static final long serialVersionUID = -1L; + + TreeMap value; + + public BlockConvertersNode() { + super(); + + this.value = new TreeMap<>(); + } + + public BlockConvertersNode( TreeMap value ) { + this(); + + this.value = value; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + List strList = new ArrayList<>(); + + Set keys = value.keySet(); + for (String key : keys) { + BlockConverter bConverter = value.get(key); + + String str = bConverter.toString(); + strList.add(str); + } + + sb.append( String.join( ", ", strList ) ); + sb.insert( 0, "[" ).append("]"); + + return sb.toString(); + } + + + public TreeMap getValue() { + return value; + } + + @Override + public boolean isBlockConvertersNode() { return true; } + + @Override + public NodeType getNodeType() { + return NodeType.BLOCK_CONVERTER; + } + + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if (o == null) return false; + if (o instanceof BlockConvertersNode) { + + final BlockConvertersNode otherValue = ((BlockConvertersNode) o); + if ( getValue() == null && otherValue.getValue() == null ) return true; + if ( getValue() != null ) { + return getValue().equals( otherValue.getValue() ); + } + } + return false; + } + + @Override + public int hashCode() { + // same as hashCode that List uses + return getValue().hashCode(); + } + + /** + *

This function takes a map of maps to construct and load the block converters. + * This process takes the keys of this map, and the related object, and then constructs + * the BlockConverter object. The BlockConverter object deals with processing it's own + * content as passed to it with the Object form this rawBlockConverters map. + *

+ * + * @param rawBlockConverters + */ + public void loadFromYamlFile(TreeMap rawBlockConverters) { + + Set keys = rawBlockConverters.keySet(); + + for (String key : keys) { + Object rawBlockConverterData = rawBlockConverters.get(key); + + BlockConverter blockConverter = new BlockConverter( key, rawBlockConverterData ); + + value.put( blockConverter.getKey(), blockConverter ); + } + } + + public TreeMap>> toYamlMap() { + TreeMap>> results = new TreeMap<>(); + + Set keys = getValue().keySet(); + for (String key : keys) { + BlockConverter blockConverter = getValue().get(key); + + // NOTE: The TreeMap will always have exactly ONE entry: + TreeMap>> rawBlockConverter = blockConverter.toYamlMap(); + String yamlKey = rawBlockConverter.firstKey(); + List> yamlBlockConverter = rawBlockConverter.firstEntry().getValue(); + + results.put( yamlKey, yamlBlockConverter ); + } + + return results; + } + +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/NullNode.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/NullNode.java index d826410ad..07fa3d574 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/NullNode.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/NullNode.java @@ -17,9 +17,13 @@ public boolean isNull() { return true; } + public Object getValue() { + return null; + } + @Override public String toString() { - return Boolean.toString( true ); + return "null"; } @Override diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/ValueNode.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/ValueNode.java index 9a7757569..8ef642e21 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/ValueNode.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/ValueNode.java @@ -18,10 +18,13 @@ public enum NodeType { LONG, INTEGER, DOUBLE, - STRING_LIST + STRING_LIST, + BLOCK_CONVERTER ; } + public abstract String toString(); + public boolean isNullNode() { return false; } public boolean isTextNode() { return false; } @@ -36,6 +39,7 @@ public enum NodeType { public boolean isStringListNode() { return false; } + public boolean isBlockConvertersNode() { return false; } public abstract NodeType getNodeType(); From f55372a470c314fbd1371ed4d1dc726c4759b117 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 18 Apr 2022 02:38:52 -0400 Subject: [PATCH 216/297] Bug Fix: The IGNORE block type was not marked as a block, therefore could not be used within a mine. --- docs/changelog_v3.3.x.md | 3 +++ .../java/tech/mcprison/prison/internal/block/PrisonBlock.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index f4d50e8dc..a18b6dad1 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.10 2022-04-18 +* **Bug Fix: The IGNORE block type was not marked as a block, therefore could not be used within a mine.** + + * **New feature: Block Converters. Setup the initial core settings for block converters within the auto features.** The core internal structure is in place and so is the ability to write the data to the file system. This has not been hooked up to anything yet. diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java index 2e200746f..c0ee5585f 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java @@ -48,8 +48,8 @@ public class PrisonBlock GLASS = new PrisonBlock( InternalBlockTypes.GLASS.name(), true ); PINK_STAINED_GLASS = new PrisonBlock( InternalBlockTypes.PINK_STAINED_GLASS.name(), true ); BLAZE_ROD = new PrisonBlock( InternalBlockTypes.BLAZE_ROD.name(), false ); - LAPIS_ORE = new PrisonBlock( InternalBlockTypes.LAPIS_ORE.name(), false ); - IGNORE = new PrisonBlock( InternalBlockTypes.IGNORE.name(), false ); + LAPIS_ORE = new PrisonBlock( InternalBlockTypes.LAPIS_ORE.name(), true ); + IGNORE = new PrisonBlock( InternalBlockTypes.IGNORE.name(), true ); NULL_BLOCK = new PrisonBlock( InternalBlockTypes.NULL_BLOCK.name(), false ); } From 9551b970a35563abd5b5e97c9c3d10855ec775f6 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 18 Apr 2022 02:47:44 -0400 Subject: [PATCH 217/297] Mine reset potential bug fix: Some rare conditions was causing problems, so using another collection to pass the blocks, and getting the size prior to calling the function to prevent the problems from happening. --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/internal/block/PrisonBlockTypes.java | 1 + .../mcprison/prison/mines/commands/MinesCommands.java | 6 ++++-- .../prison/mines/tasks/MinePagedResetAsyncTask.java | 10 ++++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a18b6dad1..f0aa7f855 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.10 2022-04-18 +* **Mine reset potential bug fix: Some rare conditions was causing problems, so using another collection to pass the blocks, and getting the size prior to calling the function to prevent the problems from happening.** +This appeared to be happening when a mine was being reset multiple times, at the same time. The mine should never be resetting multiple times, at the same time. May need to add more controls to prevent it from happening. + + * **Bug Fix: The IGNORE block type was not marked as a block, therefore could not be used within a mine.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java index 1ea97c5d4..b5054d682 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlockTypes.java @@ -58,6 +58,7 @@ private void initializeBlockTypes() { // Add in prison's internal block types here: getBlockTypes().add( PrisonBlock.IGNORE ); +// getBlockTypes().add( PrisonBlock.NULL_BLOCK ); // Map all available blocks to the blockTypesByName map: 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 7f7433656..d24ee33da 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 @@ -155,8 +155,10 @@ public void delBlockCommand(CommandSender sender, @Command(identifier = "mines block search", permissions = "mines.block", description = "Searches for a block to add to a mine.") public void searchBlockCommand(CommandSender sender, - @Arg(name = "search", def = " ", description = "Any part of the block's name or ID.") String search, - @Arg(name = "page", def = "1", description = "Page of search results (optional)") String page ) { + @Arg(name = "search", def = " ", + description = "Any part of the block's name or ID.") String search, + @Arg(name = "page", def = "1", + description = "Page of search results (optional)") String page ) { super.searchBlockCommand( sender, search, page, "mines block search", diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java index 40b14e902..dc1374c80 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java @@ -1,5 +1,6 @@ package tech.mcprison.prison.mines.tasks; +import java.util.ArrayList; import java.util.List; import tech.mcprison.prison.Prison; @@ -160,13 +161,18 @@ public void run() { endIndex = targetBlocks.size(); pageEndPosition = endIndex; } + + // Isolate the sub-list from the main targetBlocks list: + List tBlocks = new ArrayList<>(); + for (MineTargetPrisonBlock mtpb : targetBlocks.subList( position, endIndex )) { + tBlocks.add(mtpb); + } - List tBlocks = targetBlocks.subList( position, endIndex ); int size = tBlocks.size(); + position += size; mine.getWorld().get().setBlocksSynchronously( tBlocks, resetType, getNanos() ); - position += size; } From e38b870302b801ed637f8253e77f8661059b48ee Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 18 Apr 2022 02:54:42 -0400 Subject: [PATCH 218/297] Hooked up the BlockConvertersNode to the yaml file IO code so it will save and load changes to the auto features configs for anything with the BlockConverters data type. Removed unused functions. --- docs/changelog_v3.3.x.md | 4 + .../tech/mcprison/prison/file/YamlFileIO.java | 144 ++++++++++++++---- .../prison/spigot/util/SpigotYamlFileIO.java | 88 +++++------ 3 files changed, 164 insertions(+), 72 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index f0aa7f855..7bce2d1d8 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.10 2022-04-18 +* **Hooked up the BlockConvertersNode to the yaml file IO code so it will save and load changes to the auto features configs for anything with the BlockConverters data type.** +Removed unused functions. + + * **Mine reset potential bug fix: Some rare conditions was causing problems, so using another collection to pass the blocks, and getting the size prior to calling the function to prevent the problems from happening.** This appeared to be happening when a mine was being reset multiple times, at the same time. The mine should never be resetting multiple times, at the same time. May need to add more controls to prevent it from happening. diff --git a/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java b/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java index 326d63fa9..a141fac80 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java +++ b/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java @@ -8,6 +8,7 @@ import java.util.TreeMap; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; +import tech.mcprison.prison.autofeatures.BlockConvertersNode; import tech.mcprison.prison.autofeatures.BooleanNode; import tech.mcprison.prison.autofeatures.DoubleNode; import tech.mcprison.prison.autofeatures.IntegerNode; @@ -50,32 +51,83 @@ public boolean saveYamlAutoFeatures( Map config ) { for ( String key : keys ) { ValueNode value = config.get( key ); - if ( value.isNullNode() ) { + switch ( value.getNodeType() ) { + + case NULL: // skip nulls set( key, null ); - } - else if ( value.isBooleanNode() ) { + break; + + case BOOLEAN: set( key, ((BooleanNode) value).getValue() ); - } - else if ( value.isTextNode() ) { + break; + + case STRING: set( key, ((TextNode) value).getValue() ); - } - else if ( value.isDoubleNode() ) { + break; + + case DOUBLE: set( key, ((DoubleNode) value).getValue() ); - } - else if ( value.isLongNode() ) { + break; + + case LONG: set( key, ((LongNode) value).getValue() ); - } - else if ( value.isIntegerNode() ) { + break; + + case INTEGER: set( key, ((IntegerNode) value).getValue() ); - } - else if ( value.isStringListNode() ) { + break; + + case STRING_LIST: set( key, ((StringListNode) value).getValue() ); - } - else { + break; + + case BLOCK_CONVERTER: + try { + set( key, ((BlockConvertersNode) value).toYamlMap() ); + } + catch (Exception e) { + Output.get().logError("YamlFileIO.saveYamlAutoFeatures " + + "Error with BLOCK_CONVERTER toYamlMap. key: " + key, e); +// e.printStackTrace(); + } + break; + + default: // invalid type... not supported. // set( key, value ); + break; } + +// if ( value.isNullNode() ) { +// // skip nulls +// set( key, null ); +// } +// else if ( value.isBooleanNode() ) { +// set( key, ((BooleanNode) value).getValue() ); +// } +// else if ( value.isTextNode() ) { +// set( key, ((TextNode) value).getValue() ); +// } +// else if ( value.isDoubleNode() ) { +// set( key, ((DoubleNode) value).getValue() ); +// } +// else if ( value.isLongNode() ) { +// set( key, ((LongNode) value).getValue() ); +// } +// else if ( value.isIntegerNode() ) { +// set( key, ((IntegerNode) value).getValue() ); +// } +// else if ( value.isStringListNode() ) { +// set( key, ((StringListNode) value).getValue() ); +// } +// else if ( value.isBlockConverterNode() ) { +// set( key, ((BlockConvertersNode) value).t ); +// } +// else { +// // invalid type... not supported. +//// set( key, value ); +// } } return saveYaml(); @@ -156,6 +208,35 @@ else if ( autoFeat.isStringList() ) { value = StringListNode.valueOf( stringListVal ); } + else if ( autoFeat.isBlockConverter() ) { + // Setup default value for block converters: + BlockConvertersNode blockConverters = new BlockConvertersNode( + autoFeat.getBlockConverters() ); + + if ( yaml.containsKey(key) ) { + + try { + + Object rawBlockConverterNode = yaml.get( key ); + + if ( rawBlockConverterNode != null && rawBlockConverterNode instanceof TreeMap ) { + + @SuppressWarnings("unchecked") + TreeMap rawBlockConverters = (TreeMap) rawBlockConverterNode; + + blockConverters.loadFromYamlFile( rawBlockConverters ); + } + } + catch (Exception e) { + Output.get().logError("YamlFileIO.loadYamlAutoFeatures " + + "Error with BLOCK_CONVERTER loadFromYamlFile. key: " + key, e); +// e.printStackTrace(); + } + + } + + value = blockConverters; + } if ( !keys.contains( autoFeat.getKey() )) { @@ -224,21 +305,28 @@ public File getYamlFile() { abstract protected void set( String key, Object value ); abstract protected void createSection( String key ); - abstract protected boolean getBoolean( String key ); - abstract protected boolean getBoolean( String key, boolean defaultValue ); +// abstract protected boolean getBoolean( String key ); +// abstract protected boolean getBoolean( String key, boolean defaultValue ); +// +// abstract protected String getString( String key ); +// abstract protected String getString( String key, String defaultValue ); +// +// abstract protected double getDouble( String key ); +// abstract protected double getDouble( String key, double defaultValue ); +// +// abstract protected int getInteger( String key ); +// abstract protected int getInteger( String key, int intValue ); +// +// abstract protected long getLong( String key ); +// abstract protected long getLong( String key, long defaultValue ); +// +// abstract protected List getStringList( String key ); +// abstract protected List getStringList( String key, List defaultValue ); +// +// abstract protected TreeMap getBlockConverters( String key ); +// abstract protected TreeMap getBlockConverters( String key, TreeMap defaultValue ); - abstract protected String getString( String key ); - abstract protected String getString( String key, String defaultValue ); - - abstract protected double getDouble( String key ); - abstract protected double getDouble( String key, double defaultValue ); - abstract protected int getInteger( String key ); - abstract protected int getInteger( String key, int intValue ); - - abstract protected long getLong( String key ); - abstract protected long getLong( String key, long defaultValue ); - public boolean isSupportsDropsCanceling() { return supportsDropsCanceling; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java index 8cd5528b0..aa9bce412 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java @@ -93,50 +93,50 @@ protected void createSection( String key ) { } - @Override - protected boolean getBoolean( String key ) { - return yamlConfig.getBoolean( key ) ; - } - @Override - protected boolean getBoolean( String key, boolean defaultValue ) { - return yamlConfig.getBoolean( key, defaultValue ) ; - } - - @Override - protected String getString( String key ) { - return yamlConfig.getString( key ) ; - } - @Override - protected String getString( String key, String defaultValue ) { - return yamlConfig.getString( key, defaultValue ) ; - } - - @Override - protected double getDouble( String key ) { - return yamlConfig.getDouble( key ) ; - } - @Override - protected double getDouble( String key, double defaultValue ) { - return yamlConfig.getDouble( key, defaultValue ) ; - } - - @Override - protected int getInteger( String key ) { - return yamlConfig.getInt( key ) ; - } - @Override - protected int getInteger( String key, int defaultValue ) { - return yamlConfig.getInt( key, defaultValue ) ; - } - - @Override - protected long getLong( String key ) { - return yamlConfig.getLong( key ) ; - } - @Override - protected long getLong( String key, long defaultValue ) { - return yamlConfig.getLong( key, defaultValue ) ; - } +// @Override +// protected boolean getBoolean( String key ) { +// return yamlConfig.getBoolean( key ) ; +// } +// @Override +// protected boolean getBoolean( String key, boolean defaultValue ) { +// return yamlConfig.getBoolean( key, defaultValue ) ; +// } +// +// @Override +// protected String getString( String key ) { +// return yamlConfig.getString( key ) ; +// } +// @Override +// protected String getString( String key, String defaultValue ) { +// return yamlConfig.getString( key, defaultValue ) ; +// } +// +// @Override +// protected double getDouble( String key ) { +// return yamlConfig.getDouble( key ) ; +// } +// @Override +// protected double getDouble( String key, double defaultValue ) { +// return yamlConfig.getDouble( key, defaultValue ) ; +// } +// +// @Override +// protected int getInteger( String key ) { +// return yamlConfig.getInt( key ) ; +// } +// @Override +// protected int getInteger( String key, int defaultValue ) { +// return yamlConfig.getInt( key, defaultValue ) ; +// } +// +// @Override +// protected long getLong( String key ) { +// return yamlConfig.getLong( key ) ; +// } +// @Override +// protected long getLong( String key, long defaultValue ) { +// return yamlConfig.getLong( key, defaultValue ) ; +// } public void test( ) { From c1e9e4134a92eb9301f35242d572d8bd9a841995 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 18 Apr 2022 04:49:01 -0400 Subject: [PATCH 219/297] Placeholder fix: Problem with the placeholder getting a prstige rank that was one too high. The following placeholders were fixed: prison_rrt, prison_rankup_rank_tag, prison_rrt_laddername, prison_rankup_rank_tag_laddername --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/ranks/managers/PlayerManager.java | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7bce2d1d8..23e521df3 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.10 2022-04-18 +* **Placeholder fix: Problem with the placeholder getting a prestige rank that was one too high.** +The following placeholders were fixed: prison_rrt, prison_rankup_rank_tag, prison_rrt_laddername, prison_rankup_rank_tag_laddername + + * **Hooked up the BlockConvertersNode to the yaml file IO code so it will save and load changes to the auto features configs for anything with the BlockConverters data type.** Removed unused functions. diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index b511f44e2..8d900d11e 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -1316,8 +1316,8 @@ public String getPlayerNextRankName( RankPlayer rankPlayer, String ladderName ) public String getPlayerNextRankTag( RankPlayer rankPlayer, String ladderName ) { StringBuilder sb = new StringBuilder(); - boolean hasDefault = false; - boolean hasPrestige = false; +// boolean hasDefault = false; +// boolean hasPrestige = false; if ( !rankPlayer.getLadderRanks().isEmpty()) { @@ -1339,11 +1339,16 @@ public String getPlayerNextRankTag( RankPlayer rankPlayer, String ladderName ) { RankLadder prestigeLadder = PrisonRanks.getInstance() .getLadderManager().getLadderPrestiges(); if ( prestigeLadder != null ) { - rank = prestigeLadder.getLowestRank().orElseGet( null ); + + // Player does not have any prestige rank, so use the lowest prestige rank: + Rank nextRank = prestigeLadder.getLowestRank().orElseGet( null ); + sb.append( nextRank.getTag() ); + continue; } } else { - rank = prestigeRank.getRank().getRankNext(); + // Get current prestige rank + rank = prestigeRank.getRank(); } } From 105259d5912f84a5bac029c180e4730213911051 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 18 Apr 2022 04:52:46 -0400 Subject: [PATCH 220/297] Added NBT support to prison. This loads a NBT library to be used only with the spigot sub-project. This has not been hooked up to anything yet. --- docs/changelog_v3.3.x.md | 4 ++++ prison-spigot/build.gradle | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 23e521df3..7fe3a6304 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.10 2022-04-18 +* **Added NBT support to prison. This loads a NBT library to be used only with the spigot sub-project.** +This has not been hooked up to anything yet. + + * **Placeholder fix: Problem with the placeholder getting a prestige rank that was one too high.** The following placeholders were fixed: prison_rrt, prison_rankup_rank_tag, prison_rrt_laddername, prison_rankup_rank_tag_laddername diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index ed7500742..446aafe3e 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -154,6 +154,9 @@ dependencies { // compile fileTree(dir: 'lib', include: ['TokenEnchantAPI-18.5.0.jar']) + // https://www.spigotmc.org/resources/nbt-api.7939/ + implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2' + testImplementation group: 'junit', name: 'junit', version: '4.12' } @@ -194,6 +197,8 @@ shadowJar { include(dependency('com.github.cryptomorin:XSeries:8.6.2')) + include(dependency('de.tr7zw:item-nbt-api-plugin:2.9.2')) + //include(dependency('org.inventivetalent.spiget-update:bukkit:1.4.2-SNAPSHOT')) //include(dependency('me.badbones69:crazyenchantments-plugin:1.8-Dev-Build-v8')) @@ -208,6 +213,7 @@ shadowJar { relocate 'org.inventivetalent.update.spiget', 'tech.mcprison.prison.spiget' relocate 'com.cryptomorin', 'tech.mcprison.prison.cryptomorin' + relocate 'de.tr7zw', 'tech.mcprison.prison.nbtapi' //relocate 'me.badbones69.crazyenchantments.api.events.BlastUseEvent', 'tech.mcprison.prison.crazyenchantments.api' From c584f918b56a437bfcdce38ca88cc28609c6d1c6 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 18 Apr 2022 04:57:40 -0400 Subject: [PATCH 221/297] Hook up the NBT library to the SpigotItemStack class. This has not been tested yet to see how it works, especially between server resets. --- docs/changelog_v3.3.x.md | 4 + .../prison/spigot/block/SpigotItemStack.java | 80 +++++++++++++++++-- 2 files changed, 79 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7fe3a6304..ab0ad837e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.10 2022-04-18 +* **Hook up the NBT library to the SpigotItemStack class.** +This has not been tested yet to see how it works, especially between server resets. + + * **Added NBT support to prison. This loads a NBT library to be used only with the spigot sub-project.** This has not been hooked up to anything yet. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java index efe5ab084..97be21a6b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java @@ -11,6 +11,7 @@ import com.cryptomorin.xseries.XMaterial; +import me.xanium.gemseconomy.nbt.NBTItem; import tech.mcprison.prison.Prison; import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.PrisonBlock; @@ -19,12 +20,16 @@ public class SpigotItemStack extends ItemStack { - private org.bukkit.inventory.ItemStack bukkitStack; + private NBTItem bukkitStack; +// private org.bukkit.inventory.ItemStack bukkitStack; public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) { super(); - this.bukkitStack = bukkitStack; + NBTItem nbtItemStack = new NBTItem( bukkitStack ); + + this.bukkitStack = nbtItemStack; +// this.bukkitStack = bukkitStack; if (bukkitStack == null || bukkitStack.getType().equals(Material.AIR)) { setAmount( 0 ); @@ -100,6 +105,68 @@ public void setPrisonBlock( PrisonBlock pBlock ) { setMaterial( pBlock ); } + + public boolean hasNBTKey( String key ) { + boolean results = false; + + if ( bukkitStack != null ) { + results = bukkitStack.hasKey( key ); + } + + return results; + } + + public void setNBTString( String key, String value ) { + if ( bukkitStack != null ) { + bukkitStack.setString( key, value ); + } + } + public String getNBTString( String key ) { + String results = null; + if ( bukkitStack != null ) { + results = bukkitStack.getString( key ); + } + return results; + } + + public void setNBTInt( String key, int value ) { + if ( bukkitStack != null ) { + bukkitStack.setInteger( key, value ); + } + } + public int getNBTInt( String key ) { + int results = -1; + if ( bukkitStack != null ) { + results = bukkitStack.getInteger( key ); + } + return results; + } + + public void setNBTDouble( String key, double value ) { + if ( bukkitStack != null ) { + bukkitStack.setDouble( key, value ); + } + } + public double getNBTDouble( String key ) { + double results = -1d; + if ( bukkitStack != null ) { + results = bukkitStack.getDouble( key ); + } + return results; + } + + public void setNBTBoolean( String key, boolean value ) { + if ( bukkitStack != null ) { + bukkitStack.setBoolean( key, value ); + } + } + public boolean getNBTBoolean( String key ) { + boolean results = false; + if ( bukkitStack != null ) { + results = bukkitStack.getBoolean( key ); + } + return results; + } /** *

This function overrides the Prison's ItemStack class's setAmount() to perform the @@ -113,7 +180,7 @@ public void setAmount( int amount ) { super.setAmount( amount ); if ( bukkitStack != null ) { - bukkitStack.setAmount( amount ); + bukkitStack.getItem().setAmount( amount ); } } @@ -150,11 +217,14 @@ public boolean isBlock() { public org.bukkit.inventory.ItemStack getBukkitStack() { - return bukkitStack; + return bukkitStack.getItem(); } public void setBukkitStack( org.bukkit.inventory.ItemStack bukkitStack ) { - this.bukkitStack = bukkitStack; + + NBTItem nbtItemStack = new NBTItem( bukkitStack ); + this.bukkitStack = nbtItemStack; +// this.bukkitStack = bukkitStack; } public Map serialize() From c2572a1625d908bb39f4b826f56300ed82f95b85 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 20 Apr 2022 00:07:16 -0400 Subject: [PATCH 222/297] Fixed the usage of setting up the NBT library within the gradle config file. Fixed issue with unknown, or incompatible items were unable to be parsed by XMaterial which was resulting in failures. This fixes the problem by preventing the use of a partial created SpigotItemStack. --- docs/changelog_v3.3.x.md | 6 +- .../prison/selection/SelectionListener.java | 2 +- prison-spigot/build.gradle | 9 +- .../mcprison/prison/spigot/SpigotUtil.java | 19 ++- .../events/PrisonDebugBlockInspector.java | 2 +- ...ItemStackNotSupportedRuntimeException.java | 12 ++ .../prison/spigot/block/SpigotItemStack.java | 125 +++++++++++++----- .../prison/spigot/game/SpigotPlayerUtil.java | 2 +- .../spigot/utils/PrisonUtilsMineBombs.java | 10 +- 9 files changed, 145 insertions(+), 42 deletions(-) create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/PrisonItemStackNotSupportedRuntimeException.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ab0ad837e..20d38ea1a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.10 2022-04-18 +# 3.3.0-alpha.10 2022-04-20 + + +* **Fixed the usage of setting up the NBT library within the gradle config file.** +Fixed issue with unknown, or incompatible items were unable to be parsed by XMaterial which was resulting in failures. This fixes the problem by preventing the use of a partial created SpigotItemStack. * **Hook up the NBT library to the SpigotItemStack class.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionListener.java b/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionListener.java index 7faf7efe7..3b9a2f756 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionListener.java +++ b/prison-core/src/main/java/tech/mcprison/prison/selection/SelectionListener.java @@ -39,7 +39,7 @@ public void onPlayerInteract(PrisonPlayerInteractEvent e) { ItemStack ourItem = e.getItemInHand(); ItemStack toolItem = SelectionManager.SELECTION_TOOL; - if (!ourItem.equals(toolItem)) { + if ( ourItem == null || !ourItem.equals(toolItem)) { return; } e.setCanceled(true); diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index 446aafe3e..73145afbf 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -136,7 +136,11 @@ dependencies { } // compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.1' + + // https://www.spigotmc.org/resources/nbt-api.7939/ + implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2' + compileOnly fileTree(dir: 'lib', include: ['*.jar'], exclude: ['Spiget_v1.4.2.prison-build.jar', @@ -154,8 +158,6 @@ dependencies { // compile fileTree(dir: 'lib', include: ['TokenEnchantAPI-18.5.0.jar']) - // https://www.spigotmc.org/resources/nbt-api.7939/ - implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2' testImplementation group: 'junit', name: 'junit', version: '4.12' @@ -213,7 +215,8 @@ shadowJar { relocate 'org.inventivetalent.update.spiget', 'tech.mcprison.prison.spiget' relocate 'com.cryptomorin', 'tech.mcprison.prison.cryptomorin' - relocate 'de.tr7zw', 'tech.mcprison.prison.nbtapi' + relocate 'de.tr7zw.nbtapi', 'tech.mcprison.prison.nbtapi' + //relocate 'me.badbones69.crazyenchantments.api.events.BlastUseEvent', 'tech.mcprison.prison.crazyenchantments.api' diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java index fb2648fe6..ba1beeb16 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java @@ -46,6 +46,7 @@ import tech.mcprison.prison.internal.inventory.Viewable; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.backpacks.BackpacksUtil; +import tech.mcprison.prison.spigot.block.PrisonItemStackNotSupportedRuntimeException; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.spigot.compat.BlockTestStats; @@ -173,7 +174,14 @@ public static ItemStack getItemStack( XMaterial xMaterial, int amount ) { } public static SpigotItemStack getSpigotItemStack( XMaterial xMaterial, int amount ) { - SpigotItemStack itemStack = new SpigotItemStack( getItemStack( xMaterial, amount ) ); + SpigotItemStack itemStack = null; + + try { + itemStack = new SpigotItemStack( getItemStack( xMaterial, amount ) ); + } + catch (PrisonItemStackNotSupportedRuntimeException e) { + // ignore + } return itemStack; } @@ -984,10 +992,15 @@ public static org.bukkit.Location prisonLocationToBukkit(Location prisonLocation */ public static SpigotItemStack bukkitItemStackToPrison( ItemStack bukkitStack) { - SpigotItemStack results = null; +; SpigotItemStack results = null; if ( bukkitStack != null ) { - results = new SpigotItemStack( bukkitStack ); + try { + results = new SpigotItemStack( bukkitStack ); + } + catch (PrisonItemStackNotSupportedRuntimeException e) { + // ignore... + } } return results; 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 54d44d88a..99122fb13 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 @@ -44,7 +44,7 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) { ItemStack ourItem = e.getItemInHand(); ItemStack toolItem = SelectionManager.SELECTION_TOOL; - if ( !ourItem.equals(toolItem) || !Output.get().isDebug() ) { + if ( ourItem == null || !ourItem.equals(toolItem) || !Output.get().isDebug() ) { return; } //e.setCanceled(true); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/PrisonItemStackNotSupportedRuntimeException.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/PrisonItemStackNotSupportedRuntimeException.java new file mode 100644 index 000000000..c3da399c0 --- /dev/null +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/PrisonItemStackNotSupportedRuntimeException.java @@ -0,0 +1,12 @@ +package tech.mcprison.prison.spigot.block; + +public class PrisonItemStackNotSupportedRuntimeException + extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public PrisonItemStackNotSupportedRuntimeException( String exception ) { + super( exception ); + } + +} diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java index 97be21a6b..06ccea03c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java @@ -11,7 +11,7 @@ import com.cryptomorin.xseries.XMaterial; -import me.xanium.gemseconomy.nbt.NBTItem; +import de.tr7zw.nbtapi.NBTItem; import tech.mcprison.prison.Prison; import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.PrisonBlock; @@ -20,16 +20,42 @@ public class SpigotItemStack extends ItemStack { - private NBTItem bukkitStack; + private org.bukkit.inventory.ItemStack bukkitStack; + private NBTItem nbtBukkitStack; + private boolean nbtChecked = false; // private org.bukkit.inventory.ItemStack bukkitStack; - public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) { + public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) + throws PrisonItemStackNotSupportedRuntimeException { super(); - - NBTItem nbtItemStack = new NBTItem( bukkitStack ); - this.bukkitStack = nbtItemStack; + this.bukkitStack = bukkitStack; + this.nbtBukkitStack = null; + + setupBukkitStack( bukkitStack ); + } + + private void setupBukkitStack( org.bukkit.inventory.ItemStack bukkitStack ) { + XMaterial xMat = null; + + try { + xMat = XMaterial.matchXMaterial( bukkitStack ); + } catch (Exception e) { + + String message = String.format( + "Unsupported ItemStack type: %s", + e.getMessage() ); + throw new PrisonItemStackNotSupportedRuntimeException( message ); + } + + if ( xMat != XMaterial.AIR ) { + + NBTItem nbtItemStack = new NBTItem( bukkitStack ); + + this.nbtBukkitStack = nbtItemStack; // this.bukkitStack = bukkitStack; + } + if (bukkitStack == null || bukkitStack.getType().equals(Material.AIR)) { setAmount( 0 ); @@ -51,7 +77,7 @@ public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) { // in the bukkitStack: int amount = bukkitStack.getAmount(); - XMaterial xMat = XMaterial.matchXMaterial( bukkitStack ); + PrisonBlock type = SpigotUtil.getPrisonBlock( xMat ); @@ -80,6 +106,8 @@ else if ( type != null ) { setDisplayName( displayName ); setAmount( amount ); setMaterial( type ); + + setLore( lores ); } @@ -106,64 +134,91 @@ public void setPrisonBlock( PrisonBlock pBlock ) { setMaterial( pBlock ); } + + /** + *

This will check to see if the nbt library is active on this itemStack, + * of which there are some items and blocks that it cannot be used with. + * If it has not been checked before, it will attempt a check. + *

+ * + * @return + */ + public boolean isNBTEnabled() { + + if ( !nbtChecked && bukkitStack != null && bukkitStack.getType() != Material.AIR ) { + + try { + NBTItem nbtItemStack = new NBTItem( bukkitStack ); + + this.nbtBukkitStack = nbtItemStack; + } catch (Exception e) { + // ignore - the bukkit item stack is not compatible with the NBT library + } + + this.nbtChecked = true; + } + + return nbtBukkitStack != null; + } + public boolean hasNBTKey( String key ) { boolean results = false; - if ( bukkitStack != null ) { - results = bukkitStack.hasKey( key ); + if ( isNBTEnabled() ) { + results = nbtBukkitStack.hasKey( key ); } return results; } public void setNBTString( String key, String value ) { - if ( bukkitStack != null ) { - bukkitStack.setString( key, value ); + if ( isNBTEnabled() ) { + nbtBukkitStack.setString( key, value ); } } public String getNBTString( String key ) { String results = null; - if ( bukkitStack != null ) { - results = bukkitStack.getString( key ); + if ( isNBTEnabled() ) { + results = nbtBukkitStack.getString( key ); } return results; } public void setNBTInt( String key, int value ) { - if ( bukkitStack != null ) { - bukkitStack.setInteger( key, value ); + if ( isNBTEnabled() ) { + nbtBukkitStack.setInteger( key, value ); } } public int getNBTInt( String key ) { int results = -1; - if ( bukkitStack != null ) { - results = bukkitStack.getInteger( key ); + if ( isNBTEnabled() ) { + results = nbtBukkitStack.getInteger( key ); } return results; } public void setNBTDouble( String key, double value ) { - if ( bukkitStack != null ) { - bukkitStack.setDouble( key, value ); + if ( isNBTEnabled() ) { + nbtBukkitStack.setDouble( key, value ); } } public double getNBTDouble( String key ) { double results = -1d; - if ( bukkitStack != null ) { - results = bukkitStack.getDouble( key ); + if ( isNBTEnabled() ) { + results = nbtBukkitStack.getDouble( key ); } return results; } public void setNBTBoolean( String key, boolean value ) { - if ( bukkitStack != null ) { - bukkitStack.setBoolean( key, value ); + if ( isNBTEnabled() ) { + nbtBukkitStack.setBoolean( key, value ); } } public boolean getNBTBoolean( String key ) { boolean results = false; - if ( bukkitStack != null ) { - results = bukkitStack.getBoolean( key ); + if ( isNBTEnabled() ) { + results = nbtBukkitStack.getBoolean( key ); } return results; } @@ -180,7 +235,7 @@ public void setAmount( int amount ) { super.setAmount( amount ); if ( bukkitStack != null ) { - bukkitStack.getItem().setAmount( amount ); + bukkitStack.setAmount( amount ); } } @@ -217,16 +272,24 @@ public boolean isBlock() { public org.bukkit.inventory.ItemStack getBukkitStack() { - return bukkitStack.getItem(); + return bukkitStack; } - public void setBukkitStack( org.bukkit.inventory.ItemStack bukkitStack ) { - NBTItem nbtItemStack = new NBTItem( bukkitStack ); - this.bukkitStack = nbtItemStack; -// this.bukkitStack = bukkitStack; + this.bukkitStack = bukkitStack; + this.nbtBukkitStack = null; + + setupBukkitStack( bukkitStack ); + } + + + public NBTItem getNbtBukkitStack() { + return nbtBukkitStack; } + + + public Map serialize() { Map results = new HashMap<>(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java index 448b3d0b9..c7eb06425 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java @@ -452,7 +452,7 @@ public String getItemInHandLore() { SpigotItemStack itemStack = getItemInHand(); - if ( itemStack.getLore() != null && itemStack.getLore().size() > 0 ) { + if ( itemStack != null && itemStack.getLore() != null && itemStack.getLore().size() > 0 ) { for ( String lore : itemStack.getLore() ) { if ( lore.trim().length() > 0 ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index 0257a751c..af3286133 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -28,6 +28,7 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.api.ExplosiveBlockBreakEvent; import tech.mcprison.prison.spigot.block.OnBlockBreakMines; +import tech.mcprison.prison.spigot.block.PrisonItemStackNotSupportedRuntimeException; import tech.mcprison.prison.spigot.block.SpigotBlock; import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; @@ -617,7 +618,14 @@ public static SpigotItemStack getItemStackBomb( MineBombData bombData ) { if ( xBomb != null ) { - bombs = new SpigotItemStack( xBomb.parseItem() ); + + try { + bombs = new SpigotItemStack( xBomb.parseItem() ); + } + catch (PrisonItemStackNotSupportedRuntimeException e) { + // Ignore + } + if ( bombs != null ) { bombs.setDisplayName( bombData.getName() ); From 690129ef9da482c988a081569f214b004356967d Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 23 Apr 2022 09:43:30 -0400 Subject: [PATCH 223/297] Fixes the mine bomb usage of lore where the lore that is defined in the settings is no longer altered so it's now used verbatim. Also the check for mine bomb is removed from using the name, or first line of lore, and now tries to use NBT data. But note, that the NBT data is not working correctly yet. --- docs/changelog_v3.3.x.md | 7 +- .../mcprison/prison/bombs/MineBombData.java | 28 +-- .../prison/spigot/block/SpigotItemStack.java | 195 ++++++++++++------ .../spigot/utils/PrisonBombListener.java | 20 +- .../spigot/utils/PrisonUtilsMineBombs.java | 59 ++++-- 5 files changed, 222 insertions(+), 87 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 20d38ea1a..020846c12 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,12 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.10 2022-04-20 +# 3.3.0-alpha.10 2022-04-23 + + +* **Fixes the mine bomb usage of lore where the lore that is defined in the settings is no longer altered so it's now used verbatim.** +Also the check for mine bomb is removed from using the name, or first line of lore, and now tries to use NBT data. +But note, that the NBT data is not working correctly yet. * **Fixed the usage of setting up the NBT library within the gradle config file.** 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 35a76c375..5dce27843 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 @@ -14,12 +14,12 @@ public class MineBombData { private String description; - /** - *

The 'bombItemId' is first line of the bomb's item lore, and - * it really needs to be unique and not match any other bomb's id. - *

- */ - private String loreBombItemId; +// /** +// *

The 'bombItemId' is first line of the bomb's item lore, and +// * it really needs to be unique and not match any other bomb's id. +// *

+// */ +// private String loreBombItemId; private List lore; @@ -200,7 +200,7 @@ public MineBombData( String name, String itemType, String explosionShape, this.explosionShape = explosionShape; this.radius = radius; - this.loreBombItemId = "PrisonMineBomb: " + name; +// this.loreBombItemId = "PrisonMineBomb: " + name; this.lore = new ArrayList<>(); @@ -233,7 +233,7 @@ public MineBombData clone() { MineBombData cloned = new MineBombData( getName(), getItemType(), getExplosionShape(), getRadius() ); - cloned.setLoreBombItemId( getLoreBombItemId() ); +// cloned.setLoreBombItemId( getLoreBombItemId() ); cloned.setDescription( getDescription() ); @@ -303,12 +303,12 @@ public void setDescription( String description ) { this.description = description; } - public String getLoreBombItemId() { - return loreBombItemId; - } - public void setLoreBombItemId( String loreBombItemId ) { - this.loreBombItemId = loreBombItemId; - } +// public String getLoreBombItemId() { +// return loreBombItemId; +// } +// public void setLoreBombItemId( String loreBombItemId ) { +// this.loreBombItemId = loreBombItemId; +// } public List getLore() { return lore; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java index 06ccea03c..a26700731 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java @@ -15,14 +15,15 @@ import tech.mcprison.prison.Prison; import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.block.PrisonBlock; +import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotUtil; public class SpigotItemStack extends ItemStack { private org.bukkit.inventory.ItemStack bukkitStack; - private NBTItem nbtBukkitStack; - private boolean nbtChecked = false; +// private NBTItem nbtBukkitStack; +// private boolean nbtChecked = false; // private org.bukkit.inventory.ItemStack bukkitStack; public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) @@ -30,7 +31,7 @@ public SpigotItemStack( org.bukkit.inventory.ItemStack bukkitStack ) super(); this.bukkitStack = bukkitStack; - this.nbtBukkitStack = null; +// this.nbtBukkitStack = null; setupBukkitStack( bukkitStack ); } @@ -48,13 +49,13 @@ private void setupBukkitStack( org.bukkit.inventory.ItemStack bukkitStack ) { throw new PrisonItemStackNotSupportedRuntimeException( message ); } - if ( xMat != XMaterial.AIR ) { - - NBTItem nbtItemStack = new NBTItem( bukkitStack ); - - this.nbtBukkitStack = nbtItemStack; -// this.bukkitStack = bukkitStack; - } +// if ( xMat != XMaterial.AIR ) { +// +// NBTItem nbtItemStack = new NBTItem( bukkitStack, true ); +// +// this.nbtBukkitStack = nbtItemStack; +//// this.bukkitStack = bukkitStack; +// } if (bukkitStack == null || bukkitStack.getType().equals(Material.AIR)) { @@ -135,94 +136,172 @@ public void setPrisonBlock( PrisonBlock pBlock ) { } - /** - *

This will check to see if the nbt library is active on this itemStack, - * of which there are some items and blocks that it cannot be used with. - * If it has not been checked before, it will attempt a check. - *

- * - * @return - */ - public boolean isNBTEnabled() { +// /** +// *

This will check to see if the nbt library is active on this itemStack, +// * of which there are some items and blocks that it cannot be used with. +// * If it has not been checked before, it will attempt a check. +// *

+// * +// * @return +// */ +// public boolean isNBTEnabled() { +// +// if ( !nbtChecked && bukkitStack != null && bukkitStack.getType() != Material.AIR ) { +// +// try { +// NBTItem nbtItemStack = new NBTItem( bukkitStack, true ); +// +// this.nbtBukkitStack = nbtItemStack; +// } catch (Exception e) { +// // ignore - the bukkit item stack is not compatible with the NBT library +// } +// +// this.nbtChecked = true; +// } +// +// return nbtBukkitStack != null; +// } + + public NBTItem getNBT() { + NBTItem nbtItemStack = null; - if ( !nbtChecked && bukkitStack != null && bukkitStack.getType() != Material.AIR ) { - + if ( getBukkitStack() != null && getBukkitStack().getType() != Material.AIR ) { try { - NBTItem nbtItemStack = new NBTItem( bukkitStack ); + nbtItemStack = new NBTItem( getBukkitStack(), true ); - this.nbtBukkitStack = nbtItemStack; + nbtDebugLog( nbtItemStack, "getNbt" ); } catch (Exception e) { // ignore - the bukkit item stack is not compatible with the NBT library } - - this.nbtChecked = true; } - return nbtBukkitStack != null; + return nbtItemStack; + } + + private void applyNbt( NBTItem nbtItem ) { + if ( nbtItem != null && getBukkitStack() != null ) { + + nbtItem.applyNBT( getBukkitStack() ); + + nbtDebugLog( nbtItem, "applyNbt" ); + } + } + + private void nbtDebugLog( NBTItem nbtItem, String desc ) { + if ( Output.get().isDebug() ) { + org.bukkit.inventory.ItemStack iStack = nbtItem.getItem(); + + String message = String.format( + "NBT %s ItemStack for %s: %s", + desc, + iStack.hasItemMeta() && iStack.getItemMeta().hasDisplayName() ? + iStack.getItemMeta().getDisplayName() : + iStack.getType().name(), + nbtItem.toString() ); + + Output.get().logInfo( message ); + + Output.get().logInfo( "NBT: " + new NBTItem( getBukkitStack() ) ); + + } } public boolean hasNBTKey( String key ) { boolean results = false; - if ( isNBTEnabled() ) { - results = nbtBukkitStack.hasKey( key ); + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + results = nbtItem.hasKey( key ); } return results; } - public void setNBTString( String key, String value ) { - if ( isNBTEnabled() ) { - nbtBukkitStack.setString( key, value ); - } - } public String getNBTString( String key ) { String results = null; - if ( isNBTEnabled() ) { - results = nbtBukkitStack.getString( key ); + + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + results = nbtItem.getString( key ); } return results; } - - public void setNBTInt( String key, int value ) { - if ( isNBTEnabled() ) { - nbtBukkitStack.setInteger( key, value ); + public void setNBTString( String key, String value ) { + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + nbtItem.setString( key, value ); + applyNbt( nbtItem ); } } + public int getNBTInt( String key ) { int results = -1; - if ( isNBTEnabled() ) { - results = nbtBukkitStack.getInteger( key ); + + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + results = nbtItem.getInteger( key ); } return results; } - - public void setNBTDouble( String key, double value ) { - if ( isNBTEnabled() ) { - nbtBukkitStack.setDouble( key, value ); + public void setNBTInt( String key, int value ) { + + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + nbtItem.setInteger( key, value ); + applyNbt( nbtItem ); } } + public double getNBTDouble( String key ) { double results = -1d; - if ( isNBTEnabled() ) { - results = nbtBukkitStack.getDouble( key ); + + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + results = nbtItem.getDouble( key ); } return results; } - - public void setNBTBoolean( String key, boolean value ) { - if ( isNBTEnabled() ) { - nbtBukkitStack.setBoolean( key, value ); + public void setNBTDouble( String key, double value ) { + + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + nbtItem.setDouble( key, value ); + applyNbt( nbtItem ); } } + public boolean getNBTBoolean( String key ) { boolean results = false; - if ( isNBTEnabled() ) { - results = nbtBukkitStack.getBoolean( key ); + + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + results = nbtItem.getBoolean( key ); } return results; } - + public void setNBTBoolean( String key, boolean value ) { + + NBTItem nbtItem = getNBT(); + if ( nbtItem != null ) { + nbtItem.setBoolean( key, value ); + applyNbt( nbtItem ); + } + } + + +// +// public void setNbtString( org.bukkit.inventory.ItemStack bItemStack, String key, String value ) { +// NBTItem nbt = new NBTItem( bItemStack ); +// nbt.setString( key, value ); +// nbt.applyNBT( bItemStack ); +// } +// +// public String getNbtValue( org.bukkit.inventory.ItemStack bItemStack, String key ) { +// NBTItem nbt = new NBTItem( bItemStack ); +// return nbt.getString( key ); +// } +// + /** *

This function overrides the Prison's ItemStack class's setAmount() to perform the * same behavior of setting the amount to the requested value, but it also updates @@ -277,15 +356,15 @@ public org.bukkit.inventory.ItemStack getBukkitStack() { public void setBukkitStack( org.bukkit.inventory.ItemStack bukkitStack ) { this.bukkitStack = bukkitStack; - this.nbtBukkitStack = null; +// this.nbtBukkitStack = null; setupBukkitStack( bukkitStack ); } - public NBTItem getNbtBukkitStack() { - return nbtBukkitStack; - } +// public NBTItem getNbtBukkitStack() { +// return nbtBukkitStack; +// } 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 9efcadbf0..c9e3a9475 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,6 @@ package tech.mcprison.prison.spigot.utils; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -7,8 +8,13 @@ import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import de.tr7zw.nbtapi.NBTItem; +import tech.mcprison.prison.bombs.MineBombData; +import tech.mcprison.prison.output.Output; 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.util.Location; @@ -50,7 +56,17 @@ public void onInteract( PlayerInteractEvent event ) { Player player = event.getPlayer(); - if ( !getPrisonUtilsMineBombs().isItemABomb( player ) ) { +// ItemStack item = new ItemStack(Material.APPLE); +// new NBTItem(item, true).setString("yummy", "apple"); +// player.getInventory().addItem(item); + + SpigotItemStack sItemStack = new SpigotItemStack( event.getItem() ); + Output.get().logInfo( sItemStack.getNBT().toString() ); + + MineBombData bomb = getPrisonUtilsMineBombs().getBombItem( player ); + + + if ( bomb == null ) { return; } @@ -75,7 +91,7 @@ public void onInteract( PlayerInteractEvent event ) { // Output.get().logInfo( "### PrisonBombListener: PlayerInteractEvent 02 " ); - if ( getPrisonUtilsMineBombs().setBombInHand( player, sBlock ) ) { + if ( getPrisonUtilsMineBombs().setBombInHand( player, bomb, sBlock ) ) { // The item was a bomb and it was activated. // Cancel the event so the item will not be placed or processed farther. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index af3286133..36846c942 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -10,6 +10,7 @@ import org.bukkit.Effect; import org.bukkit.Particle; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import com.cryptomorin.xseries.XMaterial; import com.cryptomorin.xseries.XSound; @@ -45,6 +46,8 @@ public class PrisonUtilsMineBombs public static final String MINE_BOMBS_LORE_2_PREFIX = " &7"; public static final int MINE_BOMBS_COOLDOWN_TICKS = 5 * 20; // 5 seconds // 15 seconds + public static final String MINE_BOMBS_NBT_BOMB_KEY = "PrisonMineBombNbtKey"; + private boolean enableMineBombs = false; @@ -628,16 +631,40 @@ public static SpigotItemStack getItemStackBomb( MineBombData bombData ) { if ( bombs != null ) { + + // Set the NBT key for the bombs: + bombs.setNBTString( MINE_BOMBS_NBT_BOMB_KEY, bombData.getName() ); + + if ( !bombs.hasNBTKey(MINE_BOMBS_NBT_BOMB_KEY) ) { + String.format( + "Unable to set the NBT id on mine bomb: %s type: %s", + bombData.getName(), + bombData.getItemType() ); + } + +// // Get the modified bukkit item stack, and add it back to the PrisonItemStack: +// ItemStack bukkitItemStack = bombs.getNbtBukkitStack().getItem(); +// bombs = new SpigotItemStack( bukkitItemStack ); +//// bombs.setBukkitStack(bukkitItemStack); + bombs.setDisplayName( bombData.getName() ); + + if ( !bombs.hasNBTKey(MINE_BOMBS_NBT_BOMB_KEY) ) { + String.format( + "Unable to set the NBT id on mine bomb (2): %s type: %s", + bombData.getName(), + bombData.getItemType() ); + } + //bombs.setAmount( count ); // if ( bomb.isGlowing() ) { // bombs.addEnchantment( ); // } - List lore = new ArrayList<>( bombs.getLore() ); + List lore = new ArrayList<>( bombData.getLore() ); - lore.add( 0, bombData.getLoreBombItemId() ); + // lore.add( 0, bombData.getLoreBombItemId() ); bombs.setLore( lore ); @@ -665,20 +692,27 @@ public boolean isItemABomb( Player player ) { return ( bomb != null ); } + /** + *

This takes a player, and checks to see if it is a prison mine bomb by checking the + * NBT tag in the constant: MINE_BOMBS_NBT_BOMB_KEY. If it is, then it uses that key + * value to search for the proper bomb, and if found, then it returns it. + *

+ * + * + * @param player + * @return MineBombData if item in hand is one, otherwise null + */ public MineBombData getBombItem( Player player ) { MineBombData bomb = null; SpigotItemStack itemInHand = SpigotCompatibility.getInstance().getPrisonItemInMainHand( player ); - if ( itemInHand != null ) { - List lore = itemInHand.getLore(); + if ( itemInHand != null && itemInHand.hasNBTKey( MINE_BOMBS_NBT_BOMB_KEY ) ) { + + String bombName = itemInHand.getNBTString( MINE_BOMBS_NBT_BOMB_KEY ); + + bomb = MineBombs.getInstance().findBombByName( bombName ); - if ( lore.size() > 0 ) { - - String bombItemId = lore.get( 0 ); - - bomb = MineBombs.getInstance().findBombByItemId( bombItemId ); - } } return bomb; @@ -695,12 +729,13 @@ public MineBombData getBombItem( Player player ) { *

* * @param player + * @param bomb * @return */ - public boolean setBombInHand( Player player, SpigotBlock sBlock ) { + public boolean setBombInHand( Player player, MineBombData bomb, SpigotBlock sBlock ) { boolean isABomb = false; - MineBombData bomb = getBombItem( player ); +// MineBombData bomb = getBombItem( player ); if ( bomb != null ) { From e48d648c060e5f92b70aa075d2bf622723c4d2a6 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 24 Apr 2022 22:25:35 -0400 Subject: [PATCH 224/297] Mine Bombs and NBT settings: this fixes mine bombs to work with NBT tags, which are being used to identify which items are actually mine bombs. --- docs/changelog_v3.3.x.md | 5 +- .../tech/mcprison/prison/bombs/MineBombs.java | 31 ++- .../prison/spigot/block/SpigotItemStack.java | 192 +++++++++++------- .../spigot/utils/PrisonBombListener.java | 48 ++++- .../spigot/utils/PrisonUtilsMineBombs.java | 76 +++---- 5 files changed, 221 insertions(+), 131 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 020846c12..fd26e1647 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.10 2022-04-23 +# 3.3.0-alpha.10 2022-04-24 + + +* **Mine Bombs and NBT settings: this fixes mine bombs to work with NBT tags, which are being used to identify which items are actually mine bombs.** * **Fixes the mine bomb usage of lore where the lore that is defined in the settings is no longer altered so it's now used verbatim.** 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 2f6639a27..868850b29 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 @@ -16,6 +16,9 @@ public class MineBombs public static final String MINE_BOMBS_FILE_NAME = "mineBombsConfig.json"; public static final String MINE_BOMBS_PATH_NAME = "module_conf/mines"; + public static final String MINE_BOMBS_NBT_BOMB_KEY = "PrisonMineBombNbtKey"; + + private static MineBombs instance; private MineBombsConfigData configData; @@ -469,7 +472,7 @@ public void setupDefaultMineBombData() { MineBombData mbd = new MineBombData( - "SmallBomb", "brewing_stand", ExplosionShape.sphere.name(), 2, "Small Mine Bomb" ); + "SmallBomb", "brewing_stand", ExplosionShape.sphere.name(), 2, "&dSmall &6Mine &eBomb &3(lore line 1)" ); mbd.setNameTag( "&6&kABC&r&c-= &7{name}&c =-&6&kCBA" ); @@ -477,6 +480,9 @@ public void setupDefaultMineBombData() mbd.setToolInHandFortuneLevel( 0 ); mbd.setDescription("A small mine bomb made with some chemicals and a brewing stand."); + mbd.getLore().add( "&4Lore line 2" ); + mbd.getLore().add( "&aLore line &73" ); + mbd.getSoundEffects().add( mbeSound01.clone() ); mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); mbd.getSoundEffects().add( mbeSound03.clone() ); @@ -606,7 +612,7 @@ public void setupDefaultMineBombData() MineBombData mbd = new MineBombData( "WimpyBomb", "GUNPOWDER", ExplosionShape.sphere.name(), 5, "A Wimpy Mine Bomb" ); - mbd.setLoreBombItemId( "&7A &2Wimpy &cBomb &9...&02A3F" ); +// mbd.setLoreBombItemId( "&7A &2Wimpy &cBomb &9...&02A3F" ); mbd.setNameTag( "&7A &2Wimpy &cBomb" ); @@ -698,23 +704,28 @@ public void setConfigData( MineBombsConfigData configData ) { } - public MineBombData findBombByItemId( String bombItemId ) + public MineBombData findBombByName( String bombName ) { MineBombData results = null; - String bombItemIdConvered = Text.convertToAmpColorCodes( bombItemId ); + String cleanedBombName = Text.stripColor( bombName ); - if ( bombItemIdConvered != null && !bombItemIdConvered.isEmpty() ) { + if ( cleanedBombName != null && !cleanedBombName.isEmpty() ) { for ( String bombKey : getConfigData().getBombs().keySet() ) { MineBombData bomb = getConfigData().getBombs().get( bombKey ); - if ( bomb != null && bomb.getLoreBombItemId() != null && - bomb.getLoreBombItemId().equalsIgnoreCase( bombItemIdConvered ) ) { - - results = bomb; - + if ( bomb != null ) { + String cBombName = Text.stripColor( bomb.getName() ); + + if ( cBombName != null && + cBombName.equalsIgnoreCase( cleanedBombName ) ) { + + results = bomb; + } } + + } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java index a26700731..244a4fe3b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java @@ -17,6 +17,7 @@ import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotUtil; +import tech.mcprison.prison.util.Text; public class SpigotItemStack extends ItemStack { @@ -65,12 +66,7 @@ private void setupBukkitStack( org.bukkit.inventory.ItemStack bukkitStack ) { } else { - ItemMeta meta; - if (!bukkitStack.hasItemMeta()) { - meta = Bukkit.getItemFactory().getItemMeta(bukkitStack.getType()); - } else { - meta = bukkitStack.getItemMeta(); - } + ItemMeta meta = getMeta(); @@ -92,9 +88,9 @@ private void setupBukkitStack( org.bukkit.inventory.ItemStack bukkitStack ) { if (meta.hasDisplayName()) { displayName = meta.getDisplayName(); } - else if ( type != null ) { - displayName = type.getBlockName().toLowerCase(); - } +// else if ( type != null ) { +// displayName = type.getBlockName().toLowerCase(); +// } List lores = new ArrayList<>(); @@ -104,12 +100,12 @@ else if ( type != null ) { } } - setDisplayName( displayName ); setAmount( amount ); setMaterial( type ); - - setLore( lores ); + // Update only the prison internals for the displayName and lore: + super.setDisplayName( displayName ); + super.setLore( lores ); } @@ -178,26 +174,29 @@ public NBTItem getNBT() { return nbtItemStack; } - private void applyNbt( NBTItem nbtItem ) { - if ( nbtItem != null && getBukkitStack() != null ) { - - nbtItem.applyNBT( getBukkitStack() ); - - nbtDebugLog( nbtItem, "applyNbt" ); - } - } +// private void applyNbt( NBTItem nbtItem ) { +// if ( nbtItem != null && getBukkitStack() != null ) { +// +//// nbtItem.applyNBT( getBukkitStack() ); +// +// nbtDebugLog( nbtItem, "applyNbt" ); +// } +// } private void nbtDebugLog( NBTItem nbtItem, String desc ) { if ( Output.get().isDebug() ) { org.bukkit.inventory.ItemStack iStack = nbtItem.getItem(); + int sysId = System.identityHashCode(iStack); + String message = String.format( - "NBT %s ItemStack for %s: %s", + "NBT %s ItemStack for %s: %s sysId: %d", desc, iStack.hasItemMeta() && iStack.getItemMeta().hasDisplayName() ? iStack.getItemMeta().getDisplayName() : iStack.getType().name(), - nbtItem.toString() ); + nbtItem.toString(), + sysId ); Output.get().logInfo( message ); @@ -230,63 +229,63 @@ public void setNBTString( String key, String value ) { NBTItem nbtItem = getNBT(); if ( nbtItem != null ) { nbtItem.setString( key, value ); - applyNbt( nbtItem ); + nbtDebugLog( nbtItem, "setNBTString" ); } } - public int getNBTInt( String key ) { - int results = -1; - - NBTItem nbtItem = getNBT(); - if ( nbtItem != null ) { - results = nbtItem.getInteger( key ); - } - return results; - } - public void setNBTInt( String key, int value ) { - - NBTItem nbtItem = getNBT(); - if ( nbtItem != null ) { - nbtItem.setInteger( key, value ); - applyNbt( nbtItem ); - } - } +// public int getNBTInt( String key ) { +// int results = -1; +// +// NBTItem nbtItem = getNBT(); +// if ( nbtItem != null ) { +// results = nbtItem.getInteger( key ); +// } +// return results; +// } +// public void setNBTInt( String key, int value ) { +// +// NBTItem nbtItem = getNBT(); +// if ( nbtItem != null ) { +// nbtItem.setInteger( key, value ); +// nbtDebugLog( nbtItem, "setNBTInt" ); +// } +// } - public double getNBTDouble( String key ) { - double results = -1d; - - NBTItem nbtItem = getNBT(); - if ( nbtItem != null ) { - results = nbtItem.getDouble( key ); - } - return results; - } - public void setNBTDouble( String key, double value ) { - - NBTItem nbtItem = getNBT(); - if ( nbtItem != null ) { - nbtItem.setDouble( key, value ); - applyNbt( nbtItem ); - } - } +// public double getNBTDouble( String key ) { +// double results = -1d; +// +// NBTItem nbtItem = getNBT(); +// if ( nbtItem != null ) { +// results = nbtItem.getDouble( key ); +// } +// return results; +// } +// public void setNBTDouble( String key, double value ) { +// +// NBTItem nbtItem = getNBT(); +// if ( nbtItem != null ) { +// nbtItem.setDouble( key, value ); +// nbtDebugLog( nbtItem, "setNBTDouble" ); +// } +// } - public boolean getNBTBoolean( String key ) { - boolean results = false; - - NBTItem nbtItem = getNBT(); - if ( nbtItem != null ) { - results = nbtItem.getBoolean( key ); - } - return results; - } - public void setNBTBoolean( String key, boolean value ) { - - NBTItem nbtItem = getNBT(); - if ( nbtItem != null ) { - nbtItem.setBoolean( key, value ); - applyNbt( nbtItem ); - } - } +// public boolean getNBTBoolean( String key ) { +// boolean results = false; +// +// NBTItem nbtItem = getNBT(); +// if ( nbtItem != null ) { +// results = nbtItem.getBoolean( key ); +// } +// return results; +// } +// public void setNBTBoolean( String key, boolean value ) { +// +// NBTItem nbtItem = getNBT(); +// if ( nbtItem != null ) { +// nbtItem.setBoolean( key, value ); +// nbtDebugLog( nbtItem, "setNBTBoolean" ); +// } +// } // @@ -313,11 +312,54 @@ public void setNBTBoolean( String key, boolean value ) { public void setAmount( int amount ) { super.setAmount( amount ); - if ( bukkitStack != null ) { + if ( bukkitStack != null && bukkitStack.getAmount() != amount ) { bukkitStack.setAmount( amount ); } } + private ItemMeta getMeta() { + ItemMeta meta; + if (!bukkitStack.hasItemMeta()) { + meta = Bukkit.getItemFactory().getItemMeta(bukkitStack.getType()); + } else { + meta = bukkitStack.getItemMeta(); + } + + return meta; + } + + @Override + public void setDisplayName( String displayName ) { + + ItemMeta meta = getMeta(); + if ( meta != null && displayName != null && displayName.trim().length() > 0 ) { + + meta.setDisplayName( Text.convertToAmpColorCodes(displayName) ); + } + + getBukkitStack().setItemMeta( meta ); + + super.setDisplayName( displayName ); + } + + @Override + public void setLore( List lores ) { + List updatedLores = new ArrayList<>(); + + ItemMeta meta = getMeta(); + if ( meta != null && lores != null && lores.size() > 0 ) { + + for ( String lore : lores ) { + updatedLores.add( Text.translateAmpColorCodes(lore) ); + } + + meta.setLore( updatedLores ); + } + + getBukkitStack().setItemMeta( meta ); + + //super.setLore( updatedLores ); + } public boolean isAir() { 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 c9e3a9475..cb53d2b58 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 @@ -8,13 +8,12 @@ import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; import de.tr7zw.nbtapi.NBTItem; import tech.mcprison.prison.bombs.MineBombData; +import tech.mcprison.prison.bombs.MineBombs; import tech.mcprison.prison.output.Output; 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.util.Location; @@ -49,21 +48,50 @@ public void onInteract( PlayerInteractEvent event ) { //Output.get().logInfo( "### PrisonBombListener: PlayerInteractEvent 01 " ); - if ( event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.RIGHT_CLICK_AIR) ) { + if ( (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || + event.getAction().equals(Action.RIGHT_CLICK_AIR)) && + event.getItem() != null && event.getItem().getType() != Material.AIR ) { // If the player is holding a mine bomb, then get the bomb and decrease the // ItemStack in the player's hand by 1: - Player player = event.getPlayer(); -// ItemStack item = new ItemStack(Material.APPLE); -// new NBTItem(item, true).setString("yummy", "apple"); -// player.getInventory().addItem(item); + // Check to see if this is an mine bomb by checking the NBT key-value pair, + // which will also identify which mine bomb it is too. + // NOTE: Because we're just checking, do not auto update the itemstack. + NBTItem nbtItem = new NBTItem( event.getItem() ); + + if ( Output.get().isDebug() && nbtItem != null ) { + Output.get().logInfo( "PrisonBombListener.onInteract ntb: %s", nbtItem.toString() ); + } - SpigotItemStack sItemStack = new SpigotItemStack( event.getItem() ); - Output.get().logInfo( sItemStack.getNBT().toString() ); + if ( !nbtItem.hasKey( MineBombs.MINE_BOMBS_NBT_BOMB_KEY ) ) { + return; + } + + String bombName = nbtItem.getString( MineBombs.MINE_BOMBS_NBT_BOMB_KEY ); + + Player player = event.getPlayer(); - MineBombData bomb = getPrisonUtilsMineBombs().getBombItem( player ); +// // Temp test stuff... remove when NBTs are working: +// { +// +// ItemStack item = new ItemStack(Material.APPLE); +// SpigotItemStack spItemStack = new SpigotItemStack( item ); +// spItemStack.setNBTString("tasty", "fruit"); +// SpigotPlayer spPlayer = new SpigotPlayer( player ); +// spPlayer.getInventory().addItem(spItemStack); +// spPlayer.updateInventory(); +// +//// ItemStack item = new ItemStack(Material.APPLE); +//// new NBTItem(item, true).setString("yummy", "apple"); +//// player.getInventory().addItem(item); +// +// SpigotItemStack sItemStack = new SpigotItemStack( event.getItem() ); +// Output.get().logInfo( sItemStack.getNBT().toString() ); +// } + + MineBombData bomb = getPrisonUtilsMineBombs().getBombItem( bombName ); if ( bomb == null ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index 36846c942..958553ca8 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -15,6 +15,7 @@ import com.cryptomorin.xseries.XMaterial; import com.cryptomorin.xseries.XSound; +import de.tr7zw.nbtapi.NBTItem; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper; import tech.mcprison.prison.bombs.MineBombData; @@ -46,7 +47,6 @@ public class PrisonUtilsMineBombs public static final String MINE_BOMBS_LORE_2_PREFIX = " &7"; public static final int MINE_BOMBS_COOLDOWN_TICKS = 5 * 20; // 5 seconds // 15 seconds - public static final String MINE_BOMBS_NBT_BOMB_KEY = "PrisonMineBombNbtKey"; private boolean enableMineBombs = false; @@ -499,14 +499,15 @@ public void utilsMineBombsGive( CommandSender sender, if ( bomb != null ) { - SpigotItemStack bombs = getItemStackBomb( bomb ); + ItemStack bombs = getItemStackBomb( bomb ); if ( bombs != null ) { bombs.setAmount( count ); - player.getInventory().addItem( bombs ); + player.getWrapper().getInventory().addItem( bombs ); - player.updateInventory(); + player.getWrapper().updateInventory(); +// player.updateInventory(); } else { @@ -614,8 +615,10 @@ public void utilsMineBombsGive( CommandSender sender, } - public static SpigotItemStack getItemStackBomb( MineBombData bombData ) { + public static ItemStack getItemStackBomb( MineBombData bombData ) { + ItemStack sItemStack = null; SpigotItemStack bombs = null; + NBTItem nbtItem = null; XMaterial xBomb = XMaterial.matchXMaterial( bombData.getItemType() ).orElse( null ); @@ -623,39 +626,23 @@ public static SpigotItemStack getItemStackBomb( MineBombData bombData ) { try { - bombs = new SpigotItemStack( xBomb.parseItem() ); + + // Create the spigot/bukkit ItemStack: + sItemStack = xBomb.parseItem(); + + if ( sItemStack != null ) { + + bombs = new SpigotItemStack( sItemStack ); + } } catch (PrisonItemStackNotSupportedRuntimeException e) { // Ignore } if ( bombs != null ) { - - - // Set the NBT key for the bombs: - bombs.setNBTString( MINE_BOMBS_NBT_BOMB_KEY, bombData.getName() ); - - if ( !bombs.hasNBTKey(MINE_BOMBS_NBT_BOMB_KEY) ) { - String.format( - "Unable to set the NBT id on mine bomb: %s type: %s", - bombData.getName(), - bombData.getItemType() ); - } - -// // Get the modified bukkit item stack, and add it back to the PrisonItemStack: -// ItemStack bukkitItemStack = bombs.getNbtBukkitStack().getItem(); -// bombs = new SpigotItemStack( bukkitItemStack ); -//// bombs.setBukkitStack(bukkitItemStack); bombs.setDisplayName( bombData.getName() ); - if ( !bombs.hasNBTKey(MINE_BOMBS_NBT_BOMB_KEY) ) { - String.format( - "Unable to set the NBT id on mine bomb (2): %s type: %s", - bombData.getName(), - bombData.getItemType() ); - } - //bombs.setAmount( count ); // if ( bomb.isGlowing() ) { @@ -667,7 +654,20 @@ public static SpigotItemStack getItemStackBomb( MineBombData bombData ) { // lore.add( 0, bombData.getLoreBombItemId() ); bombs.setLore( lore ); + + + sItemStack = bombs.getBukkitStack(); + } + + if ( sItemStack != null ) { + // Set the NBT String key-value pair: + nbtItem = new NBTItem( sItemStack, true ); + nbtItem.setString( MineBombs.MINE_BOMBS_NBT_BOMB_KEY, bombData.getName() ); + + if ( Output.get().isDebug() && nbtItem != null ) { + Output.get().logInfo( "getItemStackBombs ntb: %s", nbtItem.toString() ); + } } } @@ -681,7 +681,7 @@ public static SpigotItemStack getItemStackBomb( MineBombData bombData ) { Output.get().logError( message ); } - return bombs; + return sItemStack; } @@ -707,17 +707,23 @@ public MineBombData getBombItem( Player player ) { SpigotItemStack itemInHand = SpigotCompatibility.getInstance().getPrisonItemInMainHand( player ); - if ( itemInHand != null && itemInHand.hasNBTKey( MINE_BOMBS_NBT_BOMB_KEY ) ) { + if ( itemInHand != null && itemInHand.hasNBTKey( MineBombs.MINE_BOMBS_NBT_BOMB_KEY ) ) { - String bombName = itemInHand.getNBTString( MINE_BOMBS_NBT_BOMB_KEY ); - - bomb = MineBombs.getInstance().findBombByName( bombName ); + String bombName = itemInHand.getNBTString( MineBombs.MINE_BOMBS_NBT_BOMB_KEY ); + bomb = getBombItem( bombName ); } return bomb; } + public MineBombData getBombItem( String bombName ) { + + MineBombData bomb = MineBombs.getInstance().findBombByName( bombName ); + + return bomb; + } + /** *

This takes a player and checks their main hand to see if it contains a bomb. * If it does, then it return the selected bomb, and it reduces the quantity by @@ -790,7 +796,7 @@ else if ( bomb != null ) { // Set cooldown: addPlayerCooldown( playerUUID, bomb.getCooldownTicks() ); - SpigotItemStack bombs = PrisonUtilsMineBombs.getItemStackBomb( bomb ); + SpigotItemStack bombs = new SpigotItemStack( PrisonUtilsMineBombs.getItemStackBomb( bomb )); if ( bombs != null ) { From 9d05a98bd5a1c4003b2c4d58f09d656edc6b886f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 30 Apr 2022 14:48:28 -0400 Subject: [PATCH 225/297] v3.3.0-alpha.11a on 2022-04-25 --- docs/changelog_v3.3.x.md | 6 +++++- docs/knownissues_v3.3.x.md | 16 +++++++++++++--- gradle.properties | 3 +-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index fd26e1647..cd795fa23 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.10 2022-04-24 +# 3.3.0-alpha.11a 2022-04-25 + + + +* **3.3.0-alpha.11a 2022-04-25** * **Mine Bombs and NBT settings: this fixes mine bombs to work with NBT tags, which are being used to identify which items are actually mine bombs.** diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index d09a9ddeb..be5fa7c52 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -8,13 +8,23 @@ # TODO Items for v3.3.0-alpha.10 -- Many errors when prison hits a standard potion. - jamo +- placeholders are not using the time units as the mine notifications are using. Therefore, they are continuing to use english units. Need to fix the placeholders. One is `prison_mines_timeleft_formatted_Mine`. kstance + + +- add support for NBTs - mine bombs - ClumbsyIsNotReal + - having problems formatting mine bomb lore with current restrictions since it prevents bombs from working. + + +- DONE: placeholders - show next rank is skipping p1 when no p is assigned to player. xGeorge26 + + +- DONE: Many errors when prison hits a standard potion. - jamo - autofeatures BLOCKEVENTS priority - include backpacks on auto sell - Ryankayz - Top block and top tokens - Phoung Nguyen -- auto features autosell - tie to sellall's player toggle - Ryankayz +- (done ??) auto features autosell - tie to sellall's player toggle - Ryankayz - SQL support - Six @@ -24,7 +34,7 @@ - Mine Resets - Glass block not being removed - harold -- Placeholder bar is reversed. As the player earns more money, it shrinks instead of grows. - harold +- (done ??) Placeholder bar is reversed. As the player earns more money, it shrinks instead of grows. - harold - prison_rankup_cost_bar_default - Archive old players - budderman18 diff --git a/gradle.properties b/gradle.properties index 645605c6d..0ea3c1abc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +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.10 -#version=3.3.0-alpha.7 +version=3.3.0-alpha.11a From c65c7b7d5464392af2ac98999815200ced2ef442 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 30 Apr 2022 14:53:17 -0400 Subject: [PATCH 226/297] Bug fix... with placeholder prison_rank__player_cost_remaining_rankname, and its variants, eliminate the calculation of including the current rank since that has already been paid for. Prior to this fix, it was only excluding prior ranks. --- docs/changelog_v3.3.x.md | 5 ++++- .../tech/mcprison/prison/ranks/managers/RankManager.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index cd795fa23..d1115d834 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,9 +11,12 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11a 2022-04-25 +# 3.3.0-alpha.11a 2022-04-30 +* **Bug fix... with placeholder prison_rank__player_cost_remaining_rankname, and its variants,** + eliminate the calculation of including the current rank since that has already been paid for. Prior to this fix, it was only excluding prior ranks. + * **3.3.0-alpha.11a 2022-04-25** 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 ccd4015f8..bf9c667ae 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 @@ -1424,10 +1424,10 @@ private double calculateRankCost( RankPlayer rankPlayer, Rank rank ) if ( playerRank != null ) { - // If the player is at a higher rank, then the cost will be + // If the player is at a higher rank, or the same rank, then the cost will be // zero for the rank that is being passed in, since the player has // already paid for that rank. - if ( rank.getPosition() < playerRank.getRank().getPosition() ) { + if ( rank.getPosition() <= playerRank.getRank().getPosition() ) { cost = 0; } else { From 50f3e730ce46546a6bc8bffb45150ce267757786 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 30 Apr 2022 15:01:12 -0400 Subject: [PATCH 227/297] Placeholder issues when not prefixed with "prison_" is being addressed by prefixing the identifier with "prison_" right away. This "is" addressed, but it's deep in the code and for some reason certain parts of the code is not making the connection to the correct placeholder without that prefix. So this really is not the desired way to address this, but it eliminates the problem. The reason why it's not the desired way, is because it's exposing buisness rules of how to handle the placeholders, outside of the placeholder core code. --- docs/changelog_v3.3.x.md | 4 ++++ .../PlaceHolderAPIIntegrationUppercaseWrapper.java | 4 ++++ .../spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d1115d834..abbd7c6ec 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11a 2022-04-30 +* **Placeholder issues when not prefixed with "prison_" is being addressed by prefixing the identifier with "prison_" right away.** +This "is" addressed, but it's deep in the code and for some reason certain parts of the code is not making the connection to the correct placeholder without that prefix. So this really is not the desired way to address this, but it eliminates the problem. The reason why it's not the desired way, is because it's exposing buisness rules of how to handle the placeholders, outside of the placeholder core code. + + * **Bug fix... with placeholder prison_rank__player_cost_remaining_rankname, and its variants,** eliminate the calculation of including the current rank since that has already been paid for. Prior to this fix, it was only excluding prior ranks. diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java index 726a9e5a2..0408ace64 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java @@ -77,6 +77,10 @@ public String getVersion(){ @Override public String onRequest(OfflinePlayer player, String identifier) { + if ( !identifier.toLowerCase().startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) { + identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; + } + UUID playerUuid = player.getUniqueId(); String results = Prison.get().getPlatform().getPlaceholders() .placeholderTranslate( playerUuid, player.getName(), identifier ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java index da440baf1..b5b683b34 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java @@ -76,6 +76,10 @@ public String getVersion(){ @Override public String onRequest(OfflinePlayer player, String identifier) { + if ( !identifier.toLowerCase().startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) { + identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; + } + UUID playerUuid = player.getUniqueId(); String results = Prison.get().getPlatform().getPlaceholders() .placeholderTranslate( playerUuid, player.getName(), identifier ); From b7148ea24a7ac51219931477a7151ec7c4f50a66 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 30 Apr 2022 18:02:37 -0400 Subject: [PATCH 228/297] Mine Bombs fix to allow color codes within the bomb's name. The color codes are removed for the sake of matching and selecting when giving to players so you don't have to use them in the commands. --- docs/changelog_v3.3.x.md | 4 + .../bombs/MineBombDefaultConfigSettings.java | 276 +++++++++ .../tech/mcprison/prison/bombs/MineBombs.java | 545 +++++++++--------- .../prison/spigot/block/SpigotItemStack.java | 2 +- .../spigot/gui/rank/SpigotPlayerRanksGUI.java | 8 +- .../spigot/utils/PrisonUtilsMineBombs.java | 24 +- 6 files changed, 575 insertions(+), 284 deletions(-) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombDefaultConfigSettings.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index abbd7c6ec..cf9d2b5db 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11a 2022-04-30 +* **Mine Bombs fix to allow color codes within the bomb's name.** +The color codes are removed for the sake of matching and selecting when giving to players so you don't have to use them in the commands. + + * **Placeholder issues when not prefixed with "prison_" is being addressed by prefixing the identifier with "prison_" right away.** This "is" addressed, but it's deep in the code and for some reason certain parts of the code is not making the connection to the correct placeholder without that prefix. So this really is not the desired way to address this, but it eliminates the problem. The reason why it's not the desired way, is because it's exposing buisness rules of how to handle the placeholders, outside of the placeholder core code. 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 new file mode 100644 index 000000000..265f4e2a9 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/bombs/MineBombDefaultConfigSettings.java @@ -0,0 +1,276 @@ +package tech.mcprison.prison.bombs; + +import tech.mcprison.prison.bombs.MineBombEffectsData.EffectState; +import tech.mcprison.prison.bombs.MineBombs.ExplosionShape; +import tech.mcprison.prison.output.Output; + +public class MineBombDefaultConfigSettings { + + + @SuppressWarnings( "unused" ) + public void setupDefaultMineBombData(MineBombs mineBombs) + { + if ( mineBombs.getConfigData().getBombs().size() == 0 ) { + +// XMaterial.WOODEN_PICKAXE; +// XMaterial.STONE_PICKAXE; +// XMaterial.IRON_PICKAXE; +// XMaterial.GOLDEN_PICKAXE; +// XMaterial.DIAMOND_PICKAXE; +// XMaterial.NETHERITE_PICKAXE; + + MineBombEffectsData mbeSound01 = new MineBombEffectsData( "ENTITY_CREEPER_PRIMED", EffectState.placed, 0 ); + MineBombEffectsData mbeSound02 = new MineBombEffectsData( "CAT_HISS", EffectState.placed, 0 ); + + MineBombEffectsData mbeSound03 = new MineBombEffectsData( "ENTITY_GENERIC_EXPLODE", EffectState.explode, 0 ); + MineBombEffectsData mbeSound04 = new MineBombEffectsData( "ENTITY_DRAGON_FIREBALL_EXPLODE", EffectState.explode, 0 ); + + // Does not work with spigot 1.8.x: + MineBombEffectsData mbeExplode01 = new MineBombEffectsData( "FIREWORKS_SPARK", EffectState.placed, 0 ); + // Does not work with spigot 1.8.x: + MineBombEffectsData mbeExplode02 = new MineBombEffectsData( "BUBBLE_COLUMN_UP", EffectState.placed, 0 ); + MineBombEffectsData mbeExplode03 = new MineBombEffectsData( "ENCHANTMENT_TABLE", EffectState.placed, 0 ); + +// MineBombEffectsData mbeExplode05 = new MineBombEffectsData( "END_ROD", EffectState.placed, 0 ); + MineBombEffectsData mbeExplode04 = new MineBombEffectsData( "FLAME", EffectState.placed, 0 ); + // Does not work with spigot 1.8.x: + MineBombEffectsData mbeExplode08 = new MineBombEffectsData( "DRAGON_BREATH", EffectState.placed, 0 ); + + MineBombEffectsData mbeExplode06a = new MineBombEffectsData( "SMOKE", EffectState.placed, 0 ); + // Does not work with spigot 1.8.x: + MineBombEffectsData mbeExplode06 = new MineBombEffectsData( "SMOKE_NORMAL", EffectState.placed, 0 ); + // Does not work with spigot 1.8.x: + MineBombEffectsData mbeExplode07 = new MineBombEffectsData( "SMOKE_LARGE", EffectState.placed, 0 ); + + MineBombEffectsData mbeExplode10 = new MineBombEffectsData( "EXPLOSION_NORMAL", EffectState.explode, 0 ); + MineBombEffectsData mbeExplode11 = new MineBombEffectsData( "EXPLOSION_LARGE", EffectState.explode, 0 ); + // Does not work with spigot 1.8.x: + MineBombEffectsData mbeExplode12 = new MineBombEffectsData( "EXPLOSION_HUGE", EffectState.explode, 0 ); + + + { + MineBombData mbd = new MineBombData( + "SmallBomb", "brewing_stand", ExplosionShape.sphere.name(), 2, "&dSmall &6Mine &eBomb &3(lore line 1)" ); + + mbd.setNameTag( "&6&kABC&r&c-= &7{name}&c =-&6&kCBA" ); + + mbd.setToolInHandName( "DIAMOND_PICKAXE" ); + mbd.setToolInHandFortuneLevel( 0 ); + mbd.setDescription("A small mine bomb made with some chemicals and a brewing stand."); + + mbd.getLore().add( "&4Lore line 2" ); + mbd.getLore().add( "&aLore line &73" ); + + mbd.getSoundEffects().add( mbeSound01.clone() ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); + mbd.getSoundEffects().add( mbeSound03.clone() ); + + mbd.getVisualEffects().add( mbeExplode04.clone() ); + mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); + + mbd.getVisualEffects().add( mbeExplode06a.clone() ); + mbd.getVisualEffects().add( mbeExplode10.clone() ); + mbd.getVisualEffects().add( mbeExplode06.clone() ); + + mbd.setCooldownTicks( 10 ); + + mineBombs.getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); + + } + + { + MineBombData mbd = new MineBombData( + "MediumBomb", "firework_rocket", ExplosionShape.sphere.name(), 5, "Medium Mine Bomb" ); + mbd.setDescription("A medium mine bomb made from leftover fireworks, " + + "but supercharged with a strange green glowing liquid."); + + mbd.setNameTag( "&6&k1 23 456&r&a-=- &7{name}&a -=-&6&k654 32 1" ); + + mbd.setToolInHandName( "DIAMOND_PICKAXE" ); + mbd.setToolInHandFortuneLevel( 3 ); + + mbd.getSoundEffects().add( mbeSound01.clone() ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); + mbd.getSoundEffects().add( mbeSound03.clone() ); + + mbd.getVisualEffects().add( mbeExplode04.clone() ); + mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); + + mbd.getVisualEffects().add( mbeExplode10.clone() ); + mbd.getVisualEffects().add( mbeExplode06.clone() ); + + mbd.setCooldownTicks( 60 ); + + mineBombs.getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); + + } + + { + MineBombData mbd = new MineBombData( + "LargeBomb", "tnt", ExplosionShape.sphereHollow.name(), 12, "Large Mine Bomb" ); + mbd.setRadiusInner( 3 ); + mbd.setDescription("A large mine bomb made from TNT with some strange parts " + + "that maybe be described as alien technology."); + mbd.setToolInHandName( "DIAMOND_PICKAXE" ); + mbd.setToolInHandFortuneLevel( 3 ); + + mbd.getSoundEffects().add( mbeSound01.clone() ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); + mbd.getSoundEffects().add( mbeSound03.clone().setVolumne( 2.0f ) ); + + mbd.getVisualEffects().add( mbeExplode04.clone() ); + mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); + + mbd.getVisualEffects().add( mbeExplode10.clone() ); + mbd.getVisualEffects().add( mbeExplode06.clone() ); + mbd.getVisualEffects().add( mbeExplode06a.clone() ); + + mbd.setCooldownTicks( 60 ); + + mineBombs.getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); + } + + { + MineBombData mbd = new MineBombData( + "OofBomb", "tnt_minecart", ExplosionShape.sphereHollow.name(), 21, "Oof Mine Bomb" ); + mbd.setRadiusInner( 3 ); + + mbd.setNameTag( "&c&k1&6&k23&e&k456&r&a-=- &4{countdown} &5-=- &7{name} &5-=- &4{countdown} &a-=-&e&k654&6&k32&c&k1" ); + + mbd.setDescription("An oof-ably large mine bomb made with a minecart heaping with TNT. " + + "Unlike the large mine bomb, this one obviously is built with alien technology."); + + mbd.setToolInHandName( "GOLDEN_PICKAXE" ); + mbd.setToolInHandFortuneLevel( 13 ); + + mbd.getSoundEffects().add( mbeSound01.clone() ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 10 ).setVolumne( 0.25f ).setPitch( 0.25f ) ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 20 ).setVolumne( 0.5f ).setPitch( 0.5f ) ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ).setVolumne( 1.0f ).setPitch( 0.75f ) ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 40 ).setVolumne( 2.0f ).setPitch( 1.5f ) ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 50 ).setVolumne( 5.0f ).setPitch( 2.5f ) ); + + mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 0 ).setVolumne( 3.0f ) ); + mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 5 ).setVolumne( 1.5f ) ); + mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 10 ).setVolumne( 2.5f ) ); + mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 15 ).setVolumne( 1.0f ) ); + mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 20 ).setVolumne( 2.0f ) ); + mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 25 ).setVolumne( 0.75f ) ); + mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 30 ).setVolumne( 1.5f ) ); + mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 35 ).setVolumne( 0.55f ) ); + mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 40 ).setVolumne( 1.0f ) ); + mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 45 ).setVolumne( 0.25f ) ); + mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 50 ).setVolumne( 0.5f ) ); + mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 55 ).setVolumne( 0.15f ) ); + + + mbd.getVisualEffects().add( mbeExplode06.clone() ); + mbd.getVisualEffects().add( mbeExplode06a.clone() ); + mbd.getVisualEffects().add( mbeExplode03.clone() ); + mbd.getVisualEffects().add( mbeExplode12.clone() ); + mbd.getVisualEffects().add( mbeExplode12.clone().setOffsetTicks( 30 ) ); + mbd.getVisualEffects().add( mbeExplode12.clone().setOffsetTicks( 60 ) ); + mbd.getVisualEffects().add( mbeExplode07.clone().setOffsetTicks( 60 ) ); + mbd.getVisualEffects().add( mbeExplode08.clone().setOffsetTicks( 90 ) ); + + mbd.getVisualEffects().add( mbeExplode10.clone() ); + mbd.getVisualEffects().add( mbeExplode06.clone().setOffsetTicks( 20 ) ); + + mbd.setAutosell( true ); + mbd.setGlowing( true ); + mbd.setAutosell( true ); + + mbd.setCooldownTicks( 60 ); + mbd.setFuseDelayTicks( 13 * 20 ); // 13 seconds + + mineBombs.getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); + } + + { + MineBombData mbd = new MineBombData( + "WimpyBomb", "GUNPOWDER", ExplosionShape.sphere.name(), 5, + "A Wimpy Mine Bomb" ); +// mbd.setLoreBombItemId( "&7A &2Wimpy &cBomb &9...&02A3F" ); + + mbd.setNameTag( "&7A &2Wimpy &cBomb" ); + + mbd.setRadiusInner( 2 ); + mbd.setDescription("A whimpy bomb made with gunpowder and packs the punch of a " + + "dull wooden pickaxe. For some reason, it only has a 40% chance of removing " + + "a block."); + + mbd.getLore().add( "" ); + mbd.getLore().add( "A whimpy bomb made with gunpowder and packs the punch " ); + mbd.getLore().add( "of a dull wooden pickaxe. For some reason, it only " ); + mbd.getLore().add( "has a 40% chance of removing a block." ); + mbd.getLore().add( "" ); + mbd.getLore().add( "Not labeled for retail sale." ); + + mbd.setToolInHandName( "WOODEN_PICKAXE" ); + mbd.setToolInHandFortuneLevel( 0 ); + mbd.setRemovalChance( 40.0d ); + + mbd.getSoundEffects().add( mbeSound01.clone() ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); + mbd.getSoundEffects().add( mbeSound03.clone() ); + + mbd.getVisualEffects().add( mbeExplode01.clone() ); + mbd.getVisualEffects().add( mbeExplode02.clone().setOffsetTicks( 30 ) ); + mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 10 ) ); + mbd.getVisualEffects().add( mbeExplode04.clone() ); + + mbd.getVisualEffects().add( mbeExplode10.clone() ); + mbd.getVisualEffects().add( mbeExplode06.clone() ); + mbd.getVisualEffects().add( mbeExplode06a.clone() ); + mbd.getVisualEffects().add( mbeExplode11.clone().setOffsetTicks( 05 ) ); + + mbd.setCooldownTicks( 3 * 20 ); // 3 seconds + mbd.setFuseDelayTicks( 2 * 20 ); // 2 seconds + + mbd.setGlowing( true ); + mbd.setGravity( false ); + + mbd.setCooldownTicks( 5 ); + + mineBombs.getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); + } + + + { + MineBombData mbd = new MineBombData( + "CubeBomb", "SLIME_BLOCK", ExplosionShape.cube.name(), 2, + "A Cubic Bomb" ); + mbd.setDescription("The most anti-round bomb you will ever be able to find. " + + "It's totally cubic."); + + mbd.setToolInHandName( "DIAMOND_PICKAXE" ); + mbd.setToolInHandFortuneLevel( 7 ); + mbd.setRemovalChance( 100.0d ); + + mbd.getSoundEffects().add( mbeSound01.clone() ); + mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); + mbd.getSoundEffects().add( mbeSound03.clone() ); + + mbd.getVisualEffects().add( mbeExplode04.clone() ); + mbd.getVisualEffects().add( mbeExplode02.clone().setOffsetTicks( 30 ) ); + + mbd.setGlowing( true ); + + mbd.setCooldownTicks( 60 ); + + mineBombs.getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); + } + + + mineBombs.saveConfigJson(); + + Output.get().logInfo( "Mine bombs: setup default values." ); + } + else { + Output.get().logInfo( "Could not generate a mine bombs save file since at least one " + + "mine bomb already exists." ); + } + + } + +} 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 868850b29..da62c95ff 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 @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; -import tech.mcprison.prison.bombs.MineBombEffectsData.EffectState; import tech.mcprison.prison.file.JsonFileIO; import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.output.Output; @@ -146,7 +145,8 @@ public void loadConfigJson() { File configFile = getConfigFile( fio ); if ( !configFile.exists() ) { - setupDefaultMineBombData(); + MineBombDefaultConfigSettings defaultConfigs = new MineBombDefaultConfigSettings(); + defaultConfigs.setupDefaultMineBombData( this ); } else { @@ -232,11 +232,16 @@ public void validateMineBombs() // isDirty = true; // } - String cleanName = Text.stripColor( bomb.getName().replace( " ", "_" )); + + // Bomb names can contain color codes now, but not spaces, since that will + // mess up commands related to bombs, since the commands would require the bomb names + // to not have a space. + String cleanName = bomb.getName().replace( " ", "_" ); +// String cleanName = Text.stripColor( bomb.getName().replace( " ", "_" )); if ( !cleanName.equalsIgnoreCase( bomb.getName() ) ) { errors.add( String.format( - "Invalid bomb name: Cannot contain spaces or colors. " + + "Invalid bomb name: Cannot contain spaces. The spaces have been replaced with '_'. " + "was: [%s] fixed: [%s].", bomb.getName(), cleanName ) ); @@ -428,272 +433,272 @@ public List calculateCube( Location loc, int radius ) { return results; } - - @SuppressWarnings( "unused" ) - public void setupDefaultMineBombData() - { - if ( getConfigData().getBombs().size() == 0 ) { - -// XMaterial.WOODEN_PICKAXE; -// XMaterial.STONE_PICKAXE; -// XMaterial.IRON_PICKAXE; -// XMaterial.GOLDEN_PICKAXE; -// XMaterial.DIAMOND_PICKAXE; -// XMaterial.NETHERITE_PICKAXE; - - MineBombEffectsData mbeSound01 = new MineBombEffectsData( "ENTITY_CREEPER_PRIMED", EffectState.placed, 0 ); - MineBombEffectsData mbeSound02 = new MineBombEffectsData( "CAT_HISS", EffectState.placed, 0 ); - - MineBombEffectsData mbeSound03 = new MineBombEffectsData( "ENTITY_GENERIC_EXPLODE", EffectState.explode, 0 ); - MineBombEffectsData mbeSound04 = new MineBombEffectsData( "ENTITY_DRAGON_FIREBALL_EXPLODE", EffectState.explode, 0 ); - - // Does not work with spigot 1.8.x: - MineBombEffectsData mbeExplode01 = new MineBombEffectsData( "FIREWORKS_SPARK", EffectState.placed, 0 ); - // Does not work with spigot 1.8.x: - MineBombEffectsData mbeExplode02 = new MineBombEffectsData( "BUBBLE_COLUMN_UP", EffectState.placed, 0 ); - MineBombEffectsData mbeExplode03 = new MineBombEffectsData( "ENCHANTMENT_TABLE", EffectState.placed, 0 ); - -// MineBombEffectsData mbeExplode05 = new MineBombEffectsData( "END_ROD", EffectState.placed, 0 ); - MineBombEffectsData mbeExplode04 = new MineBombEffectsData( "FLAME", EffectState.placed, 0 ); - // Does not work with spigot 1.8.x: - MineBombEffectsData mbeExplode08 = new MineBombEffectsData( "DRAGON_BREATH", EffectState.placed, 0 ); - - MineBombEffectsData mbeExplode06a = new MineBombEffectsData( "SMOKE", EffectState.placed, 0 ); - // Does not work with spigot 1.8.x: - MineBombEffectsData mbeExplode06 = new MineBombEffectsData( "SMOKE_NORMAL", EffectState.placed, 0 ); - // Does not work with spigot 1.8.x: - MineBombEffectsData mbeExplode07 = new MineBombEffectsData( "SMOKE_LARGE", EffectState.placed, 0 ); - - MineBombEffectsData mbeExplode10 = new MineBombEffectsData( "EXPLOSION_NORMAL", EffectState.explode, 0 ); - MineBombEffectsData mbeExplode11 = new MineBombEffectsData( "EXPLOSION_LARGE", EffectState.explode, 0 ); - // Does not work with spigot 1.8.x: - MineBombEffectsData mbeExplode12 = new MineBombEffectsData( "EXPLOSION_HUGE", EffectState.explode, 0 ); - - - { - MineBombData mbd = new MineBombData( - "SmallBomb", "brewing_stand", ExplosionShape.sphere.name(), 2, "&dSmall &6Mine &eBomb &3(lore line 1)" ); - - mbd.setNameTag( "&6&kABC&r&c-= &7{name}&c =-&6&kCBA" ); - - mbd.setToolInHandName( "DIAMOND_PICKAXE" ); - mbd.setToolInHandFortuneLevel( 0 ); - mbd.setDescription("A small mine bomb made with some chemicals and a brewing stand."); - - mbd.getLore().add( "&4Lore line 2" ); - mbd.getLore().add( "&aLore line &73" ); - - mbd.getSoundEffects().add( mbeSound01.clone() ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); - mbd.getSoundEffects().add( mbeSound03.clone() ); - - mbd.getVisualEffects().add( mbeExplode04.clone() ); - mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); - - mbd.getVisualEffects().add( mbeExplode06a.clone() ); - mbd.getVisualEffects().add( mbeExplode10.clone() ); - mbd.getVisualEffects().add( mbeExplode06.clone() ); - - mbd.setCooldownTicks( 10 ); - - getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); - - } - - { - MineBombData mbd = new MineBombData( - "MediumBomb", "firework_rocket", ExplosionShape.sphere.name(), 5, "Medium Mine Bomb" ); - mbd.setDescription("A medium mine bomb made from leftover fireworks, " + - "but supercharged with a strange green glowing liquid."); - - mbd.setNameTag( "&6&k1 23 456&r&a-=- &7{name}&a -=-&6&k654 32 1" ); - - mbd.setToolInHandName( "DIAMOND_PICKAXE" ); - mbd.setToolInHandFortuneLevel( 3 ); - - mbd.getSoundEffects().add( mbeSound01.clone() ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); - mbd.getSoundEffects().add( mbeSound03.clone() ); - - mbd.getVisualEffects().add( mbeExplode04.clone() ); - mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); - - mbd.getVisualEffects().add( mbeExplode10.clone() ); - mbd.getVisualEffects().add( mbeExplode06.clone() ); - - mbd.setCooldownTicks( 60 ); - - getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); - - } - - { - MineBombData mbd = new MineBombData( - "LargeBomb", "tnt", ExplosionShape.sphereHollow.name(), 12, "Large Mine Bomb" ); - mbd.setRadiusInner( 3 ); - mbd.setDescription("A large mine bomb made from TNT with some strange parts " + - "that maybe be described as alien technology."); - mbd.setToolInHandName( "DIAMOND_PICKAXE" ); - mbd.setToolInHandFortuneLevel( 3 ); - - mbd.getSoundEffects().add( mbeSound01.clone() ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); - mbd.getSoundEffects().add( mbeSound03.clone().setVolumne( 2.0f ) ); - - mbd.getVisualEffects().add( mbeExplode04.clone() ); - mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); - - mbd.getVisualEffects().add( mbeExplode10.clone() ); - mbd.getVisualEffects().add( mbeExplode06.clone() ); - mbd.getVisualEffects().add( mbeExplode06a.clone() ); - - mbd.setCooldownTicks( 60 ); - - getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); - } - - { - MineBombData mbd = new MineBombData( - "OofBomb", "tnt_minecart", ExplosionShape.sphereHollow.name(), 21, "Oof Mine Bomb" ); - mbd.setRadiusInner( 3 ); - - mbd.setNameTag( "&c&k1&6&k23&e&k456&r&a-=- &4{countdown} &5-=- &7{name} &5-=- &4{countdown} &a-=-&e&k654&6&k32&c&k1" ); - - mbd.setDescription("An oof-ably large mine bomb made with a minecart heaping with TNT. " + - "Unlike the large mine bomb, this one obviously is built with alien technology."); - - mbd.setToolInHandName( "GOLDEN_PICKAXE" ); - mbd.setToolInHandFortuneLevel( 13 ); - - mbd.getSoundEffects().add( mbeSound01.clone() ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 10 ).setVolumne( 0.25f ).setPitch( 0.25f ) ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 20 ).setVolumne( 0.5f ).setPitch( 0.5f ) ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ).setVolumne( 1.0f ).setPitch( 0.75f ) ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 40 ).setVolumne( 2.0f ).setPitch( 1.5f ) ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 50 ).setVolumne( 5.0f ).setPitch( 2.5f ) ); - - mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 0 ).setVolumne( 3.0f ) ); - mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 5 ).setVolumne( 1.5f ) ); - mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 10 ).setVolumne( 2.5f ) ); - mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 15 ).setVolumne( 1.0f ) ); - mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 20 ).setVolumne( 2.0f ) ); - mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 25 ).setVolumne( 0.75f ) ); - mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 30 ).setVolumne( 1.5f ) ); - mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 35 ).setVolumne( 0.55f ) ); - mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 40 ).setVolumne( 1.0f ) ); - mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 45 ).setVolumne( 0.25f ) ); - mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 50 ).setVolumne( 0.5f ) ); - mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 55 ).setVolumne( 0.15f ) ); - - - mbd.getVisualEffects().add( mbeExplode06.clone() ); - mbd.getVisualEffects().add( mbeExplode06a.clone() ); - mbd.getVisualEffects().add( mbeExplode03.clone() ); - mbd.getVisualEffects().add( mbeExplode12.clone() ); - mbd.getVisualEffects().add( mbeExplode12.clone().setOffsetTicks( 30 ) ); - mbd.getVisualEffects().add( mbeExplode12.clone().setOffsetTicks( 60 ) ); - mbd.getVisualEffects().add( mbeExplode07.clone().setOffsetTicks( 60 ) ); - mbd.getVisualEffects().add( mbeExplode08.clone().setOffsetTicks( 90 ) ); - - mbd.getVisualEffects().add( mbeExplode10.clone() ); - mbd.getVisualEffects().add( mbeExplode06.clone().setOffsetTicks( 20 ) ); - - mbd.setAutosell( true ); - mbd.setGlowing( true ); - mbd.setAutosell( true ); - - mbd.setCooldownTicks( 60 ); - mbd.setFuseDelayTicks( 13 * 20 ); // 13 seconds - - getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); - } - - { - MineBombData mbd = new MineBombData( - "WimpyBomb", "GUNPOWDER", ExplosionShape.sphere.name(), 5, - "A Wimpy Mine Bomb" ); -// mbd.setLoreBombItemId( "&7A &2Wimpy &cBomb &9...&02A3F" ); - - mbd.setNameTag( "&7A &2Wimpy &cBomb" ); - - mbd.setRadiusInner( 2 ); - mbd.setDescription("A whimpy bomb made with gunpowder and packs the punch of a " + - "dull wooden pickaxe. For some reason, it only has a 40% chance of removing " + - "a block."); - - mbd.getLore().add( "" ); - mbd.getLore().add( "A whimpy bomb made with gunpowder and packs the punch " ); - mbd.getLore().add( "of a dull wooden pickaxe. For some reason, it only " ); - mbd.getLore().add( "has a 40% chance of removing a block." ); - mbd.getLore().add( "" ); - mbd.getLore().add( "Not labeled for retail sale." ); - - mbd.setToolInHandName( "WOODEN_PICKAXE" ); - mbd.setToolInHandFortuneLevel( 0 ); - mbd.setRemovalChance( 40.0d ); - - mbd.getSoundEffects().add( mbeSound01.clone() ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); - mbd.getSoundEffects().add( mbeSound03.clone() ); - - mbd.getVisualEffects().add( mbeExplode01.clone() ); - mbd.getVisualEffects().add( mbeExplode02.clone().setOffsetTicks( 30 ) ); - mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 10 ) ); - mbd.getVisualEffects().add( mbeExplode04.clone() ); - - mbd.getVisualEffects().add( mbeExplode10.clone() ); - mbd.getVisualEffects().add( mbeExplode06.clone() ); - mbd.getVisualEffects().add( mbeExplode06a.clone() ); - mbd.getVisualEffects().add( mbeExplode11.clone().setOffsetTicks( 05 ) ); - - mbd.setCooldownTicks( 3 * 20 ); // 3 seconds - mbd.setFuseDelayTicks( 2 * 20 ); // 2 seconds - - mbd.setGlowing( true ); - mbd.setGravity( false ); - - mbd.setCooldownTicks( 5 ); - - getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); - } - - - { - MineBombData mbd = new MineBombData( - "CubeBomb", "SLIME_BLOCK", ExplosionShape.cube.name(), 2, - "A Cubic Bomb" ); - mbd.setDescription("The most anti-round bomb you will ever be able to find. " + - "It's totally cubic."); - - mbd.setToolInHandName( "DIAMOND_PICKAXE" ); - mbd.setToolInHandFortuneLevel( 7 ); - mbd.setRemovalChance( 100.0d ); - - mbd.getSoundEffects().add( mbeSound01.clone() ); - mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); - mbd.getSoundEffects().add( mbeSound03.clone() ); - - mbd.getVisualEffects().add( mbeExplode04.clone() ); - mbd.getVisualEffects().add( mbeExplode02.clone().setOffsetTicks( 30 ) ); - - mbd.setGlowing( true ); - - mbd.setCooldownTicks( 60 ); - - getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); - } - - - saveConfigJson(); - - Output.get().logInfo( "Mine bombs: setup default values." ); - } - else { - Output.get().logInfo( "Could not generate a mine bombs save file since at least one " + - "mine bomb already exists." ); - } - - } +// +// @SuppressWarnings( "unused" ) +// public void setupDefaultMineBombData() +// { +// if ( getConfigData().getBombs().size() == 0 ) { +// +//// XMaterial.WOODEN_PICKAXE; +//// XMaterial.STONE_PICKAXE; +//// XMaterial.IRON_PICKAXE; +//// XMaterial.GOLDEN_PICKAXE; +//// XMaterial.DIAMOND_PICKAXE; +//// XMaterial.NETHERITE_PICKAXE; +// +// MineBombEffectsData mbeSound01 = new MineBombEffectsData( "ENTITY_CREEPER_PRIMED", EffectState.placed, 0 ); +// MineBombEffectsData mbeSound02 = new MineBombEffectsData( "CAT_HISS", EffectState.placed, 0 ); +// +// MineBombEffectsData mbeSound03 = new MineBombEffectsData( "ENTITY_GENERIC_EXPLODE", EffectState.explode, 0 ); +// MineBombEffectsData mbeSound04 = new MineBombEffectsData( "ENTITY_DRAGON_FIREBALL_EXPLODE", EffectState.explode, 0 ); +// +// // Does not work with spigot 1.8.x: +// MineBombEffectsData mbeExplode01 = new MineBombEffectsData( "FIREWORKS_SPARK", EffectState.placed, 0 ); +// // Does not work with spigot 1.8.x: +// MineBombEffectsData mbeExplode02 = new MineBombEffectsData( "BUBBLE_COLUMN_UP", EffectState.placed, 0 ); +// MineBombEffectsData mbeExplode03 = new MineBombEffectsData( "ENCHANTMENT_TABLE", EffectState.placed, 0 ); +// +//// MineBombEffectsData mbeExplode05 = new MineBombEffectsData( "END_ROD", EffectState.placed, 0 ); +// MineBombEffectsData mbeExplode04 = new MineBombEffectsData( "FLAME", EffectState.placed, 0 ); +// // Does not work with spigot 1.8.x: +// MineBombEffectsData mbeExplode08 = new MineBombEffectsData( "DRAGON_BREATH", EffectState.placed, 0 ); +// +// MineBombEffectsData mbeExplode06a = new MineBombEffectsData( "SMOKE", EffectState.placed, 0 ); +// // Does not work with spigot 1.8.x: +// MineBombEffectsData mbeExplode06 = new MineBombEffectsData( "SMOKE_NORMAL", EffectState.placed, 0 ); +// // Does not work with spigot 1.8.x: +// MineBombEffectsData mbeExplode07 = new MineBombEffectsData( "SMOKE_LARGE", EffectState.placed, 0 ); +// +// MineBombEffectsData mbeExplode10 = new MineBombEffectsData( "EXPLOSION_NORMAL", EffectState.explode, 0 ); +// MineBombEffectsData mbeExplode11 = new MineBombEffectsData( "EXPLOSION_LARGE", EffectState.explode, 0 ); +// // Does not work with spigot 1.8.x: +// MineBombEffectsData mbeExplode12 = new MineBombEffectsData( "EXPLOSION_HUGE", EffectState.explode, 0 ); +// +// +// { +// MineBombData mbd = new MineBombData( +// "SmallBomb", "brewing_stand", ExplosionShape.sphere.name(), 2, "&dSmall &6Mine &eBomb &3(lore line 1)" ); +// +// mbd.setNameTag( "&6&kABC&r&c-= &7{name}&c =-&6&kCBA" ); +// +// mbd.setToolInHandName( "DIAMOND_PICKAXE" ); +// mbd.setToolInHandFortuneLevel( 0 ); +// mbd.setDescription("A small mine bomb made with some chemicals and a brewing stand."); +// +// mbd.getLore().add( "&4Lore line 2" ); +// mbd.getLore().add( "&aLore line &73" ); +// +// mbd.getSoundEffects().add( mbeSound01.clone() ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); +// mbd.getSoundEffects().add( mbeSound03.clone() ); +// +// mbd.getVisualEffects().add( mbeExplode04.clone() ); +// mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); +// +// mbd.getVisualEffects().add( mbeExplode06a.clone() ); +// mbd.getVisualEffects().add( mbeExplode10.clone() ); +// mbd.getVisualEffects().add( mbeExplode06.clone() ); +// +// mbd.setCooldownTicks( 10 ); +// +// getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); +// +// } +// +// { +// MineBombData mbd = new MineBombData( +// "MediumBomb", "firework_rocket", ExplosionShape.sphere.name(), 5, "Medium Mine Bomb" ); +// mbd.setDescription("A medium mine bomb made from leftover fireworks, " + +// "but supercharged with a strange green glowing liquid."); +// +// mbd.setNameTag( "&6&k1 23 456&r&a-=- &7{name}&a -=-&6&k654 32 1" ); +// +// mbd.setToolInHandName( "DIAMOND_PICKAXE" ); +// mbd.setToolInHandFortuneLevel( 3 ); +// +// mbd.getSoundEffects().add( mbeSound01.clone() ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); +// mbd.getSoundEffects().add( mbeSound03.clone() ); +// +// mbd.getVisualEffects().add( mbeExplode04.clone() ); +// mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); +// +// mbd.getVisualEffects().add( mbeExplode10.clone() ); +// mbd.getVisualEffects().add( mbeExplode06.clone() ); +// +// mbd.setCooldownTicks( 60 ); +// +// getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); +// +// } +// +// { +// MineBombData mbd = new MineBombData( +// "LargeBomb", "tnt", ExplosionShape.sphereHollow.name(), 12, "Large Mine Bomb" ); +// mbd.setRadiusInner( 3 ); +// mbd.setDescription("A large mine bomb made from TNT with some strange parts " + +// "that maybe be described as alien technology."); +// mbd.setToolInHandName( "DIAMOND_PICKAXE" ); +// mbd.setToolInHandFortuneLevel( 3 ); +// +// mbd.getSoundEffects().add( mbeSound01.clone() ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); +// mbd.getSoundEffects().add( mbeSound03.clone().setVolumne( 2.0f ) ); +// +// mbd.getVisualEffects().add( mbeExplode04.clone() ); +// mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 30 ) ); +// +// mbd.getVisualEffects().add( mbeExplode10.clone() ); +// mbd.getVisualEffects().add( mbeExplode06.clone() ); +// mbd.getVisualEffects().add( mbeExplode06a.clone() ); +// +// mbd.setCooldownTicks( 60 ); +// +// getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); +// } +// +// { +// MineBombData mbd = new MineBombData( +// "OofBomb", "tnt_minecart", ExplosionShape.sphereHollow.name(), 21, "Oof Mine Bomb" ); +// mbd.setRadiusInner( 3 ); +// +// mbd.setNameTag( "&c&k1&6&k23&e&k456&r&a-=- &4{countdown} &5-=- &7{name} &5-=- &4{countdown} &a-=-&e&k654&6&k32&c&k1" ); +// +// mbd.setDescription("An oof-ably large mine bomb made with a minecart heaping with TNT. " + +// "Unlike the large mine bomb, this one obviously is built with alien technology."); +// +// mbd.setToolInHandName( "GOLDEN_PICKAXE" ); +// mbd.setToolInHandFortuneLevel( 13 ); +// +// mbd.getSoundEffects().add( mbeSound01.clone() ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 10 ).setVolumne( 0.25f ).setPitch( 0.25f ) ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 20 ).setVolumne( 0.5f ).setPitch( 0.5f ) ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ).setVolumne( 1.0f ).setPitch( 0.75f ) ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 40 ).setVolumne( 2.0f ).setPitch( 1.5f ) ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 50 ).setVolumne( 5.0f ).setPitch( 2.5f ) ); +// +// mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 0 ).setVolumne( 3.0f ) ); +// mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 5 ).setVolumne( 1.5f ) ); +// mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 10 ).setVolumne( 2.5f ) ); +// mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 15 ).setVolumne( 1.0f ) ); +// mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 20 ).setVolumne( 2.0f ) ); +// mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 25 ).setVolumne( 0.75f ) ); +// mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 30 ).setVolumne( 1.5f ) ); +// mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 35 ).setVolumne( 0.55f ) ); +// mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 40 ).setVolumne( 1.0f ) ); +// mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 45 ).setVolumne( 0.25f ) ); +// mbd.getSoundEffects().add( mbeSound03.clone().setOffsetTicks( 50 ).setVolumne( 0.5f ) ); +// mbd.getSoundEffects().add( mbeSound04.clone().setOffsetTicks( 55 ).setVolumne( 0.15f ) ); +// +// +// mbd.getVisualEffects().add( mbeExplode06.clone() ); +// mbd.getVisualEffects().add( mbeExplode06a.clone() ); +// mbd.getVisualEffects().add( mbeExplode03.clone() ); +// mbd.getVisualEffects().add( mbeExplode12.clone() ); +// mbd.getVisualEffects().add( mbeExplode12.clone().setOffsetTicks( 30 ) ); +// mbd.getVisualEffects().add( mbeExplode12.clone().setOffsetTicks( 60 ) ); +// mbd.getVisualEffects().add( mbeExplode07.clone().setOffsetTicks( 60 ) ); +// mbd.getVisualEffects().add( mbeExplode08.clone().setOffsetTicks( 90 ) ); +// +// mbd.getVisualEffects().add( mbeExplode10.clone() ); +// mbd.getVisualEffects().add( mbeExplode06.clone().setOffsetTicks( 20 ) ); +// +// mbd.setAutosell( true ); +// mbd.setGlowing( true ); +// mbd.setAutosell( true ); +// +// mbd.setCooldownTicks( 60 ); +// mbd.setFuseDelayTicks( 13 * 20 ); // 13 seconds +// +// getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); +// } +// +// { +// MineBombData mbd = new MineBombData( +// "WimpyBomb", "GUNPOWDER", ExplosionShape.sphere.name(), 5, +// "A Wimpy Mine Bomb" ); +//// mbd.setLoreBombItemId( "&7A &2Wimpy &cBomb &9...&02A3F" ); +// +// mbd.setNameTag( "&7A &2Wimpy &cBomb" ); +// +// mbd.setRadiusInner( 2 ); +// mbd.setDescription("A whimpy bomb made with gunpowder and packs the punch of a " + +// "dull wooden pickaxe. For some reason, it only has a 40% chance of removing " + +// "a block."); +// +// mbd.getLore().add( "" ); +// mbd.getLore().add( "A whimpy bomb made with gunpowder and packs the punch " ); +// mbd.getLore().add( "of a dull wooden pickaxe. For some reason, it only " ); +// mbd.getLore().add( "has a 40% chance of removing a block." ); +// mbd.getLore().add( "" ); +// mbd.getLore().add( "Not labeled for retail sale." ); +// +// mbd.setToolInHandName( "WOODEN_PICKAXE" ); +// mbd.setToolInHandFortuneLevel( 0 ); +// mbd.setRemovalChance( 40.0d ); +// +// mbd.getSoundEffects().add( mbeSound01.clone() ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); +// mbd.getSoundEffects().add( mbeSound03.clone() ); +// +// mbd.getVisualEffects().add( mbeExplode01.clone() ); +// mbd.getVisualEffects().add( mbeExplode02.clone().setOffsetTicks( 30 ) ); +// mbd.getVisualEffects().add( mbeExplode03.clone().setOffsetTicks( 10 ) ); +// mbd.getVisualEffects().add( mbeExplode04.clone() ); +// +// mbd.getVisualEffects().add( mbeExplode10.clone() ); +// mbd.getVisualEffects().add( mbeExplode06.clone() ); +// mbd.getVisualEffects().add( mbeExplode06a.clone() ); +// mbd.getVisualEffects().add( mbeExplode11.clone().setOffsetTicks( 05 ) ); +// +// mbd.setCooldownTicks( 3 * 20 ); // 3 seconds +// mbd.setFuseDelayTicks( 2 * 20 ); // 2 seconds +// +// mbd.setGlowing( true ); +// mbd.setGravity( false ); +// +// mbd.setCooldownTicks( 5 ); +// +// getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); +// } +// +// +// { +// MineBombData mbd = new MineBombData( +// "CubeBomb", "SLIME_BLOCK", ExplosionShape.cube.name(), 2, +// "A Cubic Bomb" ); +// mbd.setDescription("The most anti-round bomb you will ever be able to find. " + +// "It's totally cubic."); +// +// mbd.setToolInHandName( "DIAMOND_PICKAXE" ); +// mbd.setToolInHandFortuneLevel( 7 ); +// mbd.setRemovalChance( 100.0d ); +// +// mbd.getSoundEffects().add( mbeSound01.clone() ); +// mbd.getSoundEffects().add( mbeSound02.clone().setOffsetTicks( 30 ) ); +// mbd.getSoundEffects().add( mbeSound03.clone() ); +// +// mbd.getVisualEffects().add( mbeExplode04.clone() ); +// mbd.getVisualEffects().add( mbeExplode02.clone().setOffsetTicks( 30 ) ); +// +// mbd.setGlowing( true ); +// +// mbd.setCooldownTicks( 60 ); +// +// getConfigData().getBombs().put( mbd.getName().toLowerCase(), mbd ); +// } +// +// +// saveConfigJson(); +// +// Output.get().logInfo( "Mine bombs: setup default values." ); +// } +// else { +// Output.get().logInfo( "Could not generate a mine bombs save file since at least one " + +// "mine bomb already exists." ); +// } +// +// } public MineBombsConfigData getConfigData() { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java index 244a4fe3b..e61a1af9f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/SpigotItemStack.java @@ -334,7 +334,7 @@ public void setDisplayName( String displayName ) { ItemMeta meta = getMeta(); if ( meta != null && displayName != null && displayName.trim().length() > 0 ) { - meta.setDisplayName( Text.convertToAmpColorCodes(displayName) ); + meta.setDisplayName( Text.translateAmpColorCodes(displayName) ); } getBukkitStack().setItemMeta( meta ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java index 3a4926366..0061bd30e 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java @@ -228,9 +228,11 @@ public void open() { if ( placeholderAPINotNull ) { - ranksLore.setLoreAction(PlaceholderAPI.setPlaceholders( - Bukkit.getOfflinePlayer(player.getUniqueId()), - ranksLore.getLoreAction())); + List lores = PlaceholderAPI.setPlaceholders( + Bukkit.getOfflinePlayer(player.getUniqueId()), + ranksLore.getLoreAction()); + + ranksLore.setLoreAction( lores ); } Button itemRank = new Button(null, playerHasThisRank ? materialHas : materialHasNot, showNumber ? amount : 1, ranksLore, SpigotPrison.format(rank.getTag())); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java index 958553ca8..6f58d9379 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java @@ -310,7 +310,7 @@ public void utilsMineBombsList( CommandSender sender, MineBombData bomb = mBombs.getConfigData().getBombs().get( key ); String message = String.format( - "%-12s Autosell: %b FuseDelayTicks: %d CooldownTicks: %d", + "&7%-12s &3Autosell: &7%b &3FuseDelayTicks: &7%d &3CooldownTicks: &7%d", bomb.getName(), bomb.isAutosell(), bomb.getFuseDelayTicks(), @@ -329,7 +329,7 @@ public void utilsMineBombsList( CommandSender sender, { int lenght = 1 + (bomb.getRadius() * 2); messageShape = String.format( - " Shape: %s Size: %d x %d x %d Based on Radius: %d.5", + " &3Shape: &7%s &3Size: &7%d &3x &7%d &3x &7%d &3Based on Radius: &7%d.5", bomb.getExplosionShape(), lenght, lenght, lenght, bomb.getRadius() ); @@ -342,7 +342,7 @@ public void utilsMineBombsList( CommandSender sender, case ring_z: { messageShape = String.format( - " Shape: %s Radius: %d.5 RadiusInner: %d.5", + " &3Shape: &7%s &3Radius: &7%d.5 &3RadiusInner: &7%d.5", bomb.getExplosionShape(), bomb.getRadius(), bomb.getRadiusInner() ); break; } @@ -353,13 +353,13 @@ public void utilsMineBombsList( CommandSender sender, case disk_z: { messageShape = String.format( - " Shape: %s Radius: %d.5", + " &3Shape: &7%s &3Radius: &7%d.5", bomb.getExplosionShape(), bomb.getRadius() ); break; } default: { - messageShape = " (no shape defined)"; + messageShape = " &4(no shape defined)"; } } if ( messageShape != null && !messageShape.isEmpty() ) { @@ -369,7 +369,7 @@ public void utilsMineBombsList( CommandSender sender, String message2 = String.format( - " ToolInHand: %s Fortune: %d Percent Chance: %f", + " &3ToolInHand: &7%s &3Fortune: &7%d &3Percent Chance: &7%f", bomb.getToolInHandName(), bomb.getToolInHandFortuneLevel(), bomb.getRemovalChance() ); @@ -377,7 +377,7 @@ public void utilsMineBombsList( CommandSender sender, String message3 = String.format( - " ItemType: %s Glowng: %b Gravity: %b", + " &3ItemType: &7%s &3Glowng: &7%b &3Gravity: &7%b", bomb.getItemType(), bomb.isGlowing(), bomb.isGravity() ); @@ -397,7 +397,7 @@ public void utilsMineBombsList( CommandSender sender, } if ( sounds.size() > 0 ) { - messages.add( " Sound Effects:" ); + messages.add( " &3Sound Effects:" ); messages.addAll( sounds ); } @@ -409,7 +409,7 @@ public void utilsMineBombsList( CommandSender sender, } if ( visual.size() > 0 ) { - messages.add( " Visual Effects:" ); + messages.add( " &3Visual Effects:" ); messages.addAll( visual ); } @@ -488,10 +488,14 @@ public void utilsMineBombsGive( CommandSender sender, MineBombData bomb = null; + // Remove color codes from bomb's name for matching: + bombName = Text.stripColor( bombName ); + Set keys = mBombs.getConfigData().getBombs().keySet(); for ( String key : keys ) { MineBombData mbd = mBombs.getConfigData().getBombs().get( key ); - if ( mbd.getName().equalsIgnoreCase( bombName ) ) { + String cleanedBombName = Text.stripColor( mbd.getName() ); + if ( cleanedBombName.equalsIgnoreCase( bombName ) ) { bomb = mbd; break; } From 32967cca0dfdb1b6b989a10a56372fcc99bdfc32 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 30 Apr 2022 22:23:21 -0400 Subject: [PATCH 229/297] Placeholder fix for rankup_cost and rankup_cost_remaining on both the formating of the percents and the bar. The percents were being displayed as an integer, so with rounding, they were very misleading since they would show 100% when they were really hitting 99.5% and higher. Also the bar is not working better, and if the percentage is less than 100%, then it will always show a RED segment at the end of the bar; it will ONLY show GREEN when it's 100% or higher. --- docs/changelog_v3.3.x.md | 4 ++++ .../prison/placeholders/PlaceholderManager.java | 10 +++++++--- .../mcprison/prison/ranks/managers/PlayerManager.java | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index cf9d2b5db..86c9937bb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11a 2022-04-30 +* **Placeholder fix for rankup_cost and rankup_cost_remaining on both the formating of the percents and the bar.** +The percents were being displayed as an integer, so with rounding, they were very misleading since they would show 100% when they were really hitting 99.5% and higher. Also the bar is not working better, and if the percentage is less than 100%, then it will always show a RED segment at the end of the bar; it will ONLY show GREEN when it's 100% or higher. + + * **Mine Bombs fix to allow color codes within the bomb's name.** The color codes are removed for the sake of matching and selecting when giving to players so you don't have to use them in the commands. diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java index d17bf78e6..b636426e6 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java @@ -1012,7 +1012,7 @@ else if ( value < 0 ) { value = valueTotal - value; } - double percent = value / valueTotal * 100.0; + double percent = valueTotal == 0 ? 100d : value / valueTotal * 100.0; PlaceholderAttributeBar barAttribute = attribute == null || !(attribute instanceof PlaceholderAttributeBar) ? null : @@ -1026,10 +1026,14 @@ else if ( value < 0 ) { getProgressBarConfig(); String lastColorCode = null; - for ( int i = 0; i < barConfig.getSegments(); i++ ) { + int segments = barConfig.getSegments(); + for ( int i = 0; i < segments; i++ ) { double pct = i / ((double)barConfig.getSegments()) * 100.0; - if ( pct < percent ) { + // If the calculated percent is less than the threshold and as long as it's not the last + // segment, then show a positive. If it's the last segment an it's still less than + // the percent, then show a negative no matter what to indicate it's not yet there. + if ( pct < percent && (percent == 100d || percent < 100d && i < segments - 1)) { if ( lastColorCode == null || !barConfig.getPositiveColor().equalsIgnoreCase( lastColorCode )) { sb.append( barConfig.getPositiveColor() ); diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index 8d900d11e..584fcd702 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -674,7 +674,7 @@ public String getPlayerNextRankCostPercent( RankPlayer rankPlayer, String ladder // } if ( !rankPlayer.getLadderRanks().isEmpty()) { - DecimalFormat dFmt = new DecimalFormat("#,##0"); + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); @@ -824,7 +824,7 @@ public String getPlayerNextRankCostRemaining( RankPlayer rankPlayer, String ladd // } if ( !rankPlayer.getLadderRanks().isEmpty()) { - DecimalFormat dFmt = new DecimalFormat("#,##0"); + DecimalFormat dFmt = new DecimalFormat("#,##0.00"); RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); From 129bb785f3c78892f4a693e888db6c7c749a7606 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 2 May 2022 12:08:35 -0400 Subject: [PATCH 230/297] Placeholder fix for formatted time segments to use the values setup in the language files within core. This allows the placeholders to use the proper notations for singular and plural units of times as configured for each language. --- docs/changelog_v3.3.x.md | 6 +- .../prison/placeholders/PlaceholdersUtil.java | 84 ++++++++++--------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 86c9937bb..f28a9719d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11a 2022-04-30 +# 3.3.0-alpha.11a 2022-05-02 + + +* **Placeholder fix for formatted time segments to use the values setup in the language files within core.** +This allows the placeholders to use the proper notations for singular and plural units of times as configured for each language. * **Placeholder fix for rankup_cost and rankup_cost_remaining on both the formating of the percents and the bar.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java index 456fa97f8..b5ec676b1 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; +import tech.mcprison.prison.util.Text; + public class PlaceholdersUtil extends PlaceholdersUtilMessage { @@ -55,44 +57,50 @@ public class PlaceholdersUtil * @return */ public static String formattedTime( double timeSec ) { - StringBuilder sb = new StringBuilder(); - - long days = (long)(timeSec / TIME_DAY); - timeSec -= (days * TIME_DAY); - if ( days > 0 ) { - sb.append( days ); - // y,m,w,d,h,m,s - sb.append( prefixesTimeUnits.get(3) ).append( " " ); -// sb.append( "d " ); - } - - long hours = (long)(timeSec / TIME_HOUR); - timeSec -= (hours * TIME_HOUR); - if ( sb.length() > 0 || hours > 0 ) { - sb.append( hours ); - // y,m,w,d,h,m,s - sb.append( prefixesTimeUnits.get(4) ).append( " " ); -// sb.append( "h " ); - } - - long mins = (long)(timeSec / TIME_MINUTE); - timeSec -= (mins * TIME_MINUTE); - if ( sb.length() > 0 || mins > 0 ) { - sb.append( mins ); - // y,m,w,d,h,m,s - sb.append( prefixesTimeUnits.get(5) ).append( " " ); -// sb.append( "m " ); - } - - double secs = (double)(timeSec / TIME_SECOND); - timeSec -= (secs * TIME_SECOND); - DecimalFormat dFmt = new DecimalFormat("#0"); - sb.append( dFmt.format( secs )); - // y,m,w,d,h,m,s - sb.append( prefixesTimeUnits.get(6) ).append( " " ); -// sb.append( "s " ); - - return sb.toString(); + + long durationMs = (long) (timeSec * 1000d); + String formattedTime = Text.getTimeUntilString( durationMs ); + + return formattedTime; + +// StringBuilder sb = new StringBuilder(); +// +// long days = (long)(timeSec / TIME_DAY); +// timeSec -= (days * TIME_DAY); +// if ( days > 0 ) { +// sb.append( days ); +// // y,m,w,d,h,m,s +// sb.append( prefixesTimeUnits.get(3) ).append( " " ); +//// sb.append( "d " ); +// } +// +// long hours = (long)(timeSec / TIME_HOUR); +// timeSec -= (hours * TIME_HOUR); +// if ( sb.length() > 0 || hours > 0 ) { +// sb.append( hours ); +// // y,m,w,d,h,m,s +// sb.append( prefixesTimeUnits.get(4) ).append( " " ); +//// sb.append( "h " ); +// } +// +// long mins = (long)(timeSec / TIME_MINUTE); +// timeSec -= (mins * TIME_MINUTE); +// if ( sb.length() > 0 || mins > 0 ) { +// sb.append( mins ); +// // y,m,w,d,h,m,s +// sb.append( prefixesTimeUnits.get(5) ).append( " " ); +//// sb.append( "m " ); +// } +// +// double secs = (double)(timeSec / TIME_SECOND); +// timeSec -= (secs * TIME_SECOND); +// DecimalFormat dFmt = new DecimalFormat("#0"); +// sb.append( dFmt.format( secs )); +// // y,m,w,d,h,m,s +// sb.append( prefixesTimeUnits.get(6) ).append( " " ); +//// sb.append( "s " ); +// +// return sb.toString(); } /** From 064f8584b76918ad67088a48dc636e99d700ae07 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 11 May 2022 02:31:22 -0400 Subject: [PATCH 231/297] **3.3.0-alpha.11b 2022-05-02** --- docs/changelog_v3.3.x.md | 3 +++ gradle.properties | 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 f28a9719d..9aaac0932 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11a 2022-05-02 +* **3.3.0-alpha.11b 2022-05-02** + + * **Placeholder fix for formatted time segments to use the values setup in the language files within core.** This allows the placeholders to use the proper notations for singular and plural units of times as configured for each language. diff --git a/gradle.properties b/gradle.properties index 0ea3c1abc..f1dd9ad4e 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.11a +version=3.3.0-alpha.11b From ea298e05a09897ca6b3312781a5dda3ad2f82253 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Wed, 11 May 2022 02:34:24 -0400 Subject: [PATCH 232/297] Fixed signs for sellall to enable them to work with any wood variant. --- .../mcprison/prison/spigot/gui/ListenersPrisonManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 26884226f..988e69105 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 @@ -231,8 +231,11 @@ public void onPlayerInteractEvent(PlayerInteractEvent e){ clickedBlock = e.getClickedBlock().getType(); } - // Check if the clicked block's a sign - if (clickedBlock == Material.SIGN || clickedBlock == Material.WALL_SIGN) { + // Check if the clicked block's a sign. Newer spigot versions have many kinds of + // signs, so check if the material name contains "sign": + String matName = clickedBlock.name().toLowerCase(); + if ( matName.contains("sign")) { +// if (clickedBlock == Material.SIGN || clickedBlock == Material.WALL_SIGN) { // Get the player Player p = e.getPlayer(); From 510b625c01bda3284f4d44269f258f8a726edc1b Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 14 May 2022 01:21:03 -0400 Subject: [PATCH 233/297] Changed placeholder attributes to print the raw value and placeholder. Changes to the logging to allow & to be encoded to the unicode string of `U+0026` so it can bypass the color code conversions, then it is converted back to an & before sending to bukkit. This works far better than trying to use Java regEx quotes. --- docs/changelog_v3.3.x.md | 12 +++++++++++- .../PlaceholderAttributeNumberFormat.java | 19 +++++++++++-------- .../java/tech/mcprison/prison/util/Text.java | 15 +++++++++++++++ .../prison/spigot/SpigotPlatform.java | 4 ++++ 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9aaac0932..377712ac8 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,17 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11a 2022-05-02 +# 3.3.0-alpha.11b 2022-05-14 + + +* **Changed placeholder attributes to print the raw value and placeholder.** +Changes to the logging to allow & to be encoded to the unicode string of +`U+0026` so it can bypass the color code conversions, then it is converted back +to an & before sending to bukkit. This works far better than trying to +use Java regEx quotes. + + +* **Fixed signs for sellall to enable them to work with any wood variant.** * **3.3.0-alpha.11b 2022-05-02** diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeNumberFormat.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeNumberFormat.java index d62c4af88..93fd03bd9 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeNumberFormat.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeNumberFormat.java @@ -199,9 +199,9 @@ public String format( Double value ) { break; } - if ( results.contains( "^|^" ) ) { - //results = results.replace( "^|^", "&" ); - } +// if ( results.contains( "^|^" ) ) { +// //results = results.replace( "^|^", "&" ); +// } } catch (Exception e ) { @@ -226,15 +226,18 @@ else if ( isHex() ) { } if ( isDebug() ) { - Output.get().logInfo( - String.format( "Placeholder Attribute nFormat: double value= %s " + + String rawResults = Text.escapeAmpCodes(results); + String rawAttribute = Text.escapeAmpCodes(getRaw()); + + String message = String.format( "Placeholder Attribute nFormat: double value= %s " + "format=[%s] spaces=%d unitType=%s Results: [%s] " + - "raw: &7[&3\\R%s\\E&7]" + + "raw: &3[&7%s&3] &3[&7%s&3]" + "(remove :debug from placeholder to disable this message)", Double.toString( value ), getFormat(), getSpaces(), - getUnitType(), results, getRaw() - )); + getUnitType(), results, rawResults, rawAttribute + ); + Output.get().logInfo( message ); } return results; diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/Text.java b/prison-core/src/main/java/tech/mcprison/prison/util/Text.java index 61d4fcdd4..ad8d23548 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/util/Text.java +++ b/prison-core/src/main/java/tech/mcprison/prison/util/Text.java @@ -471,6 +471,21 @@ public static String convertToAmpColorCodes( String textEncoded ) { return results; } + + /** + *

This function will convert all amps to a unicode so they will + * not be translated to the color codes. Then before the message is + * processed by bukkit, they are then converted back so as to + * show where they are used. This will convert the color codes + * that have already been converted. + *

+ * + * @param textEncoded + * @return + */ + public static String escapeAmpCodes( String textEncoded ) { + return convertToAmpColorCodes(textEncoded).replaceAll("&", "U+0026"); + } /** * Converts a double (3.45) into a US-localized currency string ($3.45). 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 79b2ae35e..6b64cfc49 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 @@ -583,6 +583,10 @@ public void logCore( String message ) { ConsoleCommandSender sender = Bukkit.getConsoleSender(); + if ( message.contains( "U+0026" ) ) { + message = message.replace("U+0026", "&"); + } + String[] msgs = message.split( "\\{br\\}" ); for ( String msg : msgs ) { From 214aab30d00825938d6eaf59ac3dfb40508a0004 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 14 May 2022 12:47:42 -0400 Subject: [PATCH 234/297] GUI Menus enable NBT support. This is a major change. The details for the menus options and commands are now stored in NBT data so they do not have to rely on the item name, lore, or other tricks. This is a first phase, and more work needs to be done to remove hooks with the item names for other menu options. Main set of changes has been done to the menu tools. --- docs/changelog_v3.3.x.md | 5 + .../spigot/gui/ListenersPrisonManager.java | 14 +- .../prison/spigot/gui/SpigotGUIMenuTools.java | 183 ++++++++++++------ .../prison/spigot/gui/guiutility/Button.java | 8 +- .../gui/guiutility/SpigotGUIComponents.java | 10 +- .../spigot/gui/rank/SpigotPlayerRanksGUI.java | 15 +- .../prison/spigot/nbt/PrisonNBTUtil.java | 79 ++++++++ 7 files changed, 246 insertions(+), 68 deletions(-) create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/nbt/PrisonNBTUtil.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 377712ac8..b98c02356 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11b 2022-05-14 +* **GUI Menus enable NBT support.** +This is a major change. The details for the menus options and commands are now stored in NBT data so they do not have to rely on the item name, lore, or other tricks. +This is a first phase, and more work needs to be done to remove hooks with the item names for other menu options. Main set of changes has been done to the menu tools. + + * **Changed placeholder attributes to print the raw value and placeholder.** Changes to the logging to allow & to be encoded to the unicode string of `U+0026` so it can bypass the color code conversions, then it is converted back 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 988e69105..9b4e52de0 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 @@ -77,6 +77,7 @@ import tech.mcprison.prison.spigot.gui.sellall.SellAllPrestigesSetMultiplierGUI; import tech.mcprison.prison.spigot.gui.sellall.SellAllPriceGUI; import tech.mcprison.prison.spigot.sellall.SellAllUtil; +import tech.mcprison.prison.util.Text; /** * @author GABRYCA @@ -223,13 +224,11 @@ public void onPlayerInteractEvent(PlayerInteractEvent e){ } // Check if the feature's enabled. - if (sellAllUtil.isSellAllSignEnabled) { + if (sellAllUtil.isSellAllSignEnabled && e.getClickedBlock() != null ) { // Get clicked block. - Material clickedBlock = null; - if (e.getClickedBlock() != null) { - clickedBlock = e.getClickedBlock().getType(); - } + Material clickedBlock = e.getClickedBlock().getType(); + // Check if the clicked block's a sign. Newer spigot versions have many kinds of // signs, so check if the material name contains "sign": @@ -403,7 +402,7 @@ public void onClick(InventoryClickEvent e){ buttonNameMain = SpigotPrison.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()); parts = buttonNameMain.split(" "); module = Prison.get().getModuleManager().getModule(PrisonRanks.MODULE_NAME).orElse(null); - title = compat.getGUITitle(e).substring(2); + title = Text.stripColor( compat.getGUITitle(e) ); } catch (ArrayIndexOutOfBoundsException ex){ Output.get().sendWarn(new SpigotPlayer(p), "An error occurred while using the GUI, please check logs."); ex.printStackTrace(); @@ -1895,7 +1894,8 @@ private void rankManagerGUI(InventoryClickEvent e, Player p, String[] parts) { private void playerRanksGUI(InventoryClickEvent e, Player p, String buttonNameMain) { // Check the buttonName and do the actions. - if (buttonNameMain.equals(SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup).substring(2)))){ + 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")); p.closeInventory(); } 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 75f3c5c5e..7067f1439 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,9 +11,11 @@ import com.cryptomorin.xseries.XMaterial; +import de.tr7zw.nbtapi.NBTItem; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; +import tech.mcprison.prison.spigot.nbt.PrisonNBTUtil; import tech.mcprison.prison.util.Text; public class SpigotGUIMenuTools @@ -22,6 +24,10 @@ public class SpigotGUIMenuTools public static final String GUI_MENU_TOOLS_PAGE = "GUIPage"; public static final String GUI_MENU_TOOLS_COMMAND = "Command: "; public static final String GUI_MENU_TOOLS_COMMANDS_BACK = "CommandsBack: "; + + public static final String GUI_MENU_TOOLS_NBT_ENABLED = "guiNBT"; + public static final String GUI_MENU_TOOLS_NBT_COMMAND = "guiNBTCommand"; + private static SpigotGUIMenuTools instance; @@ -336,72 +342,118 @@ public boolean processGUIPage( Player p, String title, InventoryClickEvent e ) { boolean isPageAction = false; ItemStack currentItem = e.getCurrentItem(); - if ( currentItem != null && currentItem.hasItemMeta() ) { + + if ( currentItem != null ) { - ItemMeta meta = currentItem.getItemMeta(); - - if ( meta.hasLore() ) { + PrisonNBTUtil nbtUtil = new PrisonNBTUtil(); + NBTItem nbtItem = nbtUtil == null ? null : nbtUtil.getNBT(currentItem); + + // process if NBTs are enabled: + if ( nbtItem != null && nbtUtil.hasNBTKey(nbtItem, GUI_MENU_TOOLS_NBT_ENABLED) ) { + String command = nbtUtil.getNBTString(nbtItem, GUI_MENU_TOOLS_NBT_COMMAND); - String command = null; + if ( command != null ) { + isPageAction = true; + Bukkit.dispatchCommand(p, command); + } - List lores = meta.getLore(); + } + + // Otherwise process the old way where the command is in the lore: + else if ( currentItem != null && currentItem.hasItemMeta() ) { - boolean isMenuToolsPage = false; + ItemMeta meta = currentItem.getItemMeta(); - for ( String lore : lores ) { - - if ( lore.contains( SpigotGUIMenuTools.GUI_MENU_TOOLS_PAGE ) ) { - isMenuToolsPage = true; - } - if ( lore.contains( SpigotGUIMenuTools.GUI_MENU_TOOLS_COMMAND ) ) { - command = Text.stripColor( lore ).replace( SpigotGUIMenuTools.GUI_MENU_TOOLS_COMMAND, "" ).trim(); + if ( meta.hasLore() ) { + + String command = null; + + List lores = meta.getLore(); + + boolean isMenuToolsPage = false; + + for ( String lore : lores ) { + + if ( lore.contains( SpigotGUIMenuTools.GUI_MENU_TOOLS_PAGE ) ) { + isMenuToolsPage = true; + } + if ( lore.contains( SpigotGUIMenuTools.GUI_MENU_TOOLS_COMMAND ) ) { + command = Text.stripColor( lore ).replace( SpigotGUIMenuTools.GUI_MENU_TOOLS_COMMAND, "" ).trim(); + } + + if ( command != null && command.equalsIgnoreCase( "close" ) ) { + p.closeInventory(); + } } - if ( command != null && command.equalsIgnoreCase( "close" ) ) { - p.closeInventory(); + if ( isMenuToolsPage && command != null ) { + isPageAction = true; + Bukkit.dispatchCommand(p, command); } - } - - if ( isMenuToolsPage && command != null ) { - isPageAction = true; - Bukkit.dispatchCommand(p, command); } + } + + + } + return isPageAction; } - private ButtonLore createButtonLore( boolean enableCmd, // String message, - GUIMenuPageData pageData, int page ) { - - ButtonLore buttonLore = new ButtonLore(); - -// if ( message != null ) { -// buttonLore.addLineLoreDescription( message ); -// } - - - if ( enableCmd && pageData != null ) { - - buttonLore.addLineLoreAction( "&0" + - GUI_MENU_TOOLS_PAGE ); - - if ( pageData.getCommandToRun() != null ) { - buttonLore.addLineLoreAction( "&0" + - GUI_MENU_TOOLS_COMMAND + pageData.getCommandToRun() + - ( page <= 0 ? "" : " " + page) ); - } - -// if ( pageData.getCommandsBack() != null ) { -// buttonLore.addLineLoreDescription( "&0" + -// GUI_MENU_TOOLS_COMMANDS_BACK + pageData.getCommandsBack() ); + private void addButtonNBT( Button guiButton, GUIMenuPageData pageData, int page ) { + + if ( pageData != null ) { + + PrisonNBTUtil nbtUtil = new PrisonNBTUtil(); + NBTItem nbtItem = nbtUtil == null ? null : nbtUtil.getNBT( guiButton.getButtonItem() ); + + // process if NBTs are enabled: + if ( nbtItem != null ) { + String command = pageData.getCommandToRun() + + ( page <= 0 ? "" : " " + page); +// String command = GUI_MENU_TOOLS_COMMAND + pageData.getCommandToRun() + +// ( page <= 0 ? "" : " " + page); + + nbtUtil.setNBTString(nbtItem, GUI_MENU_TOOLS_NBT_ENABLED, "true"); + nbtUtil.setNBTString(nbtItem, GUI_MENU_TOOLS_NBT_COMMAND, command ); + + } + } + + } + +// private ButtonLore createButtonLore( boolean enableCmd, // String message, +// GUIMenuPageData pageData, int page ) { +// +// ButtonLore buttonLore = new ButtonLore(); +// +//// if ( message != null ) { +//// buttonLore.addLineLoreDescription( message ); +//// } +// +// +// if ( enableCmd && pageData != null ) { +// +// buttonLore.addLineLoreAction( "&0" + +// GUI_MENU_TOOLS_PAGE ); +// +// if ( pageData.getCommandToRun() != null ) { +// buttonLore.addLineLoreAction( "&0" + +// GUI_MENU_TOOLS_COMMAND + pageData.getCommandToRun() + +// ( page <= 0 ? "" : " " + page) ); // } - - } - return buttonLore; - } +// +//// if ( pageData.getCommandsBack() != null ) { +//// buttonLore.addLineLoreDescription( "&0" + +//// GUI_MENU_TOOLS_COMMANDS_BACK + pageData.getCommandsBack() ); +//// } +// +// } +// return buttonLore; +// } public Button createButtonBack( GUIMenuPageData pageData, int position ) { @@ -418,7 +470,8 @@ public Button createButtonBack( GUIMenuPageData pageData, int position ) { String message = pageData.getCommandGoBack().equalsIgnoreCase( "close" ) ? "Close" : "Go Back"; - ButtonLore buttonLore = createButtonLore( true, newPageData, 0 ); +// ButtonLore buttonLore = createButtonLore( true, newPageData, 0 ); + ButtonLore buttonLore = null; int pos = pageData.getMenuPosition( position ); @@ -428,6 +481,8 @@ public Button createButtonBack( GUIMenuPageData pageData, int position ) { Button guiButton = new Button( pos, xMat, pageNumber, buttonLore, message ); + addButtonNBT( guiButton, newPageData, 0 ); + return pageData.setButton( position, guiButton ); } @@ -439,7 +494,8 @@ public Button createButtonPageOne( GUIMenuPageData pageData, int position ) { String message = "Page 1 of " + pageData.getPageLast(); - ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber ); +// ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber ); + ButtonLore buttonLore = null; int pos = pageData.getMenuPosition( position ); @@ -448,6 +504,8 @@ public Button createButtonPageOne( GUIMenuPageData pageData, int position ) { Button guiButton = new Button( pos, xMat, pageNumber, buttonLore, message ); + addButtonNBT( guiButton, pageData, pageNumber ); + return pageData.setButton( position, guiButton ); } @@ -460,7 +518,8 @@ public Button createButtonPagePrior( GUIMenuPageData pageData, int position ) { String message = "Page " + pageNumber + " of " + pageData.getPageLast(); - ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber ); +// ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber ); + ButtonLore buttonLore = null; int pos = pageData.getMenuPosition( position ); @@ -469,6 +528,8 @@ public Button createButtonPagePrior( GUIMenuPageData pageData, int position ) { Button guiButton = new Button( pos, xMat, pageNumber, buttonLore, message ); + addButtonNBT( guiButton, pageData, pageNumber ); + return pageData.setButton( position, guiButton ); } @@ -478,13 +539,16 @@ public Button createButtonPageCurrent( GUIMenuPageData pageData, int position ) String message = "Page " + pageNumber + " of " + pageData.getPageLast(); - ButtonLore buttonLore = createButtonLore( false, pageData, pageNumber ); +// ButtonLore buttonLore = createButtonLore( false, pageData, pageNumber ); + ButtonLore buttonLore = null; int pos = pageData.getMenuPosition( position ); XMaterial xMat = XMaterial.COMPASS; Button guiButton = new Button( pos, xMat, pageNumber, buttonLore, message ); + + addButtonNBT( guiButton, pageData, pageNumber ); return pageData.setButton( position, guiButton ); } @@ -498,7 +562,8 @@ public Button createButtonPageNext( GUIMenuPageData pageData, int position ) { String message = "Page " + pageNumber + " of " + pageData.getPageLast(); - ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber ); +// ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber ); + ButtonLore buttonLore = null; int pos = pageData.getMenuPosition( position ); @@ -506,6 +571,8 @@ public Button createButtonPageNext( GUIMenuPageData pageData, int position ) { menuStateOff1 : menuStateOn1; Button guiButton = new Button( pos, xMat, pageNumber, buttonLore, message ); + + addButtonNBT( guiButton, pageData, pageNumber ); return pageData.setButton( position, guiButton ); } @@ -519,7 +586,8 @@ public Button createButtonPageLast( GUIMenuPageData pageData, int position ) { String message = "Page " + pageNumber + " of " + pageData.getPageLast(); - ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber ); + ButtonLore buttonLore = null; +// ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber ); int pos = pageData.getMenuPosition( position ); @@ -527,13 +595,16 @@ public Button createButtonPageLast( GUIMenuPageData pageData, int position ) { menuStateOff2 : menuStateOn2; Button guiButton = new Button( pos, xMat, pageNumber, buttonLore, message ); + + addButtonNBT( guiButton, pageData, pageNumber ); return pageData.setButton( position, guiButton ); } public Button createButtonMenuBackground( GUIMenuPageData pageData, int position ) { - ButtonLore buttonLore = createButtonLore( false, null, 1 ); + ButtonLore buttonLore = null; +// ButtonLore buttonLore = createButtonLore( false, null, 1 ); int pos = pageData.getMenuPosition( position ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java index 310c8da8e..904d33b5a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java @@ -142,7 +142,9 @@ public Button(Integer position, XMaterial buttonMaterial, int amount, ButtonLore } if (position == null || position < 54) { this.position = position; - this.buttonItem = createButton(buttonMaterial.parseItem(), amount, lore.getLore(), SpigotPrison.format(title)); + this.buttonItem = createButton(buttonMaterial.parseItem(), amount, + (lore == null ? null : lore.getLore() ), + SpigotPrison.format(title)); } } @@ -157,7 +159,9 @@ public Button(Integer position, XMaterial buttonMaterial, int amount, ButtonLore public Button(Integer position, XMaterial buttonMaterial, ButtonLore lore, String title){ if (position == null || position < 54) { this.position = position; - this.buttonItem = createButton(buttonMaterial.parseItem(), lore.getLore(), SpigotPrison.format(title)); + this.buttonItem = createButton(buttonMaterial.parseItem(), + (lore == null ? null : lore.getLore() ), + SpigotPrison.format(title)); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java index 0ce5b8884..8db312b0f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java @@ -98,7 +98,15 @@ private ItemStack getItemStack(ItemStack item, List lore, String display try { meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } catch (NoClassDefFoundError ignored){} - meta.setLore(lore); + + if ( lore != null ) { + meta.setLore(lore); + } + + meta.addItemFlags( ItemFlag.HIDE_ENCHANTS ); + meta.addItemFlags( ItemFlag.HIDE_ATTRIBUTES ); + meta.addItemFlags( ItemFlag.HIDE_POTION_EFFECTS ); + item.setItemMeta(meta); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java index 0061bd30e..40ab29c1f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java @@ -12,6 +12,7 @@ import com.cryptomorin.xseries.XMaterial; +import de.tr7zw.nbtapi.NBTItem; import me.clip.placeholderapi.PlaceholderAPI; import tech.mcprison.prison.Prison; import tech.mcprison.prison.modules.Module; @@ -36,6 +37,7 @@ import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; import tech.mcprison.prison.spigot.gui.guiutility.SpigotGUIComponents; +import tech.mcprison.prison.spigot.nbt.PrisonNBTUtil; /** * @author GABRYCA @@ -265,9 +267,18 @@ public void open() { - // Add Rankup button: + // Add Rankup button: Using NBTs: + String rankupTitle = ladderName.equalsIgnoreCase("prestiges") ? "Prestige" : "Rankup"; ButtonLore rankupLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_rankup), messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup_if_enough_money)); - Button rankupButton = new Button( 0, XMaterial.EMERALD_BLOCK, rankupLore, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup))); + Button rankupButton = new Button( 0, XMaterial.EMERALD_BLOCK, rankupLore, rankupTitle ); + String rankupCommand = "rankup " + (ladderName.equalsIgnoreCase("default") ? "" : ladderName); + + PrisonNBTUtil nbtUtil = new PrisonNBTUtil(); + NBTItem nbtItem = nbtUtil == null ? null : nbtUtil.getNBT(rankupButton.getButtonItem()); + nbtUtil.setNBTString(nbtItem, SpigotGUIMenuTools.GUI_MENU_TOOLS_NBT_ENABLED, "true"); + nbtUtil.setNBTString(nbtItem, SpigotGUIMenuTools.GUI_MENU_TOOLS_NBT_COMMAND, rankupCommand); + +// SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup))); // NOTE: Button position will be properly assigned in the setButtonNextAvilable: gui.addButton( guiPageData.setButtonNextAvailable( rankupButton ) ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/nbt/PrisonNBTUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/nbt/PrisonNBTUtil.java new file mode 100644 index 000000000..7fa01561c --- /dev/null +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/nbt/PrisonNBTUtil.java @@ -0,0 +1,79 @@ +package tech.mcprison.prison.spigot.nbt; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import de.tr7zw.nbtapi.NBTItem; +import tech.mcprison.prison.output.Output; + +public class PrisonNBTUtil { + + + public NBTItem getNBT( ItemStack bukkitStack ) { + NBTItem nbtItemStack = null; + + if ( bukkitStack != null && bukkitStack.getType() != Material.AIR ) { + try { + nbtItemStack = new NBTItem( bukkitStack, true ); + + nbtDebugLog( nbtItemStack, "getNbt" ); + } catch (Exception e) { + // ignore - the bukkit item stack is not compatible with the NBT library + } + } + + return nbtItemStack; + } + + + private void nbtDebugLog( NBTItem nbtItem, String desc ) { + if ( Output.get().isDebug() ) { + org.bukkit.inventory.ItemStack iStack = nbtItem.getItem(); + + int sysId = System.identityHashCode(iStack); + + String message = String.format( + "NBT %s ItemStack for %s: %s sysId: %d", + desc, + iStack.hasItemMeta() && iStack.getItemMeta().hasDisplayName() ? + iStack.getItemMeta().getDisplayName() : + iStack.getType().name(), + nbtItem.toString(), + sysId ); + + Output.get().logInfo( message ); + + //Output.get().logInfo( "NBT: " + new NBTItem( getBukkitStack() ) ); + + } + } + + + public boolean hasNBTKey( NBTItem nbtItem, String key ) { + boolean results = false; + + if ( nbtItem != null ) { + results = nbtItem.hasKey( key ); + } + + return results; + } + + public String getNBTString( NBTItem nbtItem, String key ) { + String results = null; + + if ( nbtItem != null ) { + results = nbtItem.getString( key ); + } + return results; + } + + public void setNBTString( NBTItem nbtItem, String key, String value ) { + + if ( nbtItem != null ) { + nbtItem.setString( key, value ); + nbtDebugLog( nbtItem, "setNBTString" ); + } + } + +} From f749a219368f29accef7a4ef81c39382434cb53d Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 20 May 2022 02:34:59 -0400 Subject: [PATCH 235/297] 3.3.0-alpha.11c 2022-05-14 --- 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 b98c02356..98cd19126 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11b 2022-05-14 +# 3.3.0-alpha.11c 2022-05-14 + + + +* **3.3.0-alpha.11c 2022-05-14** * **GUI Menus enable NBT support.** diff --git a/gradle.properties b/gradle.properties index f1dd9ad4e..43dd6aa2e 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.11b +version=3.3.0-alpha.11c From 3adb2d5380fdde2ce18eb9fd155fb85e0ce66ff2 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 20 May 2022 02:43:06 -0400 Subject: [PATCH 236/297] The normalDrops processing was not hooked up to the newest way auto pickup is disabled, which was skipping normalDrops if auto pickup was disabled. The number of blocks in the normalDrops is now being passed back through the code so it can identify that it was successful and finalize the processing. --- docs/changelog_v3.3.x.md | 5 +- .../autofeatures/AutoManagerFeatures.java | 119 ++++++++++++------ 2 files changed, 86 insertions(+), 38 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 98cd19126..9cf6be198 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,9 +11,12 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11c 2022-05-14 +# 3.3.0-alpha.11c 2022-05-20 +* **The normalDrops processing was not hooked up to the newest way auto pickup is disabled, which was skipping normalDrops if auto pickup was disabled.** +The number of blocks in the normalDrops is now being passed back through the code so it can identify that it was successful and finalize the processing. + * **3.3.0-alpha.11c 2022-05-14** 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 3bbd7f679..cb3ce451a 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 @@ -206,7 +206,7 @@ public boolean doAction( PrisonMinesBlockBreakEvent pmEvent, StringBuilder debug private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent, StringBuilder debugInfo ) { - int count = 0; + int totalDrops = 0; Player player = pmEvent.getPlayer(); Mine mine = pmEvent.getMine(); @@ -224,9 +224,17 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent, StringBu boolean permSmelt = player.isPermissionSet( getMessage( AutoFeatures.permissionAutoSmelt )); boolean permBlock = player.isPermissionSet( getMessage( AutoFeatures.permissionAutoBlock )); - boolean configPickup = isBoolean( AutoFeatures.autoPickupEnabled ); - boolean configSmelt = isBoolean( AutoFeatures.autoSmeltEnabled ); - boolean configBlock = isBoolean( AutoFeatures.autoBlockEnabled ); + boolean isAutoFeaturesEnabled = isBoolean( AutoFeatures.isAutoFeaturesEnabled ); + + boolean configPickup = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoPickupEnabled ); + boolean configSmelt = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoSmeltEnabled ); + boolean configBlock = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoBlockEnabled ); + + + boolean configNormalDrop = isBoolean( AutoFeatures.handleNormalDropsEvents ); + boolean configNormalDropSmelt = isBoolean( AutoFeatures.normalDropSmelt ); + boolean configNormalDropBlock = isBoolean( AutoFeatures.normalDropBlock ); + boolean limit2minesPickup = isBoolean( AutoFeatures.pickupLimitToMines ); boolean limit2minesSmelt = isBoolean( AutoFeatures.smeltLimitToMines ); @@ -247,34 +255,42 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent, StringBu if ( Output.get().isDebug( DebugTarget.blockBreak ) ) { debugInfo.append( "(applyAutoEvents: " ) - .append( pmEvent.getSpigotBlock().getBlockName() ) - - .append( " Pickup [") - .append( isAutoPickup ? "enabled: " : "disabled:" ) - .append( lorePickup ? "lore " : "" ) - .append( permPickup ? "perm " : "" ) - .append( configPickup ? "config " : "" ) - .append( limit2minesPickup ? "limit2mines" : "noLimit" ) - .append( "] ") - - .append( " Smelt [") - .append( isAutoSmelt ? "enabled: " : "disabled:" ) - .append( loreSmelt ? "lore " : "" ) - .append( permSmelt ? "perm " : "" ) - .append( configSmelt ? "config " : "" ) - .append( limit2minesSmelt ? "limit2mines" : "noLimit" ) - .append( "] ") - - .append( " Block [") - .append( isAutoBlock ? "enabled: " : "disabled:" ) - .append( loreBlock ? "lore " : "" ) - .append( permBlock ? "perm " : "" ) - .append( configBlock ? "config " : "" ) - .append( limit2minesBlock ? "limit2mines" : "noLimit" ) - .append( "] ") - - - .append( ")" ); + .append( pmEvent.getSpigotBlock().getBlockName() ); + + if ( !isAutoFeaturesEnabled ) { + debugInfo.append("isAutoFeaturesEnabled=false (disabled)"); + } + else { + + debugInfo + .append( " Pickup [") + .append( isAutoPickup ? "enabled: " : "disabled:" ) + .append( lorePickup ? "lore " : "" ) + .append( permPickup ? "perm " : "" ) + .append( configPickup ? "config " : "" ) + .append( limit2minesPickup ? "limit2mines" : "noLimit" ) + .append( "] ") + + .append( " Smelt [") + .append( isAutoSmelt ? "enabled: " : "disabled:" ) + .append( loreSmelt ? "lore " : "" ) + .append( permSmelt ? "perm " : "" ) + .append( configSmelt ? "config " : "" ) + .append( limit2minesSmelt ? "limit2mines" : "noLimit" ) + .append( "] ") + + .append( " Block [") + .append( isAutoBlock ? "enabled: " : "disabled:" ) + .append( loreBlock ? "lore " : "" ) + .append( permBlock ? "perm " : "" ) + .append( configBlock ? "config " : "" ) + .append( limit2minesBlock ? "limit2mines" : "noLimit" ) + .append( "] "); + + } + + debugInfo + .append( ")" ); } // NOTE: Using isPermissionSet so players that are op'd to not auto enable everything. @@ -284,11 +300,40 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent, StringBu if ( (mine != null || mine == null && !isBoolean( AutoFeatures.pickupLimitToMines )) && isAutoPickup ) { - count = autoFeaturePickup( pmEvent, isAutoSmelt, isAutoBlock, debugInfo ); + if ( isAutoPickup ) { + + // processing auto pickup + totalDrops = autoFeaturePickup( pmEvent, isAutoSmelt, isAutoBlock, debugInfo ); // count = autoFeaturePickup( pmEvent.getSpigotBlock(), player, itemInHand, isAutoSmelt, isAutoBlock, debugInfo ); - - // Cannot set to air yet, or auto smelt and auto block will only get AIR: + + // Cannot set to air yet, or auto smelt and auto block will only get AIR: // autoPickupCleanup( block, count ); + } + else { + // Need to check to see if normal drops should be processed: + + if ( configNormalDrop ) { + debugInfo + .append( "(NormalDrop handling enabled: " ) + .append( "normalDropSmelt[" ) + .append( configNormalDropSmelt ? "enabled" : "disabled" ) + .append( "] " ) + .append( "normalDropBlock[" ) + .append( configNormalDropBlock ? "enabled" : "disabled" ) + .append( "] " ) + .append( ")" ); + + // process normal drops here: + + totalDrops = calculateNormalDrop( pmEvent, debugInfo ); + + } + else { + debugInfo.append(" [Warning: normalDrop handling is disabled] " ); + } + + } + } // else { @@ -335,7 +380,7 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent, StringBu // } - return count; + return totalDrops; } @@ -367,7 +412,7 @@ private boolean applyAutoEvents( PrisonMinesBlockBreakEvent pmEvent, StringBuild int totalDrops = applyAutoEventsDetails( pmEvent, debugInfo ); - debugInfo.append( "(autoEvents totalDropa: " + totalDrops + ") "); + debugInfo.append( "(autoEvents totalDrops: " + totalDrops + ") "); return applyDropsBlockBreakage( pmEvent, totalDrops, debugInfo ); From 107340df3aefc186245205950bc8521aa2a583a3 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 21 May 2022 14:27:51 -0400 Subject: [PATCH 237/297] Move auto feature messages to the spigot message file so they can be customized. Removed the inventory full messages from the AutoFeaturesConifg.yml file. --- docs/changelog_v3.3.x.md | 6 +- .../autofeatures/AutoFeaturesFileConfig.java | 12 +-- .../prison/localization/Localizable.java | 5 ++ .../resources/lang/spigot/en_US.properties | 16 +++- .../autofeatures/AutoManagerFeatures.java | 18 ++-- .../spigot/block/OnBlockBreakEventCore.java | 86 ++++++++++--------- .../block/OnBlockBreakEventCoreMessages.java | 46 ++++++++++ .../spigot/block/OnBlockBreakMines.java | 3 +- 8 files changed, 134 insertions(+), 58 deletions(-) create mode 100644 prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCoreMessages.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9cf6be198..1f830ec0e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11c 2022-05-20 +# 3.3.0-alpha.11c 2022-05-21 + + +* **Move auto feature messages to the spigot message file so they can be customized.** +Removed the inventory full messages from the AutoFeaturesConifg.yml file. * **The normalDrops processing was not hooked up to the newest way auto pickup is disabled, which was skipping normalDrops if auto pickup was disabled.** 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 4356fc892..1c17c4ab4 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 @@ -55,12 +55,12 @@ public enum AutoFeatures { "Otherwise this must be set to 'true' to allow any of the " + "options to work."), - - messages, - - inventoryIsFull(messages, "&cWARNING! Your inventory's full!"), - inventoryIsFullDroppingItems(messages, "&cWARNING! Your inventory's full and you're dropping items!"), - inventoryIsFullLosingItems(messages, "&cWARNING! Your inventory's full and you're losing items!"), +// NOTE: Moved to the spigot language files: +// messages, +// +// inventoryIsFull(messages, "&cWARNING! Your inventory's full!"), +// inventoryIsFullDroppingItems(messages, "&cWARNING! Your inventory's full and you're dropping items!"), +// inventoryIsFullLosingItems(messages, "&cWARNING! Your inventory's full and you're losing items!"), options, diff --git a/prison-core/src/main/java/tech/mcprison/prison/localization/Localizable.java b/prison-core/src/main/java/tech/mcprison/prison/localization/Localizable.java index 8878a9098..ca25eec0c 100755 --- a/prison-core/src/main/java/tech/mcprison/prison/localization/Localizable.java +++ b/prison-core/src/main/java/tech/mcprison/prison/localization/Localizable.java @@ -309,6 +309,11 @@ else if ( isFailSilently() ) { } /** + *

Use this function to return the String value of the message using + * the default locale. All supplied parameters will be applied and + * this is the final product. + *

+ * * Localizes this {@link Localizable} in the owning {@link LocaleManager}'s * default locale. * diff --git a/prison-core/src/main/resources/lang/spigot/en_US.properties b/prison-core/src/main/resources/lang/spigot/en_US.properties index 4f21290ac..6f14c8368 100644 --- a/prison-core/src/main/resources/lang/spigot/en_US.properties +++ b/prison-core/src/main/resources/lang/spigot/en_US.properties @@ -49,7 +49,7 @@ ## /prison support submit. ## -messages__version=4 +messages__version=5 messages__auto_refresh=true ## Click to do something @@ -301,4 +301,16 @@ spigot_message_gui_reload_success=GUIs reloaded with success! spigot_message_gui_sellall_disabled=Sorry, SellAll is disabled. spigot_message_gui_sellall_empty=Sorry, there's nothing to show. spigot_message_gui_too_high=Sorry, but the value is too high (above maximum possible). -spigot_message_gui_too_low_value=Sorry, but the value is too low (below minimum possible). \ No newline at end of file +spigot_message_gui_too_low_value=Sorry, but the value is too low (below minimum possible). + + + + +spigot_blockbreak_mines__mine_is_being_reset__please_wait=Mine %1 is being reset... please wait. + +spigot_blockbreak_core__validate_event__your_tool_is_worn_out=&cYour tool is worn out and can't be used. + +spigot_auto_manager__inventory_is_full=&cWARNING! Your inventory's full! +spigot_auto_manager__is_full_dropping_item__ignore__not_useds=&cWARNING! Your inventory's full and you're dropping items! +spigot_auto_manager__inventory_is_full_losing_items=&cWARNING! Your inventory's full and you're losing items! + 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 cb3ce451a..8054cb0e5 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 @@ -1135,7 +1135,10 @@ private void dropAtBlock( SpigotItemStack itemStack, SpigotBlock block ) { } private void notifyPlayerThatInventoryIsFull( Player player ) { - notifyPlayerWithSound( player, AutoFeatures.inventoryIsFull ); + String message = inventoryIsFullMsg(); + + // AutoFeatures.inventoryIsFull + notifyPlayerWithSound( player, message ); } // @SuppressWarnings( "unused" ) @@ -1144,13 +1147,16 @@ private void notifyPlayerThatInventoryIsFull( Player player ) { // } private void notifyPlayerThatInventoryIsFullLosingItems( Player player ) { - notifyPlayerWithSound( player, AutoFeatures.inventoryIsFullLosingItems ); - + + String message = inventoryIsFullLosingItemsMsg(); + + // AutoFeatures.inventoryIsFullLosingItems + notifyPlayerWithSound( player, message ); } - private void notifyPlayerWithSound( Player player, AutoFeatures messageId ) { - - String message = getMessage( messageId ); + private void notifyPlayerWithSound( Player player, String message ) { + +// String message = getMessage( AutoFeatures messageId ); // Play sound when full if (isBoolean(AutoFeatures.playSoundIfInventoryIsFull)) { 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 6c6e57ddf..0e31159bc 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 @@ -5,7 +5,6 @@ import java.util.List; import java.util.Random; -import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -41,9 +40,11 @@ public abstract class OnBlockBreakEventCore extends OnBlockBreakMines { - - private int uses = 0; - private long usesElapsedTimeNano = 0L; + // The two variables, uses and usesElapsedTimeNano, are designed to better understand + // how frequently this class is used and it's impact on the server. It's is disabled + // but not deleted since it is useful for future useage. +// private int uses = 0; +// private long usesElapsedTimeNano = 0L; private AutoFeaturesWrapper autoFeatureWrapper = null; @@ -119,26 +120,26 @@ protected List getListString( AutoFeatures feature ) { - public enum ItemLoreCounters { - - // NOTE: the String value must include a trailing space! - - itemLoreBlockBreakCount( ChatColor.LIGHT_PURPLE + "Prison Blocks Mined:" + - ChatColor.GRAY + " "), - - itemLoreBlockExplodeCount( ChatColor.LIGHT_PURPLE + "Prison Blocks Exploded:" + - ChatColor.GRAY + " "); - - - private final String lore; - ItemLoreCounters( String lore ) { - this.lore = lore; - } - public String getLore() { - return lore; - } - - } +// public enum ItemLoreCounters { +// +// // NOTE: the String value must include a trailing space! +// +// itemLoreBlockBreakCount( ChatColor.LIGHT_PURPLE + "Prison Blocks Mined:" + +// ChatColor.GRAY + " "), +// +// itemLoreBlockExplodeCount( ChatColor.LIGHT_PURPLE + "Prison Blocks Exploded:" + +// ChatColor.GRAY + " "); +// +// +// private final String lore; +// ItemLoreCounters( String lore ) { +// this.lore = lore; +// } +// public String getLore() { +// return lore; +// } +// +// } public enum ItemLoreEnablers { Pickup, @@ -217,7 +218,7 @@ protected void finalizeBreakTheBlocks( PrisonMinesBlockBreakEvent pmEvent ) !pmEvent.getMine().getMineStateMutex().isMinable() ) { SpigotPlayer sPlayer = pmEvent.getSpigotPlayer(); - sPlayer.setActionBar( "Mine " + pmEvent.getMine().getTag() + " is being reset... please wait." ); + sPlayer.setActionBar( mineIsBeingResetMsg( pmEvent.getMine().getTag() ) ); break; } @@ -626,7 +627,7 @@ else if ( targetExplodedBlock.isMined() ) { if ( isToolDisabled( pmEvent.getPlayer() ) ) { // This will prevent sending too many messages since it is using PlayerMessagingTask: - pmEvent.getSpigotPlayer().setActionBar( "&cYour tool is worn-out and cannot be used." ); + pmEvent.getSpigotPlayer().setActionBar( toolIsWornOutMsg() ); // PrisonUtilsTitles uTitles = new PrisonUtilsTitles(); // uTitles.utilsTitlesActionBarForce( pmEvent.getSpigotPlayer(), null, @@ -950,6 +951,7 @@ public void doActionBlockEventOnly( SpigotBlock spigotBlock, Mine mine, Player p * is enabled. This function is overridden in AutoManager when auto manager is enabled. *

* + * Dead code? * * @param mine * @param e @@ -1825,22 +1827,22 @@ protected void itemLoreCounter( SpigotItemStack itemInHand, String itemLore, int - @SuppressWarnings( "unused" ) - private synchronized String incrementUses(Long elapsedNano) { - String message = null; - usesElapsedTimeNano += elapsedNano; - - if ( ++uses >= 100 ) { - double avgNano = usesElapsedTimeNano / uses; - double avgMs = avgNano / 1000000; - message = String.format( "OnBlockBreak: count= %s avgNano= %s avgMs= %s ", - Integer.toString(uses), Double.toString(avgNano), Double.toString(avgMs) ); - - uses = 0; - usesElapsedTimeNano = 0L; - } - return message; - } +// @SuppressWarnings( "unused" ) +// private synchronized String incrementUses(Long elapsedNano) { +// String message = null; +// usesElapsedTimeNano += elapsedNano; +// +// if ( ++uses >= 100 ) { +// double avgNano = usesElapsedTimeNano / uses; +// double avgMs = avgNano / 1000000; +// message = String.format( "OnBlockBreak: count= %s avgNano= %s avgMs= %s ", +// Integer.toString(uses), Double.toString(avgNano), Double.toString(avgMs) ); +// +// uses = 0; +// usesElapsedTimeNano = 0L; +// } +// return message; +// } // // private boolean isTeExplosionTriggerEnabled() { // return teExplosionTriggerEnabled; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCoreMessages.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCoreMessages.java new file mode 100644 index 000000000..b4c49a21d --- /dev/null +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCoreMessages.java @@ -0,0 +1,46 @@ +package tech.mcprison.prison.spigot.block; + +import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.spigot.SpigotPrison; + +public class OnBlockBreakEventCoreMessages { + + + protected void exampleMsg( CommandSender sender, String mineName ) { + SpigotPrison.getInstance().getLocaleManager() + .getLocalizable( "spigot_blockbreak_core__" ) + .withReplacements( + mineName ) + .sendTo( sender ); + } + + + protected String mineIsBeingResetMsg( String mineTagName ) { + return SpigotPrison.getInstance().getLocaleManager() + .getLocalizable( "spigot_blockbreak_mines__mine_is_being_reset__please_wait" ) + .withReplacements( + mineTagName ) + .localize(); + } + + protected String toolIsWornOutMsg() { + return SpigotPrison.getInstance().getLocaleManager() + .getLocalizable( "spigot_blockbreak_mines__mine_is_being_reset__please_wait" ) + .localize(); + } + + protected String inventoryIsFullMsg() { + return SpigotPrison.getInstance().getLocaleManager() + .getLocalizable( "spigot_auto_manager__inventory_is_full" ) + .localize(); + } + + protected String inventoryIsFullLosingItemsMsg() { + return SpigotPrison.getInstance().getLocaleManager() + .getLocalizable( "spigot_auto_manager__inventory_is_full_losing_items" ) + .localize(); + } + + + +} diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java index d7561a2e0..83bfa5cbc 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java @@ -26,6 +26,7 @@ import tech.mcprison.prison.spigot.utils.BlockUtils; public class OnBlockBreakMines + extends OnBlockBreakEventCoreMessages { private PrisonMines prisonMineManager; private boolean mineModuleDisabled = false; @@ -161,7 +162,7 @@ protected MinesEventResults ignoreMinesBlockBreakEvent( Player player, Block blo if ( !mine.getMineStateMutex().isMinable() ) { SpigotPlayer sPlayer = new SpigotPlayer( player ); - sPlayer.setActionBar( "Mine " + mine.getTag() + " is being reset... please wait." ); + sPlayer.setActionBar( mineIsBeingResetMsg( mine.getTag() ) ); results.setCancelEvent( true ); results.setIgnoreEvent( true ); } From 023a43787ba8c13f7c82d4325e7103343a0c9525 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 21 May 2022 15:33:49 -0400 Subject: [PATCH 238/297] Sellall messages: Start to setup the correct usage of the multi-language message handling through the new prison-sellall module. This fixes the messaging within the SellAllUtil class. --- docs/changelog_v3.3.x.md | 4 + .../resources/lang/sellall/en_US.properties | 64 ++++++++++++++ .../sellall/PrisonSellallUtilsMessages.java | 35 ++++++++ .../messages/SpigotSellallUtilMessages.java | 85 +++++++++++++++++++ .../prison/spigot/configs/MessagesConfig.java | 10 +-- .../prison/spigot/sellall/SellAllUtil.java | 65 ++++++++++---- 6 files changed, 241 insertions(+), 22 deletions(-) create mode 100644 prison-core/src/main/resources/lang/sellall/en_US.properties create mode 100644 prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellallUtilsMessages.java create mode 100644 prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 1f830ec0e..19f645303 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11c 2022-05-21 +* **Sellall messages: Start to setup the correct usage of the multi-language message handling through the new prison-sellall module.** +This fixes the messaging within the SellAllUtil class. + + * **Move auto feature messages to the spigot message file so they can be customized.** Removed the inventory full messages from the AutoFeaturesConifg.yml file. diff --git a/prison-core/src/main/resources/lang/sellall/en_US.properties b/prison-core/src/main/resources/lang/sellall/en_US.properties new file mode 100644 index 000000000..e32dd1655 --- /dev/null +++ b/prison-core/src/main/resources/lang/sellall/en_US.properties @@ -0,0 +1,64 @@ +# NOTE: A messages__version is an arbitrary integer that will be manually incremented within Prison +# when there are changes to these messages. This value represents when message content is +# changed, fixed, or added to. This value may not be increased if the change is very small and +# insignificant, such as a space or a couple of letters. +# +# messages__auto_refresh=true indicates that this file will automatically be replaced if +# Prison detects a messages__version difference. The old file will be deleted (renamed) and +# a new copy will be placed in the directory to be used. If this value is set to false, then +# Prison will not refresh this file and there could be issues with the display of other messages. +# If auto refresh is set to false, we are not held responsible for possible issues that can +# arise from inaccurate messages. If set to false, then you are responsible for maintaining +# the messages on your own. +# +# If you make changes to this file, and you have messages__auto_refresh=false, then those +# changes will be replaced when this file is updated. Since the old file is renamed, and +# not deleted, you can manually merge your changes back in to the new update. The old +# renamed files will never be deleted by prison; you can remove them when you feel like it +# is safe to do so. +# +# Please consider helping Prison, and everyone else who may use Prison, by contributing all +# translations to other languages. They should be faithful translations, and not something +# for the sake of humor or changes just for cosmetic styling. If you have something you would +# like to share, please contact a staff member on our Discord server. +#Thanks for your contributions! +# + +## +## Prison Supports Unicode (UTF-8) encoding in these properties files. BUt you must +## follow these instructions to ensure everything works properly. +## +## 1. You should only edit these files using a UTF-8 editor. On windows use NotePad, not WordPad. +## WordPad will save as plain text. To confirm the save was successful: save, close the editor, +## then reopen to confirm the encoding was preserved. +## +## 2. When running on Windows, you must enable utf-8 encoding in minecraft's console. Windows +## defaults to a characterpage 1252. To enable window's use of utf-8, you need to change the +## encoding prior to launching spigot/paper: +## chcp 65001 +## +## Full example of a windows script, which hooks for java debugging: +## rem Note: chcp 65001 enables utf-8 in windows, when normally windows uses characterpage 1252 +## chcp 65001 +## java -Dfile.encoding="UTF-8" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms1g -Xmx4g -jar spigot-1.8.8.jar nogui --log-strip-color +## pause +## +## 3. When viewing the logs/latest.log files you must use an editor such as NotePad instead of WordPad. +## +## 4. Unicode is properly displayed in game, in console, in the logs, and with paste.helpch.at when using +## /prison support submit. +## + +messages__version=1 +messages__auto_refresh=true + + +sellall_function__message=&dSample &7Message + + +sellall_spigot_utils__money_earned=&3You earned &a$%1 +sellall_spigot_utils__only_sellall_signs_are_enabled=&3You can only sell through signs. The command is disabled. +sellall_spigot_utils__rate_limit_exceeded=&3Slow down. Usage rate limit has been exceeded. +sellall_spigot_utils__shop_is_empty=&3Sorry, this sellall shop is empty. +sellall_spigot_utils__you_have_nothing_to_sell=&wSorry, you have nothing to sell. + diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellallUtilsMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellallUtilsMessages.java new file mode 100644 index 000000000..8c67dfeeb --- /dev/null +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/PrisonSellallUtilsMessages.java @@ -0,0 +1,35 @@ +package tech.mcprison.prison.sellall; + +public class PrisonSellallUtilsMessages +{ + // This does nothing. Used as an example until real messages can be added. + protected String prisonSellallTest01Msg() { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_01" ) + .localize(); + } + + // This does nothing. Used as an example until real messages can be added. + protected String prisonSellallTest02Msg( String parameter ) { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_02" ) + .withReplacements( parameter ) + .localize(); + } + + protected String prisonSellallTest03Msg() { + + String msg01 = prisonSellallTest01Msg(); + String msg02 = prisonSellallTest02Msg( "sample02" ); + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_03" ) + .withReplacements( + msg01, + msg02 ) + .localize(); + + } +} diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java new file mode 100644 index 000000000..3f02079ec --- /dev/null +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java @@ -0,0 +1,85 @@ +package tech.mcprison.prison.sellall.messages; + +import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.ranks.PrisonRanks; +import tech.mcprison.prison.sellall.PrisonSellall; + +/** + * Note that this is a message class that is providing message support for + * other classes outside of the prison-sellall module. Therefore this + * class is not 'paired' with the class that is using it. + * It should be noted that if these messages are intended to be used outside + * of this module, the messages are still stored within the path of + * `plugins/Prison/module_conf/sellall/lang/`. + * + * Please note that the location of these language files are stored within + * core project's resources: 'lang/sellall/'. + * + */ +public class SpigotSellallUtilMessages { + // This does nothing. Used as an example until real messages can be added. + protected String prisonSellallTest01Msg() { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_01" ) + .localize(); + } + + // This does nothing. Used as an example until real messages can be added. + protected String prisonSellallTest02Msg( String parameter ) { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_02" ) + .withReplacements( parameter ) + .localize(); + } + + protected String prisonSellallTest03Msg() { + + String msg01 = prisonSellallTest01Msg(); + String msg02 = prisonSellallTest02Msg( "sample02" ); + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_test__sample_03" ) + .withReplacements( + msg01, + msg02 ) + .localize(); + + } + + + protected String sellallAmountEarnedMsg( String earningsAmount ) { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_spigot_utils__money_earned" ) + .withReplacements( earningsAmount ) + .localize(); + } + + protected void sellallCanOnlyUseSignsMsg( CommandSender sender ) { + PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_utils__only_sellall_signs_are_enabled" ) + .sendTo( sender ); + } + + protected void sellallRateLimitExceededMsg( CommandSender sender ) { + PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_utils__rate_limit_exceeded" ) + .sendTo( sender ); + } + + + protected void sellallShopIsEmptyMsg( CommandSender sender ) { + PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_utils__shop_is_empty" ) + .sendTo( sender ); + } + + protected void sellallYouHaveNothingToSellMsg( CommandSender sender ) { + PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_utils__you_have_nothing_to_sell" ) + .sendTo( sender ); + } + +} diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java index bacb4caa1..9ae3baaa5 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java @@ -313,9 +313,9 @@ public enum StringID { spigot_message_sellall_delay_edit_success, spigot_message_sellall_delay_enabled, spigot_message_sellall_delay_not_number, - spigot_message_sellall_delay_wait, +// spigot_message_sellall_delay_wait, spigot_message_sellall_gui_disabled, - spigot_message_sellall_money_earned, +// spigot_message_sellall_money_earned, spigot_message_sellall_multiplier_add_success, spigot_message_sellall_multiplier_are_disabled, spigot_message_sellall_multiplier_cant_find, @@ -323,9 +323,9 @@ public enum StringID { spigot_message_sellall_multiplier_disabled, spigot_message_sellall_multiplier_edit_success, spigot_message_sellall_multiplier_enabled, - spigot_message_sellall_sell_empty, - spigot_message_sellall_sell_nothing_sellable, - spigot_message_sellall_sell_sign_only, +// spigot_message_sellall_sell_empty, +// spigot_message_sellall_sell_nothing_sellable, +// spigot_message_sellall_sell_sign_only, spigot_message_sellall_sell_sign_notify, spigot_message_sellall_trigger_already_disabled, spigot_message_sellall_trigger_already_enabled, 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 46c120aad..e01e672d1 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 @@ -24,8 +24,8 @@ import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack; import tech.mcprison.prison.Prison; import tech.mcprison.prison.PrisonAPI; -import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper; 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; @@ -34,12 +34,14 @@ import tech.mcprison.prison.ranks.data.PlayerRank; import tech.mcprison.prison.ranks.data.Rank; import tech.mcprison.prison.ranks.data.RankPlayer; +import tech.mcprison.prison.sellall.messages.SpigotSellallUtilMessages; 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.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; @@ -49,7 +51,8 @@ /** * @author AnonymousGCA (GABRYCA) * */ -public class SellAllUtil { +public class SellAllUtil + extends SpigotSellallUtilMessages { private static SellAllUtil instance; @@ -68,7 +71,7 @@ public class SellAllUtil { private ArrayList activePlayerDelay = new ArrayList<>(); private List sellAllDisabledWorlds; - private MessagesConfig messages; +// private MessagesConfig messages; private double defaultMultiplier; private int defaultSellAllDelay; private int defaultAutoSellEarningNotificationDelay; @@ -668,7 +671,7 @@ public void updateConfig(){ * */ private void initCachedData() { sellAllConfig = SpigotPrison.getInstance().updateSellAllConfig(); - messages = SpigotPrison.getInstance().getMessagesConfig(); +// 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"); @@ -1491,7 +1494,10 @@ public void removeFromAutoSellDelayAndNotify(Player p){ DecimalFormat fFmt = new DecimalFormat("#,##0.00"); String amt = fFmt.format( autoSellEarningsNotificationWaiting.get(p) ); - String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; + + String message = sellallAmountEarnedMsg( amt ); + +// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; // new SpigotPlayer(p).setActionBar( message ); Output.get().send( new SpigotPlayer(p), message ); } @@ -1733,21 +1739,27 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile if (!isUsingSign && isSellAllSignEnabled && isSellAllBySignOnlyEnabled && !p.hasPermission(permissionBypassSign)){ if (!completelySilent) { - Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_sign_only)); + + sellallCanOnlyUseSignsMsg( new SpigotCommandSender(p) ); +// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_sign_only)); } return false; } if (isSellAllDelayEnabled && isPlayerWaitingSellAllDelay(p)){ if (notifyPlayerDelay && !completelySilent) { - Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_delay_wait)); + + sellallRateLimitExceededMsg( new SpigotCommandSender(p) ); +// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_delay_wait)); } return false; } if (sellAllBlocks.isEmpty()){ if (!completelySilent){ - Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_empty)); + + sellallShopIsEmptyMsg( new SpigotCommandSender(p) ); +// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_empty)); } return false; } @@ -1790,7 +1802,10 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile } else if (notifyPlayerEarned){ DecimalFormat fFmt = new DecimalFormat("#,##0.00"); String amt = fFmt.format( money ); - String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; + + String message = sellallAmountEarnedMsg( amt ); + +// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; // new SpigotPlayer(p).setActionBar( message ); Output.get().send( new SpigotPlayer(p), message ); @@ -1802,7 +1817,9 @@ public boolean sellAllSell(Player p, boolean isUsingSign, boolean completelySile if (isSellAllSoundEnabled && playSoundOnSellAll) { p.playSound(p.getLocation(), sellAllSoundFail, 3, 1); } - Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_nothing_sellable)); + + sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) ); +// Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_nothing_sellable)); } return false; } @@ -1869,7 +1886,10 @@ public double sellAllSell(Player p, SpigotItemStack itemStack, else if (notifyPlayerEarned){ DecimalFormat fFmt = new DecimalFormat("#,##0.00"); String amt = fFmt.format( money ); - String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; + + String message = sellallAmountEarnedMsg( amt ) ; + +// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; // new SpigotPlayer(p).setActionBar( message ); Output.get().send( new SpigotPlayer(p), message ); @@ -1929,21 +1949,27 @@ else if (notifyPlayerEarned){ 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) { - Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_sign_only)); + + sellallCanOnlyUseSignsMsg( new SpigotCommandSender(p) ); +// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_sign_only)); } return itemStacks; } if (isSellAllDelayEnabled && isPlayerWaitingSellAllDelay(p)){ if (notifyPlayerDelay && !completelySilent) { - Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_delay_wait)); + + sellallRateLimitExceededMsg( new SpigotCommandSender(p) ); +// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_delay_wait)); } return itemStacks; } if (sellAllBlocks.isEmpty()){ if (!completelySilent){ - Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_empty)); + + sellallShopIsEmptyMsg( new SpigotCommandSender(p) ); +// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_empty)); } return itemStacks; } @@ -1989,7 +2015,10 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack } else if (notifyPlayerEarned){ DecimalFormat fFmt = new DecimalFormat("#,##0.00"); String amt = fFmt.format( money ); - String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; + + String message = sellallAmountEarnedMsg( amt ); + +// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt; // new SpigotPlayer(p).setActionBar( message ); Output.get().send( new SpigotPlayer(p), message ); @@ -2000,7 +2029,9 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack if (isSellAllSoundEnabled && playSoundOnSellAll) { p.playSound(p.getLocation(), sellAllSoundFail, 3, 1); } - Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_nothing_sellable)); + + sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) ); +// Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_nothing_sellable)); } } return itemStacks; From 7552dbb1021b98562922b576607d03a21ebc70b9 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 21 May 2022 17:12:17 -0400 Subject: [PATCH 239/297] Spigot GUI Messages: Hook up more messages to prison's messaging system. --- docs/changelog_v3.3.x.md | 3 + .../resources/lang/sellall/en_US.properties | 22 +++++- .../messages/SpigotSellallUtilMessages.java | 79 +++++++++++++++++++ .../prison/spigot/configs/MessagesConfig.java | 28 +++---- .../gui/autofeatures/SpigotAutoBlockGUI.java | 6 +- .../autofeatures/SpigotAutoFeaturesGUI.java | 19 +++-- .../gui/autofeatures/SpigotAutoPickupGUI.java | 4 +- .../gui/autofeatures/SpigotAutoSmeltGUI.java | 4 +- .../gui/backpacks/BackpacksAdminListGUI.java | 2 +- .../gui/guiutility/SpigotGUIComponents.java | 4 +- .../mine/SpigotMineBlockPercentageGUI.java | 11 ++- .../spigot/gui/mine/SpigotMineInfoGUI.java | 6 +- .../mine/SpigotMineNotificationRadiusGUI.java | 12 ++- .../gui/mine/SpigotMineResetTimeGUI.java | 11 ++- .../spigot/gui/mine/SpigotMinesBlocksGUI.java | 2 +- .../spigot/gui/mine/SpigotMinesGUI.java | 4 +- .../spigot/gui/rank/SpigotLaddersGUI.java | 4 +- .../spigot/gui/rank/SpigotRankPriceGUI.java | 15 +++- .../gui/rank/SpigotRankUPCommandsGUI.java | 2 +- .../spigot/gui/rank/SpigotRanksGUI.java | 2 +- .../gui/sellall/SellAllAdminBlocksGUI.java | 4 +- .../spigot/gui/sellall/SellAllAdminGUI.java | 7 +- .../spigot/gui/sellall/SellAllDelayGUI.java | 14 +++- .../SellAllPrestigesMultiplierGUI.java | 2 +- .../SellAllPrestigesSetMultiplierGUI.java | 16 +++- .../spigot/gui/sellall/SellAllPriceGUI.java | 21 +++-- 26 files changed, 234 insertions(+), 70 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 19f645303..fa96c6f80 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11c 2022-05-21 +* **Spigot GUI Messages: Hook up more messages to prison's messaging system.** + + * **Sellall messages: Start to setup the correct usage of the multi-language message handling through the new prison-sellall module.** This fixes the messaging within the SellAllUtil class. diff --git a/prison-core/src/main/resources/lang/sellall/en_US.properties b/prison-core/src/main/resources/lang/sellall/en_US.properties index e32dd1655..d074f3a5c 100644 --- a/prison-core/src/main/resources/lang/sellall/en_US.properties +++ b/prison-core/src/main/resources/lang/sellall/en_US.properties @@ -56,9 +56,29 @@ messages__auto_refresh=true sellall_function__message=&dSample &7Message +sellall_spigot_gui__click_to_decrease=&3Click to decrease. +sellall_spigot_gui__click_to_increase=&3Click to increase. + +sellall_spigot_gui__left_click_to_confirm=&3Left-Click to confirm. +sellall_spigot_gui__left_click_to_reset=&3Left-Click to reset. +sellall_spigot_gui__left_click_to_open=&3Left-Click to open. +sellall_spigot_gui__left_click_to_edit=&3Left-Click to edit. + +sellall_spigot_gui__right_click_to_cancel=&3Right-Click to cancel. +sellall_spigot_gui__right_click_to_delete=&3Right-Click to delete. +sellall_spigot_gui__right_click_to_disable=&3Right-Click to disable. +sellall_spigot_gui__right_click_to_enable=&3Right-Click to enable. +sellall_spigot_gui__right_click_to_toggle=&3Right-Click to toggle. + +sellall_spigot_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +sellall_spigot_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +sellall_spigot_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + + sellall_spigot_utils__money_earned=&3You earned &a$%1 sellall_spigot_utils__only_sellall_signs_are_enabled=&3You can only sell through signs. The command is disabled. sellall_spigot_utils__rate_limit_exceeded=&3Slow down. Usage rate limit has been exceeded. sellall_spigot_utils__shop_is_empty=&3Sorry, this sellall shop is empty. -sellall_spigot_utils__you_have_nothing_to_sell=&wSorry, you have nothing to sell. +sellall_spigot_utils__you_have_nothing_to_sell=&3Sorry, you have nothing to sell. diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java index 3f02079ec..96b1c1d58 100644 --- a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java @@ -82,4 +82,83 @@ protected void sellallYouHaveNothingToSellMsg( CommandSender sender ) { .sendTo( sender ); } + + protected String guiClickToDecreaseMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__click_to_decrease" ) + .localize(); + } + + protected String guiClickToIncreaseMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__click_to_increase" ) + .localize(); + } + + protected String guiLeftClickToConfirmMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__left_click_to_confirm" ) + .localize(); + } + protected String guiLeftClickToResetMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__left_click_to_reset" ) + .localize(); + } + protected String guiLeftClickToOpenMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__left_click_to_open" ) + .localize(); + } + protected String guiLeftClickToEditMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__left_click_to_edit" ) + .localize(); + } + + protected String guiRightClickToCancelMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__right_click_to_cancel" ) + .localize(); + } + protected String guiRightClickToDeleteMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__right_click_to_delete" ) + .localize(); + } + protected String guiRightClickToDisableMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__right_click_to_disable" ) + .localize(); + } + protected String guiRightClickToEnableMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__right_click_to_enable" ) + .localize(); + } + protected String guiRightClickToToggleMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__right_click_to_toggle" ) + .localize(); + } + + + protected String guiRightClickShiftToDeleteMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_delete" ) + .localize(); + } + protected String guiRightClickShiftToDisableMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_disable" ) + .localize(); + } + protected String guiRightClickShiftToToggleMsg() { + return PrisonRanks.getInstance().getRanksMessages() + .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_toggle" ) + .localize(); + } + + + } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java index 9ae3baaa5..4eb04d0cd 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java @@ -126,12 +126,12 @@ public enum StringID { spigot_gui_lore_click_to_cancel, spigot_gui_lore_click_to_close, spigot_gui_lore_click_to_confirm, - spigot_gui_lore_click_to_decrease, +// spigot_gui_lore_click_to_decrease, spigot_gui_lore_click_to_delete, spigot_gui_lore_click_to_disable, spigot_gui_lore_click_to_edit, spigot_gui_lore_click_to_enable, - spigot_gui_lore_click_to_increase, +// spigot_gui_lore_click_to_increase, spigot_gui_lore_click_to_manage_rank, spigot_gui_lore_click_to_open, spigot_gui_lore_click_to_rankup, @@ -141,20 +141,20 @@ public enum StringID { spigot_gui_lore_click_to_teleport, spigot_gui_lore_click_to_use, - spigot_gui_lore_click_left_to_confirm, - spigot_gui_lore_click_left_to_edit, - spigot_gui_lore_click_left_to_open, - spigot_gui_lore_click_left_to_reset, +// spigot_gui_lore_click_left_to_confirm, +// spigot_gui_lore_click_left_to_edit, +// spigot_gui_lore_click_left_to_open, +// spigot_gui_lore_click_left_to_reset, - spigot_gui_lore_click_right_to_cancel, - spigot_gui_lore_click_right_to_delete, - spigot_gui_lore_click_right_to_disable, - spigot_gui_lore_click_right_to_enable, - spigot_gui_lore_click_right_to_toggle, +// spigot_gui_lore_click_right_to_cancel, +// spigot_gui_lore_click_right_to_delete, +// spigot_gui_lore_click_right_to_disable, +// spigot_gui_lore_click_right_to_enable, +// spigot_gui_lore_click_right_to_toggle, - spigot_gui_lore_click_right_and_shift_to_delete, - spigot_gui_lore_click_right_and_shift_to_disable, - spigot_gui_lore_click_right_and_shift_to_toggle, +// spigot_gui_lore_click_right_and_shift_to_delete, +// spigot_gui_lore_click_right_and_shift_to_disable, +// spigot_gui_lore_click_right_and_shift_to_toggle, spigot_gui_lore_backpack_id, spigot_gui_lore_blocks, diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java index 68ebf3934..64df19797 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java @@ -30,8 +30,10 @@ public void open() { PrisonGUI gui = new PrisonGUI(p, 36, "&3AutoFeatures -> AutoBlock"); // Lores - ButtonLore enabledLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_disable), null); - ButtonLore disabledLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_enable), null); + ButtonLore enabledLore = new ButtonLore( + guiRightClickShiftToDisableMsg(), null); + ButtonLore disabledLore = new ButtonLore( + guiRightClickToEnableMsg(), null); gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), "&cClose")); if (afConfig != null) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java index 824c7ce85..620f2e80d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java @@ -35,8 +35,11 @@ public void open() { if (afConfig != null && afConfig.isFeatureBoolean(AutoFeatures.isAutoManagerEnabled)) { - ButtonLore disable = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_disable), messages.getString(MessagesConfig.StringID.spigot_gui_lore_enabled)); - ButtonLore enable = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_enable), messages.getString(MessagesConfig.StringID.spigot_gui_lore_disabled)); + ButtonLore disable = new ButtonLore( + guiRightClickShiftToDisableMsg(), + messages.getString(MessagesConfig.StringID.spigot_gui_lore_enabled)); + ButtonLore enable = new ButtonLore( + guiRightClickToEnableMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_disabled)); gui = new PrisonGUI(p, dimension, "&3PrisonManager -> AutoFeatures"); gui.addButton(new Button(dimension -1,XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); @@ -60,13 +63,13 @@ public void open() { } disable.setLoreAction(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_open), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_disable) + guiLeftClickToOpenMsg(), + guiRightClickToDisableMsg() )); enable.setLoreAction(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_open), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_enable) + guiLeftClickToOpenMsg(), + guiRightClickToEnableMsg() )); if (afConfig.isFeatureBoolean(AutoFeatures.autoPickupEnabled)) { @@ -93,7 +96,9 @@ public void open() { gui = new PrisonGUI(p, 9, "&3PrisonManager -> AutoFeatures"); - ButtonLore lore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_enable), messages.getString(MessagesConfig.StringID.spigot_gui_lore_disabled)); + ButtonLore lore = new ButtonLore( + guiRightClickToEnableMsg(), + messages.getString(MessagesConfig.StringID.spigot_gui_lore_disabled)); Button enabledOrDisabled = new Button(2, XMaterial.LIME_STAINED_GLASS_PANE, lore, SpigotPrison.format("&cAll Disabled")); gui.addButton(enabledOrDisabled); gui.addButton(new Button(6,XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java index 8f46a98eb..85a557b3a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java @@ -31,8 +31,8 @@ public void open() { int dimension = 36; PrisonGUI gui = new PrisonGUI(p, dimension, "&3AutoFeatures -> AutoPickup"); - ButtonLore enabledLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_disable), null); - ButtonLore disabledLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_enable), null); + ButtonLore enabledLore = new ButtonLore( guiRightClickShiftToDisableMsg(), null); + ButtonLore disabledLore = new ButtonLore( guiRightClickToEnableMsg(), null); ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java index 5c9147ace..6f1d9ba4c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java @@ -31,8 +31,8 @@ public void open() { int dimension = 36; PrisonGUI gui = new PrisonGUI(p, dimension, "&3AutoFeatures -> AutoSmelt"); - ButtonLore enabledLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_disable), null); - ButtonLore disabledLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_enable), null); + ButtonLore enabledLore = new ButtonLore( guiRightClickShiftToDisableMsg(), null); + ButtonLore disabledLore = new ButtonLore( guiRightClickToEnableMsg(), null); ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminListGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminListGUI.java index 52671fa96..8a7603317 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminListGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminListGUI.java @@ -20,7 +20,7 @@ public class BackpacksAdminListGUI extends SpigotGUIComponents { private final Player p; private final String playerBackpackName; private final Configuration backpacksData = BackpacksUtil.get().getBackpacksData(); - private final String loreShiftAndRightClickToDelete = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_delete); + private final String loreShiftAndRightClickToDelete = guiRightClickShiftToDeleteMsg(); private final String loreInfo = messages.getString(MessagesConfig.StringID.spigot_gui_lore_info); private final String lorePlayerOwner = messages.getString(MessagesConfig.StringID.spigot_gui_lore_owner); private final String loreBackpackID = messages.getString(MessagesConfig.StringID.spigot_gui_lore_backpack_id); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java index 8db312b0f..1a1086e28 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java @@ -20,6 +20,7 @@ import tech.mcprison.prison.modules.Module; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; +import tech.mcprison.prison.sellall.messages.SpigotSellallUtilMessages; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; @@ -30,7 +31,8 @@ * @author rbluer RoyalBlueRanger * @author GABRYCA */ -public abstract class SpigotGUIComponents { +public abstract class SpigotGUIComponents + extends SpigotSellallUtilMessages { public static MessagesConfig messages = getMessages(); public static Configuration guiConfig = getGuiConfig(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineBlockPercentageGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineBlockPercentageGUI.java index 4a3395b3c..092707830 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineBlockPercentageGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineBlockPercentageGUI.java @@ -35,9 +35,14 @@ public void open() { int dimension = 45; PrisonGUI gui = new PrisonGUI(p, dimension, "&3MineInfo -> BlockPercentage"); - ButtonLore changeDecreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); - ButtonLore confirmButtonLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_confirm), messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_cancel)), createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_percentage) + " " + val)); - ButtonLore changeIncreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); + ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null); + + ButtonLore confirmButtonLore = new ButtonLore(createLore( + messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_confirm), + guiRightClickToCancelMsg() ), + createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_percentage) + " " + val)); + + ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); XMaterial decreaseMaterial = XMaterial.REDSTONE_BLOCK; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java index 37991298c..7ec6e3d91 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java @@ -40,9 +40,9 @@ public void open(){ PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), SpigotPrison.format("&3Mines -> MineInfo")); ButtonLore resetMineLore = new ButtonLore(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_reset), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_toggle), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_toggle)), + guiLeftClickToResetMsg(), + guiRightClickToToggleMsg(), + guiRightClickShiftToToggleMsg() ), createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_skip_reset_instruction_1), messages.getString(MessagesConfig.StringID.spigot_gui_lore_skip_reset_instruction_2), messages.getString(MessagesConfig.StringID.spigot_gui_lore_skip_reset_instruction_3), diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationRadiusGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationRadiusGUI.java index 8cc8453dc..962d0169e 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationRadiusGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationRadiusGUI.java @@ -31,11 +31,15 @@ public void open() { int dimension = 45; PrisonGUI gui = new PrisonGUI(p, dimension, "&3MineNotifications -> Radius"); - ButtonLore changeDecreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); - ButtonLore confirmButtonLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_confirm)), createLore( + ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null); + + ButtonLore confirmButtonLore = new ButtonLore(createLore( + guiLeftClickToConfirmMsg() ), + createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_radius) + " " + val, - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_cancel))); - ButtonLore changeIncreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); + guiRightClickToCancelMsg() )); + + ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); // XMaterials. XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineResetTimeGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineResetTimeGUI.java index eb82c9cf9..4fd611bbb 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineResetTimeGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineResetTimeGUI.java @@ -30,9 +30,14 @@ public void open() { PrisonGUI gui = new PrisonGUI(p, dimension, "&3MineInfo -> ResetTime"); - ButtonLore changeDecreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); - ButtonLore confirmButtonLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_confirm), messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_cancel)), createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_reset_time) + " " + val)); - ButtonLore changeIncreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); + ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null); + + ButtonLore confirmButtonLore = new ButtonLore(createLore( + guiLeftClickToConfirmMsg(), + guiRightClickToCancelMsg() ), + createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_reset_time) + " " + val)); + + ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); // XMaterials. XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java index 6489885f1..6313fbf27 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java @@ -25,7 +25,7 @@ public class SpigotMinesBlocksGUI extends SpigotGUIComponents { private final String mineName; // Global Strings. - private final String loreShiftRightClickToDelete = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_delete); + private final String loreShiftRightClickToDelete = guiRightClickShiftToDeleteMsg(); private final String loreClickToEditBlock = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit); private final String loreInfo = messages.getString(MessagesConfig.StringID.spigot_gui_lore_info); private final String loreChance = messages.getString(MessagesConfig.StringID.spigot_gui_lore_chance); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java index c9579d958..1a23be812 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java @@ -77,8 +77,8 @@ public void open(){ PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3MinesManager -> Mines"); // Global Strings. - String loreLeftClickOpen = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_open); - String loreShiftRightClickToDelete = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_delete); + String loreLeftClickOpen = guiLeftClickToOpenMsg(); + String loreShiftRightClickToDelete = guiRightClickShiftToDeleteMsg(); String loreInfo = messages.getString(MessagesConfig.StringID.spigot_gui_lore_info); String loreWorld = messages.getString(MessagesConfig.StringID.spigot_gui_lore_world); String loreSpawnPoint = messages.getString(MessagesConfig.StringID.spigot_gui_lore_spawnpoint); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java index a6aa859ff..0f6be7acd 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java @@ -76,7 +76,9 @@ public void open(){ PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3RanksManager -> Ladders"); - ButtonLore laddersLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_delete)); + ButtonLore laddersLore = new ButtonLore( + messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), + guiRightClickShiftToDeleteMsg() ); for ( RankLadder ladder : laddersDisplay ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java index cd79f8a7c..bf38564d2 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java @@ -34,9 +34,18 @@ public void open() { int dimension = 45; PrisonGUI gui = new PrisonGUI(p, dimension, "&3RankManager -> RankPrice"); - ButtonLore changeDecreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); - ButtonLore confirmButtonLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_confirm), messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_cancel)), createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_price) + " " + val)); - ButtonLore changeIncreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); + ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null); +// ButtonLore changeDecreaseValueLore = new ButtonLore( +// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); + + ButtonLore confirmButtonLore = new ButtonLore(createLore( + guiLeftClickToConfirmMsg(), + guiRightClickToCancelMsg() ), + createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_price) + " " + val)); + + ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); +// ButtonLore changeIncreaseValueLore = new ButtonLore( +// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java index 876d66491..953ba7cc9 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java @@ -22,7 +22,7 @@ public class SpigotRankUPCommandsGUI extends SpigotGUIComponents { private final Rank rank; // Global Strings. - private final String shiftRightClickToDelete = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_delete); + private final String shiftRightClickToDelete = guiRightClickShiftToDeleteMsg(); private final String loreInfo = messages.getString(MessagesConfig.StringID.spigot_gui_lore_info); private final String loreCommand = messages.getString(MessagesConfig.StringID.spigot_gui_lore_command); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java index e05fdf4f8..abd8621ad 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java @@ -75,7 +75,7 @@ public void open(){ PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3Ladders -> Ranks"); // Global Strings. - String loreShiftRightClickDelete = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_and_shift_to_delete); + String loreShiftRightClickDelete = guiRightClickShiftToDeleteMsg(); String loreClickToManageRank = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_manage_rank); String loreInfo = messages.getString(MessagesConfig.StringID.spigot_gui_lore_info); String loreId = messages.getString(MessagesConfig.StringID.spigot_gui_lore_id); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java index 0b3bd1554..67a3d7b78 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java @@ -81,8 +81,8 @@ public void open() { PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3SellAll -> Blocks"); // Global strings. - String loreLine1 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_delete); - String loreLine2 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_edit); + String loreLine1 = guiRightClickToDeleteMsg(); + String loreLine2 = guiLeftClickToEditMsg(); String lorePermission = messages.getString(MessagesConfig.StringID.spigot_gui_lore_permission); String permissionSellAllBlock = sellAllConfig.getString("Options.Sell_Per_Block_Permission"); String loreValue = messages.getString(MessagesConfig.StringID.spigot_gui_lore_value); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java index 0df4d6625..7cfb6d56c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java @@ -69,12 +69,13 @@ public void open() { if (sellAllConfig.getString("Options.Full_Inv_AutoSell").equalsIgnoreCase("true")){ autoSellLore.setLoreAction(createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_disable) + guiRightClickToDisableMsg() )); autoSellButton = new Button(13, XMaterial.CHEST, autoSellLore, "&3AutoSell"); } else { - autoSellLore.setLoreAction(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_enable)); + autoSellLore.setLoreAction( + guiRightClickToEnableMsg() ); autoSellButton = new Button(13, XMaterial.CHEST, autoSellLore, "&cAutoSell-Disabled"); } @@ -82,7 +83,7 @@ public void open() { sellAllDelayLore.setLoreAction(createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_disable))); + guiRightClickToCancelMsg())); sellAllDelayLore.setLoreDescription(createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_delay) + " " + sellAllConfig.getString("Options.Sell_Delay_Seconds") + "s", messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_delay_use_1), diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java index 636955a28..c3669467f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java @@ -49,9 +49,17 @@ public void open() { // int dimension = 45; PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3SellAll -> Delay"); - ButtonLore changeDecreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); - ButtonLore confirmButtonLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_confirm), messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_cancel)), createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_delay) + " " + val + "s")); - ButtonLore changeIncreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); + ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null); +// ButtonLore changeDecreaseValueLore = new ButtonLore( +// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); + ButtonLore confirmButtonLore = new ButtonLore(createLore( + guiLeftClickToConfirmMsg(), + guiRightClickToCancelMsg() ), + createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_delay) + " " + val + "s")); + + ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); +// ButtonLore changeIncreaseValueLore = new ButtonLore( +// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK; XMaterial increaseMat = XMaterial.EMERALD_BLOCK; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java index 03926f73b..5f1d6a647 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java @@ -35,7 +35,7 @@ public void open() { String lorePrestigeName = messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_name); String lorePrestigeMultiplier = messages.getString(MessagesConfig.StringID.spigot_gui_lore_multiplier); String loreClickToEdit = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit); - String loreClickToDelete = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_delete); + String loreClickToDelete = guiRightClickToDeleteMsg(); // Only loop over the blocks that we need to show: int i = counter; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java index 6774209d1..633139fec 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java @@ -31,11 +31,19 @@ public void open() { int dimension = 45; PrisonGUI gui = new PrisonGUI(p, dimension, "&3Edit -> Multiplier"); - ButtonLore changeDecreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); + ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null); +// ButtonLore changeDecreaseValueLore = new ButtonLore( +// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); + ButtonLore confirmButtonLore = new ButtonLore(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_confirm), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_cancel)), createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_multiplier) + " " + "x" + val)); - ButtonLore changeIncreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); + guiLeftClickToConfirmMsg(), + guiRightClickToCancelMsg() ), + createLore( + messages.getString(MessagesConfig.StringID.spigot_gui_lore_multiplier) + " " + "x" + val)); + + ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); +// ButtonLore changeIncreaseValueLore = new ButtonLore( +// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK; XMaterial increaseMat = XMaterial.EMERALD_BLOCK; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java index 55ece4a1b..902a8dbcf 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java @@ -1,7 +1,9 @@ package tech.mcprison.prison.spigot.gui.sellall; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -12,7 +14,8 @@ /** * @author GABRYCA */ -public class SellAllPriceGUI extends SpigotGUIComponents { +public class SellAllPriceGUI + extends SpigotGUIComponents { private final Player p; private final String itemID; @@ -31,10 +34,18 @@ public void open() { int dimension = 45; PrisonGUI gui = new PrisonGUI(p, dimension, "&3SellAll -> ItemValue"); - ButtonLore changeDecreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); + ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null); +// ButtonLore changeDecreaseValueLore = new ButtonLore( +// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null); + ButtonLore confirmButtonLore = new ButtonLore(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_left_to_confirm), messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_right_to_cancel)), createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_price) + " " + val)); - ButtonLore changeIncreaseValueLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); + guiLeftClickToConfirmMsg(), + guiRightClickToCancelMsg() ), + createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_price) + " " + val)); + + ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); +// ButtonLore changeIncreaseValueLore = new ButtonLore( +// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null); XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK; XMaterial increaseMat = XMaterial.EMERALD_BLOCK; From 689f822d4e5e99e2066c39d657d3ef1e8fc73517 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 21 May 2022 17:24:33 -0400 Subject: [PATCH 240/297] Change the name of the SpigotSellallUtilMessages class to SpigotVariousGuiMessages due to the fact these messages are used in more than just sellall. It should be noted that eventually the non-sellall messages may have to be removed from the sellall module. --- docs/changelog_v3.3.x.md | 4 ++++ ...SellallUtilMessages.java => SpigotVariousGuiMessages.java} | 2 +- .../prison/spigot/gui/guiutility/SpigotGUIComponents.java | 4 ++-- .../java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) rename prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/{SpigotSellallUtilMessages.java => SpigotVariousGuiMessages.java} (99%) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index fa96c6f80..d16d0aef2 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11c 2022-05-21 +* **Change the name of the SpigotSellallUtilMessages class to SpigotVariousGuiMessages due to the fact these messages are used in more than just sellall.** +It should be noted that eventually the non-sellall messages may have to be removed from the sellall module. + + * **Spigot GUI Messages: Hook up more messages to prison's messaging system.** diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java similarity index 99% rename from prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java rename to prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java index 96b1c1d58..94cd23c72 100644 --- a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotSellallUtilMessages.java +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java @@ -16,7 +16,7 @@ * core project's resources: 'lang/sellall/'. * */ -public class SpigotSellallUtilMessages { +public class SpigotVariousGuiMessages { // This does nothing. Used as an example until real messages can be added. protected String prisonSellallTest01Msg() { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java index 1a1086e28..dd28254bb 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java @@ -20,7 +20,7 @@ import tech.mcprison.prison.modules.Module; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; -import tech.mcprison.prison.sellall.messages.SpigotSellallUtilMessages; +import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; @@ -32,7 +32,7 @@ * @author GABRYCA */ public abstract class SpigotGUIComponents - extends SpigotSellallUtilMessages { + extends SpigotVariousGuiMessages { public static MessagesConfig messages = getMessages(); public static Configuration guiConfig = getGuiConfig(); 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 e01e672d1..4b926e9b4 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 @@ -34,7 +34,7 @@ import tech.mcprison.prison.ranks.data.PlayerRank; import tech.mcprison.prison.ranks.data.Rank; import tech.mcprison.prison.ranks.data.RankPlayer; -import tech.mcprison.prison.sellall.messages.SpigotSellallUtilMessages; +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; @@ -52,7 +52,7 @@ * @author AnonymousGCA (GABRYCA) * */ public class SellAllUtil - extends SpigotSellallUtilMessages { + extends SpigotVariousGuiMessages { private static SellAllUtil instance; From bed71bdd99828bc291513103b0798f7a8ad93c9b Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 21 May 2022 19:14:34 -0400 Subject: [PATCH 241/297] GUI cleaned up by eliminating so many excessive uses of translating amp color codes to the native color codes. Found some locations where there were at least 7 layers of function calls, with each layer trying to translate the color codes, which of course was excessive. --- docs/changelog_v3.3.x.md | 4 ++ .../resources/lang/sellall/en_US.properties | 3 + .../messages/SpigotVariousGuiMessages.java | 24 ++++++++ .../mcprison/prison/spigot/SpigotPrison.java | 5 +- .../prison/spigot/configs/MessagesConfig.java | 2 +- .../prison/spigot/gui/SpigotPrisonGUI.java | 17 +++--- .../gui/autofeatures/SpigotAutoBlockGUI.java | 52 ++++++++--------- .../autofeatures/SpigotAutoFeaturesGUI.java | 31 +++++----- .../gui/autofeatures/SpigotAutoPickupGUI.java | 58 +++++++++---------- .../gui/autofeatures/SpigotAutoSmeltGUI.java | 18 +++--- .../gui/backpacks/BackpacksListPlayerGUI.java | 9 +-- .../prison/spigot/gui/guiutility/Button.java | 20 +++---- .../spigot/gui/guiutility/ButtonLore.java | 29 +++++----- .../spigot/gui/guiutility/PrisonGUI.java | 7 ++- .../gui/guiutility/SpigotGUIComponents.java | 20 ++++++- .../spigot/gui/mine/SpigotMineInfoGUI.java | 22 +++---- .../gui/mine/SpigotMineNotificationsGUI.java | 11 ++-- .../spigot/gui/mine/SpigotMinesBlocksGUI.java | 9 ++- .../spigot/gui/mine/SpigotPlayerMinesGUI.java | 12 ++-- .../gui/rank/SpigotConfirmPrestigeGUI.java | 9 +-- .../spigot/gui/rank/SpigotLaddersGUI.java | 4 +- .../gui/rank/SpigotPlayerPrestigesGUI.java | 7 ++- .../spigot/gui/rank/SpigotPlayerRanksGUI.java | 8 ++- .../spigot/gui/rank/SpigotRankManagerGUI.java | 13 ++--- .../spigot/gui/rank/SpigotRankPriceGUI.java | 30 +++++----- .../gui/rank/SpigotRankUPCommandsGUI.java | 8 +-- .../spigot/gui/rank/SpigotRanksGUI.java | 20 ++++--- .../gui/sellall/SellAllAdminAutoSellGUI.java | 7 ++- .../gui/sellall/SellAllAdminBlocksGUI.java | 3 +- .../spigot/gui/sellall/SellAllAdminGUI.java | 14 +++-- .../spigot/gui/sellall/SellAllDelayGUI.java | 4 +- .../SellAllPrestigesSetMultiplierGUI.java | 27 ++++----- .../spigot/gui/sellall/SellAllPriceGUI.java | 26 ++++----- .../prison/spigot/sellall/SellAllUtil.java | 3 +- 34 files changed, 296 insertions(+), 240 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d16d0aef2..22fc68c69 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11c 2022-05-21 +* **GUI cleaned up by eliminating so many excessive uses of translating amp color codes to the native color codes.** +Found some locations where there were at least 7 layers of function calls, with each layer trying to translate the color codes, which of course was excessive. + + * **Change the name of the SpigotSellallUtilMessages class to SpigotVariousGuiMessages due to the fact these messages are used in more than just sellall.** It should be noted that eventually the non-sellall messages may have to be removed from the sellall module. diff --git a/prison-core/src/main/resources/lang/sellall/en_US.properties b/prison-core/src/main/resources/lang/sellall/en_US.properties index d074f3a5c..0d498fe8b 100644 --- a/prison-core/src/main/resources/lang/sellall/en_US.properties +++ b/prison-core/src/main/resources/lang/sellall/en_US.properties @@ -75,6 +75,9 @@ sellall_spigot_gui__right_click_and_shift_to_disable=&3Right-Click and shift to sellall_spigot_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. +sellall_spigot_gui__price=&3Price: %1 + + sellall_spigot_utils__money_earned=&3You earned &a$%1 sellall_spigot_utils__only_sellall_signs_are_enabled=&3You can only sell through signs. The command is disabled. diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java index 94cd23c72..10e27f106 100644 --- a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java @@ -1,5 +1,7 @@ package tech.mcprison.prison.sellall.messages; +import java.text.DecimalFormat; + import tech.mcprison.prison.internal.CommandSender; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.sellall.PrisonSellall; @@ -161,4 +163,26 @@ protected String guiRightClickShiftToToggleMsg() { + protected String guiPriceMsg( Double price ) { + + DecimalFormat dFmt = new DecimalFormat( "#,##0.00" ); + String value = price == null ? dFmt.format(0) : dFmt.format(price); + + return guiPriceMsg( value ); + } + protected String guiPriceMsg( Integer price ) { + + DecimalFormat dFmt = new DecimalFormat( "#,##0" ); + String value = price == null ? dFmt.format(0) : dFmt.format(price); + + return guiPriceMsg( value ); + } + protected String guiPriceMsg( String price ) { + + return PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_spigot_utils__money_earned" ) + .withReplacements( price ) + .localize(); + } + } 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 088e019d7..f718ba8c7 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 @@ -504,9 +504,10 @@ public static String format(String format){ } public static String stripColor(String format){ - format = format(format); + return Text.stripColor(format); +// format = format(format); - return format == null ? null : ChatColor.stripColor(format); +// return format == null ? null : ChatColor.stripColor(format); } /** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java index 4eb04d0cd..e89a21b47 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java @@ -173,7 +173,7 @@ public enum StringID { spigot_gui_lore_permission, spigot_gui_lore_players_at_rank, spigot_gui_lore_prestige_name, - spigot_gui_lore_price, +// spigot_gui_lore_price, spigot_gui_lore_radius, spigot_gui_lore_rank_tag, spigot_gui_lore_reset_time, diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java index 6b6396c20..af8ac26dc 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java @@ -1,8 +1,9 @@ package tech.mcprison.prison.spigot.gui; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; -import tech.mcprison.prison.spigot.SpigotPrison; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools.GUIMenuPageData; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -35,13 +36,13 @@ public void open() { PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3PrisonManager"); // Create and add buttons. - gui.addButton(new Button(10, XMaterial.TRIPWIRE_HOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_button_description)), "&3Ranks - Ladders")); - gui.addButton(new Button(13, XMaterial.IRON_PICKAXE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_autofeatures_button_description)), SpigotPrison.format("&3AutoManager"))); - gui.addButton(new Button(16, XMaterial.DIAMOND_ORE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_mines_button_description)), SpigotPrison.format("&3Mines"))); - gui.addButton(new Button(29, XMaterial.CHEST, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_button_description)), SpigotPrison.format("&3SellAll"))); + gui.addButton(new Button(10, XMaterial.TRIPWIRE_HOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_button_description)), "&3Ranks - Ladders" )); + gui.addButton(new Button(13, XMaterial.IRON_PICKAXE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_autofeatures_button_description)), "&3AutoManager" )); + gui.addButton(new Button(16, XMaterial.DIAMOND_ORE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_mines_button_description)), "&3Mines" )); + gui.addButton(new Button(29, XMaterial.CHEST, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_button_description)), "&3SellAll" )); - // gui.addButton(new Button(33, XMaterial.CHEST_MINECART, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_backpacks_button_description)), SpigotPrison.format("&3Backpacks"))); -// gui.addButton(new Button(44, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), SpigotPrison.format("&cClose"))); + // gui.addButton(new Button(33, XMaterial.CHEST_MINECART, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_backpacks_button_description)), "&3Backpacks" )); +// gui.addButton(new Button(44, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), "&cClose")); // Add the page controls: diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java index 64df19797..e1aa6e93a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java @@ -1,11 +1,11 @@ package tech.mcprison.prison.spigot.gui.autofeatures; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; @@ -39,75 +39,75 @@ public void open() { if (afConfig != null) { if (afConfig.isFeatureBoolean(AutoFeatures.blockAllBlocks)) { - gui.addButton(new Button(null, XMaterial.LIME_STAINED_GLASS_PANE, enabledLore, SpigotPrison.format("&aAll_Blocks Enabled"))); + gui.addButton(new Button(null, XMaterial.LIME_STAINED_GLASS_PANE, enabledLore, "&aAll_Blocks Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.RED_STAINED_GLASS_PANE, disabledLore, SpigotPrison.format("&cAll_Blocks Disabled"))); + gui.addButton(new Button(null, XMaterial.RED_STAINED_GLASS_PANE, disabledLore, "&cAll_Blocks Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockGoldBlock)) { - gui.addButton(new Button(null, XMaterial.GOLD_BLOCK, enabledLore, SpigotPrison.format("&aGold_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.GOLD_BLOCK, enabledLore, "&aGold_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.GOLD_BLOCK, disabledLore, SpigotPrison.format("&cGold_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.GOLD_BLOCK, disabledLore, "&cGold_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockIronBlock)) { - gui.addButton(new Button(null, XMaterial.IRON_BLOCK, enabledLore, SpigotPrison.format("&aIron_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.IRON_BLOCK, enabledLore, "&aIron_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.IRON_BLOCK, disabledLore, SpigotPrison.format("&cIron_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.IRON_BLOCK, disabledLore, "&cIron_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockCoalBlock)) { - gui.addButton(new Button(null, XMaterial.COAL_BLOCK, enabledLore, SpigotPrison.format("&aCoal_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.COAL_BLOCK, enabledLore, "&aCoal_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.COAL_BLOCK, disabledLore, SpigotPrison.format("&cCoal_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.COAL_BLOCK, disabledLore, "&cCoal_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockDiamondBlock)) { - gui.addButton(new Button(null, XMaterial.DIAMOND_BLOCK, enabledLore, SpigotPrison.format("&aDiamond_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.DIAMOND_BLOCK, enabledLore, "&aDiamond_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.DIAMOND_BLOCK, disabledLore, SpigotPrison.format("&cDiamond_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.DIAMOND_BLOCK, disabledLore, "&cDiamond_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockRedstoneBlock)) { - gui.addButton(new Button(null, XMaterial.REDSTONE_BLOCK, enabledLore, SpigotPrison.format("&aRedstone_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.REDSTONE_BLOCK, enabledLore, "&aRedstone_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.REDSTONE_BLOCK, disabledLore, SpigotPrison.format("&cRedstone_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.REDSTONE_BLOCK, disabledLore, "&cRedstone_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockEmeraldBlock)) { - gui.addButton(new Button(null, XMaterial.EMERALD_BLOCK, enabledLore, SpigotPrison.format("&aEmerald_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.EMERALD_BLOCK, enabledLore, "&aEmerald_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.EMERALD_BLOCK, disabledLore, SpigotPrison.format("&cEmerald_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.EMERALD_BLOCK, disabledLore, "&cEmerald_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockQuartzBlock)) { - gui.addButton(new Button(null, XMaterial.QUARTZ_BLOCK, enabledLore, SpigotPrison.format("&aQuartz_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.QUARTZ_BLOCK, enabledLore, "&aQuartz_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.QUARTZ_BLOCK, disabledLore, SpigotPrison.format("&cQuartz_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.QUARTZ_BLOCK, disabledLore, "&cQuartz_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockPrismarineBlock)) { - gui.addButton(new Button(null, XMaterial.PRISMARINE, enabledLore, SpigotPrison.format("&aPrismarine_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.PRISMARINE, enabledLore, "&aPrismarine_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.PRISMARINE, disabledLore, SpigotPrison.format("&cPrismarine_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.PRISMARINE, disabledLore, "&cPrismarine_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockLapisBlock)) { - gui.addButton(new Button(null, XMaterial.LAPIS_BLOCK, enabledLore, SpigotPrison.format("&aLapis_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.LAPIS_BLOCK, enabledLore, "&aLapis_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.LAPIS_BLOCK, disabledLore, SpigotPrison.format("&cLapis_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.LAPIS_BLOCK, disabledLore, "&cLapis_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockSnowBlock)) { - gui.addButton(new Button(null, XMaterial.SNOW_BLOCK, enabledLore, SpigotPrison.format("&aSnow_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.SNOW_BLOCK, enabledLore, "&aSnow_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.SNOW_BLOCK, disabledLore, SpigotPrison.format("&cSnow_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.SNOW_BLOCK, disabledLore, "&cSnow_Block Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.blockGlowstone)) { - gui.addButton(new Button(null, XMaterial.GLOWSTONE, enabledLore, SpigotPrison.format("&aGlowstone_Block Enabled"))); + gui.addButton(new Button(null, XMaterial.GLOWSTONE, enabledLore, "&aGlowstone_Block Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.GLOWSTONE, disabledLore, SpigotPrison.format("&cGlowstone_Block Disabled"))); + gui.addButton(new Button(null, XMaterial.GLOWSTONE, disabledLore, "&cGlowstone_Block Disabled" )); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java index 620f2e80d..379683b6d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java @@ -6,7 +6,6 @@ import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; @@ -42,24 +41,24 @@ public void open() { guiRightClickToEnableMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_disabled)); gui = new PrisonGUI(p, dimension, "&3PrisonManager -> AutoFeatures"); - gui.addButton(new Button(dimension -1,XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); + gui.addButton(new Button(dimension -1,XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); if (afConfig.isFeatureBoolean(AutoFeatures.playSoundIfInventoryIsFull)) { - gui.addButton(new Button(0, XMaterial.LIME_STAINED_GLASS_PANE, disable, SpigotPrison.format("&aFull-Inventory-Sound Enabled"))); + gui.addButton(new Button(0, XMaterial.LIME_STAINED_GLASS_PANE, disable, "&aFull-Inventory-Sound Enabled" )); } else { - gui.addButton(new Button(0, XMaterial.RED_STAINED_GLASS_PANE, enable, SpigotPrison.format("&cFull-Inventory-Sound Disabled"))); + gui.addButton(new Button(0, XMaterial.RED_STAINED_GLASS_PANE, enable, "&cFull-Inventory-Sound Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.actionBarMessageIfInventoryIsFull)) { - gui.addButton(new Button(8, XMaterial.LIME_STAINED_GLASS_PANE, disable, SpigotPrison.format("&aFull-Inventory-ActionBar Enabled"))); + gui.addButton(new Button(8, XMaterial.LIME_STAINED_GLASS_PANE, disable, "&aFull-Inventory-ActionBar Enabled" )); } else { - gui.addButton(new Button(8, XMaterial.RED_STAINED_GLASS_PANE, enable, SpigotPrison.format("&cFull-Inventory-ActionBar Disabled"))); + gui.addButton(new Button(8, XMaterial.RED_STAINED_GLASS_PANE, enable, "&cFull-Inventory-ActionBar Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.isAutoManagerEnabled)) { - gui.addButton(new Button(18, XMaterial.LIME_STAINED_GLASS_PANE, disable, SpigotPrison.format("&aAll Enabled"))); + gui.addButton(new Button(18, XMaterial.LIME_STAINED_GLASS_PANE, disable, "&aAll Enabled" )); } else { - gui.addButton(new Button(18, XMaterial.RED_STAINED_GLASS_PANE, enable, SpigotPrison.format("&cAll Disabled"))); + gui.addButton(new Button(18, XMaterial.RED_STAINED_GLASS_PANE, enable, "&cAll Disabled" )); } disable.setLoreAction(createLore( @@ -73,23 +72,23 @@ public void open() { )); if (afConfig.isFeatureBoolean(AutoFeatures.autoPickupEnabled)) { - gui.addButton(new Button(11, XMaterial.CHEST, disable, SpigotPrison.format("&3AutoPickup Enabled"))); + gui.addButton(new Button(11, XMaterial.CHEST, disable, "&3AutoPickup Enabled" )); } else { - gui.addButton(new Button(11, XMaterial.CHEST, enable, SpigotPrison.format("&cAutoPickup Disabled"))); + gui.addButton(new Button(11, XMaterial.CHEST, enable, "&cAutoPickup Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.autoSmeltEnabled)) { - gui.addButton(new Button(13, XMaterial.FURNACE, disable, SpigotPrison.format("&3AutoSmelt Enabled"))); + gui.addButton(new Button(13, XMaterial.FURNACE, disable, "&3AutoSmelt Enabled" )); } else { - gui.addButton(new Button(13, XMaterial.FURNACE, enable, SpigotPrison.format("&cAutoSmelt Disabled"))); + gui.addButton(new Button(13, XMaterial.FURNACE, enable, "&cAutoSmelt Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.autoBlockEnabled)) { - gui.addButton(new Button(15, XMaterial.CRAFTING_TABLE, disable, SpigotPrison.format("&3AutoBlock Enabled"))); + gui.addButton(new Button(15, XMaterial.CRAFTING_TABLE, disable, "&3AutoBlock Enabled" )); } else { - gui.addButton(new Button(15, XMaterial.CRAFTING_TABLE, enable, SpigotPrison.format("&cAutoBlock Disabled"))); + gui.addButton(new Button(15, XMaterial.CRAFTING_TABLE, enable, "&cAutoBlock Disabled" )); } } else { @@ -99,9 +98,9 @@ public void open() { ButtonLore lore = new ButtonLore( guiRightClickToEnableMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_disabled)); - Button enabledOrDisabled = new Button(2, XMaterial.LIME_STAINED_GLASS_PANE, lore, SpigotPrison.format("&cAll Disabled")); + Button enabledOrDisabled = new Button(2, XMaterial.LIME_STAINED_GLASS_PANE, lore, "&cAll Disabled" ); gui.addButton(enabledOrDisabled); - gui.addButton(new Button(6,XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); + gui.addButton(new Button(6,XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); } gui.open(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java index 85a557b3a..15fbafbee 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java @@ -1,12 +1,12 @@ package tech.mcprison.prison.spigot.gui.autofeatures; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -35,85 +35,85 @@ public void open() { ButtonLore disabledLore = new ButtonLore( guiRightClickToEnableMsg(), null); ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); - gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); + gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); if (afConfig != null) { if (afConfig.isFeatureBoolean(AutoFeatures.pickupAllBlocks)) { - gui.addButton(new Button(null, XMaterial.LIME_STAINED_GLASS_PANE, enabledLore, SpigotPrison.format("&aAll_Blocks Enabled"))); + gui.addButton(new Button(null, XMaterial.LIME_STAINED_GLASS_PANE, enabledLore, "&aAll_Blocks Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.RED_STAINED_GLASS_PANE, disabledLore, SpigotPrison.format("&cAll_Blocks Disabled"))); + gui.addButton(new Button(null, XMaterial.RED_STAINED_GLASS_PANE, disabledLore, "&cAll_Blocks Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupCobbleStone)) { - gui.addButton(new Button(null, XMaterial.COBBLESTONE, enabledLore, SpigotPrison.format("&aCobblestone Enabled"))); + gui.addButton(new Button(null, XMaterial.COBBLESTONE, enabledLore, "&aCobblestone Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.COBBLESTONE, disabledLore, SpigotPrison.format("&cCobblestone Disabled"))); + gui.addButton(new Button(null, XMaterial.COBBLESTONE, disabledLore, "&cCobblestone Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupStone)) { - gui.addButton(new Button(null, XMaterial.STONE, enabledLore, SpigotPrison.format("&aStone Enabled"))); + gui.addButton(new Button(null, XMaterial.STONE, enabledLore, "&aStone Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.STONE, disabledLore, SpigotPrison.format("&cStone Disabled"))); + gui.addButton(new Button(null, XMaterial.STONE, disabledLore, "&cStone Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupGoldOre)) { - gui.addButton(new Button(null, XMaterial.GOLD_ORE, enabledLore, SpigotPrison.format("&aGold_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.GOLD_ORE, enabledLore, "&aGold_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.GOLD_ORE, disabledLore, SpigotPrison.format("&cGold_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.GOLD_ORE, disabledLore, "&cGold_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupIronOre)) { - gui.addButton(new Button(null, XMaterial.IRON_ORE, enabledLore, SpigotPrison.format("&aIron_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.IRON_ORE, enabledLore, "&aIron_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.IRON_ORE, disabledLore, SpigotPrison.format("&cIron_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.IRON_ORE, disabledLore, "&cIron_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupCoalOre)) { - gui.addButton(new Button(null, XMaterial.COAL_ORE, enabledLore, SpigotPrison.format("&aCoal_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.COAL_ORE, enabledLore, "&aCoal_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.COAL_ORE, disabledLore, SpigotPrison.format("&cCoal_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.COAL_ORE, disabledLore, "&cCoal_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupDiamondOre)) { - gui.addButton(new Button(null, XMaterial.DIAMOND_ORE, enabledLore, SpigotPrison.format("&aDiamond_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.DIAMOND_ORE, enabledLore, "&aDiamond_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.DIAMOND_ORE, disabledLore, SpigotPrison.format("&cDiamond_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.DIAMOND_ORE, disabledLore, "&cDiamond_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupRedStoneOre)) { - gui.addButton(new Button(null, XMaterial.REDSTONE_ORE, enabledLore, SpigotPrison.format("&aRedstone_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.REDSTONE_ORE, enabledLore, "&aRedstone_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.REDSTONE_ORE, disabledLore, SpigotPrison.format("&cRedstone_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.REDSTONE_ORE, disabledLore, "&cRedstone_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupEmeraldOre)) { - gui.addButton(new Button(null, XMaterial.EMERALD_ORE, enabledLore, SpigotPrison.format("&aEmerald_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.EMERALD_ORE, enabledLore, "&aEmerald_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.EMERALD_ORE, disabledLore, SpigotPrison.format("&cEmerald_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.EMERALD_ORE, disabledLore, "&cEmerald_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupQuartzOre)) { - gui.addButton(new Button(null, XMaterial.NETHER_QUARTZ_ORE, 1, enabledLore, SpigotPrison.format("&aQuartz_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.NETHER_QUARTZ_ORE, 1, enabledLore, "&aQuartz_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.NETHER_QUARTZ_ORE, 1, disabledLore, SpigotPrison.format("&cQuartz_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.NETHER_QUARTZ_ORE, 1, disabledLore, "&cQuartz_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupLapisOre)) { - gui.addButton(new Button(null, XMaterial.LAPIS_ORE, enabledLore, SpigotPrison.format("&aLapis_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.LAPIS_ORE, enabledLore, "&aLapis_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.LAPIS_ORE, disabledLore, SpigotPrison.format("&cLapis_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.LAPIS_ORE, disabledLore, "&cLapis_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupSnowBall)) { - gui.addButton(new Button(null, XMaterial.SNOWBALL, 1, enabledLore, SpigotPrison.format("&aSnow_Ball Enabled"))); + gui.addButton(new Button(null, XMaterial.SNOWBALL, 1, enabledLore, "&aSnow_Ball Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.SNOWBALL, 1, disabledLore, SpigotPrison.format("&cSnow_Ball Disabled"))); + gui.addButton(new Button(null, XMaterial.SNOWBALL, 1, disabledLore, "&cSnow_Ball Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.pickupGlowstoneDust)) { - gui.addButton(new Button(null, XMaterial.GLOWSTONE_DUST, enabledLore, SpigotPrison.format("&aGlowstone_Dust Enabled"))); + gui.addButton(new Button(null, XMaterial.GLOWSTONE_DUST, enabledLore, "&aGlowstone_Dust Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.GLOWSTONE_DUST, disabledLore, SpigotPrison.format("&cGlowstone_Dust Disabled"))); + gui.addButton(new Button(null, XMaterial.GLOWSTONE_DUST, disabledLore, "&cGlowstone_Dust Disabled" )); } } else { Output.get().sendError(new SpigotPlayer(p), "An error occurred, the AutoFeatures Config is broken or missing!"); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java index 6f1d9ba4c..96373318a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java @@ -1,12 +1,12 @@ package tech.mcprison.prison.spigot.gui.autofeatures; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -35,25 +35,25 @@ public void open() { ButtonLore disabledLore = new ButtonLore( guiRightClickToEnableMsg(), null); ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); - gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); + gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); if(afConfig != null) { if (afConfig.isFeatureBoolean(AutoFeatures.smeltAllBlocks)) { - gui.addButton(new Button(null, XMaterial.LIME_STAINED_GLASS_PANE, enabledLore, SpigotPrison.format("&aAll_Ores Enabled"))); + gui.addButton(new Button(null, XMaterial.LIME_STAINED_GLASS_PANE, enabledLore, "&aAll_Ores Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.RED_STAINED_GLASS_PANE, disabledLore, SpigotPrison.format("&cAll_Ores Disabled"))); + gui.addButton(new Button(null, XMaterial.RED_STAINED_GLASS_PANE, disabledLore, "&cAll_Ores Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.smeltGoldOre)) { - gui.addButton(new Button(null, XMaterial.GOLD_ORE, enabledLore, SpigotPrison.format("&aGold_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.GOLD_ORE, enabledLore, "&aGold_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.GOLD_ORE, disabledLore, SpigotPrison.format("&cGold_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.GOLD_ORE, disabledLore, "&cGold_Ore Disabled" )); } if (afConfig.isFeatureBoolean(AutoFeatures.smeltIronOre)) { - gui.addButton(new Button(null, XMaterial.IRON_ORE, enabledLore, SpigotPrison.format("&aIron_Ore Enabled"))); + gui.addButton(new Button(null, XMaterial.IRON_ORE, enabledLore, "&aIron_Ore Enabled" )); } else { - gui.addButton(new Button(null, XMaterial.IRON_ORE, disabledLore, SpigotPrison.format("&cIron_Ore Disabled"))); + gui.addButton(new Button(null, XMaterial.IRON_ORE, disabledLore, "&cIron_Ore Disabled" )); } } else { Output.get().sendError(new SpigotPlayer(p), "An error occurred, the AutoFeatures Config is broken or missing!"); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java index 01a894136..cdd959754 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java @@ -1,9 +1,10 @@ package tech.mcprison.prison.spigot.gui.backpacks; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.backpacks.BackpacksUtil; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; @@ -49,10 +50,10 @@ public void open(){ if (slot < 45) { if (id != null) { - lore.setLoreDescription(SpigotPrison.format("&3/backpack " + id)); + lore.setLoreDescription( "&3/backpack " + id ); gui.addButton(new Button(slot, XMaterial.CHEST, lore, "&3Backpack-" + id)); } else { - lore.setLoreDescription(SpigotPrison.format("&3/backpack")); + lore.setLoreDescription( "&3/backpack" ); gui.addButton(new Button(slot, XMaterial.CHEST, lore, "&3Backpack")); } slot++; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java index 904d33b5a..272829cf4 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java @@ -7,8 +7,6 @@ import com.cryptomorin.xseries.XMaterial; -import tech.mcprison.prison.spigot.SpigotPrison; - /** * @author GABRYCA * */ @@ -28,7 +26,7 @@ public class Button extends SpigotGUIComponents{ public Button(Integer position, XMaterial buttonItem, List lore, String title){ if (position == null || position < 54) { this.position = position; - this.buttonItem = createButton(buttonItem.parseItem(), lore, SpigotPrison.format(title)); + this.buttonItem = createButton(buttonItem.parseItem(), lore, title ); } } @@ -42,7 +40,7 @@ public Button(Integer position, XMaterial buttonItem, List lore, String public Button(Integer position, ItemStack buttonItem, String title){ if (position == null || position < 54) { this.position = position; - this.buttonItem = createButton(buttonItem, null, SpigotPrison.format(title)); + this.buttonItem = createButton(buttonItem, null, title ); } } @@ -56,7 +54,7 @@ public Button(Integer position, ItemStack buttonItem, String title){ public Button(Integer position, XMaterial buttonItem, String title){ if (position == null || position < 54) { this.position = position; - this.buttonItem = createButton(buttonItem.parseItem(), null, SpigotPrison.format(title)); + this.buttonItem = createButton(buttonItem.parseItem(), null, title ); } } @@ -72,7 +70,7 @@ public Button(Integer position, XMaterial buttonItem, String title){ public Button(Integer position, XMaterial buttonItem, int amount, List lore, String title){ if (position == null || position < 54) { this.position = position; - this.buttonItem = createButton(buttonItem.parseItem(), amount, lore, SpigotPrison.format(title)); + this.buttonItem = createButton(buttonItem.parseItem(), amount, lore, title ); } } @@ -103,7 +101,7 @@ public Button(Integer position, XMaterial buttonMaterial, int amount, String tit } if ((position == null || position < 54) && amount <= 64) { this.position = position; - this.buttonItem = createButton(buttonMaterial.parseItem(), amount, null, SpigotPrison.format(title)); + this.buttonItem = createButton(buttonMaterial.parseItem(), amount, null, title ); } } @@ -144,7 +142,7 @@ public Button(Integer position, XMaterial buttonMaterial, int amount, ButtonLore this.position = position; this.buttonItem = createButton(buttonMaterial.parseItem(), amount, (lore == null ? null : lore.getLore() ), - SpigotPrison.format(title)); + title ); } } @@ -161,7 +159,7 @@ public Button(Integer position, XMaterial buttonMaterial, ButtonLore lore, Strin this.position = position; this.buttonItem = createButton(buttonMaterial.parseItem(), (lore == null ? null : lore.getLore() ), - SpigotPrison.format(title)); + title ); } } @@ -238,10 +236,10 @@ public void setButtonLore(ButtonLore lore){ public void addButtonLoreLine(String line){ if (getButtonLore() != null){ List lore = getButtonLore(); - lore.add(SpigotPrison.format(line)); + lore.add( line ); setButtonLore(lore); } else { - setButtonLore(createLore(SpigotPrison.format(line))); + setButtonLore(createLore( line )); } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/ButtonLore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/ButtonLore.java index 45dc560d5..dce686f4a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/ButtonLore.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/ButtonLore.java @@ -1,10 +1,10 @@ package tech.mcprison.prison.spigot.gui.guiutility; -import tech.mcprison.prison.spigot.SpigotPrison; - import java.util.ArrayList; import java.util.List; +import tech.mcprison.prison.util.Text; + /** * @author AnonymousGCA (GABRYCA) * */ @@ -34,13 +34,13 @@ public class ButtonLore extends SpigotGUIComponents{ public ButtonLore(List descriptionAction, List description){ if (!descriptionAction.isEmpty()) { for (String dAction : descriptionAction) { - this.descriptionAction.add(SpigotPrison.format(colorIDAction + dAction)); + this.descriptionAction.add( Text.translateAmpColorCodes(colorIDAction + dAction) ); } } if (!description.isEmpty()) { for (String descriptionLore : description) { - this.description.add(SpigotPrison.format(colorIDDescription + descriptionLore)); + this.description.add( Text.translateAmpColorCodes(colorIDDescription + descriptionLore) ); } } } @@ -63,11 +63,11 @@ public ButtonLore(){} * */ public ButtonLore(String descriptionAction, String description){ if (descriptionAction != null) { - this.descriptionAction.add(SpigotPrison.format(colorIDAction + descriptionAction)); + this.descriptionAction.add( Text.translateAmpColorCodes(colorIDAction + descriptionAction) ); } if (description != null) { - this.description.add(SpigotPrison.format(colorIDDescription + description)); + this.description.add( Text.translateAmpColorCodes(colorIDDescription + description) ); } } @@ -79,7 +79,7 @@ public ButtonLore(String descriptionAction, String description){ public void setLoreAction(List descriptionAction){ this.descriptionAction.clear(); for (String dAction : descriptionAction) { - this.descriptionAction.add(SpigotPrison.format(colorIDAction + dAction)); + this.descriptionAction.add( Text.translateAmpColorCodes(colorIDAction + dAction) ); } } @@ -90,7 +90,7 @@ public void setLoreAction(List descriptionAction){ * */ public void setLoreAction(String descriptionAction){ this.descriptionAction.clear(); - this.descriptionAction.add(SpigotPrison.format(colorIDAction + descriptionAction)); + this.descriptionAction.add( Text.translateAmpColorCodes(colorIDAction + descriptionAction) ); } /** @@ -99,7 +99,7 @@ public void setLoreAction(String descriptionAction){ * @param line - String. * */ public void addLineLoreAction(String line){ - this.descriptionAction.add(SpigotPrison.format(colorIDAction + line)); + this.descriptionAction.add( Text.translateAmpColorCodes(colorIDAction + line) ); } /** @@ -110,7 +110,8 @@ public void addLineLoreAction(String line){ public void setLoreDescription(List description){ this.description.clear(); for (String descriptionLore : description) { - this.description.add(SpigotPrison.format(colorIDDescription + descriptionLore)); + addLineLoreDescription( descriptionLore ); +// this.description.add( Text.translateAmpColorCodes(colorIDDescription + descriptionLore) ); } } @@ -121,7 +122,7 @@ public void setLoreDescription(List description){ * */ public void setLoreDescription(String description){ this.description.clear(); - this.description.add(SpigotPrison.format(colorIDDescription + description)); + this.description.add( Text.translateAmpColorCodes(colorIDDescription + description) ); } /** @@ -130,7 +131,7 @@ public void setLoreDescription(String description){ * @param line - String. * */ public void addLineLoreDescription(String line){ - this.description.add(SpigotPrison.format(colorIDDescription + line)); + this.description.add( Text.translateAmpColorCodes(colorIDDescription + line) ); } /** @@ -233,9 +234,9 @@ public List getLore(){ if (!description.isEmpty()) { lore.add(""); - lore.add(SpigotPrison.format(addBracket())); + lore.add( addBracket() ); lore.addAll(description); - lore.add(SpigotPrison.format(addBracket())); + lore.add( addBracket() ); } return lore; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/PrisonGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/PrisonGUI.java index a2bf845b9..17409119c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/PrisonGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/PrisonGUI.java @@ -3,9 +3,10 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; + import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.game.SpigotPlayer; +import tech.mcprison.prison.util.Text; /** * @author GABRYCA @@ -25,7 +26,7 @@ public class PrisonGUI extends SpigotGUIComponents{ * */ public PrisonGUI(Player p, int size, String title){ this.p = p; - this.inv = Bukkit.createInventory(null, size, SpigotPrison.format(title)); + this.inv = Bukkit.createInventory(null, size, Text.translateAmpColorCodes(title)); } /** @@ -54,7 +55,7 @@ public void setInventory(Inventory inv){ * @param title - Inventory title. * */ public void createInventory(Player owner, int size, String title){ - this.inv = Bukkit.createInventory(owner, size, SpigotPrison.format(title)); + this.inv = Bukkit.createInventory(owner, size, Text.translateAmpColorCodes(title)); } /** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java index dd28254bb..74be7976d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java @@ -26,6 +26,7 @@ import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.ListenersPrisonManager; import tech.mcprison.prison.spigot.sellall.SellAllUtil; +import tech.mcprison.prison.util.Text; /** * @author rbluer RoyalBlueRanger @@ -83,11 +84,14 @@ protected ItemStack createButton(ItemStack item, int amount, List lore, meta = XMaterial.BARRIER.parseItem().getItemMeta(); } - return getItemStack(item, lore, SpigotPrison.format(display), meta); + return getItemStack(item, lore, display, meta); } /** * Get ItemStack of an Item. + * + * Lore should not be converted from the Amp color codes, since they will all be + * converted within this function. * * @param item * @param lore @@ -96,12 +100,22 @@ protected ItemStack createButton(ItemStack item, int amount, List lore, * */ private ItemStack getItemStack(ItemStack item, List lore, String display, ItemMeta meta) { if (meta != null) { - meta.setDisplayName(SpigotPrison.format(display)); + meta.setDisplayName( Text.translateAmpColorCodes(display) ); try { meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } catch (NoClassDefFoundError ignored){} if ( lore != null ) { + + // Go through all of the lore and convert the & color codes to the native color codes: + for ( int i = 0; i < lore.size(); i++ ) { + String loreLine = lore.get(i); + String loreColor = Text.translateAmpColorCodes(loreLine); + if ( !loreLine.equals(loreColor) ) { + lore.set(i, loreColor); + } + } + meta.setLore(lore); } @@ -125,7 +139,7 @@ private ItemStack getItemStack(ItemStack item, List lore, String display protected List createLore( String... lores ) { List results = new ArrayList<>(); for ( String lore : lores ) { - results.add( SpigotPrison.format(lore) ); + results.add( Text.translateAmpColorCodes(lore) ); } return results; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java index 7ec6e3d91..9779b17d2 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java @@ -1,10 +1,10 @@ package tech.mcprison.prison.spigot.gui.mine; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.mines.data.Mine; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools; @@ -37,7 +37,7 @@ public void open(){ .createGUIPageObject( totalArraySize, 1, "gui admin mines", "gui admin mines" ); - PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), SpigotPrison.format("&3Mines -> MineInfo")); + PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3Mines -> MineInfo" ); ButtonLore resetMineLore = new ButtonLore(createLore( guiLeftClickToResetMsg(), @@ -61,14 +61,14 @@ public void open(){ // ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); // Create the button, set the material, amount, lore and name -// gui.addButton(new Button(dimension-1, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); - gui.addButton(new Button(10, XMaterial.EMERALD_BLOCK, resetMineLore, SpigotPrison.format("&3Reset_Mine: " + mineName))); - gui.addButton(new Button(12, XMaterial.COMPASS, mineSpawnLore, SpigotPrison.format("&3Mine_Spawn: " + mineName))); - gui.addButton(new Button(14, XMaterial.OAK_SIGN, minesNotificationsLore, SpigotPrison.format("&3Mine_notifications: " + mineName))); - gui.addButton(new Button(16, XMaterial.ARROW, minesTpLore, SpigotPrison.format("&3TP_to_the_Mine: " + mineName))); - gui.addButton(new Button(28, XMaterial.COAL_ORE, blocksOfTheMineLore, SpigotPrison.format("&3Blocks_of_the_Mine: " + mineName))); - gui.addButton(new Button(30, XMaterial.CLOCK, 1, mineResetTimeLore, SpigotPrison.format("&3Reset_Time: " + mineName))); - gui.addButton(new Button(32 ,XMaterial.FEATHER, mineRenameLore, SpigotPrison.format("&3Mine_Name: " + mineName))); +// gui.addButton(new Button(dimension-1, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose"))); + gui.addButton(new Button(10, XMaterial.EMERALD_BLOCK, resetMineLore, "&3Reset_Mine: " + mineName )); + gui.addButton(new Button(12, XMaterial.COMPASS, mineSpawnLore, "&3Mine_Spawn: " + mineName )); + gui.addButton(new Button(14, XMaterial.OAK_SIGN, minesNotificationsLore, "&3Mine_notifications: " + mineName )); + gui.addButton(new Button(16, XMaterial.ARROW, minesTpLore, "&3TP_to_the_Mine: " + mineName )); + gui.addButton(new Button(28, XMaterial.COAL_ORE, blocksOfTheMineLore, "&3Blocks_of_the_Mine: " + mineName )); + gui.addButton(new Button(30, XMaterial.CLOCK, 1, mineResetTimeLore, "&3Reset_Time: " + mineName )); + gui.addButton(new Button(32 ,XMaterial.FEATHER, mineRenameLore, "&3Mine_Name: " + mineName )); // Mine show Item of Player's GUI aka /gui mines. XMaterial xMaterial = XMaterial.COAL_ORE; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationsGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationsGUI.java index 5c626ed13..47a9abd09 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationsGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationsGUI.java @@ -1,11 +1,12 @@ package tech.mcprison.prison.spigot.gui.mine; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.Mine; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; @@ -48,17 +49,17 @@ public void open() { if (enabledOrDisabled.equalsIgnoreCase("disabled")){ // Add the selected lore - disabledModeLore.addLineLoreDescription(SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_selected))); + disabledModeLore.addLineLoreDescription( messages.getString(MessagesConfig.StringID.spigot_gui_lore_selected) ); } else if (enabledOrDisabled.equalsIgnoreCase("within")){ // Add the selected lore - modeWithinLore.addLineLoreDescription(SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_selected))); + modeWithinLore.addLineLoreDescription( messages.getString(MessagesConfig.StringID.spigot_gui_lore_selected) ); } else if (enabledOrDisabled.equalsIgnoreCase("radius")){ // Add the selected lore - modeRadiusLore.addLineLoreDescription(SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_selected))); + modeRadiusLore.addLineLoreDescription( messages.getString(MessagesConfig.StringID.spigot_gui_lore_selected) ); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java index 6313fbf27..c2b15dc7c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java @@ -1,13 +1,12 @@ package tech.mcprison.prison.spigot.gui.mine; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; -import tech.mcprison.prison.Prison; +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.Mine; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -75,8 +74,8 @@ public void open(){ ButtonLore blocksLore = new ButtonLore(createLore(loreClickToEditBlock, loreShiftRightClickToDelete), createLore(loreInfo)); // Add a lore - blocksLore.addLineLoreDescription(SpigotPrison.format(loreChance + block.getChance() + "%")); - blocksLore.addLineLoreDescription(SpigotPrison.format(loreBlockType + blockmaterial)); + blocksLore.addLineLoreDescription( loreChance + block.getChance() + "%" ); + blocksLore.addLineLoreDescription( loreBlockType + blockmaterial ); // Add the button to the GUI. gui.addButton(new Button(null, xMat, blocksLore, "&3" + blockmaterialdisplay + " " + mineName + " " + block.getChance())); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java index 198a65031..ceed2fb34 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java @@ -11,7 +11,6 @@ import tech.mcprison.prison.mines.data.PrisonSortableResults; import tech.mcprison.prison.mines.managers.MineManager.MineSortOrder; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.configs.GuiConfig; import tech.mcprison.prison.spigot.configs.MessagesConfig; @@ -22,6 +21,7 @@ import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; import tech.mcprison.prison.spigot.gui.guiutility.SpigotGUIComponents; +import tech.mcprison.prison.util.Text; /** * @author GABRYCA @@ -99,13 +99,13 @@ public void open() { GuiConfig guiConfigClass = new GuiConfig(); guiConfig = guiConfigClass.getFileGuiConfig(); - String permission = SpigotPrison.format(permissionWarpPlugin); + String permission = Text.translateAmpColorCodes(permissionWarpPlugin); // Get Mine Name. String mineName = m.getName(); // Add mineName lore for TP. - minesLore.addLineLoreAction(SpigotPrison.format("&3" + mineName)); + minesLore.addLineLoreAction( "&3" + mineName ); // If the player has permission to access the mine, then see if there is a custom @@ -140,14 +140,14 @@ public void open() { } // material = ( mineMaterial == null ? Material.COAL_ORE : mineMaterial); - minesLore.addLineLoreDescription(SpigotPrison.format(statusUnlockedMine)); - minesLore.addLineLoreAction(SpigotPrison.format(clickToTeleport)); + minesLore.addLineLoreDescription( statusUnlockedMine ); + minesLore.addLineLoreAction( clickToTeleport ); } else { xMat = XMaterial.REDSTONE_BLOCK; // material = XMaterial.REDSTONE_BLOCK.parseMaterial(); - minesLore.addLineLoreDescription(SpigotPrison.format(statusLockedMine)); + minesLore.addLineLoreDescription( statusLockedMine ); } // Get mine Tag, but make sure it is valid and the mine's name is not null: diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java index 3e95cce1e..cc94162af 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java @@ -1,8 +1,9 @@ package tech.mcprison.prison.spigot.gui.rank; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; -import tech.mcprison.prison.spigot.SpigotPrison; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; @@ -35,8 +36,8 @@ public void open(){ // Create the button, set up the material, amount, lore and name - gui.addButton(new Button(2, XMaterial.EMERALD_BLOCK, confirmLore, SpigotPrison.format("&3Confirm: Prestige"))); - gui.addButton(new Button(6, XMaterial.REDSTONE_BLOCK, cancelLore, SpigotPrison.format("&3Cancel: Don't Prestige"))); + gui.addButton(new Button(2, XMaterial.EMERALD_BLOCK, confirmLore, "&3Confirm: Prestige" )); + gui.addButton(new Button(6, XMaterial.REDSTONE_BLOCK, cancelLore, "&3Cancel: Don't Prestige" )); gui.open(); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java index 0f6be7acd..8e7f4ab2d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java @@ -82,7 +82,7 @@ public void open(){ for ( RankLadder ladder : laddersDisplay ) { - gui.addButton(new Button(null, XMaterial.LADDER, laddersLore, SpigotPrison.format("&3" + ladder.getName()))); + gui.addButton(new Button(null, XMaterial.LADDER, laddersLore, "&3" + ladder.getName() )); } @@ -102,7 +102,7 @@ public void open(){ //// RankLadder ladder = lm.getLadder(i); // // // Add the button to the inventory -// gui.addButton(new Button(null, XMaterial.LADDER, laddersLore, SpigotPrison.format("&3" + ladder.getName()))); +// gui.addButton(new Button(null, XMaterial.LADDER, laddersLore, "&3" + ladder.getName()))); // } // if (i < lm.getLadders().size()) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerPrestigesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerPrestigesGUI.java index 378b0919b..fd372e1da 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerPrestigesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerPrestigesGUI.java @@ -182,7 +182,7 @@ public void open() { // Global strings. String loreInfo = messages.getString(MessagesConfig.StringID.spigot_gui_lore_info); - String lorePrice3 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_price); +// String lorePrice3 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_price); // Global boolean. boolean enchantmentEffectEnabled = getBoolean(guiConfig.getString("Options.Ranks.Enchantment_effect_current_rank")); @@ -204,7 +204,8 @@ public void open() { double cost = pRank == null ? -1 : pRank.getRankCost(); - ButtonLore ranksLore = new ButtonLore(loreInfo, lorePrice3 + cost ); + String lorePrice = guiPriceMsg( cost ); + ButtonLore ranksLore = new ButtonLore(loreInfo, lorePrice ); if (placeholderAPINotNull) { if (hackyCounterEnchant == 1) { @@ -243,7 +244,7 @@ public void open() { ButtonLore rankupLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_rankup), messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup_if_enough_money)); - Button rankupButton = new Button(0, XMaterial.EMERALD_BLOCK, rankupLore, SpigotPrison.format("&aPrestige")); + Button rankupButton = new Button(0, XMaterial.EMERALD_BLOCK, rankupLore, "&aPrestige" ); // NOTE: Button position will be properly assigned in the setButtonNextAvilable: gui.addButton( guiPageData.setButtonNextAvailable( rankupButton ) ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java index 40ab29c1f..f436da2de 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java @@ -38,6 +38,7 @@ import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; import tech.mcprison.prison.spigot.gui.guiutility.SpigotGUIComponents; import tech.mcprison.prison.spigot.nbt.PrisonNBTUtil; +import tech.mcprison.prison.util.Text; /** * @author GABRYCA @@ -211,7 +212,7 @@ public void open() { ); stringValue = stringValue.replace("{rankName}", rank.getName()); - stringValue = stringValue.replace("{rankTag}", SpigotPrison.format(rank.getTag())); + stringValue = stringValue.replace("{rankTag}", Text.translateAmpColorCodes(rank.getTag())); stringValue = stringValue.replace("{rankMultiplier}", mFmt.format( rankMultiplier )); stringValue = stringValue.replace("{ladderName}", rank.getLadder().getName()); @@ -237,7 +238,10 @@ public void open() { ranksLore.setLoreAction( lores ); } - Button itemRank = new Button(null, playerHasThisRank ? materialHas : materialHasNot, showNumber ? amount : 1, ranksLore, SpigotPrison.format(rank.getTag())); + Button itemRank = new Button(null, + playerHasThisRank ? materialHas : materialHasNot, + showNumber ? amount : 1, ranksLore, + rank.getTag() ); amount++; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java index 0225ab274..da36a57c0 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java @@ -12,7 +12,6 @@ import tech.mcprison.prison.ranks.data.Rank; import tech.mcprison.prison.ranks.data.RankPlayer; import tech.mcprison.prison.ranks.data.RankPlayerFactory; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -58,12 +57,12 @@ public void open() { try { rankCost = PlaceholdersUtil.formattedKmbtSISize(pRank.getRankCost(), formatDecimal, ""); } catch (NullPointerException ex){ - rankCost = "Can't get"; + rankCost = "Unavailable"; } ButtonLore editPriceLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open)), createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_info), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_price) + " " + rankCost)); + guiPriceMsg( rankCost) )); ButtonLore editTagLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open)), createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_info), @@ -73,10 +72,10 @@ public void open() { ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); // Create the button - gui.addButton(new Button(26, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); - gui.addButton(new Button(10, XMaterial.COMMAND_BLOCK_MINECART, rankupCommandsLore, SpigotPrison.format("&3RankupCommands" + " " + rank.getName()))); - gui.addButton(new Button(13, XMaterial.GOLD_NUGGET, editPriceLore, SpigotPrison.format("&3RankPrice" + " " + rank.getName()))); - gui.addButton(new Button(16, XMaterial.NAME_TAG, editTagLore, SpigotPrison.format("&3RankTag" + " " + rank.getName()))); + gui.addButton(new Button(26, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); + gui.addButton(new Button(10, XMaterial.COMMAND_BLOCK_MINECART, rankupCommandsLore, "&3RankupCommands" + " " + rank.getName() )); + gui.addButton(new Button(13, XMaterial.GOLD_NUGGET, editPriceLore, "&3RankPrice" + " " + rank.getName() )); + gui.addButton(new Button(16, XMaterial.NAME_TAG, editTagLore, "&3RankTag" + " " + rank.getName() )); gui.open(); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java index bf38564d2..5a183d174 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java @@ -1,9 +1,9 @@ package tech.mcprison.prison.spigot.gui.rank; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; -import tech.mcprison.prison.spigot.SpigotPrison; -import tech.mcprison.prison.spigot.configs.MessagesConfig; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; @@ -41,7 +41,7 @@ public void open() { ButtonLore confirmButtonLore = new ButtonLore(createLore( guiLeftClickToConfirmMsg(), guiRightClickToCancelMsg() ), - createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_price) + " " + val)); + createLore( guiPriceMsg(val) )); ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); // ButtonLore changeIncreaseValueLore = new ButtonLore( @@ -50,23 +50,23 @@ public void open() { XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK; // Decrease button - gui.addButton(new Button(1, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " - 1" ))); - gui.addButton(new Button(10, decreaseMat, 10, changeDecreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " - 10"))); - gui.addButton(new Button(19, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " - 100"))); - gui.addButton(new Button(28, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " - 1000"))); - gui.addButton(new Button(37, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " - 10000"))); + gui.addButton(new Button(1, decreaseMat, changeDecreaseValueLore, "&3" + rankName + " " + val + " - 1" )); + gui.addButton(new Button(10, decreaseMat, 10, changeDecreaseValueLore, "&3" + rankName + " " + val + " - 10" )); + gui.addButton(new Button(19, decreaseMat, changeDecreaseValueLore, "&3" + rankName + " " + val + " - 100" )); + gui.addButton(new Button(28, decreaseMat, changeDecreaseValueLore, "&3" + rankName + " " + val + " - 1000" )); + gui.addButton(new Button(37, decreaseMat, changeDecreaseValueLore, "&3" + rankName + " " + val + " - 10000" )); // Create a button and set the position - gui.addButton(new Button(22, XMaterial.TRIPWIRE_HOOK, confirmButtonLore, SpigotPrison.format("&3Confirm: " + rankName + " " + val))); + gui.addButton(new Button(22, XMaterial.TRIPWIRE_HOOK, confirmButtonLore, "&3Confirm: " + rankName + " " + val )); XMaterial increaseMat = XMaterial.EMERALD_BLOCK; // Increase button - gui.addButton(new Button(7, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " + 1" ))); - gui.addButton(new Button(16, increaseMat, 10, changeIncreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " + 10"))); - gui.addButton(new Button(25, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " + 100"))); - gui.addButton(new Button(34, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " + 1000"))); - gui.addButton(new Button(43, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + rankName + " " + val + " + 10000"))); + gui.addButton(new Button(7, increaseMat, changeIncreaseValueLore, "&3" + rankName + " " + val + " + 1" )); + gui.addButton(new Button(16, increaseMat, 10, changeIncreaseValueLore, "&3" + rankName + " " + val + " + 10" )); + gui.addButton(new Button(25, increaseMat, changeIncreaseValueLore, "&3" + rankName + " " + val + " + 100" )); + gui.addButton(new Button(34, increaseMat, changeIncreaseValueLore, "&3" + rankName + " " + val + " + 1000" )); + gui.addButton(new Button(43, increaseMat, changeIncreaseValueLore, "&3" + rankName + " " + val + " + 10000" )); gui.open(); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java index 953ba7cc9..9ff9009b2 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java @@ -1,11 +1,11 @@ package tech.mcprison.prison.spigot.gui.rank; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.data.Rank; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -67,10 +67,10 @@ public void open() { ButtonLore commandsLore = new ButtonLore(shiftRightClickToDelete, loreInfo); - commandsLore.addLineLoreDescription(SpigotPrison.format(loreCommand + " " + command)); + commandsLore.addLineLoreDescription( loreCommand + " " + command ); // Add the button to the inventory - gui.addButton(new Button(null, XMaterial.TRIPWIRE_HOOK, commandsLore, SpigotPrison.format("&3" + rank.getName() + " " + command))); + gui.addButton(new Button(null, XMaterial.TRIPWIRE_HOOK, commandsLore, "&3" + rank.getName() + " " + command )); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java index abd8621ad..833f664a6 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java @@ -11,7 +11,6 @@ import tech.mcprison.prison.placeholders.PlaceholdersUtil; import tech.mcprison.prison.ranks.data.Rank; import tech.mcprison.prison.ranks.data.RankLadder; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools; @@ -81,7 +80,7 @@ public void open(){ String loreId = messages.getString(MessagesConfig.StringID.spigot_gui_lore_id); String loreName = messages.getString(MessagesConfig.StringID.spigot_gui_lore_name); String loreTag2 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_rank_tag); - String lorePrice3 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_price); +// String lorePrice3 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_price); String lorePlayersWithRank = messages.getString(MessagesConfig.StringID.spigot_gui_lore_players_at_rank); // Decimal Rank cost format. @@ -107,14 +106,17 @@ public void open(){ // double ladderBaseRankMultiplier = PlayerRank.getLadderBaseRankdMultiplier( rank ); // Add the RankID Lore - ranksLore.addLineLoreDescription(SpigotPrison.format(loreId + " " + rank.getId())); - ranksLore.addLineLoreDescription(SpigotPrison.format(loreName + " " + rank.getName())); + ranksLore.addLineLoreDescription( loreId + " " + rank.getId() ); + ranksLore.addLineLoreDescription( loreName + " " + rank.getName() ); if ( rank.getTag() != null ) { - ranksLore.addLineLoreDescription(SpigotPrison.format(loreTag2 + " " + rank.getTag()) ); + ranksLore.addLineLoreDescription( loreTag2 + " " + rank.getTag() ); } - ranksLore.addLineLoreDescription(SpigotPrison.format(lorePrice3 + " " + PlaceholdersUtil.formattedKmbtSISize(rawRankCost, formatDecimal, ""))); + + String price = PlaceholdersUtil.formattedKmbtSISize(rawRankCost, formatDecimal, ""); + String lorePrice = guiPriceMsg( price ); + ranksLore.addLineLoreDescription( lorePrice ); // Init a variable int playerCount = rank.getPlayers().size(); @@ -124,11 +126,11 @@ public void open(){ // .collect(Collectors.toList()); // Add the number of players with this rank - ranksLore.addLineLoreDescription(SpigotPrison.format(lorePlayersWithRank + " " + playerCount)); + ranksLore.addLineLoreDescription( lorePlayersWithRank + " " + playerCount ); // Add the button to the inventory - gui.addButton(new Button( null, XMaterial.TRIPWIRE_HOOK, ranksLore, SpigotPrison.format("&3" + rank.getName()))); -// gui.addButton(new Button(i - counter, XMaterial.TRIPWIRE_HOOK, ranksLore, SpigotPrison.format("&3" + rank.getName()))); + gui.addButton(new Button( null, XMaterial.TRIPWIRE_HOOK, ranksLore, "&3" + rank.getName() )); +// gui.addButton(new Button(i - counter, XMaterial.TRIPWIRE_HOOK, ranksLore, "&3" + rank.getName() )); } // if (i < ladder.get().getRanks().size()) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminAutoSellGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminAutoSellGUI.java index f57604ca7..583846864 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminAutoSellGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminAutoSellGUI.java @@ -1,8 +1,9 @@ package tech.mcprison.prison.spigot.gui.sellall; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; -import tech.mcprison.prison.spigot.SpigotPrison; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; @@ -50,7 +51,7 @@ public void open() { enableDisableButton = new Button(15, XMaterial.RED_STAINED_GLASS_PANE, enableDisableLore, "&cAutoSell-Disabled"); } - gui.addButton(new Button(dimension-1, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); + gui.addButton(new Button(dimension-1, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); gui.addButton(perUserToggleableButton); gui.addButton(enableDisableButton); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java index 67a3d7b78..d21a93a65 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java @@ -8,7 +8,6 @@ import com.cryptomorin.xseries.XMaterial; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; @@ -96,7 +95,7 @@ public void open() { ButtonLore itemsLore = new ButtonLore(createLore(loreLine1, loreLine2), createLore(loreValue + sellAllConfig.getString("Items." + key + ".ITEM_VALUE"))); if (sellAllPerBlockPermissionEnabled) { - itemsLore.addLineLoreDescription(SpigotPrison.format(lorePermission + "&7" + permissionSellAllBlock + sellAllConfig.getString("Items." + key + ".ITEM_ID"))); + itemsLore.addLineLoreDescription( lorePermission + "&7" + permissionSellAllBlock + sellAllConfig.getString("Items." + key + ".ITEM_ID") ); } String xMatIdName = "Items." + key + ".ITEM_ID"; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java index 7cfb6d56c..cbd2728ad 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java @@ -1,7 +1,9 @@ package tech.mcprison.prison.spigot.gui.sellall; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.output.Output; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; @@ -102,16 +104,16 @@ public void open() { try { if (sellAllConfig.getConfigurationSection("Multiplier") == null) { - multipliersLore.addLineLoreDescription(SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_no_multipliers))); + multipliersLore.addLineLoreDescription( messages.getString(MessagesConfig.StringID.spigot_gui_lore_no_multipliers) ); } else if (sellAllConfig.getConfigurationSection("Multiplier").getKeys(false).size() == 0) { - multipliersLore.addLineLoreDescription(SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_no_multipliers))); + multipliersLore.addLineLoreDescription( messages.getString(MessagesConfig.StringID.spigot_gui_lore_no_multipliers) ); } } catch (NullPointerException ex){ - multipliersLore.addLineLoreDescription(SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_gui_lore_no_multipliers))); + multipliersLore.addLineLoreDescription( messages.getString(MessagesConfig.StringID.spigot_gui_lore_no_multipliers) ); } - gui.addButton(new Button(15, XMaterial.EMERALD, setCurrencyLore, SpigotPrison.format("&3SellAll-Currency"))); - gui.addButton(new Button(8, XMaterial.PAPER, multipliersLore, SpigotPrison.format("&3Prestige-Multipliers"))); + gui.addButton(new Button(15, XMaterial.EMERALD, setCurrencyLore, "&3SellAll-Currency" )); + gui.addButton(new Button(8, XMaterial.PAPER, multipliersLore, "&3Prestige-Multipliers" )); gui.addButton(new Button(0, XMaterial.DIAMOND_ORE, blocksLore, "&3Blocks-Shop")); // gui.addButton(new Button(dimension-1, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, SpigotPrison.format("&cClose"))); gui.addButton(sellAllDelayButton); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java index c3669467f..084720e6b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java @@ -65,8 +65,8 @@ public void open() { XMaterial increaseMat = XMaterial.EMERALD_BLOCK; // Decrease button - gui.addButton(new Button(1, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3Delay " + + val + " - 1" ))); - gui.addButton(new Button(10, decreaseMat, 10, changeDecreaseValueLore, SpigotPrison.format("&3Delay " + val + " - 10"))); + gui.addButton(new Button(1, decreaseMat, changeDecreaseValueLore, "&3Delay " + + val + " - 1" )); + gui.addButton(new Button(10, decreaseMat, 10, changeDecreaseValueLore, "&3Delay " + val + " - 10" )); gui.addButton(new Button(19, decreaseMat, changeDecreaseValueLore, "&3Delay " + val + " - 100")); gui.addButton(new Button(28, decreaseMat, changeDecreaseValueLore, "&3Delay " + val + " - 1000")); gui.addButton(new Button(37, decreaseMat, changeDecreaseValueLore, "&3Delay " + val + " - 10000")); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java index 633139fec..b2713ebd3 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java @@ -1,8 +1,9 @@ package tech.mcprison.prison.spigot.gui.sellall; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; -import tech.mcprison.prison.spigot.SpigotPrison; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; @@ -49,22 +50,22 @@ public void open() { XMaterial increaseMat = XMaterial.EMERALD_BLOCK; // Decrease button - gui.addButton(new Button(1, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " - 0.1" ))); - gui.addButton(new Button(10, decreaseMat, 10, changeDecreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " - 0.5"))); - gui.addButton(new Button(19, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " - 1"))); - gui.addButton(new Button(28, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " - 2"))); - gui.addButton(new Button(37, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " - 5"))); + gui.addButton(new Button(1, decreaseMat, changeDecreaseValueLore, "&3" + prestigeName + " " + val + " - 0.1" )); + gui.addButton(new Button(10, decreaseMat, 10, changeDecreaseValueLore, "&3" + prestigeName + " " + val + " - 0.5" )); + gui.addButton(new Button(19, decreaseMat, changeDecreaseValueLore, "&3" + prestigeName + " " + val + " - 1" )); + gui.addButton(new Button(28, decreaseMat, changeDecreaseValueLore, "&3" + prestigeName + " " + val + " - 2" )); + gui.addButton(new Button(37, decreaseMat, changeDecreaseValueLore, "&3" + prestigeName + " " + val + " - 5" )); // Create a button and set the position - gui.addButton(new Button(22, XMaterial.CLOCK, confirmButtonLore, SpigotPrison.format("&3Confirm: " + prestigeName + " " + val))); + gui.addButton(new Button(22, XMaterial.CLOCK, confirmButtonLore, "&3Confirm: " + prestigeName + " " + val )); // Increase button - gui.addButton(new Button(7, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " + 0.1" ))); - gui.addButton(new Button(16, increaseMat, 10, changeIncreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " + 0.5"))); - gui.addButton(new Button(25, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " + 1"))); - gui.addButton(new Button(43, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " + 2"))); - gui.addButton(new Button(54, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + prestigeName + " " + val + " + 5"))); + gui.addButton(new Button(7, increaseMat, changeIncreaseValueLore, "&3" + prestigeName + " " + val + " + 0.1" )); + gui.addButton(new Button(16, increaseMat, 10, changeIncreaseValueLore, "&3" + prestigeName + " " + val + " + 0.5" )); + gui.addButton(new Button(25, increaseMat, changeIncreaseValueLore, "&3" + prestigeName + " " + val + " + 1" )); + gui.addButton(new Button(43, increaseMat, changeIncreaseValueLore, "&3" + prestigeName + " " + val + " + 2" )); + gui.addButton(new Button(54, increaseMat, changeIncreaseValueLore, "&3" + prestigeName + " " + val + " + 5" )); gui.open(); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java index 902a8dbcf..1149a5817 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java @@ -4,8 +4,6 @@ import com.cryptomorin.xseries.XMaterial; -import tech.mcprison.prison.spigot.SpigotPrison; -import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; @@ -41,7 +39,7 @@ public void open() { ButtonLore confirmButtonLore = new ButtonLore(createLore( guiLeftClickToConfirmMsg(), guiRightClickToCancelMsg() ), - createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_price) + " " + val)); + createLore( guiPriceMsg( val ) )); ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); // ButtonLore changeIncreaseValueLore = new ButtonLore( @@ -51,21 +49,21 @@ public void open() { XMaterial increaseMat = XMaterial.EMERALD_BLOCK; // Decrease button - gui.addButton(new Button(1, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " - 1" ))); - gui.addButton(new Button(10, decreaseMat, 10, changeDecreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " - 10"))); - gui.addButton(new Button(19, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " - 100"))); - gui.addButton(new Button(28, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " - 1000"))); - gui.addButton(new Button(37, decreaseMat, changeDecreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " - 10000"))); + gui.addButton(new Button(1, decreaseMat, changeDecreaseValueLore, "&3" + itemID + " " + val + " - 1" )); + gui.addButton(new Button(10, decreaseMat, 10, changeDecreaseValueLore, "&3" + itemID + " " + val + " - 10" )); + gui.addButton(new Button(19, decreaseMat, changeDecreaseValueLore, "&3" + itemID + " " + val + " - 100" )); + gui.addButton(new Button(28, decreaseMat, changeDecreaseValueLore, "&3" + itemID + " " + val + " - 1000" )); + gui.addButton(new Button(37, decreaseMat, changeDecreaseValueLore, "&3" + itemID + " " + val + " - 10000" )); // Create a button and set the position - gui.addButton(new Button(22, XMaterial.TRIPWIRE_HOOK, confirmButtonLore, SpigotPrison.format("&3Confirm: " + itemID + " " + val))); + gui.addButton(new Button(22, XMaterial.TRIPWIRE_HOOK, confirmButtonLore, "&3Confirm: " + itemID + " " + val )); // Increase button - gui.addButton(new Button(7, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " + 1" ))); - gui.addButton(new Button(16, increaseMat, 10, changeIncreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " + 10"))); - gui.addButton(new Button(25, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " + 100"))); - gui.addButton(new Button(34, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " + 1000"))); - gui.addButton(new Button(43, increaseMat, changeIncreaseValueLore, SpigotPrison.format("&3" + itemID + " " + val + " + 10000"))); + gui.addButton(new Button(7, increaseMat, changeIncreaseValueLore, "&3" + itemID + " " + val + " + 1" )); + gui.addButton(new Button(16, increaseMat, 10, changeIncreaseValueLore, "&3" + itemID + " " + val + " + 10" )); + gui.addButton(new Button(25, increaseMat, changeIncreaseValueLore, "&3" + itemID + " " + val + " + 100" )); + gui.addButton(new Button(34, increaseMat, changeIncreaseValueLore, "&3" + itemID + " " + val + " + 1000" )); + gui.addButton(new Button(43, increaseMat, changeIncreaseValueLore, "&3" + itemID + " " + val + " + 10000" )); gui.open(); } 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 4b926e9b4..00d13503a 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 @@ -47,6 +47,7 @@ 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; /** * @author AnonymousGCA (GABRYCA) @@ -683,7 +684,7 @@ private void initCachedData() { 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 = SpigotPrison.format(sellAllConfig.getString("Options.SellAll_Sign_Visible_Tag")); + sellAllSignTag = Text.translateAmpColorCodes(sellAllConfig.getString("Options.SellAll_Sign_Visible_Tag") ); sellAllBlocks = initSellAllBlocks(); sellAllPrestigeMultipliers = initPrestigeMultipliers(); sellAllItemTriggers = initSellAllItemTrigger(); From eb409376b03f44cec3ac1a9a4453f7e1a35a2c9e Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 22 May 2022 11:04:31 -0400 Subject: [PATCH 242/297] More fixes to the gui messages... including moving all of the new gui specific messages out of prison-sellall module to the prison-core module so they will still be accessible if the prison-sellall module is disabled. --- docs/changelog_v3.3.x.md | 5 +- .../prison/gui/PrisonCoreGuiMessages.java | 169 ++++++++++++++++++ .../main/resources/lang/core/de_DE.properties | 42 ++++- .../main/resources/lang/core/en_GB.properties | 43 ++++- .../main/resources/lang/core/en_US.properties | 40 ++++- .../main/resources/lang/core/es_ES.properties | 43 ++++- .../main/resources/lang/core/hu_HU.properties | 43 ++++- .../main/resources/lang/core/it_IT.properties | 45 ++++- .../main/resources/lang/core/nl_BE.properties | 45 ++++- .../main/resources/lang/core/nl_NL.properties | 45 ++++- .../main/resources/lang/core/zh_TW.properties | 45 ++++- .../resources/lang/sellall/en_US.properties | 23 +-- .../messages/SpigotVariousGuiMessages.java | 118 ++---------- .../spigot/backpacks/BackpacksUtil.java | 13 +- .../prison/spigot/configs/MessagesConfig.java | 12 +- .../prison/spigot/gui/SpigotPrisonGUI.java | 8 +- .../gui/backpacks/BackpacksAdminGUI.java | 2 +- .../BackpacksAdminPlayerListGUI.java | 2 +- .../gui/backpacks/BackpacksListPlayerGUI.java | 2 +- .../gui/guiutility/SpigotGUIComponents.java | 4 +- .../spigot/gui/mine/SpigotBlocksListGUI.java | 6 +- .../gui/mine/SpigotBlocksMineListGUI.java | 6 +- .../spigot/gui/mine/SpigotMineInfoGUI.java | 17 +- .../spigot/gui/mine/SpigotMinesBlocksGUI.java | 2 +- .../spigot/gui/rank/SpigotLaddersGUI.java | 2 +- .../spigot/gui/rank/SpigotRankManagerGUI.java | 15 +- .../spigot/gui/sellall/SellAllAdminGUI.java | 14 +- .../SellAllPrestigesMultiplierGUI.java | 27 +-- .../SellAllPrestigesSetMultiplierGUI.java | 6 +- 29 files changed, 642 insertions(+), 202 deletions(-) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/gui/PrisonCoreGuiMessages.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 22fc68c69..416a0ebf1 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11c 2022-05-21 +# 3.3.0-alpha.11c 2022-05-22 + + +* **GUI: More fixes to the gui messages... including moving all of the new gui specific messages out of prison-sellall module to the prison-core module so they will still be accessible if the prison-sellall module is disabled.** * **GUI cleaned up by eliminating so many excessive uses of translating amp color codes to the native color codes.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/gui/PrisonCoreGuiMessages.java b/prison-core/src/main/java/tech/mcprison/prison/gui/PrisonCoreGuiMessages.java new file mode 100644 index 000000000..cd684cc03 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/gui/PrisonCoreGuiMessages.java @@ -0,0 +1,169 @@ +package tech.mcprison.prison.gui; + +import java.text.DecimalFormat; + +import tech.mcprison.prison.Prison; + +public class PrisonCoreGuiMessages { + + + protected String guiClickToDecreaseMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__click_to_decrease" ) + .localize(); + } + protected String guiClickToIncreaseMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__click_to_increase" ) + .localize(); + } + protected String guiClickToEditMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__click_to_edit" ) + .localize(); + } + protected String guiClickToOpenMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__click_to_open" ) + .localize(); + } + + protected String guiLeftClickToConfirmMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__left_click_to_confirm" ) + .localize(); + } + protected String guiLeftClickToResetMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__left_click_to_reset" ) + .localize(); + } + protected String guiLeftClickToOpenMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__left_click_to_open" ) + .localize(); + } + protected String guiLeftClickToEditMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__left_click_to_edit" ) + .localize(); + } + + protected String guiRightClickToCancelMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__right_click_to_cancel" ) + .localize(); + } + protected String guiRightClickToDeleteMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__right_click_to_delete" ) + .localize(); + } + protected String guiRightClickToDisableMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__right_click_to_disable" ) + .localize(); + } + protected String guiRightClickToEnableMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__right_click_to_enable" ) + .localize(); + } + protected String guiRightClickToToggleMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__right_click_to_toggle" ) + .localize(); + } + + + protected String guiRightClickShiftToDeleteMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_delete" ) + .localize(); + } + protected String guiRightClickShiftToDisableMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_disable" ) + .localize(); + } + protected String guiRightClickShiftToToggleMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_toggle" ) + .localize(); + } + + + + protected String guiPageNextMsg() { + + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__page_next" ) + .localize(); + } + protected String guiPagePriorMsg() { + + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__page_prior" ) + .localize(); + } + + + protected String guiPriceMsg( Double price ) { + + DecimalFormat dFmt = new DecimalFormat( "#,##0.00" ); + String value = price == null ? dFmt.format(0) : dFmt.format(price); + + return guiPriceMsg( value ); + } + protected String guiPriceMsg( Integer price ) { + + DecimalFormat dFmt = new DecimalFormat( "#,##0" ); + String value = price == null ? dFmt.format(0) : dFmt.format(price); + + return guiPriceMsg( value ); + } + protected String guiPriceMsg( String price ) { + + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_utils__money_earned" ) + .withReplacements( price ) + .localize(); + } + + + protected String guiConfirmMsg( String prestigeName, double value ) { + + DecimalFormat dFmt = new DecimalFormat( "#,##0.0" ); + String valueStr = dFmt.format(value); + + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__confirm" ) + .withReplacements( prestigeName, valueStr ) + .localize(); + } + + protected String guiMultiplierMsg( double value ) { + + DecimalFormat dFmt = new DecimalFormat( "#,##0.0" ); + String valueStr = dFmt.format(value); + + return guiMultiplierMsg( valueStr ); + } + protected String guiMultiplierMsg( String value ) { + + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__multiplier" ) + .withReplacements( value ) + .localize(); + } + + protected String guiPrestigeNameMsg( String prestigeName ) { + + return Prison.get().getLocaleManager() + .getLocalizable( "sellall_spigot_gui__prestige_name" ) + .withReplacements( prestigeName ) + .localize(); + } + + +} diff --git a/prison-core/src/main/resources/lang/core/de_DE.properties b/prison-core/src/main/resources/lang/core/de_DE.properties index 973ea18a2..217bca79d 100644 --- a/prison-core/src/main/resources/lang/core/de_DE.properties +++ b/prison-core/src/main/resources/lang/core/de_DE.properties @@ -70,7 +70,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -131,4 +131,42 @@ numberRangeError=Der Parameter [%1] muss gleich oder gr tooFewCharacters=Der Parameter [%1] muss gleich oder größer als %2 Zeichen sein. tooManyCharacters=Der Parameter [%1] muss gleich oder kleiner als %2 Zeichen sein. playerNotOnline=Der Spieler %1 ist nicht online. -worldNotFound=Die Welt %1 wurde nicht gefunden. \ No newline at end of file +worldNotFound=Die Welt %1 wurde nicht gefunden. + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/core/en_GB.properties b/prison-core/src/main/resources/lang/core/en_GB.properties index 6c6dd2841..1b1ce12b2 100644 --- a/prison-core/src/main/resources/lang/core/en_GB.properties +++ b/prison-core/src/main/resources/lang/core/en_GB.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -129,3 +129,44 @@ tooFewCharacters=The parameter [%1] must be equal or greater than %2 characters. tooManyCharacters=The parameter [%1] must be equal or less than %2 characters. playerNotOnline=The player %1 is not online. worldNotFound=The world %1 was not found. + + + + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/core/en_US.properties b/prison-core/src/main/resources/lang/core/en_US.properties index af822b085..dd1a97b9e 100644 --- a/prison-core/src/main/resources/lang/core/en_US.properties +++ b/prison-core/src/main/resources/lang/core/en_US.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=6 +messages__version=7 messages__auto_refresh=true @@ -132,3 +132,41 @@ tooFewCharacters=The parameter [%1] must be equal or greater than %2 characters. tooManyCharacters=The parameter [%1] must be equal or less than %2 characters. playerNotOnline=The player %1 is not online. worldNotFound=The world %1 was not found. + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/core/es_ES.properties b/prison-core/src/main/resources/lang/core/es_ES.properties index 674f968e2..c7633d829 100644 --- a/prison-core/src/main/resources/lang/core/es_ES.properties +++ b/prison-core/src/main/resources/lang/core/es_ES.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -129,3 +129,44 @@ tooFewCharacters=El parámetro [%1] debe ser igual o mayor a %2 caracteres. tooManyCharacters=El parámetro [%1] debe ser igual o menor a %2 caracteres. playerNotOnline=El jugador %1 no se encuentra conectado. worldNotFound=El mundo %1 no ha sido encontrado. + + + + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/core/hu_HU.properties b/prison-core/src/main/resources/lang/core/hu_HU.properties index c0048af5b..e6e453261 100644 --- a/prison-core/src/main/resources/lang/core/hu_HU.properties +++ b/prison-core/src/main/resources/lang/core/hu_HU.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -129,3 +129,44 @@ tooFewCharacters=A(z) [%1] paraméternek egyenlÅ‘nek vagy nagyobbnak kell lennie tooManyCharacters=A(z) [%1] paraméternek egyenlÅ‘nek vagy kisebbnek kell lennie, mint %2 karakter. playerNotOnline=A(z) %1 játékos nem online. worldNotFound=A(z) %1 világ nem található. + + + + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/core/it_IT.properties b/prison-core/src/main/resources/lang/core/it_IT.properties index e9683998c..a9721af90 100644 --- a/prison-core/src/main/resources/lang/core/it_IT.properties +++ b/prison-core/src/main/resources/lang/core/it_IT.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -128,4 +128,45 @@ numberRangeError=Il parametro [%1] deve essere uguale o maggiore di %2 e minore tooFewCharacters=Il parametro [%1] deve essere uguale o maggiore di %2 caratteri. tooManyCharacters=Il parametro [%1] deve essere uguale o minore di %2 caratteri. playerNotOnline=IL player %1 non è online. -worldNotFound=Il mondo %1 non è stato trovato. \ No newline at end of file +worldNotFound=Il mondo %1 non è stato trovato. + + + + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/core/nl_BE.properties b/prison-core/src/main/resources/lang/core/nl_BE.properties index 96b319250..ab01ed187 100644 --- a/prison-core/src/main/resources/lang/core/nl_BE.properties +++ b/prison-core/src/main/resources/lang/core/nl_BE.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -128,4 +128,45 @@ numberRangeError=De parameter [%1] moet gelijk of groter zijn dan %2 en kleiner tooFewCharacters=De parameter [%1] moet gelijk of groter zijn dan %2 charters. tooManyCharacters=De parameter [%1] moet gelijk of kleiner zijn dan %2 character. playerNotOnline=De speler %1 is niet online. -worldNotFound=De wereld %1 kon niet worden gevonden. \ No newline at end of file +worldNotFound=De wereld %1 kon niet worden gevonden. + + + + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/core/nl_NL.properties b/prison-core/src/main/resources/lang/core/nl_NL.properties index 96b319250..ab01ed187 100644 --- a/prison-core/src/main/resources/lang/core/nl_NL.properties +++ b/prison-core/src/main/resources/lang/core/nl_NL.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -128,4 +128,45 @@ numberRangeError=De parameter [%1] moet gelijk of groter zijn dan %2 en kleiner tooFewCharacters=De parameter [%1] moet gelijk of groter zijn dan %2 charters. tooManyCharacters=De parameter [%1] moet gelijk of kleiner zijn dan %2 character. playerNotOnline=De speler %1 is niet online. -worldNotFound=De wereld %1 kon niet worden gevonden. \ No newline at end of file +worldNotFound=De wereld %1 kon niet worden gevonden. + + + + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/core/zh_TW.properties b/prison-core/src/main/resources/lang/core/zh_TW.properties index 50ebe74b2..a5da3ad22 100644 --- a/prison-core/src/main/resources/lang/core/zh_TW.properties +++ b/prison-core/src/main/resources/lang/core/zh_TW.properties @@ -67,7 +67,7 @@ # like to share, please contact a staff member on our Discord server. #Thanks for your contributions! # -messages__version=5 +messages__version=6 messages__auto_refresh=true @@ -127,3 +127,46 @@ tooFewCharacters=åƒæ•¸ [%1] 必須等於或大於 %2 人物 tooManyCharacters=åƒæ•¸ [%1] 必須等於或å°æ–¼ %2 人物 playerNotOnline=玩家 %1 並未線上 worldNotFound=世界 %1 無法找到 + + + + + + + + + + +core_gui__click_to_decrease=&3Click to decrease. +core_gui__click_to_increase=&3Click to increase. +core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_open=&3Click to open. + + +core_gui__left_click_to_confirm=&3Left-Click to confirm. +core_gui__left_click_to_reset=&3Left-Click to reset. +core_gui__left_click_to_open=&3Left-Click to open. +core_gui__left_click_to_edit=&3Left-Click to edit. + + +core_gui__right_click_to_cancel=&3Right-Click to cancel. +core_gui__right_click_to_delete=&3Right-Click to delete. +core_gui__right_click_to_disable=&3Right-Click to disable. +core_gui__right_click_to_enable=&3Right-Click to enable. +core_gui__right_click_to_toggle=&3Right-Click to toggle. + + +core_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. +core_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. +core_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. + + +core_gui__page_next=&3Next page. +core_gui__page_prior=&3Prior page. + + +core_gui__price=&3Price: %1 +core_gui__confirm=&3Confirm: %1 %2 +core_gui__multiplier=&3Multiplier: x %1 +core_gui__prestige_name=&3Prestige name: %1 + diff --git a/prison-core/src/main/resources/lang/sellall/en_US.properties b/prison-core/src/main/resources/lang/sellall/en_US.properties index 0d498fe8b..462b2f242 100644 --- a/prison-core/src/main/resources/lang/sellall/en_US.properties +++ b/prison-core/src/main/resources/lang/sellall/en_US.properties @@ -56,28 +56,6 @@ messages__auto_refresh=true sellall_function__message=&dSample &7Message -sellall_spigot_gui__click_to_decrease=&3Click to decrease. -sellall_spigot_gui__click_to_increase=&3Click to increase. - -sellall_spigot_gui__left_click_to_confirm=&3Left-Click to confirm. -sellall_spigot_gui__left_click_to_reset=&3Left-Click to reset. -sellall_spigot_gui__left_click_to_open=&3Left-Click to open. -sellall_spigot_gui__left_click_to_edit=&3Left-Click to edit. - -sellall_spigot_gui__right_click_to_cancel=&3Right-Click to cancel. -sellall_spigot_gui__right_click_to_delete=&3Right-Click to delete. -sellall_spigot_gui__right_click_to_disable=&3Right-Click to disable. -sellall_spigot_gui__right_click_to_enable=&3Right-Click to enable. -sellall_spigot_gui__right_click_to_toggle=&3Right-Click to toggle. - -sellall_spigot_gui__right_click_and_shift_to_delete=&3Right-Click and shift to delete. -sellall_spigot_gui__right_click_and_shift_to_disable=&3Right-Click and shift to disable. -sellall_spigot_gui__right_click_and_shift_to_toggle=&3Right-Click and shift to toggle. - - -sellall_spigot_gui__price=&3Price: %1 - - sellall_spigot_utils__money_earned=&3You earned &a$%1 sellall_spigot_utils__only_sellall_signs_are_enabled=&3You can only sell through signs. The command is disabled. @@ -85,3 +63,4 @@ sellall_spigot_utils__rate_limit_exceeded=&3Slow down. Usage rate limit has been sellall_spigot_utils__shop_is_empty=&3Sorry, this sellall shop is empty. sellall_spigot_utils__you_have_nothing_to_sell=&3Sorry, you have nothing to sell. + diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java index 10e27f106..65c9bcb1e 100644 --- a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java @@ -1,9 +1,7 @@ package tech.mcprison.prison.sellall.messages; -import java.text.DecimalFormat; - +import tech.mcprison.prison.gui.PrisonCoreGuiMessages; import tech.mcprison.prison.internal.CommandSender; -import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.sellall.PrisonSellall; /** @@ -18,7 +16,11 @@ * core project's resources: 'lang/sellall/'. * */ -public class SpigotVariousGuiMessages { +public class SpigotVariousGuiMessages + extends PrisonCoreGuiMessages { + + + // This does nothing. Used as an example until real messages can be added. protected String prisonSellallTest01Msg() { @@ -60,129 +62,29 @@ protected String sellallAmountEarnedMsg( String earningsAmount ) { } protected void sellallCanOnlyUseSignsMsg( CommandSender sender ) { - PrisonRanks.getInstance().getRanksMessages() + PrisonSellall.getInstance().getSellallMessages() .getLocalizable( "sellall_spigot_utils__only_sellall_signs_are_enabled" ) .sendTo( sender ); } protected void sellallRateLimitExceededMsg( CommandSender sender ) { - PrisonRanks.getInstance().getRanksMessages() + PrisonSellall.getInstance().getSellallMessages() .getLocalizable( "sellall_spigot_utils__rate_limit_exceeded" ) .sendTo( sender ); } protected void sellallShopIsEmptyMsg( CommandSender sender ) { - PrisonRanks.getInstance().getRanksMessages() + PrisonSellall.getInstance().getSellallMessages() .getLocalizable( "sellall_spigot_utils__shop_is_empty" ) .sendTo( sender ); } protected void sellallYouHaveNothingToSellMsg( CommandSender sender ) { - PrisonRanks.getInstance().getRanksMessages() + PrisonSellall.getInstance().getSellallMessages() .getLocalizable( "sellall_spigot_utils__you_have_nothing_to_sell" ) .sendTo( sender ); } - protected String guiClickToDecreaseMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__click_to_decrease" ) - .localize(); - } - - protected String guiClickToIncreaseMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__click_to_increase" ) - .localize(); - } - - protected String guiLeftClickToConfirmMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__left_click_to_confirm" ) - .localize(); - } - protected String guiLeftClickToResetMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__left_click_to_reset" ) - .localize(); - } - protected String guiLeftClickToOpenMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__left_click_to_open" ) - .localize(); - } - protected String guiLeftClickToEditMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__left_click_to_edit" ) - .localize(); - } - - protected String guiRightClickToCancelMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__right_click_to_cancel" ) - .localize(); - } - protected String guiRightClickToDeleteMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__right_click_to_delete" ) - .localize(); - } - protected String guiRightClickToDisableMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__right_click_to_disable" ) - .localize(); - } - protected String guiRightClickToEnableMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__right_click_to_enable" ) - .localize(); - } - protected String guiRightClickToToggleMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__right_click_to_toggle" ) - .localize(); - } - - - protected String guiRightClickShiftToDeleteMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_delete" ) - .localize(); - } - protected String guiRightClickShiftToDisableMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_disable" ) - .localize(); - } - protected String guiRightClickShiftToToggleMsg() { - return PrisonRanks.getInstance().getRanksMessages() - .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_toggle" ) - .localize(); - } - - - - protected String guiPriceMsg( Double price ) { - - DecimalFormat dFmt = new DecimalFormat( "#,##0.00" ); - String value = price == null ? dFmt.format(0) : dFmt.format(price); - - return guiPriceMsg( value ); - } - protected String guiPriceMsg( Integer price ) { - - DecimalFormat dFmt = new DecimalFormat( "#,##0" ); - String value = price == null ? dFmt.format(0) : dFmt.format(price); - - return guiPriceMsg( value ); - } - protected String guiPriceMsg( String price ) { - - return PrisonSellall.getInstance().getSellallMessages() - .getLocalizable( "sellall_spigot_utils__money_earned" ) - .withReplacements( price ) - .localize(); - } - } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksUtil.java index d882bb4ed..97542afce 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksUtil.java @@ -22,18 +22,19 @@ import com.cryptomorin.xseries.XMaterial; import tech.mcprison.prison.Prison; +import tech.mcprison.prison.gui.PrisonCoreGuiMessages; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.SpigotUtil; import tech.mcprison.prison.spigot.compat.Compatibility; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; import tech.mcprison.prison.spigot.configs.BackpacksConfig; -import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; /** * @author GABRYCA * */ -public class BackpacksUtil { +public class BackpacksUtil + extends PrisonCoreGuiMessages { private static BackpacksUtil instance; private Configuration backpacksConfig = SpigotPrison.getInstance().getBackpacksConfig(); @@ -69,9 +70,9 @@ public boolean isMultipleBackpacksEnabled(){ return getBoolean(backpacksConfig.getString("Options.Multiple-BackPacks-For-Player-Enabled")); } - private void backpacksConfigUpdater(){ - backpackConfigUpdater(); - } +// private void backpacksConfigUpdater(){ +// backpackConfigUpdater(); +// } public void removeFromOpenBackpacks(Player p){ openBackpacks.remove(p.getName()); @@ -1281,7 +1282,7 @@ private void backPackItem(Player p) { ItemStack item; List itemLore = createLore( - SpigotPrison.getInstance().getMessagesConfig().getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open) + guiClickToOpenMsg() ); item = createButton(SpigotUtil.getXMaterial(backpacksConfig.getString("Options.BackPack_Item")).parseItem(), itemLore, backpacksConfig.getString("Options.BackPack_Item_Title")); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java index e89a21b47..e3d3f46ea 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java @@ -129,11 +129,11 @@ public enum StringID { // spigot_gui_lore_click_to_decrease, spigot_gui_lore_click_to_delete, spigot_gui_lore_click_to_disable, - spigot_gui_lore_click_to_edit, +// spigot_gui_lore_click_to_edit, spigot_gui_lore_click_to_enable, // spigot_gui_lore_click_to_increase, spigot_gui_lore_click_to_manage_rank, - spigot_gui_lore_click_to_open, +// spigot_gui_lore_click_to_open, spigot_gui_lore_click_to_rankup, spigot_gui_lore_click_to_rename, spigot_gui_lore_click_to_select, @@ -166,13 +166,13 @@ public enum StringID { spigot_gui_lore_id, spigot_gui_lore_info, spigot_gui_lore_minename, - spigot_gui_lore_multiplier, +// spigot_gui_lore_multiplier, spigot_gui_lore_name, spigot_gui_lore_owner, spigot_gui_lore_percentage, spigot_gui_lore_permission, spigot_gui_lore_players_at_rank, - spigot_gui_lore_prestige_name, +// spigot_gui_lore_prestige_name, // spigot_gui_lore_price, spigot_gui_lore_radius, spigot_gui_lore_rank_tag, @@ -187,8 +187,8 @@ public enum StringID { spigot_gui_lore_disabled, spigot_gui_lore_enabled, spigot_gui_lore_locked, - spigot_gui_lore_next_page, - spigot_gui_lore_prior_page, +// spigot_gui_lore_next_page, +// spigot_gui_lore_prior_page, spigot_gui_lore_rankup, spigot_gui_lore_selected, spigot_gui_lore_unlocked, diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java index af8ac26dc..b6504198b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java @@ -36,10 +36,10 @@ public void open() { PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3PrisonManager"); // Create and add buttons. - gui.addButton(new Button(10, XMaterial.TRIPWIRE_HOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_button_description)), "&3Ranks - Ladders" )); - gui.addButton(new Button(13, XMaterial.IRON_PICKAXE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_autofeatures_button_description)), "&3AutoManager" )); - gui.addButton(new Button(16, XMaterial.DIAMOND_ORE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_mines_button_description)), "&3Mines" )); - gui.addButton(new Button(29, XMaterial.CHEST, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_button_description)), "&3SellAll" )); + gui.addButton(new Button(10, XMaterial.TRIPWIRE_HOOK, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_button_description)), "&3Ranks - Ladders" )); + gui.addButton(new Button(13, XMaterial.IRON_PICKAXE, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_autofeatures_button_description)), "&3AutoManager" )); + gui.addButton(new Button(16, XMaterial.DIAMOND_ORE, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_mines_button_description)), "&3Mines" )); + gui.addButton(new Button(29, XMaterial.CHEST, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_button_description)), "&3SellAll" )); // gui.addButton(new Button(33, XMaterial.CHEST_MINECART, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_backpacks_button_description)), "&3Backpacks" )); // gui.addButton(new Button(44, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), "&cClose")); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminGUI.java index 107aef8dd..d6d522731 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminGUI.java @@ -33,7 +33,7 @@ public void open(){ int dimension = 27; PrisonGUI gui = new PrisonGUI(p, dimension, "&3Backpacks-Admin"); - ButtonLore lore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), null); + ButtonLore lore = new ButtonLore( guiLeftClickToOpenMsg(), null); gui.addButton(new Button(11, XMaterial.CHEST, lore, "&3Backpacks-List")); gui.addButton(new Button(15, XMaterial.PAPER, lore, "&3Backpack-Settings")); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminPlayerListGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminPlayerListGUI.java index d536adef9..a14bb2889 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminPlayerListGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminPlayerListGUI.java @@ -21,7 +21,7 @@ public class BackpacksAdminPlayerListGUI extends SpigotGUIComponents { private final Player p; private final Configuration backpacksData = BackpacksUtil.get().getBackpacksData(); - private final String clickToOpen = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open); + private final String clickToOpen = guiLeftClickToOpenMsg(); public BackpacksAdminPlayerListGUI(Player p){ this.p = p; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java index cdd959754..8e58e9c4d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java @@ -40,7 +40,7 @@ public void open(){ messages.getString(MessagesConfig.StringID.spigot_gui_lore_add_backpack_instruction_3))); // Global Strings. - String loreClickToOpen = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open); + String loreClickToOpen = guiLeftClickToOpenMsg(); if (!BackpacksUtil.get().getBackpacksIDs(p).isEmpty()) { int slot = 0; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java index 74be7976d..275aa48f0 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java @@ -17,10 +17,10 @@ import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper; +import tech.mcprison.prison.gui.PrisonCoreGuiMessages; import tech.mcprison.prison.modules.Module; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; -import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages; import tech.mcprison.prison.spigot.SpigotPrison; import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; @@ -33,7 +33,7 @@ * @author GABRYCA */ public abstract class SpigotGUIComponents - extends SpigotVariousGuiMessages { + extends PrisonCoreGuiMessages { public static MessagesConfig messages = getMessages(); public static Configuration guiConfig = getGuiConfig(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksListGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksListGUI.java index e9e49b0cd..a8980a93b 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksListGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksListGUI.java @@ -64,10 +64,12 @@ public void open(){ prisonBlock.getBlockName().toUpperCase() + " &0" + mineName + " " + counter)); } if ( i < blockTypes.size() ) { - gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_next_page), null), "&7Next &0" + mineName + " " + (i + 1))); + gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore( + guiPageNextMsg(), null), "&7Next &0" + mineName + " " + (i + 1))); } if ( i >= (pageSize * 2) ) { - gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_prior_page), null), "&7Prior &0" + mineName + " " + (i - (pageSize * 2) - 1))); + gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore( + guiPagePriorMsg(), null), "&7Prior &0" + mineName + " " + (i - (pageSize * 2) - 1))); } // Open the inventory diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksMineListGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksMineListGUI.java index 32abe6b10..039035bd3 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksMineListGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksMineListGUI.java @@ -62,10 +62,12 @@ public void open(){ prisonBlock.getBlockName().toUpperCase() + " " + mineName + " " + counter)); } if ( i < blockTypes.size() ) { - gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_next_page), null), "&7Next " + mineName + " " + (i + 1))); + gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore( + guiPageNextMsg(), null), "&7Next " + mineName + " " + (i + 1))); } if ( i >= (pageSize * 2) ) { - gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_prior_page), null), "&7Prior " + mineName + " " + (i - (pageSize * 2) - 1))); + gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore( + guiPagePriorMsg(), null), "&7Prior " + mineName + " " + (i - (pageSize * 2) - 1))); } // Open the inventory diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java index 9779b17d2..e4d5dc642 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineInfoGUI.java @@ -52,11 +52,19 @@ public void open(){ messages.getString(MessagesConfig.StringID.spigot_gui_lore_set_mine_delay_instruction_3))); ButtonLore mineSpawnLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_use), messages.getString(MessagesConfig.StringID.spigot_gui_lore_spawnpoint)); - ButtonLore minesNotificationsLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit)); + + ButtonLore minesNotificationsLore = new ButtonLore( guiClickToOpenMsg(), guiClickToEditMsg() ); + ButtonLore minesTpLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_teleport), messages.getString(MessagesConfig.StringID.spigot_gui_lore_tp_to_mine)); - ButtonLore blocksOfTheMineLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_blocks)); - ButtonLore mineResetTimeLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open)), createLore( + + ButtonLore blocksOfTheMineLore = new ButtonLore( + guiClickToOpenMsg(), + messages.getString(MessagesConfig.StringID.spigot_gui_lore_blocks)); + + ButtonLore mineResetTimeLore = new ButtonLore(createLore( guiClickToOpenMsg() ), + createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_reset_time) + " &7" + mine.getResetTime())); + ButtonLore mineRenameLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_rename), messages.getString(MessagesConfig.StringID.spigot_gui_lore_minename) + " " + mineName); // ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); @@ -81,7 +89,8 @@ public void open(){ } // Lore - ButtonLore mineShowItemLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit)), createLore( + ButtonLore mineShowItemLore = new ButtonLore(createLore( guiClickToEditMsg() ), + createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_show_item) + " &7" + xMaterial.name(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_show_item_description_1), messages.getString(MessagesConfig.StringID.spigot_gui_lore_show_item_description_2), diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java index c2b15dc7c..96f6bd971 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java @@ -25,7 +25,7 @@ public class SpigotMinesBlocksGUI extends SpigotGUIComponents { // Global Strings. private final String loreShiftRightClickToDelete = guiRightClickShiftToDeleteMsg(); - private final String loreClickToEditBlock = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit); + private final String loreClickToEditBlock = guiClickToEditMsg(); private final String loreInfo = messages.getString(MessagesConfig.StringID.spigot_gui_lore_info); private final String loreChance = messages.getString(MessagesConfig.StringID.spigot_gui_lore_chance); private final String loreBlockType = messages.getString(MessagesConfig.StringID.spigot_gui_lore_blocktype); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java index 8e7f4ab2d..5db020331 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java @@ -77,7 +77,7 @@ public void open(){ PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3RanksManager -> Ladders"); ButtonLore laddersLore = new ButtonLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), + guiLeftClickToOpenMsg(), guiRightClickShiftToDeleteMsg() ); for ( RankLadder ladder : laddersDisplay ) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java index da36a57c0..373055711 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java @@ -42,7 +42,7 @@ public void open() { int dimension = 27; PrisonGUI gui = new PrisonGUI(p, dimension, "&3Ranks -> RankManager"); - ButtonLore rankupCommandsLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), null); + ButtonLore rankupCommandsLore = new ButtonLore( guiLeftClickToOpenMsg(), null); // Decimal Rank cost format. DecimalFormat formatDecimal = new DecimalFormat("###,##0.00"); @@ -60,13 +60,16 @@ public void open() { rankCost = "Unavailable"; } - ButtonLore editPriceLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open)), createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_info), + ButtonLore editPriceLore = new ButtonLore( + createLore( guiLeftClickToOpenMsg()), + createLore( + messages.getString(MessagesConfig.StringID.spigot_gui_lore_info), guiPriceMsg( rankCost) )); - ButtonLore editTagLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open)), createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_info), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_rank_tag) + " " + rank.getTag())); + ButtonLore editTagLore = new ButtonLore(createLore( guiLeftClickToOpenMsg() ), + createLore( + messages.getString(MessagesConfig.StringID.spigot_gui_lore_info), + messages.getString(MessagesConfig.StringID.spigot_gui_lore_rank_tag) + " " + rank.getTag())); ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java index cbd2728ad..6931bdb69 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java @@ -56,12 +56,13 @@ public void open() { PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3Prison -> SellAll-Admin"); - ButtonLore blocksLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), null); + ButtonLore blocksLore = new ButtonLore( guiClickToOpenMsg(), null); // ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); - ButtonLore setCurrencyLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit)), createLore( + ButtonLore setCurrencyLore = new ButtonLore(createLore( guiClickToEditMsg() ), + createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_currency) + " " + sellAllConfig.getString("Options.SellAll_Currency"), - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit))); - ButtonLore multipliersLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit)); + guiClickToEditMsg() )); + ButtonLore multipliersLore = new ButtonLore( guiClickToOpenMsg(), guiClickToEditMsg() ); ButtonLore autoSellLore = new ButtonLore(); ButtonLore sellAllDelayLore = new ButtonLore(); @@ -69,8 +70,7 @@ public void open() { Button sellAllDelayButton; if (sellAllConfig.getString("Options.Full_Inv_AutoSell").equalsIgnoreCase("true")){ - autoSellLore.setLoreAction(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), + autoSellLore.setLoreAction(createLore( guiClickToOpenMsg(), guiRightClickToDisableMsg() )); @@ -84,7 +84,7 @@ public void open() { if (sellAllConfig.getString("Options.Sell_Delay_Enabled").equalsIgnoreCase("true")){ sellAllDelayLore.setLoreAction(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), + guiClickToOpenMsg(), guiRightClickToCancelMsg())); sellAllDelayLore.setLoreDescription(createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_delay) + " " + sellAllConfig.getString("Options.Sell_Delay_Seconds") + "s", diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java index 5f1d6a647..95327e8ae 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java @@ -32,9 +32,9 @@ public void open() { int pageSize = 45; // Global strings. - String lorePrestigeName = messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_name); - String lorePrestigeMultiplier = messages.getString(MessagesConfig.StringID.spigot_gui_lore_multiplier); - String loreClickToEdit = messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_edit); +// String lorePrestigeName = messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_name); +// String lorePrestigeMultiplier = messages.getString(MessagesConfig.StringID.spigot_gui_lore_multiplier); + String loreClickToEdit = guiClickToEditMsg(); String loreClickToDelete = guiRightClickToDeleteMsg(); // Only loop over the blocks that we need to show: @@ -46,11 +46,16 @@ public void open() { if (flagValue == i) { - ButtonLore loreMult = new ButtonLore(createLore( - loreClickToEdit, - loreClickToDelete), createLore( - lorePrestigeName + " " + sellAllConfig.getString("Multiplier." + prestige + ".PRESTIGE_NAME"), - lorePrestigeMultiplier + " " + sellAllConfig.getString("Multiplier." + prestige + ".MULTIPLIER"))); + String multPrestigeName = sellAllConfig.getString("Multiplier." + prestige + ".PRESTIGE_NAME"); + String multPrestigeMultiplier = sellAllConfig.getString("Multiplier." + prestige + ".MULTIPLIER"); + + ButtonLore loreMult = new ButtonLore( + createLore( + loreClickToEdit, + loreClickToDelete), + createLore( + guiPrestigeNameMsg( multPrestigeName ), + guiMultiplierMsg( multPrestigeMultiplier ) )); gui.addButton(new Button(null, XMaterial.PAPER, loreMult, sellAllConfig.getString("Multiplier." + prestige + ".PRESTIGE_NAME"))); } @@ -59,10 +64,12 @@ public void open() { } if (i < sellAllConfig.getConfigurationSection("Multiplier").getKeys(false).size()) { - gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_next_page), null), "&7Next " + (i + 1))); + gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore( + guiPageNextMsg(), null), "&7Next " + (i + 1))); } if (i >= (pageSize * 2)) { - gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_prior_page), null), "&7Prior " + (i - (pageSize * 2) - 1))); + gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore( + guiPagePriorMsg(), null), "&7Prior " + (i - (pageSize * 2) - 1))); } gui.open(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java index b2713ebd3..5df4b43dd 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java @@ -4,7 +4,6 @@ import com.cryptomorin.xseries.XMaterial; -import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; @@ -39,8 +38,7 @@ public void open() { ButtonLore confirmButtonLore = new ButtonLore(createLore( guiLeftClickToConfirmMsg(), guiRightClickToCancelMsg() ), - createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_multiplier) + " " + "x" + val)); + createLore( guiMultiplierMsg( val ) )); ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); // ButtonLore changeIncreaseValueLore = new ButtonLore( @@ -58,7 +56,7 @@ public void open() { // Create a button and set the position - gui.addButton(new Button(22, XMaterial.CLOCK, confirmButtonLore, "&3Confirm: " + prestigeName + " " + val )); + gui.addButton(new Button(22, XMaterial.CLOCK, confirmButtonLore, guiConfirmMsg( prestigeName, val ) )); // Increase button gui.addButton(new Button(7, increaseMat, changeIncreaseValueLore, "&3" + prestigeName + " " + val + " + 0.1" )); From 7e90f4149dac6393d9798ff3a906f72327d23902 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 22 May 2022 18:20:08 -0400 Subject: [PATCH 243/297] GUI messages: a few more updates and corrections --- docs/changelog_v3.3.x.md | 3 + .../prison/gui/PrisonCoreGuiMessages.java | 105 ++++++++++++++---- .../main/resources/lang/core/en_US.properties | 11 ++ .../resources/lang/sellall/en_US.properties | 1 + .../resources/lang/spigot/en_US.properties | 72 ++++++------ .../messages/SpigotVariousGuiMessages.java | 8 +- .../commands/PrisonSpigotSellAllCommands.java | 6 +- .../prison/spigot/configs/MessagesConfig.java | 20 ++-- .../prison/spigot/gui/PrisonSetupGUI.java | 6 +- .../gui/autofeatures/SpigotAutoBlockGUI.java | 4 +- .../autofeatures/SpigotAutoFeaturesGUI.java | 2 +- .../gui/autofeatures/SpigotAutoPickupGUI.java | 3 +- .../gui/autofeatures/SpigotAutoSmeltGUI.java | 3 +- .../gui/backpacks/BackpacksAdminGUI.java | 3 +- .../gui/backpacks/BackpacksListPlayerGUI.java | 3 +- .../mine/SpigotMineBlockPercentageGUI.java | 5 +- .../gui/mine/SpigotMineNotificationsGUI.java | 2 +- .../gui/mine/SpigotMinesConfirmGUI.java | 9 +- .../gui/rank/SpigotConfirmPrestigeGUI.java | 5 +- .../spigot/gui/rank/SpigotRankManagerGUI.java | 2 +- .../gui/sellall/SellAllAdminAutoSellGUI.java | 11 +- .../gui/sellall/SellAllAdminBlocksGUI.java | 25 +++-- .../spigot/gui/sellall/SellAllAdminGUI.java | 15 ++- .../spigot/gui/sellall/SellAllDelayGUI.java | 5 +- .../spigot/gui/sellall/SellAllPlayerGUI.java | 22 +++- .../SellAllPrestigesMultiplierGUI.java | 5 +- 26 files changed, 238 insertions(+), 118 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 416a0ebf1..305f3d387 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11c 2022-05-22 +* **GUI messages: a few more updates and corrections** + + * **GUI: More fixes to the gui messages... including moving all of the new gui specific messages out of prison-sellall module to the prison-core module so they will still be accessible if the prison-sellall module is disabled.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/gui/PrisonCoreGuiMessages.java b/prison-core/src/main/java/tech/mcprison/prison/gui/PrisonCoreGuiMessages.java index cd684cc03..ad76ce684 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/gui/PrisonCoreGuiMessages.java +++ b/prison-core/src/main/java/tech/mcprison/prison/gui/PrisonCoreGuiMessages.java @@ -9,86 +9,118 @@ public class PrisonCoreGuiMessages { protected String guiClickToDecreaseMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__click_to_decrease" ) + .getLocalizable( "core_gui__click_to_decrease" ) .localize(); } protected String guiClickToIncreaseMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__click_to_increase" ) + .getLocalizable( "core_gui__click_to_increase" ) + .localize(); + } + + + protected String guiClickToCancelMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__click_to_cancel" ) + .localize(); + } + protected String guiClickToCloseMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__click_to_close" ) + .localize(); + } + protected String guiClickToConfirmMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__click_to_confirm" ) + .localize(); + } + protected String guiClickToDeleteMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__click_to_delete" ) + .localize(); + } + protected String guiClickToDisableMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__click_to_disable" ) .localize(); } protected String guiClickToEditMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__click_to_edit" ) + .getLocalizable( "core_gui__click_to_edit" ) + .localize(); + } + protected String guiClickToEnableMsg() { + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__click_to_enable" ) .localize(); } protected String guiClickToOpenMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__click_to_open" ) + .getLocalizable( "core_gui__click_to_open" ) .localize(); } protected String guiLeftClickToConfirmMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__left_click_to_confirm" ) + .getLocalizable( "core_gui__left_click_to_confirm" ) .localize(); } protected String guiLeftClickToResetMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__left_click_to_reset" ) + .getLocalizable( "core_gui__left_click_to_reset" ) .localize(); } protected String guiLeftClickToOpenMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__left_click_to_open" ) + .getLocalizable( "core_gui__left_click_to_open" ) .localize(); } protected String guiLeftClickToEditMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__left_click_to_edit" ) + .getLocalizable( "core_gui__left_click_to_edit" ) .localize(); } protected String guiRightClickToCancelMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__right_click_to_cancel" ) + .getLocalizable( "core_gui__right_click_to_cancel" ) .localize(); } protected String guiRightClickToDeleteMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__right_click_to_delete" ) + .getLocalizable( "core_gui__right_click_to_delete" ) .localize(); } protected String guiRightClickToDisableMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__right_click_to_disable" ) + .getLocalizable( "core_gui__right_click_to_disable" ) .localize(); } protected String guiRightClickToEnableMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__right_click_to_enable" ) + .getLocalizable( "core_gui__right_click_to_enable" ) .localize(); } protected String guiRightClickToToggleMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__right_click_to_toggle" ) + .getLocalizable( "core_gui__right_click_to_toggle" ) .localize(); } protected String guiRightClickShiftToDeleteMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_delete" ) + .getLocalizable( "core_gui__right_click_and_shift_to_delete" ) .localize(); } protected String guiRightClickShiftToDisableMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_disable" ) + .getLocalizable( "core_gui__right_click_and_shift_to_disable" ) .localize(); } protected String guiRightClickShiftToToggleMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__right_click_and_shift_to_toggle" ) + .getLocalizable( "core_gui__right_click_and_shift_to_toggle" ) .localize(); } @@ -97,13 +129,13 @@ protected String guiRightClickShiftToToggleMsg() { protected String guiPageNextMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__page_next" ) + .getLocalizable( "core_gui__page_next" ) .localize(); } protected String guiPagePriorMsg() { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__page_prior" ) + .getLocalizable( "core_gui__page_prior" ) .localize(); } @@ -137,11 +169,26 @@ protected String guiConfirmMsg( String prestigeName, double value ) { String valueStr = dFmt.format(value); return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__confirm" ) + .getLocalizable( "core_gui__confirm" ) .withReplacements( prestigeName, valueStr ) .localize(); } + + protected String guiDelayMsg( int value ) { + DecimalFormat dFmt = new DecimalFormat( "#,##0" ); + String valueStr = dFmt.format(value); + + return guiDelayMsg( valueStr ); + } + protected String guiDelayMsg( String value ) { + + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__delay" ) + .withReplacements( value ) + .localize(); + } + protected String guiMultiplierMsg( double value ) { DecimalFormat dFmt = new DecimalFormat( "#,##0.0" ); @@ -152,15 +199,31 @@ protected String guiMultiplierMsg( double value ) { protected String guiMultiplierMsg( String value ) { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__multiplier" ) + .getLocalizable( "core_gui__multiplier" ) .withReplacements( value ) .localize(); } + protected String guiValueMsg( String value ) { + + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__value" ) + .withReplacements( value ) + .localize(); + } + + protected String guiPermissionMsg( String prestigeName ) { + + return Prison.get().getLocaleManager() + .getLocalizable( "core_gui__puermission" ) + .withReplacements( prestigeName ) + .localize(); + } + protected String guiPrestigeNameMsg( String prestigeName ) { return Prison.get().getLocaleManager() - .getLocalizable( "sellall_spigot_gui__prestige_name" ) + .getLocalizable( "core_gui__prestige_name" ) .withReplacements( prestigeName ) .localize(); } diff --git a/prison-core/src/main/resources/lang/core/en_US.properties b/prison-core/src/main/resources/lang/core/en_US.properties index dd1a97b9e..0e19b2347 100644 --- a/prison-core/src/main/resources/lang/core/en_US.properties +++ b/prison-core/src/main/resources/lang/core/en_US.properties @@ -139,7 +139,15 @@ worldNotFound=The world %1 was not found. core_gui__click_to_decrease=&3Click to decrease. core_gui__click_to_increase=&3Click to increase. + + +core_gui__click_to_cancel=&3Click to cancel. +core_gui__click_to_close=&3Click to close. +core_gui__click_to_confirm=&3Click to confirm. +core_gui__click_to_delete=&3Click to delete. +core_gui__click_to_disable=&3Click to disable. core_gui__click_to_edit=&3Click to edit. +core_gui__click_to_enable=&3Click to enable. core_gui__click_to_open=&3Click to open. @@ -167,6 +175,9 @@ core_gui__page_prior=&3Prior page. core_gui__price=&3Price: %1 core_gui__confirm=&3Confirm: %1 %2 +core_gui__delay=&3Delay: %1 secs core_gui__multiplier=&3Multiplier: x %1 +core_gui__value=&3Value: %1 +core_gui__permission=&3Permission: &7%1 core_gui__prestige_name=&3Prestige name: %1 diff --git a/prison-core/src/main/resources/lang/sellall/en_US.properties b/prison-core/src/main/resources/lang/sellall/en_US.properties index 462b2f242..bf07f4ee0 100644 --- a/prison-core/src/main/resources/lang/sellall/en_US.properties +++ b/prison-core/src/main/resources/lang/sellall/en_US.properties @@ -63,4 +63,5 @@ sellall_spigot_utils__rate_limit_exceeded=&3Slow down. Usage rate limit has been sellall_spigot_utils__shop_is_empty=&3Sorry, this sellall shop is empty. sellall_spigot_utils__you_have_nothing_to_sell=&3Sorry, you have nothing to sell. +sellall_spigot_utils__sellall_is_disabled=&3Sorry, sellall is disabled.. diff --git a/prison-core/src/main/resources/lang/spigot/en_US.properties b/prison-core/src/main/resources/lang/spigot/en_US.properties index 6f14c8368..fae35647b 100644 --- a/prison-core/src/main/resources/lang/spigot/en_US.properties +++ b/prison-core/src/main/resources/lang/spigot/en_US.properties @@ -55,17 +55,17 @@ messages__auto_refresh=true ## Click to do something spigot_gui_lore_click_to_add=Click to add. spigot_gui_lore_click_to_add_backpack=Click to add a Backpack. -spigot_gui_lore_click_to_cancel=Click to cancel. -spigot_gui_lore_click_to_close=Click to close. -spigot_gui_lore_click_to_confirm=Click to confirm. -spigot_gui_lore_click_to_decrease=Click to decrease. -spigot_gui_lore_click_to_delete=Click to delete. -spigot_gui_lore_click_to_disable=Click to disable. -spigot_gui_lore_click_to_edit=Click to edit. -spigot_gui_lore_click_to_enable=Click to enable. -spigot_gui_lore_click_to_increase=Click to increase. +#spigot_gui_lore_click_to_cancel=Click to cancel. +#spigot_gui_lore_click_to_close=Click to close. +#spigot_gui_lore_click_to_confirm=Click to confirm. +#spigot_gui_lore_click_to_decrease=Click to decrease. +#spigot_gui_lore_click_to_delete=Click to delete. +#spigot_gui_lore_click_to_disable=Click to disable. +#spigot_gui_lore_click_to_edit=Click to edit. +#spigot_gui_lore_click_to_enable=Click to enable. +#spigot_gui_lore_click_to_increase=Click to increase. spigot_gui_lore_click_to_manage_rank=Click to manage Rank. -spigot_gui_lore_click_to_open=Click to open. +#spigot_gui_lore_click_to_open=Click to open. spigot_gui_lore_click_to_rankup=Click to Rankup. spigot_gui_lore_click_to_rename=Click to rename. spigot_gui_lore_click_to_select=Click to select. @@ -74,22 +74,22 @@ spigot_gui_lore_click_to_teleport=Click to teleport. spigot_gui_lore_click_to_use=Click to use. ## Left-Click to do something. -spigot_gui_lore_click_left_to_confirm=Left-Click to confirm. -spigot_gui_lore_click_left_to_reset=Left-Click to reset. -spigot_gui_lore_click_left_to_open=Left-Click to open. -spigot_gui_lore_click_left_to_edit=Left-Click to edit. +#spigot_gui_lore_click_left_to_confirm=Left-Click to confirm. +#spigot_gui_lore_click_left_to_reset=Left-Click to reset. +#spigot_gui_lore_click_left_to_open=Left-Click to open. +#spigot_gui_lore_click_left_to_edit=Left-Click to edit. ## Right-Click to do something. -spigot_gui_lore_click_right_to_cancel=Right-Click to cancel. -spigot_gui_lore_click_right_to_delete=Right-Click to delete. -spigot_gui_lore_click_right_to_disable=Right-Click to disable. -spigot_gui_lore_click_right_to_enable=Right-Click to enable. -spigot_gui_lore_click_right_to_toggle=Right-Click to toggle. +#spigot_gui_lore_click_right_to_cancel=Right-Click to cancel. +#spigot_gui_lore_click_right_to_delete=Right-Click to delete. +#spigot_gui_lore_click_right_to_disable=Right-Click to disable. +#spigot_gui_lore_click_right_to_enable=Right-Click to enable. +#spigot_gui_lore_click_right_to_toggle=Right-Click to toggle. ## Shift and Right-Click to do something -spigot_gui_lore_click_right_and_shift_to_delete=Shift and Right-Click to delete. -spigot_gui_lore_click_right_and_shift_to_disable=Shift and Right-Click to disable. -spigot_gui_lore_click_right_and_shift_to_toggle=Shift and Right-Click to toggle. +#spigot_gui_lore_click_right_and_shift_to_delete=Shift and Right-Click to delete. +#spigot_gui_lore_click_right_and_shift_to_disable=Shift and Right-Click to disable. +#spigot_gui_lore_click_right_and_shift_to_toggle=Shift and Right-Click to toggle. ## Titles or data naming. spigot_gui_lore_backpack_id=Backpack ID: @@ -98,18 +98,18 @@ spigot_gui_lore_blocktype=Blocktype: spigot_gui_lore_chance=Chance: spigot_gui_lore_command=Command: spigot_gui_lore_currency=Currency: -spigot_gui_lore_delay=Delay: +#spigot_gui_lore_delay=Delay: spigot_gui_lore_id=ID: spigot_gui_lore_info=Info: spigot_gui_lore_minename=Minename: -spigot_gui_lore_multiplier=Multiplier: +#spigot_gui_lore_multiplier=Multiplier: spigot_gui_lore_name=Name: spigot_gui_lore_owner=Owner: spigot_gui_lore_percentage=Percentage: -spigot_gui_lore_permission=Permission: +#spigot_gui_lore_permission=Permission: spigot_gui_lore_players_at_rank=Players at rank: -spigot_gui_lore_prestige_name=Prestige name: -spigot_gui_lore_price=Price: +#spigot_gui_lore_prestige_name=Prestige name: +#spigot_gui_lore_price=Price: spigot_gui_lore_radius=Radius: spigot_gui_lore_rank_tag=Rank Tag: spigot_gui_lore_reset_time=Reset time(s): @@ -117,15 +117,15 @@ spigot_gui_lore_size=Size: spigot_gui_lore_show_item=Show Item: spigot_gui_lore_spawnpoint=Spawnpoint: spigot_gui_lore_volume=Volume: -spigot_gui_lore_value=Value: +#spigot_gui_lore_value=Value: spigot_gui_lore_world=World: ## Simple actions or status. spigot_gui_lore_disabled=Disabled. spigot_gui_lore_enabled=Enabled. spigot_gui_lore_locked=Locked! -spigot_gui_lore_next_page=Next page. -spigot_gui_lore_prior_page=Prior page. +#spigot_gui_lore_next_page=Next page. +#spigot_gui_lore_prior_page=Prior page. spigot_gui_lore_rankup=Rankup. spigot_gui_lore_selected=Selected. spigot_gui_lore_unlocked=Unlocked! @@ -256,9 +256,9 @@ spigot_message_sellall_delay_disabled_cant_use=Sorry, please enable SellAll Dela spigot_message_sellall_delay_edit_success=Sellall Delay edited with success. spigot_message_sellall_delay_enabled=SellAll Delay enabled with success. spigot_message_sellall_delay_not_number=SellAll Delay number isn't valid. -spigot_message_sellall_delay_wait=Sellall delay is enabled, please slow down. +#spigot_message_sellall_delay_wait=Sellall delay is enabled, please slow down. spigot_message_sellall_gui_disabled=SellAll GUI is disabled. -spigot_message_sellall_money_earned=You earned &a$ +#spigot_message_sellall_money_earned=You earned &a$ spigot_message_sellall_multiplier_add_success=SellAll Multiplier added with success. spigot_message_sellall_multiplier_are_disabled=Sorry, SellAll Multipliers are disabled. spigot_message_sellall_multiplier_cant_find=Sorry, can't find SellAll Multiplier. @@ -266,9 +266,9 @@ spigot_message_sellall_multiplier_delete_success=SellAll Multiplier deleted with spigot_message_sellall_multiplier_disabled=SellAll Multipliers Disabled with success. spigot_message_sellall_multiplier_edit_success=SellAll Multiplier edited with success. spigot_message_sellall_multiplier_enabled=SellAll Multipliers Enabled with success. -spigot_message_sellall_sell_empty=Sorry, there aren't items in the SellAll shop. -spigot_message_sellall_sell_nothing_sellable=Sorry but you've nothing to sell. -spigot_message_sellall_sell_sign_only=You can use SellAll Sell only with Signs. +#spigot_message_sellall_sell_empty=Sorry, there aren't items in the SellAll shop. +#spigot_message_sellall_sell_nothing_sellable=Sorry but you've nothing to sell. +#spigot_message_sellall_sell_sign_only=You can use SellAll Sell only with Signs. spigot_message_sellall_sell_sign_notify=You sold trough a sign with success. spigot_message_sellall_trigger_already_disabled=SellAll Trigger already disabled. spigot_message_sellall_trigger_already_enabled=SellAll Trigger already enabled. @@ -298,7 +298,7 @@ spigot_message_gui_ranks_rankup_commands_empty=Sorry, there aren't Rankup Comman spigot_message_gui_ranks_rankup_commands_too_many=Sorry, there are too many Rankup Commands and the GUI can't show them. spigot_message_gui_ranks_too_many=Sorry, there are too many Ranks and the GUI can't show them. spigot_message_gui_reload_success=GUIs reloaded with success! -spigot_message_gui_sellall_disabled=Sorry, SellAll is disabled. +#spigot_message_gui_sellall_disabled=Sorry, SellAll is disabled. spigot_message_gui_sellall_empty=Sorry, there's nothing to show. spigot_message_gui_too_high=Sorry, but the value is too high (above maximum possible). spigot_message_gui_too_low_value=Sorry, but the value is too low (below minimum possible). diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java index 65c9bcb1e..e17d5ce8a 100644 --- a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java +++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java @@ -80,11 +80,17 @@ protected void sellallShopIsEmptyMsg( CommandSender sender ) { .sendTo( sender ); } - protected void sellallYouHaveNothingToSellMsg( CommandSender sender ) { + public void sellallYouHaveNothingToSellMsg( CommandSender sender ) { PrisonSellall.getInstance().getSellallMessages() .getLocalizable( "sellall_spigot_utils__you_have_nothing_to_sell" ) .sendTo( sender ); } + public void sellallIsDisabledMsg( CommandSender sender ) { + PrisonSellall.getInstance().getSellallMessages() + .getLocalizable( "sellall_spigot_utils__sellall_is_disabled" ) + .sendTo( sender ); + } + } 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 5a0c4557f..b8670c8a9 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 @@ -20,6 +20,7 @@ import tech.mcprison.prison.internal.CommandSender; 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.compat.Compatibility; @@ -439,7 +440,10 @@ private void sellAllGuiCommand(CommandSender sender, if (!sellAllUtil.openSellAllGUI( p, page, "sellall gui", "close" )){ // If the sender's an admin (OP or have the prison.admin permission) it'll send an error message. if (p.hasPermission("prison.admin")) { - Output.get().sendError(sender, messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_disabled)); + + new SpigotVariousGuiMessages().sellallIsDisabledMsg( sender ); +// Output.get().sendError(sender, +// messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_disabled)); } } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java index e3d3f46ea..fa9109509 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/MessagesConfig.java @@ -123,14 +123,14 @@ public enum StringID { spigot_gui_lore_click_to_add, spigot_gui_lore_click_to_add_backpack, - spigot_gui_lore_click_to_cancel, - spigot_gui_lore_click_to_close, - spigot_gui_lore_click_to_confirm, +// spigot_gui_lore_click_to_cancel, +// spigot_gui_lore_click_to_close, +// spigot_gui_lore_click_to_confirm, // spigot_gui_lore_click_to_decrease, - spigot_gui_lore_click_to_delete, - spigot_gui_lore_click_to_disable, +// spigot_gui_lore_click_to_delete, +// spigot_gui_lore_click_to_disable, // spigot_gui_lore_click_to_edit, - spigot_gui_lore_click_to_enable, +// spigot_gui_lore_click_to_enable, // spigot_gui_lore_click_to_increase, spigot_gui_lore_click_to_manage_rank, // spigot_gui_lore_click_to_open, @@ -162,7 +162,7 @@ public enum StringID { spigot_gui_lore_chance, spigot_gui_lore_command, spigot_gui_lore_currency, - spigot_gui_lore_delay, +// spigot_gui_lore_delay, spigot_gui_lore_id, spigot_gui_lore_info, spigot_gui_lore_minename, @@ -170,7 +170,7 @@ public enum StringID { spigot_gui_lore_name, spigot_gui_lore_owner, spigot_gui_lore_percentage, - spigot_gui_lore_permission, +// spigot_gui_lore_permission, spigot_gui_lore_players_at_rank, // spigot_gui_lore_prestige_name, // spigot_gui_lore_price, @@ -181,7 +181,7 @@ public enum StringID { spigot_gui_lore_size, spigot_gui_lore_spawnpoint, spigot_gui_lore_volume, - spigot_gui_lore_value, +// spigot_gui_lore_value, spigot_gui_lore_world, spigot_gui_lore_disabled, @@ -354,7 +354,7 @@ public enum StringID { spigot_message_gui_ranks_rankup_commands_too_many, spigot_message_gui_ranks_too_many, spigot_message_gui_reload_success, - spigot_message_gui_sellall_disabled, +// spigot_message_gui_sellall_disabled, spigot_message_gui_sellall_empty, spigot_message_gui_too_high, spigot_message_gui_too_low_value, diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/PrisonSetupGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/PrisonSetupGUI.java index ed4227bd8..db5821412 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/PrisonSetupGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/PrisonSetupGUI.java @@ -25,7 +25,9 @@ public void open(){ PrisonGUI gui = new PrisonGUI(p, 9, "&3Prison Setup -> Confirmation"); // Create lore. - ButtonLore lore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_confirm)), createLore( + ButtonLore lore = new ButtonLore(createLore( + guiClickToConfirmMsg() ), + createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_setup_1), messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_setup_2), messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_setup_3), @@ -40,7 +42,7 @@ public void open(){ // Add button. gui.addButton(new Button(6, XMaterial.REDSTONE_BLOCK, createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_cancel)), "&3Cancel: Setup")); + guiClickToCancelMsg()), "&3Cancel: Setup")); // Open Prison GUI. gui.open(); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java index e1aa6e93a..985a7b414 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoBlockGUI.java @@ -6,7 +6,6 @@ import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; -import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; @@ -34,7 +33,8 @@ public void open() { guiRightClickShiftToDisableMsg(), null); ButtonLore disabledLore = new ButtonLore( guiRightClickToEnableMsg(), null); - gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), "&cClose")); + gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, + new ButtonLore( guiClickToCloseMsg(), null), "&cClose")); if (afConfig != null) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java index 379683b6d..30bc0ea0d 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoFeaturesGUI.java @@ -30,7 +30,7 @@ public void open() { PrisonGUI gui; - ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); + ButtonLore closeGUILore = new ButtonLore( guiClickToCloseMsg(), null); if (afConfig != null && afConfig.isFeatureBoolean(AutoFeatures.isAutoManagerEnabled)) { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java index 15fbafbee..f4d60a7b1 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoPickupGUI.java @@ -7,7 +7,6 @@ import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; @@ -33,7 +32,7 @@ public void open() { ButtonLore enabledLore = new ButtonLore( guiRightClickShiftToDisableMsg(), null); ButtonLore disabledLore = new ButtonLore( guiRightClickToEnableMsg(), null); - ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); + ButtonLore closeGUILore = new ButtonLore( guiClickToCloseMsg(), null); gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java index 96373318a..44f6a79c5 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/autofeatures/SpigotAutoSmeltGUI.java @@ -7,7 +7,6 @@ import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; import tech.mcprison.prison.output.Output; -import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.game.SpigotPlayer; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; @@ -33,7 +32,7 @@ public void open() { ButtonLore enabledLore = new ButtonLore( guiRightClickShiftToDisableMsg(), null); ButtonLore disabledLore = new ButtonLore( guiRightClickToEnableMsg(), null); - ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); + ButtonLore closeGUILore = new ButtonLore( guiClickToCloseMsg(), null); gui.addButton(new Button(35, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminGUI.java index d6d522731..e43c2572e 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksAdminGUI.java @@ -37,7 +37,8 @@ public void open(){ gui.addButton(new Button(11, XMaterial.CHEST, lore, "&3Backpacks-List")); gui.addButton(new Button(15, XMaterial.PAPER, lore, "&3Backpack-Settings")); - gui.addButton(new Button(dimension -1, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), "&cClose")); + gui.addButton(new Button(dimension -1, XMaterial.RED_STAINED_GLASS_PANE, + new ButtonLore( guiClickToCloseMsg(), null), "&cClose")); gui.open(); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java index 8e58e9c4d..ab2e817cf 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksListPlayerGUI.java @@ -65,7 +65,8 @@ public void open(){ gui.addButton(new Button(49, XMaterial.EMERALD_BLOCK, loreAddBackpackButton, "&aNew Backpack")); } - gui.addButton(new Button(dimension-1, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), "&cClose")); + gui.addButton(new Button(dimension-1, XMaterial.RED_STAINED_GLASS_PANE, + new ButtonLore( guiClickToCloseMsg(), null), "&cClose")); gui.open(); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineBlockPercentageGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineBlockPercentageGUI.java index 092707830..57a80989c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineBlockPercentageGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineBlockPercentageGUI.java @@ -38,7 +38,7 @@ public void open() { ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null); ButtonLore confirmButtonLore = new ButtonLore(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_confirm), + guiClickToConfirmMsg(), guiRightClickToCancelMsg() ), createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_percentage) + " " + val)); @@ -65,7 +65,8 @@ public void open() { gui.addButton(new Button(43, increaseMat, changeIncreaseValueLore, "&3" + mineName + " " + blockName + " " + val + " + 100 &0" + counter)); // Close gui: - gui.addButton(new Button(40, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), "&cClose &0" + mineName + " " + counter)); + gui.addButton(new Button(40, XMaterial.RED_STAINED_GLASS_PANE, + new ButtonLore( guiClickToCloseMsg(), null), "&cClose &0" + mineName + " " + counter)); // Show the selected block at the top center position: XMaterial xMat = SpigotUtil.getXMaterial( blockName ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationsGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationsGUI.java index 47a9abd09..90368b47a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationsGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMineNotificationsGUI.java @@ -40,7 +40,7 @@ public void open() { ButtonLore modeWithinLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_select), messages.getString(MessagesConfig.StringID.spigot_gui_lore_enable_within_mode)); ButtonLore modeRadiusLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_select), messages.getString(MessagesConfig.StringID.spigot_gui_lore_enable_radius_mode)); ButtonLore disabledModeLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_select), messages.getString(MessagesConfig.StringID.spigot_gui_lore_disable_notifications)); - ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); + ButtonLore closeGUILore = new ButtonLore( guiClickToCloseMsg(), null); // Add button. gui.addButton(new Button(26, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose")); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesConfirmGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesConfirmGUI.java index 0b4355ae4..4e04fa2ef 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesConfirmGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesConfirmGUI.java @@ -1,8 +1,9 @@ package tech.mcprison.prison.spigot.gui.mine; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; -import tech.mcprison.prison.spigot.configs.MessagesConfig; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; @@ -27,8 +28,8 @@ public void open(){ int dimension = 9; PrisonGUI gui = new PrisonGUI(p, dimension, "&3Mines -> Delete"); - ButtonLore confirmLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_confirm), null); - ButtonLore cancelLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_cancel), null); + ButtonLore confirmLore = new ButtonLore( guiClickToConfirmMsg(), null); + ButtonLore cancelLore = new ButtonLore( guiClickToCancelMsg(), null); // Position of the button diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java index cc94162af..c852e82c9 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java @@ -27,12 +27,13 @@ public void open(){ int dimension = 9; PrisonGUI gui = new PrisonGUI(p, dimension, "&3Prestige -> Confirmation"); - ButtonLore confirmLore = new ButtonLore(createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_confirm)), createLore( + ButtonLore confirmLore = new ButtonLore(createLore( + guiClickToConfirmMsg()), createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_warning_1), messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_warning_2), messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_warning_3))); - ButtonLore cancelLore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_cancel), null); + ButtonLore cancelLore = new ButtonLore( guiClickToCancelMsg(), null); // Create the button, set up the material, amount, lore and name diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java index 373055711..140c5387c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankManagerGUI.java @@ -72,7 +72,7 @@ public void open() { messages.getString(MessagesConfig.StringID.spigot_gui_lore_rank_tag) + " " + rank.getTag())); - ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); + ButtonLore closeGUILore = new ButtonLore( guiClickToCloseMsg(), null); // Create the button gui.addButton(new Button(26, XMaterial.RED_STAINED_GLASS_PANE, closeGUILore, "&cClose" )); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminAutoSellGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminAutoSellGUI.java index 583846864..c70e9bb0c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminAutoSellGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminAutoSellGUI.java @@ -4,7 +4,6 @@ import com.cryptomorin.xseries.XMaterial; -import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; @@ -28,7 +27,7 @@ public void open() { PrisonGUI gui = new PrisonGUI(p, dimension, "&3SellAll -> AutoSell"); - ButtonLore closeGUILore = new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null); + ButtonLore closeGUILore = new ButtonLore( guiClickToCloseMsg(), null); ButtonLore perUserToggleableLore = new ButtonLore(); ButtonLore enableDisableLore = new ButtonLore(); @@ -36,18 +35,18 @@ public void open() { Button enableDisableButton; if (sellAllConfig.getString("Options.Full_Inv_AutoSell_perUserToggleable").equalsIgnoreCase("true")){ - perUserToggleableLore.setLoreAction(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_disable)); + perUserToggleableLore.setLoreAction( guiClickToDisableMsg() ); perUserToggleableButton = new Button(11, XMaterial.LIME_STAINED_GLASS_PANE, perUserToggleableLore, "&3PerUserToggleable"); } else { - perUserToggleableLore.setLoreAction(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_enable)); + perUserToggleableLore.setLoreAction( guiClickToEnableMsg() ); perUserToggleableButton = new Button(11, XMaterial.RED_STAINED_GLASS_PANE, perUserToggleableLore, "&cPerUserToggleable-Disabled"); } if (sellAllConfig.getString("Options.Full_Inv_AutoSell").equalsIgnoreCase("true")){ - enableDisableLore.setLoreAction(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_disable)); + enableDisableLore.setLoreAction( guiClickToDisableMsg() ); enableDisableButton = new Button(15, XMaterial.LIME_STAINED_GLASS_PANE, enableDisableLore, "&3AutoSell"); } else { - enableDisableLore.setLoreAction(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_enable)); + enableDisableLore.setLoreAction( guiClickToEnableMsg() ); enableDisableButton = new Button(15, XMaterial.RED_STAINED_GLASS_PANE, enableDisableLore, "&cAutoSell-Disabled"); } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java index d21a93a65..90ab2541c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java @@ -8,9 +8,9 @@ import com.cryptomorin.xseries.XMaterial; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages; import tech.mcprison.prison.spigot.SpigotUtil; -import tech.mcprison.prison.spigot.configs.MessagesConfig; -import tech.mcprison.prison.spigot.game.SpigotPlayer; +import tech.mcprison.prison.spigot.game.SpigotCommandSender; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools.GUIMenuPageData; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -59,8 +59,10 @@ public void open() { } if (emptyInv){ - SpigotPlayer spigotPlayer = new SpigotPlayer(p); - Output.get().sendWarn(spigotPlayer, messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_empty)); + new SpigotVariousGuiMessages().sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) ); + +// SpigotPlayer spigotPlayer = new SpigotPlayer(p); +// Output.get().sendWarn(spigotPlayer, messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_empty)); return; } @@ -82,9 +84,9 @@ public void open() { // Global strings. String loreLine1 = guiRightClickToDeleteMsg(); String loreLine2 = guiLeftClickToEditMsg(); - String lorePermission = messages.getString(MessagesConfig.StringID.spigot_gui_lore_permission); +// String lorePermission = messages.getString(MessagesConfig.StringID.spigot_gui_lore_permission); String permissionSellAllBlock = sellAllConfig.getString("Options.Sell_Per_Block_Permission"); - String loreValue = messages.getString(MessagesConfig.StringID.spigot_gui_lore_value); +// String loreValue = messages.getString(MessagesConfig.StringID.spigot_gui_lore_value); boolean sellAllPerBlockPermissionEnabled = getBoolean(sellAllConfig.getString("Options.Sell_Per_Block_Permission_Enabled")); @@ -92,10 +94,17 @@ public void open() { for (String key : itemsDisplay) { - ButtonLore itemsLore = new ButtonLore(createLore(loreLine1, loreLine2), createLore(loreValue + sellAllConfig.getString("Items." + key + ".ITEM_VALUE"))); + String itemValue = sellAllConfig.getString("Items." + key + ".ITEM_VALUE"); + String loreValue = guiValueMsg( itemValue ); + + ButtonLore itemsLore = new ButtonLore(createLore(loreLine1, loreLine2), + createLore( loreValue )); + + String sellallPerm = permissionSellAllBlock + sellAllConfig.getString("Items." + key + ".ITEM_ID"); + String lorePermission = guiPermissionMsg( sellallPerm ); if (sellAllPerBlockPermissionEnabled) { - itemsLore.addLineLoreDescription( lorePermission + "&7" + permissionSellAllBlock + sellAllConfig.getString("Items." + key + ".ITEM_ID") ); + itemsLore.addLineLoreDescription( lorePermission ); } String xMatIdName = "Items." + key + ".ITEM_ID"; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java index 6931bdb69..6453f3019 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java @@ -5,8 +5,10 @@ import com.cryptomorin.xseries.XMaterial; import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages; import tech.mcprison.prison.spigot.SpigotPrison; 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.SpigotGUIMenuTools; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools.GUIMenuPageData; @@ -40,7 +42,11 @@ public SellAllAdminGUI( Player p, int page, String cmdPage, String cmdReturn ) { public void open() { if (!SpigotPrison.getInstance().getConfig().getString("sellall").equalsIgnoreCase("true")){ - Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_disabled)); + + new SpigotVariousGuiMessages().sellallIsDisabledMsg( new SpigotCommandSender(p) ); + +// Output.get().sendWarn(new SpigotPlayer(p), +// messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_disabled)); return; } @@ -86,15 +92,18 @@ public void open() { sellAllDelayLore.setLoreAction(createLore( guiClickToOpenMsg(), guiRightClickToCancelMsg())); + + String loreDelay = guiDelayMsg( sellAllConfig.getString("Options.Sell_Delay_Seconds") ); + sellAllDelayLore.setLoreDescription(createLore( - messages.getString(MessagesConfig.StringID.spigot_gui_lore_delay) + " " + sellAllConfig.getString("Options.Sell_Delay_Seconds") + "s", + loreDelay, messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_delay_use_1), messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_delay_use_2))); sellAllDelayButton = new Button(11, XMaterial.CLOCK, sellAllDelayLore, "&3Delay-Enabled"); } else { - sellAllDelayLore.setLoreAction(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_enable)); + sellAllDelayLore.setLoreAction( guiClickToEnableMsg() ); sellAllDelayLore.setLoreDescription(createLore( messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_delay_use_1), messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_delay_use_2))); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java index 084720e6b..51bde973f 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java @@ -4,8 +4,6 @@ import com.cryptomorin.xseries.XMaterial; -import tech.mcprison.prison.spigot.SpigotPrison; -import tech.mcprison.prison.spigot.configs.MessagesConfig; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools.GUIMenuPageData; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -55,7 +53,8 @@ public void open() { ButtonLore confirmButtonLore = new ButtonLore(createLore( guiLeftClickToConfirmMsg(), guiRightClickToCancelMsg() ), - createLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_delay) + " " + val + "s")); + + createLore( guiDelayMsg( val ) )); ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null); // ButtonLore changeIncreaseValueLore = new ButtonLore( diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPlayerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPlayerGUI.java index 8cdcd37b4..df4207bfb 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPlayerGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPlayerGUI.java @@ -5,10 +5,9 @@ import org.bukkit.entity.Player; -import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages; import tech.mcprison.prison.spigot.SpigotUtil; -import tech.mcprison.prison.spigot.configs.MessagesConfig; -import tech.mcprison.prison.spigot.game.SpigotPlayer; +import tech.mcprison.prison.spigot.game.SpigotCommandSender; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools; import tech.mcprison.prison.spigot.gui.SpigotGUIMenuTools.GUIMenuPageData; import tech.mcprison.prison.spigot.gui.guiutility.Button; @@ -54,7 +53,10 @@ public void open() { } if (emptyInv){ - Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_empty)); + + new SpigotVariousGuiMessages().sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) ); +// Output.get().sendWarn(new SpigotPlayer(p), +// messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_empty)); return; } @@ -78,12 +80,20 @@ public void open() { // Global strings. - String loreValue = messages.getString(MessagesConfig.StringID.spigot_gui_lore_value); +// String loreValue = messages.getString(MessagesConfig.StringID.spigot_gui_lore_value); // int itemsAdded = 0, itemsRead = 0; for ( String key : itemsDisplay ) { - gui.addButton(new Button(null, SpigotUtil.getXMaterial(sellAllConfig.getString("Items." + key + ".ITEM_ID")), new ButtonLore(null, loreValue + " " + sellAllConfig.getString("Items." + key + ".ITEM_VALUE")), "&3" + sellAllConfig.getString("Items." + key + ".ITEM_ID"))); + String itemId = sellAllConfig.getString("Items." + key + ".ITEM_ID"); + String itemValue = sellAllConfig.getString("Items." + key + ".ITEM_VALUE"); + + String loreValue = guiValueMsg( itemValue ); + + gui.addButton( + new Button(null, SpigotUtil.getXMaterial(itemId), + new ButtonLore(null, loreValue), + "&3" + itemId)); // itemsRead++; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java index 95327e8ae..3af452f10 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java @@ -1,8 +1,9 @@ package tech.mcprison.prison.spigot.gui.sellall; -import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; -import tech.mcprison.prison.spigot.configs.MessagesConfig; + +import com.cryptomorin.xseries.XMaterial; + import tech.mcprison.prison.spigot.gui.guiutility.Button; import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore; import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI; From f41f1f4d2c7505605dd5f54d4adefe85499c413b Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 22 May 2022 23:26:43 -0400 Subject: [PATCH 244/297] Prison v3.3.0-alpha.11d --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 43dd6aa2e..9c6158b29 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.11c +version=3.3.0-alpha.11d From a0d0409f7debaaf1308c6907376976ae692b6d27 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 22 May 2022 23:57:45 -0400 Subject: [PATCH 245/297] Bug fix: Minepacks has a new function in their API to force backpack changes to be saved. Before it could only be marked as changed, which was not enough to get it to save in all situations. Prison is now calling "save()" to ensure its behaving better now. --- docs/changelog_v3.3.x.md | 10 +++++++++- .../integrations/IntegrationMinepacksPlugin.java | 12 ++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 305f3d387..5eb818703 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,15 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11c 2022-05-22 +# 3.3.0-alpha.11d 2022-05-22 + + +* **Bug fix: Minepacks has a new function in their API to force backpack changes to be saved.** +Before it could only be marked as changed, which was not enough to get it to save in all situations. Prison is now calling "save()" to ensure its behaving better now. +NOTE: releasing this fix with alpha.11d even though it has been added after being set to 11d. + + +* **Prison v3.3.0-alpha.11d 2022-05-22** * **GUI messages: a few more updates and corrections** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java index 767e6238a..d777ad4e6 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java @@ -77,7 +77,8 @@ public HashMap addItems( Player player, HashMap addItemsBukkit( Player player, HashMap smeltItems( Player player, XMaterial so extras.putAll( addItems( player, temp ) ); - bp.setChanged(); +// bp.setChanged(); + bp.save(); } } @@ -181,7 +184,8 @@ public int itemStackRemoveAll(Player player, XMaterial xMat) { removed += SpigotUtil.itemStackRemoveAll( xMat, bp.getInventory() ); if ( removed > 0 ) { - bp.setChanged(); +// bp.setChanged(); + bp.save(); } } } From 2744dc96f9d16ffe5fb6437f2138a25293ddd5a6 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 23 May 2022 08:42:56 -0400 Subject: [PATCH 246/297] Fixed an issue with sellall when the module sellall is not defined but sellall is enabled in the config.yml file. --- docs/changelog_v3.3.x.md | 5 ++++- .../tech/mcprison/prison/spigot/SpigotPrison.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 5eb818703..a9e2e911e 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11d 2022-05-22 +# 3.3.0-alpha.11d 2022-05-23 + + +* **Bug fix: Fixed an issue with sellall when the module sellall is not defined but sellall is enabled in the config.yml file.** * **Bug fix: Minepacks has a new function in their API to force backpack changes to be saved.** 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 f718ba8c7..5bdd5e890 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 @@ -780,7 +780,16 @@ private void initModulesAndCommands() { } - if (modulesConf.getBoolean( PrisonSellall.MODULE_NAME.toLowerCase() ) ) { + // If the sellall module is defined in modules.yml, then use that setting, otherwise + // use the sellall config setting within the config.yml file. + String moduleName = PrisonSellall.MODULE_NAME.toLowerCase(); + boolean isDefined = modulesConf.contains(moduleName); + + if ( isDefined && modulesConf.getBoolean(moduleName) || + !isDefined && getConfig().contains("sellall") && getConfig().isBoolean("sellall") ) { + +// modulesConf.getBoolean( PrisonSellall.MODULE_NAME.toLowerCase(), true ) || +// getConfig().contains("sellall") && getConfig().isBoolean("sellall")) { PrisonSellall sellallModule = new PrisonSellall(getDescription().getVersion() ); // Register and enable Ranks: From 3ffe98d81a894b3dadfcaf83fa98a16245663eb3 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 23 May 2022 08:53:45 -0400 Subject: [PATCH 247/297] v3.3.0-alpha.11e --- 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 a9e2e911e..dacf34bdb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11d 2022-05-23 +# 3.3.0-alpha.11e 2022-05-23 + + +* **v3.3.0-alpha.11e 2022-05-23** * **Bug fix: Fixed an issue with sellall when the module sellall is not defined but sellall is enabled in the config.yml file.** diff --git a/gradle.properties b/gradle.properties index 9c6158b29..bbdf249b6 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.11d +version=3.3.0-alpha.11e From 33b627efd6a3abd35407546788a4c28e17d0721f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 24 May 2022 01:02:59 -0400 Subject: [PATCH 248/297] Fixed an incorrect mapping to a message: auto features tool is worn out. --- .../prison/spigot/block/OnBlockBreakEventCoreMessages.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCoreMessages.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCoreMessages.java index b4c49a21d..e649dbd20 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCoreMessages.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCoreMessages.java @@ -25,7 +25,7 @@ protected String mineIsBeingResetMsg( String mineTagName ) { protected String toolIsWornOutMsg() { return SpigotPrison.getInstance().getLocaleManager() - .getLocalizable( "spigot_blockbreak_mines__mine_is_being_reset__please_wait" ) + .getLocalizable( "spigot_blockbreak_core__validate_event__your_tool_is_worn_out" ) .localize(); } From a0662c6ab69c24ca0e88b73979c45342ffd01ce5 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 24 May 2022 01:07:04 -0400 Subject: [PATCH 249/297] Major exploit fix: sellall was not indicating that the inventory was changed within the Minepacks backpacks, and therefore players were able to sellall of their inventory, logoff, and then when they log back on, it will be restored. Now, all inventory changes are forcing a save for the backpacks. --- docs/changelog_v3.3.x.md | 8 ++++++ .../IntegrationMinepacksPlugin.java | 25 +++++++++++++++---- .../prison/spigot/sellall/SellAllUtil.java | 4 +++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index dacf34bdb..4852a7f10 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,14 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11e 2022-05-23 +* **Major exploit fix: sellall was not indicating that the inventory was changed within the Minepacks backpacks,** +and therefore players were able to sellall of their inventory, logoff, and then when they log back on, it will be restored. +Now, all inventory changes are forcing a save for the backpacks. + + +* **Fixed an incorrect mapping to a message: auto features tool is worn out.** + + * **v3.3.0-alpha.11e 2022-05-23** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java index d777ad4e6..5501f2e68 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java @@ -68,6 +68,8 @@ public HashMap addItems( Player player, HashMap addItems( Player player, HashMap addItemsBukkit( Player player, HashMap 0 ) { + // bp.setChanged(); bp.save(); } 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 00d13503a..dca9fce25 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 @@ -569,6 +569,8 @@ private HashMap getHashMapOfPlayerInventories(Player p) { Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p); if (backpack != null) { xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, backpack.getInventory()); +// backpack.setChanged(); + backpack.save(); } } @@ -1468,6 +1470,8 @@ public void removeSellableItems(Player p){ Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p); if (backpack != null) { removeSellableItems(p, backpack.getInventory()); +// backpack.setChanged(); + backpack.save(); } } From 8e7ba7226aa2ea2422215ce3cc76aade46882c1e Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 28 May 2022 20:05:46 -0400 Subject: [PATCH 250/297] Placeholder fix for `prison_mines_blocks_mined_minename` since it was not being incremented after the fixing of the autopickup=false and handle normal drops = true. Also found that the calculated field for the mine's total blocks mined was not being recalculated after load the mines from their save files. This now is working properly. --- .../tech/mcprison/prison/mines/data/Mine.java | 17 ++++++++++++++++- .../autofeatures/AutoManagerFeatures.java | 3 +-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java index 9c53a3e5a..9faf1bcda 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/Mine.java @@ -315,6 +315,9 @@ private void loadFromDocument( Document document ) setRankString( rankString ); + long totalBlockCount = 0L; + + // This is a validation set to ensure only one block type is loaded file system. // Must keep the first one loaded. Set validateBlockNames = new HashSet<>(); @@ -339,7 +342,6 @@ private void loadFromDocument( Document document ) ObsoleteBlockType blockType = ObsoleteBlockType.getBlock(blockTypeName); if ( blockType != null ) { - /** *

The following is code to correct the use of items being used as a * block in a mine, which will cause a failure in trying to place an @@ -380,6 +382,8 @@ else if ( blockType == ObsoleteBlockType.NETHER_BRICK ) { block.parseFromSaveFileFormatStats( docBlock ); + totalBlockCount += block.getBlockCountTotal(); + // BlockOld block = new BlockOld(blockType, chance, blockCount); // block.setConstraintMin( constraintMin ); // block.setConstraintMax( constraintMax ); @@ -412,6 +416,10 @@ else if (validateBlockNames.contains( blockTypeName ) ) { List docPrisonBlocks = (List) document.get("prisonBlocks"); if ( docPrisonBlocks != null ) { + + // If prisonBlocks are defined, then use these for the block counts: + totalBlockCount = 0L; + for (String docBlock : docPrisonBlocks) { if ( docBlock != null ) { @@ -432,6 +440,8 @@ else if (validateBlockNames.contains( blockTypeName ) ) { if ( prisonBlock != null ) { + totalBlockCount += prisonBlock.getBlockCountTotal(); + if ( !validateBlockNames.contains( prisonBlock.getBlockName() )) { if ( prisonBlock.isLegacyBlock() ) { @@ -492,9 +502,14 @@ else if ( validateBlockNames.contains( prisonBlock.getBlockName() ) ) { } } + } + // Set the total blocks mined count: + setTotalBlocksMined( totalBlockCount ); + + // Check if one of the blocks is effected by gravity, and if so, set that indicator. checkGravityAffectedBlocks(); 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 8054cb0e5..f2d776e37 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 @@ -297,8 +297,7 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent, StringBu // Ops will have to have the perms set to actually use them. // AutoPickup - if ( (mine != null || mine == null && !isBoolean( AutoFeatures.pickupLimitToMines )) && - isAutoPickup ) { + if ( (mine != null || mine == null && !isBoolean( AutoFeatures.pickupLimitToMines )) ) { if ( isAutoPickup ) { From 3d49ef499d6e07e6bf04ac96348deeb5f402e206 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 29 May 2022 01:11:51 -0400 Subject: [PATCH 251/297] Fixed a bug on the smelting of coal_ore which was yielding 10 times too much, but this was never seen since a silk touch pickaxe would have to been used. --- docs/changelog_v3.3.x.md | 9 ++++++++- .../prison/spigot/autofeatures/AutoManagerFeatures.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 4852a7f10..0145686c0 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,14 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11e 2022-05-23 +# 3.3.0-alpha.11e 2022-05-29 + + +* **Fixed a bug on the smelting of coal_ore which was yielding 10 times too much, but this was never seen since a silk touch pickaxe would have to been used.** + + +* **Placeholder fix for `prison_mines_blocks_mined_minename` since it was not being incremented after the fixing of the autopickup=false and handle normal drops = true.** +Also found that the calculated field for the mine's total blocks mined was not being recalculated after load the mines from their save files. This now is working properly. * **Major exploit fix: sellall was not indicating that the inventory was changed within the Minepacks backpacks,** 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 f2d776e37..702545522 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 @@ -1776,7 +1776,7 @@ else if ( sItemStack.getMaterial() != null ) { case DEEPSLATE_COAL_ORE: if ( isAll || isBoolean( AutoFeatures.smeltCoalOre ) ) { - SpigotUtil.itemStackReplaceItems( drops, source, XMaterial.COAL,11 ); + SpigotUtil.itemStackReplaceItems( drops, source, XMaterial.COAL, 1 ); } break; From 9cd72ed3bb7f6c1ab89ba037c8ef6c309de2e3cc Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 29 May 2022 01:19:37 -0400 Subject: [PATCH 252/297] BlockConverters: More work on these settings. Setting up to work with AutoFeaturesConfig.yml, but having second thoughts about adding these configs to that file since it will complicate the config details. --- docs/changelog_v3.3.x.md | 4 + .../autofeatures/AutoFeaturesFileConfig.java | 118 ++++++++++++- .../prison/autofeatures/BlockConverter.java | 159 +++++++++++++++--- .../autofeatures/BlockConvertersNode.java | 15 +- 4 files changed, 265 insertions(+), 31 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0145686c0..119874219 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11e 2022-05-29 +* **BlockConverters: More work on these settings.** +Setting up to work with AutoFeaturesConfig.yml, but having second thoughts about adding these configs to that file since it will complicate the config details. + + * **Fixed a bug on the smelting of coal_ore which was yielding 10 times too much, but this was never seen since a silk touch pickaxe would have to been used.** 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 1c17c4ab4..ad13b7140 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 @@ -288,6 +288,7 @@ public enum AutoFeatures { smeltLimitToMines(smeltFeature, true), smeltAllBlocks(smeltFeature, true), +// smeltTransformer(smeltFeature, NodeType.BLOCK_CONVERTER, "smelt" ), smeltCobblestone(smeltFeature, false), @@ -533,7 +534,7 @@ private AutoFeatures(AutoFeatures section, NodeType nodeType, String... values ) } } else if ( nodeType == NodeType.BLOCK_CONVERTER ) { - loadSampleBlockConverters( blockConverters, Arrays.asList( values ) ); + loadDefaultBlockConverters( blockConverters, Arrays.asList( values ) ); } } @@ -821,11 +822,11 @@ protected AutoFeaturesFileConfig() { } - public static void loadSampleBlockConverters( + public static void loadDefaultBlockConverters( TreeMap blockConverters, List sampleSets ) { if ( sampleSets.contains( "sample01" ) ) { - BlockConverter bc1 = new BlockConverter( "coal_ore" ); + BlockConverter bc1 = new BlockConverter( "coal_ore", 9 ); bc1.getTargets().add( new BlockConverterTarget( "diamond", 1 )); @@ -841,12 +842,119 @@ public static void loadSampleBlockConverters( - blockConverters.put( bc1.getKey(), bc1 ); - blockConverters.put( bc2.getKey(), bc2 ); + blockConverters.put( bc1.getKeyBlockName(), bc1 ); + blockConverters.put( bc2.getKeyBlockName(), bc2 ); + + } + + if ( sampleSets.contains( "smelt" ) ) { + + addSmeltBlockConverter( "cobblestone", "stone", blockConverters ); + addSmeltBlockConverter( "cobbled_deepslate", "deepslate", "1.17", blockConverters ); + + addSmeltBlockConverter( "gold_ore", "gold_ingot", blockConverters ); + addSmeltBlockConverter( "nether_gold_ore", "gold_ingot", "1.16", blockConverters ); + addSmeltBlockConverter( "deepslate_gold_ore", "gold_ingot", "1.17", blockConverters ); + addSmeltBlockConverter( "raw_gold", "gold_ingot", "1.17", blockConverters ); + + addSmeltBlockConverter( "iron_ore", "iron_ingot", blockConverters ); + addSmeltBlockConverter( "deepslate_iron_ore", "iron_ingot", "1.17", blockConverters ); + addSmeltBlockConverter( "raw_iron", "iron_ingot", "1.17", blockConverters ); + + addSmeltBlockConverter( "coal_ore", "coal", blockConverters ); + addSmeltBlockConverter( "deepslate_coal_ore", "coal", "1.17", blockConverters ); + + addSmeltBlockConverter( "diamond_ore", "diamond", blockConverters ); + addSmeltBlockConverter( "deepslate_diamond_ore", "diamond", "1.17", blockConverters ); + + addSmeltBlockConverter( "emerald_ore", "emerald", blockConverters ); + addSmeltBlockConverter( "deepslate_emerald_ore", "emerald", "1.17", blockConverters ); + + addSmeltBlockConverter( "lapis_ore", "lapis_lazuli", blockConverters ); + addSmeltBlockConverter( "deepslate_lapis_ore", "lapis_lazuli", "1.17", blockConverters ); + + // NOTE: redstone dust is called redstone within XMaterials: + addSmeltBlockConverter( "redstone_ore", "redstone", blockConverters ); + addSmeltBlockConverter( "deepslate_redstone_ore", "redstone", "1.17", blockConverters ); + + addSmeltBlockConverter( "nether_quartz_ore", "quartz", blockConverters ); + + addSmeltBlockConverterDisabled( "ancient_debris", "netherite_scrap", "1.16", blockConverters ); + + addSmeltBlockConverter( "copper_ore", "copper_ingot", "1.17", blockConverters ); + addSmeltBlockConverter( "deepslate_copper_ore", "copper_ingot", "1.17", blockConverters ); + addSmeltBlockConverter( "raw_copper", "copper_ingot", "1.17", blockConverters ); + + + addSmeltBlockConverter( "sand", "glass", blockConverters ); + addSmeltBlockConverter( "red_sand", "glass", blockConverters ); + + addSmeltBlockConverter( "clay_ball", "brick", blockConverters ); + + addSmeltBlockConverter( "netherrack", "nether_brick", blockConverters ); + addSmeltBlockConverter( "nether_brick", "cracked_nether_brick", blockConverters ); + + + addSmeltBlockConverterDisabled( "cactus", "green_dye", blockConverters ); + addSmeltBlockConverterDisabled( "sea_pickle", "lime_dye", "1.13", blockConverters ); + addSmeltBlockConverterDisabled( "chorus_fruit", "popped_chorus_fruit", "1.9", blockConverters ); + addSmeltBlockConverterDisabled( "wet_sponge", "sponge", blockConverters ); + + + addSmeltBlockConverterDisabled( "potato", "baked_potato", blockConverters ); + addSmeltBlockConverterDisabled( "kep", "dried_kelp", "1.13", blockConverters ); } } + private static void addSmeltBlockConverter( + String keyBlockName, String targetName, + TreeMap blockConverters ) { + + addSmeltBlockConverter( keyBlockName, targetName, null, true, blockConverters ); + } + private static void addSmeltBlockConverterDisabled( + String keyBlockName, String targetName, + TreeMap blockConverters ) { + + addSmeltBlockConverter( keyBlockName, targetName, null, false, blockConverters ); + } + + private static void addSmeltBlockConverter( + String keyBlockName, String targetName, + String semanticVersion, + TreeMap blockConverters ) { + + addSmeltBlockConverter( keyBlockName, targetName, null, true, blockConverters ); + } + private static void addSmeltBlockConverterDisabled( + String keyBlockName, String targetName, + String semanticVersion, + TreeMap blockConverters ) { + + addSmeltBlockConverter( keyBlockName, targetName, null, false, blockConverters ); + } + + private static void addSmeltBlockConverter( + String keyBlockName, String targetName, + String semanticVersion, + boolean enabled, + TreeMap blockConverters ) { + + BlockConverter bc = new BlockConverter( keyBlockName, 1 ); + bc.getTargets().add( new BlockConverterTarget( targetName, 1 ) ); + + // All converters are auto-enabled, so only need to disable: + if ( !enabled ) { + bc.setEnabled( enabled ); + } + + if ( semanticVersion != null && semanticVersion.trim().length() > 0 ) { + bc.setMininumSpigotSemanticVersion( semanticVersion ); + } + + blockConverters.put( bc.getKeyBlockName(), bc ); + } public void reloadConfig() { // First clear the configs: diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java index bafcfccd3..61df59387 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java @@ -4,47 +4,115 @@ import java.util.List; import java.util.TreeMap; +/** + *

+ *

+ * + */ public class BlockConverter { - private String key; + private String keyBlockName; + private int keyQuantity; + private boolean enabled; + + private String mininumSpigotSemanticVersion; private List targets; - public BlockConverter( String blockName ) { + public BlockConverter( String blockName, int keyQuantity ) { super(); - this.key = blockName; + this.keyBlockName = blockName; + this.keyQuantity = keyQuantity; + this.enabled = true; + + this.mininumSpigotSemanticVersion = null; this.targets = new ArrayList<>(); } + + public BlockConverter( String blockName, int keyQuantity, String mininumSpigotSemanticVersion ) { + this( blockName, keyQuantity ); + + this.mininumSpigotSemanticVersion = mininumSpigotSemanticVersion; + } + + public BlockConverter( String blockName ) { + this( blockName, 1 ); + } public BlockConverter( String blockName, Object rawTarget ) { - this( blockName ); + this( blockName, 1 ); parseConverterTarget( rawTarget ); } /** - *

The rawTarget object is an ArrayList of TreeMaps, where each - * TreeMap represents a BlockConverterTarget object. + *

The rawTarget object is an TreeMap of objects. The + * class variables are stored in this map, with the "transformers" + * being stored under that key. The transformer's are an ArrayList + * of TreeMaps, where each TreeMap represents a BlockConverterTarget object. *

* * @param rawTarget */ private void parseConverterTarget( Object rawTargets ) { - if ( rawTargets != null && rawTargets instanceof ArrayList ) { + if ( rawTargets != null && rawTargets instanceof TreeMap ) { @SuppressWarnings("unchecked") - List rTargets = (List) rawTargets; + TreeMap rTargets = (TreeMap) rawTargets; - for ( Object rTarget : rTargets) { + if ( rTargets.size() >= 3 ) { + if ( rTargets.containsKey("keyBlockName") ) { + setKeyBlockName( rTargets.get( "keyBlockName" ).toString() ); + } + if ( rTargets.containsKey("keyQuantity") ) { + int keyBlockQty = (Integer) rTargets.get( "keyQuantity" ); + setKeyQuantity(keyBlockQty); + } + if ( rTargets.containsKey("mininumSpigotSemanticVersion") ) { + setMininumSpigotSemanticVersion( rTargets.get( "mininumSpigotSemanticVersion" ).toString() ); + } + if ( rTargets.containsKey("enabled") ) { + setEnabled( (boolean) rTargets.get( "enabled" ) ); + } - BlockConverterTarget target = new BlockConverterTarget( rTarget ); + if ( rTargets.containsKey( "transformers") ) { + + @SuppressWarnings("unchecked") + List roTargets = (List) rTargets.get( "transformers" ); + + for ( Object roTarget : roTargets) { + + BlockConverterTarget target = new BlockConverterTarget( roTarget ); + + getTargets().add( target ); + } + } - getTargets().add( target ); } + } +// if ( rawTargets != null && rawTargets instanceof ArrayList ) { +// +// @SuppressWarnings("unchecked") +// List rTargets = (List) rawTargets; +// +// for ( Object rTarget : rTargets) { +// +// if ( rTarget instanceof String ) { +// String temp = (String) rTarget; +// if ( temp.equals("") ) { +// setKeyBlockName( temp ); +// } +// } +// +// BlockConverterTarget target = new BlockConverterTarget( rTarget ); +// +// getTargets().add( target ); +// } +// } } /** @@ -64,8 +132,20 @@ private void parseConverterTarget( Object rawTargets ) { * * @return */ - public TreeMap>> toYamlMap() { - TreeMap>> results = new TreeMap<>(); + public TreeMap toYamlMap() { + + TreeMap results = new TreeMap<>(); + + results.put( "keyBlockName", getKeyBlockName() ); + results.put( "keyQuantity", getKeyQuantity() ); + results.put( "enabled", isEnabled() ); + + if ( getMininumSpigotSemanticVersion() != null ) { + results.put( "mininumSpigotSemanticVersion", getMininumSpigotSemanticVersion() ); + } + +// TreeMap>> results = new TreeMap<>(); + List> targets = new ArrayList<>(); @@ -75,7 +155,7 @@ public TreeMap>> toYamlMap() { targets.add(rawTarget); } - results.put( getKey(), targets ); + results.put( "transformers", targets ); return results; } @@ -84,7 +164,20 @@ public TreeMap>> toYamlMap() { public String toString() { StringBuilder sb = new StringBuilder(); - sb.append( getKey() ).append( ": ["); + sb.append( getKeyBlockName() ); + + sb.append( " (keyQuantity: " ).append( getKeyQuantity() ); + + if ( isEnabled() ) { + sb.append( " enabled" ); + } + else { + sb.append( " !enabled" ); + } + + sb.append( ")" ); + + sb.append( ": ["); List strList = new ArrayList<>(); for (BlockConverterTarget bcTarget : targets) { @@ -98,11 +191,39 @@ public String toString() { return sb.toString(); } - public String getKey() { - return key; +// public String getKey() { +// return key; +// } +// public void setKey(String key) { +// this.key = key; +// } + + public String getKeyBlockName() { + return keyBlockName; + } + public void setKeyBlockName(String keyBlockName) { + this.keyBlockName = keyBlockName; + } + + public int getKeyQuantity() { + return keyQuantity; + } + public void setKeyQuantity(int keyQuantity) { + this.keyQuantity = keyQuantity; + } + + public String getMininumSpigotSemanticVersion() { + return mininumSpigotSemanticVersion; + } + public void setMininumSpigotSemanticVersion(String mininumSpigotSemanticVersion) { + this.mininumSpigotSemanticVersion = mininumSpigotSemanticVersion; + } + + public boolean isEnabled() { + return enabled; } - public void setKey(String key) { - this.key = key; + public void setEnabled(boolean enabled) { + this.enabled = enabled; } public List getTargets() { diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java index 511c371ad..e31bbd73e 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java @@ -97,23 +97,24 @@ public void loadFromYamlFile(TreeMap rawBlockConverters) { BlockConverter blockConverter = new BlockConverter( key, rawBlockConverterData ); - value.put( blockConverter.getKey(), blockConverter ); + value.put( blockConverter.getKeyBlockName(), blockConverter ); } } - public TreeMap>> toYamlMap() { - TreeMap>> results = new TreeMap<>(); + public TreeMap> toYamlMap() { + TreeMap> results = new TreeMap<>(); Set keys = getValue().keySet(); for (String key : keys) { BlockConverter blockConverter = getValue().get(key); // NOTE: The TreeMap will always have exactly ONE entry: - TreeMap>> rawBlockConverter = blockConverter.toYamlMap(); - String yamlKey = rawBlockConverter.firstKey(); - List> yamlBlockConverter = rawBlockConverter.firstEntry().getValue(); + TreeMap rawBlockConverter = blockConverter.toYamlMap(); + String yamlKey = rawBlockConverter.get( "keyBlockName" ).toString(); - results.put( yamlKey, yamlBlockConverter ); +// List> yamlBlockConverter = rawBlockConverter.firstEntry().getValue(); + + results.put( yamlKey, rawBlockConverter ); } return results; From df8909719a0544a8a361ec3d87577bf09f610573 Mon Sep 17 00:00:00 2001 From: Oreoezi Date: Tue, 31 May 2022 00:29:51 +0300 Subject: [PATCH 253/297] Added Romanian Locale --- .../resources/lang/core/ro_RO.properties | 84 +++++++++++++++++++ .../resources/lang/mines/ro_RO.properties | 78 +++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 prison-core/out/production/resources/lang/core/ro_RO.properties create mode 100644 prison-core/out/production/resources/lang/mines/ro_RO.properties diff --git a/prison-core/out/production/resources/lang/core/ro_RO.properties b/prison-core/out/production/resources/lang/core/ro_RO.properties new file mode 100644 index 000000000..3693e68b8 --- /dev/null +++ b/prison-core/out/production/resources/lang/core/ro_RO.properties @@ -0,0 +1,84 @@ +# +# Prison este un plugin de Minecraft pentru jocul prison. +# Copyright (C) 2021 The Prison Team +# +# Acest program este FOSS, astfel îl puteți distribui sau modifica +# în cadrul termenilor din GNU General Public License, publicată de +# Free Software Foundation, în concordanță cu versiunea 3 sau +# orice versiune mai noua. +# +# Acest program este distribuit cu scopul de a fi folositor, +# dar FĂRĂ NICIO GARANTIE, inclusiv cea insinuată de +# VANTABILITATE sau FIABILITATEA PENTRU UN ANUMIT SCOP. Verifică +# GNU General Public License pentru mai multe detalii. +# +# Ar fi trebuit să primești o copie a GNU General Public License +# cu acest program. Dacă nu, intră pe . +# + +## +## Prison acceptă standardul Unicode (UTF-8) în aceste fișiere, însă trebuie să +## urmăresti aceste instrucțiuni dacă vrei să meargă totul corespunzător. +## +## 1. Trebuie să editezi aceste fișiere doar cu un editor UTF-8. Pe Windows folosește NotePad, nu WordPad. +## WordPad va salva plaintext. Pentru a confirma că ai salvat: salvează, închide editorul, +## redeschide editorul pentru a confirma că salvările au fost aplicate. +## +## 2. Dacă îl rulezi pe Windows, trebuie să activezi utf-8 encoding în consola de la Minecraft. Windows +## folosește implicit characterpage 1252. Pentru a permite consolei să folosească utf-8, trebuie să schimbi +## encoding-ul înainte de a deschide spigot/paper: +## chcp 65001 +## +## Exemplu complet de script pentru windows, cu hook-uri pentru java debug: +## rem PS: chcp 65001 activează utf-8 in windows, characterpage 1252 fiind implicit +## chcp 65001 +## java -Dfile.encoding="UTF-8" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms1g -Xmx4g -jar spigot-1.8.8.jar nogui --log-strip-color +## pause +## +## 3. Când te uiți la fișiere din logs/latest.log trebuie să folosești un editor ca NotePad, nu WordPad. +## +## 4. Jocul reprezintă Unicode corect, la fel si în consolă, în loguri, și cu paste.helpch.at dacă folosiți +## /prison support submit. +## + + +# PS: messages__version este un număr întreg care este incrementat manual în Prison +# când sunt schimbate aceste mesaje. Această valoare reprezintă dacă mesajele au fost +# schimbate, corectate sau au fost adăugate mesaje noi. Acest număr nu trebuie să fie incrementat +# dacă schimbările sunt mici sau nesemnificative, cum ar fi un spațiu sau câteva litere. +# +# messages__auto_refresh=true indică faptul că acest fișier va fi înlocuit imediat ce +# Prison detectează o diferență în messages__version. Fișierul vechi va fi șters (redenumit) și +# o versiune nouă va fi plasată în folder pentru a fi folosită. Dacă valoarea acestuia este false, atunci +# Prison nu va actualiza acest fișier și este posibil să apară probleme cu afișarea mesajelor pe viitor. +# Dacă auto refresh este false, nu suntem responsabili pentru nicio problemă care ar putea proveni +# din cauza mesajelor. Dacă este false, atunci tu esti responsabil de actualitatea mesajelor. +# +# Dacă faci schimbări la acest fișier și ai messages__auto_refresh=false, atunci acele schimbări +# nu vor fi șterse când fișierul va fi actualizat. Fișierul vechi fiind redenumit, astfel +# nefiind șters, poți integra manual schimbările în fișierul nou. Fișierele vechi, redenumite +# nu vor fi șterse de către Prison; poți să le ștergi când consideri că este sigur să o faci. +# +# Puteți ajuta Prison și utilizatorii acestuia prin a adăuga traduceri în alte limbi. +# Acestea ar trebui să fie traduceri precise, ce mențin înțelesul mesajului original, +# fără glume de prost gust și abateri de la semnificația originală. Dacă dorești să +# ne transmiți ceva, poți contacta un membru staff de pe server-ul nostru de Discord. +#Mulțumim pentru contribuții! +# +includeError=[%1] are o valoare invalidă. +excludeError=[%1] are o valoare invalidă. +cantAsConsole=Nu poți face asta drept consolă. +missingArgument=Parametrul [%1] nu este definit (nu are valoare implicită). +missingFlagArgument=Flag-ul -%1 nu are parametrul necesar. +undefinedFlagArgument=Parametrul [%1] pentru flag-ul -%2 nu este definit. +internalErrorOccurred=Execuția comenzii a cauzat o eroare. +noPermission=Nu ai permisiunea să rulezi această comandă. +blockParseError=Parametrul [%1] nu este un block valid. +numberParseError=Parametrul [%1] nu este un număr. +numberTooLow=Parametrul [%1] trebuie să fie mai mare sau egal cu %2. +numberTooHigh=Parametrul [%1] trebuie să fie mai mic sau egal cu %2. +numberRangeError=Parametrul [%1] trebuie să fie mai mare sau egal cu %2 și mai mic sau egal cu %3. +tooFewCharacters=Parametrul [%1] trebuie să aibă mai mult de %2 caractere. +tooManyCharacters=Parametrul [%1] trebuie să aiba mai puțin de %2 caractere. +playerNotOnline=Jucătorul %1 nu este online. +worldNotFound=Lumea %1 nu există. diff --git a/prison-core/out/production/resources/lang/mines/ro_RO.properties b/prison-core/out/production/resources/lang/mines/ro_RO.properties new file mode 100644 index 000000000..46c5b39c9 --- /dev/null +++ b/prison-core/out/production/resources/lang/mines/ro_RO.properties @@ -0,0 +1,78 @@ +# PS: messages__version este un număr întreg care este incrementat manual în Prison +# când sunt schimbate aceste mesaje. Această valoare reprezintă dacă mesajele au fost +# schimbate, corectate sau au fost adăugate mesaje noi. Acest număr nu trebuie să fie incrementat +# dacă schimbările sunt mici sau nesemnificative, cum ar fi un spațiu sau câteva litere. +# +# messages__auto_refresh=true indică faptul că acest fișier va fi înlocuit imediat ce +# Prison detectează o diferență în messages__version. Fișierul vechi va fi șters (redenumit) și +# o versiune nouă va fi plasată în folder pentru a fi folosită. Dacă valoarea acestuia este false, atunci +# Prison nu va actualiza acest fișier și este posibil să apară probleme cu afișarea mesajelor pe viitor. +# Dacă auto refresh este false, nu suntem responsabili pentru nicio problemă care ar putea proveni +# din cauza mesajelor. Dacă este false, atunci tu esti responsabil de actualitatea mesajelor. +# +# Dacă faci schimbări la acest fișier și ai messages__auto_refresh=false, atunci acele schimbări +# nu vor fi șterse când fișierul va fi actualizat. Fișierul vechi fiind redenumit, astfel +# nefiind șters, poți integra manual schimbările în fișierul nou. Fișierele vechi, redenumite +# nu vor fi șterse de către Prison; poți să le ștergi când consideri că este sigur să o faci. +# +# Puteți ajuta Prison și utilizatorii acestuia prin a adăuga traduceri în alte limbi. +# Acestea ar trebui să fie traduceri precise, ce mențin înțelesul mesajului original, +# fără glume de prost gust și abateri de la semnificația originală. Dacă dorești să +# ne transmiți ceva, poți contacta un membru staff de pe server-ul nostru de Discord. +#Mulțumim pentru contribuții! +# + +## +## Prison acceptă standardul Unicode (UTF-8) în aceste fișiere, însă trebuie să +## urmăresti aceste instrucțiuni dacă vrei să meargă totul corespunzător. +## +## 1. Trebuie să editezi aceste fișiere doar cu un editor UTF-8. Pe Windows folosește NotePad, nu WordPad. +## WordPad va salva plaintext. Pentru a confirma că ai salvat: salvează, închide editorul, +## redeschide editorul pentru a confirma că salvările au fost aplicate. +## +## 2. Dacă îl rulezi pe Windows, trebuie să activezi utf-8 encoding în consola de la Minecraft. Windows +## folosește implicit characterpage 1252. Pentru a permite consolei să folosească utf-8, trebuie să schimbi +## encoding-ul înainte de a deschide spigot/paper: +## chcp 65001 +## +## Exemplu complet de script pentru windows, cu hook-uri pentru java debug: +## rem PS: chcp 65001 activează utf-8 in windows, characterpage 1252 fiind implicit +## chcp 65001 +## java -Dfile.encoding="UTF-8" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms1g -Xmx4g -jar spigot-1.8.8.jar nogui --log-strip-color +## pause +## +## 3. Când te uiți la fișiere din logs/latest.log trebuie să folosești un editor ca NotePad, nu WordPad. +## +## 4. Jocul reprezintă Unicode corect, la fel si în consolă, în loguri, și cu paste.helpch.at dacă folosiți +## /prison support submit. +## +reset_warning=&7Mina %1 va fi resetată &3%2&7. +reset_message=&7Mina %1 a fost resetată. +not_allowed=&7Nu ai voie să minezi aici. +autosmelt_enable=&bAutosmelt-ul &7a fost &aactivat&7. +autosmelt_disable=&bAutosmelt-ul &7a fost &cdezactivat&7. +autoblock_enable=&bAutoblock-ul &7a fost &aactivat&7. +autoblock_disable=&bAutoblock-ul &7a fost &cdezactivat&7. +autopickup_enable=&bAutopickup-ul &7a fost &aactivat&7. +autopickup_disable=&bAutopickup-ul &7a fost &cdezactivat&7. +teleported=&7Ai fost teleportat la mina &3%1&7. +mine_reset=&7Mina &3%1&7 a fost resetată. +mine_reset_fail=&7Nu am putut reseta mina &3%1&7. &8Uite-te în consolă pentru mai multe detalii. +mine_created=&7Mina a fost creată cu succes. +mine_deleted=&7Mina a fost ștearsă. +select_bounds=&7Trebuie să selectezi colțurile minei. &8Scrie /mines wand pentru a face asta. +world_diff=&7Nu ai voie să creezi o mină în două lumi diferite. +mine_exists=&7Deja există o mină cu numele acesta. +mine_does_not_exist=&7Nu există mină cu numele acesta. +spawn_set=&7Spawnpoint-ul minei a fost setat. +spawn_removed=&7Spawnpoint-ul minei a fost șters. +spawnpoint_same_world=&cSpawnpoint-ul &7trebuie să fie în aceeași &clume &7cu mina. +not_a_block=&c%1 &7nu este un block. +block_already_added=&7Acel block a fost adăugat deja în mină. +mine_full=&cMina va fi prea plină. &7Încearcă să scazi șansele apariției acestui block și/sau altor block-uri din mină pentru a avea mai mult spațiu. +block_added=&7Block-ul &3%1 &7a fost adăugat în mina &3%2&7. +block_set=&7Block-ul &3%1 &7a fost schimbat în mina &3%2&7. +block_not_removed=&7Acel block nu este în mină. +block_deleted=&7Block-ul &3%1 &7a fost scos din mina &3%2&7. +mine_redefined=&7Mina a fost &3redefinită &7cu succes. +missing_world=&7Lumea în care a fost creată mina nu există. From 38fae4a922c599e674503c9311eab3a32776ac11 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 30 May 2022 17:07:29 -0400 Subject: [PATCH 254/297] BlockConverters: Adjusting around how they are setup, and how they are generated. BlockConverters are now in their own config file: blockConvertersConfig.json. They are no longer being stacked/placed in the autoFeaturesConfig.yml file, so all the conversion code is no longer required. With it being json, it now can reflect the java classes without any special considerations on the conversion process. --- docs/changelog_v3.3.x.md | 7 +- .../tech/mcprison/prison/PrisonCommand.java | 10 +- .../autofeatures/AutoFeaturesFileConfig.java | 224 ++++------------- .../autofeatures/AutoFeaturesWrapper.java | 25 ++ .../prison/autofeatures/BlockConverter.java | 232 +++++++++--------- .../autofeatures/BlockConverterTarget.java | 198 ++++++++------- .../BlockConvertersFileConfig.java | 148 +++++++++++ .../BlockConvertersInitializer.java | 215 ++++++++++++++++ .../autofeatures/BlockConvertersNode.java | 108 ++++---- .../prison/autofeatures/ValueNode.java | 4 +- .../tech/mcprison/prison/file/FileIO.java | 25 +- .../tech/mcprison/prison/file/JsonFileIO.java | 4 + .../tech/mcprison/prison/file/YamlFileIO.java | 79 +++--- .../prison/ranks/commands/RanksCommands.java | 5 +- .../prison/spigot/SpigotPlatform.java | 3 + 15 files changed, 787 insertions(+), 500 deletions(-) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java create mode 100644 prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 119874219..c872fd9b3 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,12 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11e 2022-05-29 +# 3.3.0-alpha.11e 2022-05-30 + + +* **BlockConverters: Adjusting around how they are setup, and how they are generated.** +BlockConverters are now in their own config file: blockConvertersConfig.json. +They are no longer being stacked/placed in the autoFeaturesConfig.yml file, so all the conversion code is no longer required. With it being json, it now can reflect the java classes without any special considerations on the conversion process. * **BlockConverters: More work on these settings.** 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 7e4def774..b8c803d40 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -827,7 +827,7 @@ public void localesReloadCommand(CommandSender sender ) { onlyPlayers = false, permissions = "prison.autofeatures") public void reloadAutoFeatures(CommandSender sender ) { - AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig().reloadConfig(); + AutoFeaturesWrapper.getInstance().reloadConfigs(); String message = "&7AutoFeatures were reloaded. The new settings are now in effect. "; sender.sendMessage( message ); @@ -840,6 +840,14 @@ public void reloadAutoFeatures(CommandSender sender ) { catch ( IOException e ) { // Ingore } + try { + String filePath = AutoFeaturesWrapper.getInstance().getBlockConvertersConfig() + .getConfigFile().getCanonicalPath(); + sender.sendMessage( filePath ); + } + catch ( IOException e ) { + // Ingore + } } 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 ad13b7140..3b71227da 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 @@ -6,7 +6,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.TreeMap; import tech.mcprison.prison.Prison; import tech.mcprison.prison.autofeatures.ValueNode.NodeType; @@ -287,6 +286,8 @@ public enum AutoFeatures { smeltLimitToMines(smeltFeature, true), smeltAllBlocks(smeltFeature, true), + + smeltConfigurations(smeltFeature, "see smeltFeatures in BlockConversionsConfig.json"), // smeltTransformer(smeltFeature, NodeType.BLOCK_CONVERTER, "smelt" ), @@ -355,7 +356,7 @@ public enum AutoFeatures { private final boolean isLong; private final boolean isDouble; private final boolean isStringList; - private final boolean isBlockConverter; +// private final boolean isBlockConverter; private final String path; private final String message; @@ -364,7 +365,7 @@ public enum AutoFeatures { private final Long longValue; private final Double doubleValue; private final List listValue; - private final TreeMap blockConverters; +// private final TreeMap blockConverters; private AutoFeatures() { this.parent = null; @@ -375,7 +376,7 @@ private AutoFeatures() { this.isLong = false; this.isDouble = false; this.isStringList = false; - this.isBlockConverter = false; +// this.isBlockConverter = false; this.path = null; this.message = null; @@ -384,7 +385,7 @@ private AutoFeatures() { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); - this.blockConverters = new TreeMap<>(); +// this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section) { this.parent = section; @@ -395,7 +396,7 @@ private AutoFeatures(AutoFeatures section) { this.isLong = false; this.isDouble = false; this.isStringList = false; - this.isBlockConverter = false; +// this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -404,7 +405,7 @@ private AutoFeatures(AutoFeatures section) { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); - this.blockConverters = new TreeMap<>(); +// this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, String message) { this.parent = section; @@ -415,7 +416,7 @@ private AutoFeatures(AutoFeatures section, String message) { this.isLong = false; this.isDouble = false; this.isStringList = false; - this.isBlockConverter = false; +// this.isBlockConverter = false; this.path = section.getKey(); this.message = message; @@ -424,7 +425,7 @@ private AutoFeatures(AutoFeatures section, String message) { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); - this.blockConverters = new TreeMap<>(); +// this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, Boolean value) { this.parent = section; @@ -435,7 +436,7 @@ private AutoFeatures(AutoFeatures section, Boolean value) { this.isLong = false; this.isDouble = false; this.isStringList = false; - this.isBlockConverter = false; +// this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -444,7 +445,7 @@ private AutoFeatures(AutoFeatures section, Boolean value) { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); - this.blockConverters = new TreeMap<>(); +// this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, int value) { this.parent = section; @@ -455,7 +456,7 @@ private AutoFeatures(AutoFeatures section, int value) { this.isLong = false; this.isDouble = false; this.isStringList = false; - this.isBlockConverter = false; +// this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -464,7 +465,7 @@ private AutoFeatures(AutoFeatures section, int value) { this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); - this.blockConverters = new TreeMap<>(); +// this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, long value) { this.parent = section; @@ -475,7 +476,7 @@ private AutoFeatures(AutoFeatures section, long value) { this.isLong = true; this.isDouble = false; this.isStringList = false; - this.isBlockConverter = false; +// this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -484,7 +485,7 @@ private AutoFeatures(AutoFeatures section, long value) { this.longValue = value; this.doubleValue = null; this.listValue = new ArrayList<>(); - this.blockConverters = new TreeMap<>(); +// this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, double value) { this.parent = section; @@ -495,7 +496,7 @@ private AutoFeatures(AutoFeatures section, double value) { this.isLong = false; this.isDouble = true; this.isStringList = false; - this.isBlockConverter = false; +// this.isBlockConverter = false; this.path = section.getKey(); this.message = null; @@ -504,7 +505,7 @@ private AutoFeatures(AutoFeatures section, double value) { this.longValue = null; this.doubleValue = value; this.listValue = new ArrayList<>(); - this.blockConverters = new TreeMap<>(); +// this.blockConverters = new TreeMap<>(); } private AutoFeatures(AutoFeatures section, NodeType nodeType, String... values ) { this.parent = section; @@ -515,7 +516,7 @@ private AutoFeatures(AutoFeatures section, NodeType nodeType, String... values ) this.isLong = false; this.isDouble = false; this.isStringList = (nodeType == NodeType.STRING_LIST); - this.isBlockConverter = (nodeType == NodeType.BLOCK_CONVERTER); +// this.isBlockConverter = (nodeType == NodeType.BLOCK_CONVERTER); this.path = section.getKey(); this.message = null; @@ -524,7 +525,7 @@ private AutoFeatures(AutoFeatures section, NodeType nodeType, String... values ) this.longValue = null; this.doubleValue = null; this.listValue = new ArrayList<>(); - this.blockConverters = new TreeMap<>(); +// this.blockConverters = new TreeMap<>(); if ( nodeType == NodeType.STRING_LIST ) { @@ -533,9 +534,9 @@ private AutoFeatures(AutoFeatures section, NodeType nodeType, String... values ) this.listValue.addAll( Arrays.asList( values )); } } - else if ( nodeType == NodeType.BLOCK_CONVERTER ) { - loadDefaultBlockConverters( blockConverters, Arrays.asList( values ) ); - } +// else if ( nodeType == NodeType.BLOCK_CONVERTER ) { +// loadDefaultBlockConverters( blockConverters, Arrays.asList( values ) ); +// } } public AutoFeatures getParent() { @@ -562,9 +563,9 @@ public boolean isDouble() { public boolean isStringList() { return isStringList; } - public boolean isBlockConverter() { - return isBlockConverter; - } +// public boolean isBlockConverter() { +// return isBlockConverter; +// } public String getPath() { return path; @@ -588,9 +589,9 @@ public Double getDoubleValue() { public List getListValue() { return listValue; } - public TreeMap getBlockConverters() { - return blockConverters; - } +// public TreeMap getBlockConverters() { +// return blockConverters; +// } public String getKey() { return (path != null ? path + "." : "") + this.name(); @@ -717,24 +718,24 @@ else if ( getListValue() != null && getListValue().size() > 0 ) { } - public TreeMap getBlockConverters( Map conf ) { - TreeMap results = null; - - - if ( conf.containsKey(getKey()) && conf.get( getKey() ).isBlockConvertersNode() ) { - BlockConvertersNode blockConverters = (BlockConvertersNode) conf.get( getKey() ); - results = blockConverters.getValue(); - } -// else if ( getListValue() != null && getListValue().size() > 0 ) { -// results = getListValue(); +// public TreeMap getBlockConverters( Map conf ) { +// TreeMap results = null; +// +// +// if ( conf.containsKey(getKey()) && conf.get( getKey() ).isBlockConvertersNode() ) { +// BlockConvertersNode blockConverters = (BlockConvertersNode) conf.get( getKey() ); +// results = blockConverters.getValue(); // } - - if ( results == null ) { - results = new BlockConvertersNode().getValue(); - } - - return results; - } +//// else if ( getListValue() != null && getListValue().size() > 0 ) { +//// results = getListValue(); +//// } +// +// if ( results == null ) { +// results = new BlockConvertersNode().getValue(); +// } +// +// return results; +// } /** @@ -821,140 +822,7 @@ protected AutoFeaturesFileConfig() { } - - public static void loadDefaultBlockConverters( - TreeMap blockConverters, List sampleSets ) { - - if ( sampleSets.contains( "sample01" ) ) { - BlockConverter bc1 = new BlockConverter( "coal_ore", 9 ); - bc1.getTargets().add( new BlockConverterTarget( "diamond", 1 )); - - - BlockConverter bc2 = new BlockConverter( "ice_block" ); - BlockConverterTarget bc2t1 = new BlockConverterTarget( "water_bucket", 2); - BlockConverterTarget bc2t2 = new BlockConverterTarget( "gravel", 1); - BlockConverterTarget bc2t3 = new BlockConverterTarget( "pufferfish", 1, 0.15 ); - bc2t3.getPermissions().add("prison.not.used.sample.pufferfish"); - bc2t3.getPermissions().add("prison.not.used.sample.admin"); - bc2.getTargets().add( bc2t1 ); - bc2.getTargets().add( bc2t2 ); - bc2.getTargets().add( bc2t3 ); - - - - blockConverters.put( bc1.getKeyBlockName(), bc1 ); - blockConverters.put( bc2.getKeyBlockName(), bc2 ); - - } - - if ( sampleSets.contains( "smelt" ) ) { - - addSmeltBlockConverter( "cobblestone", "stone", blockConverters ); - addSmeltBlockConverter( "cobbled_deepslate", "deepslate", "1.17", blockConverters ); - - addSmeltBlockConverter( "gold_ore", "gold_ingot", blockConverters ); - addSmeltBlockConverter( "nether_gold_ore", "gold_ingot", "1.16", blockConverters ); - addSmeltBlockConverter( "deepslate_gold_ore", "gold_ingot", "1.17", blockConverters ); - addSmeltBlockConverter( "raw_gold", "gold_ingot", "1.17", blockConverters ); - - addSmeltBlockConverter( "iron_ore", "iron_ingot", blockConverters ); - addSmeltBlockConverter( "deepslate_iron_ore", "iron_ingot", "1.17", blockConverters ); - addSmeltBlockConverter( "raw_iron", "iron_ingot", "1.17", blockConverters ); - - addSmeltBlockConverter( "coal_ore", "coal", blockConverters ); - addSmeltBlockConverter( "deepslate_coal_ore", "coal", "1.17", blockConverters ); - - addSmeltBlockConverter( "diamond_ore", "diamond", blockConverters ); - addSmeltBlockConverter( "deepslate_diamond_ore", "diamond", "1.17", blockConverters ); - - addSmeltBlockConverter( "emerald_ore", "emerald", blockConverters ); - addSmeltBlockConverter( "deepslate_emerald_ore", "emerald", "1.17", blockConverters ); - - addSmeltBlockConverter( "lapis_ore", "lapis_lazuli", blockConverters ); - addSmeltBlockConverter( "deepslate_lapis_ore", "lapis_lazuli", "1.17", blockConverters ); - - // NOTE: redstone dust is called redstone within XMaterials: - addSmeltBlockConverter( "redstone_ore", "redstone", blockConverters ); - addSmeltBlockConverter( "deepslate_redstone_ore", "redstone", "1.17", blockConverters ); - - addSmeltBlockConverter( "nether_quartz_ore", "quartz", blockConverters ); - - addSmeltBlockConverterDisabled( "ancient_debris", "netherite_scrap", "1.16", blockConverters ); - - addSmeltBlockConverter( "copper_ore", "copper_ingot", "1.17", blockConverters ); - addSmeltBlockConverter( "deepslate_copper_ore", "copper_ingot", "1.17", blockConverters ); - addSmeltBlockConverter( "raw_copper", "copper_ingot", "1.17", blockConverters ); - - - addSmeltBlockConverter( "sand", "glass", blockConverters ); - addSmeltBlockConverter( "red_sand", "glass", blockConverters ); - - addSmeltBlockConverter( "clay_ball", "brick", blockConverters ); - - addSmeltBlockConverter( "netherrack", "nether_brick", blockConverters ); - addSmeltBlockConverter( "nether_brick", "cracked_nether_brick", blockConverters ); - - addSmeltBlockConverterDisabled( "cactus", "green_dye", blockConverters ); - addSmeltBlockConverterDisabled( "sea_pickle", "lime_dye", "1.13", blockConverters ); - addSmeltBlockConverterDisabled( "chorus_fruit", "popped_chorus_fruit", "1.9", blockConverters ); - addSmeltBlockConverterDisabled( "wet_sponge", "sponge", blockConverters ); - - - addSmeltBlockConverterDisabled( "potato", "baked_potato", blockConverters ); - addSmeltBlockConverterDisabled( "kep", "dried_kelp", "1.13", blockConverters ); - - } - } - - private static void addSmeltBlockConverter( - String keyBlockName, String targetName, - TreeMap blockConverters ) { - - addSmeltBlockConverter( keyBlockName, targetName, null, true, blockConverters ); - } - private static void addSmeltBlockConverterDisabled( - String keyBlockName, String targetName, - TreeMap blockConverters ) { - - addSmeltBlockConverter( keyBlockName, targetName, null, false, blockConverters ); - } - - private static void addSmeltBlockConverter( - String keyBlockName, String targetName, - String semanticVersion, - TreeMap blockConverters ) { - - addSmeltBlockConverter( keyBlockName, targetName, null, true, blockConverters ); - } - private static void addSmeltBlockConverterDisabled( - String keyBlockName, String targetName, - String semanticVersion, - TreeMap blockConverters ) { - - addSmeltBlockConverter( keyBlockName, targetName, null, false, blockConverters ); - } - - private static void addSmeltBlockConverter( - String keyBlockName, String targetName, - String semanticVersion, - boolean enabled, - TreeMap blockConverters ) { - - BlockConverter bc = new BlockConverter( keyBlockName, 1 ); - bc.getTargets().add( new BlockConverterTarget( targetName, 1 ) ); - - // All converters are auto-enabled, so only need to disable: - if ( !enabled ) { - bc.setEnabled( enabled ); - } - - if ( semanticVersion != null && semanticVersion.trim().length() > 0 ) { - bc.setMininumSpigotSemanticVersion( semanticVersion ); - } - - blockConverters.put( bc.getKeyBlockName(), bc ); - } public void reloadConfig() { // First clear the configs: diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.java index 50f964a89..52027f8f4 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.java @@ -4,6 +4,7 @@ import java.util.List; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; +import tech.mcprison.prison.output.Output; public class AutoFeaturesWrapper { @@ -11,11 +12,18 @@ public class AutoFeaturesWrapper private static AutoFeaturesWrapper instance = null; private AutoFeaturesFileConfig autoFeaturesConfig = null; + + private BlockConvertersFileConfig blockConvertersConfig = null; private AutoFeaturesWrapper() { super(); this.autoFeaturesConfig = new AutoFeaturesFileConfig(); + + if ( Output.get().isDebug() ) { + + this.blockConvertersConfig = new BlockConvertersFileConfig(); + } } public static AutoFeaturesWrapper getInstance() { @@ -31,11 +39,28 @@ public static AutoFeaturesWrapper getInstance() { return instance; } + + public void reloadConfigs() { + getAutoFeaturesConfig().reloadConfig(); + + if ( Output.get().isDebug() ) { + + getBlockConvertersConfig().reloadConfig(); + } + } public AutoFeaturesFileConfig getAutoFeaturesConfig() { return autoFeaturesConfig; } + public BlockConvertersFileConfig getBlockConvertersConfig() { + return blockConvertersConfig; + } + + public void setBlockConvertersConfig(BlockConvertersFileConfig blockConvertersConfig) { + this.blockConvertersConfig = blockConvertersConfig; + } + public boolean isBoolean( AutoFeatures feature ) { return autoFeaturesConfig.isFeatureBoolean( feature ); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java index 61df59387..597562e04 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.TreeMap; /** *

@@ -17,7 +16,9 @@ public class BlockConverter { private String mininumSpigotSemanticVersion; - private List targets; + private ArrayList permissions; + + private ArrayList targets; public BlockConverter( String blockName, int keyQuantity ) { super(); @@ -28,6 +29,8 @@ public BlockConverter( String blockName, int keyQuantity ) { this.mininumSpigotSemanticVersion = null; + this.permissions = new ArrayList<>(); + this.targets = new ArrayList<>(); } @@ -41,124 +44,124 @@ public BlockConverter( String blockName ) { this( blockName, 1 ); } - public BlockConverter( String blockName, Object rawTarget ) { - this( blockName, 1 ); - - parseConverterTarget( rawTarget ); - } +// public BlockConverter( String blockName, Object rawTarget ) { +// this( blockName, 1 ); +// +// parseConverterTarget( rawTarget ); +// } - /** - *

The rawTarget object is an TreeMap of objects. The - * class variables are stored in this map, with the "transformers" - * being stored under that key. The transformer's are an ArrayList - * of TreeMaps, where each TreeMap represents a BlockConverterTarget object. - *

- * - * @param rawTarget - */ - private void parseConverterTarget( Object rawTargets ) { - - if ( rawTargets != null && rawTargets instanceof TreeMap ) { - - @SuppressWarnings("unchecked") - TreeMap rTargets = (TreeMap) rawTargets; - - if ( rTargets.size() >= 3 ) { - if ( rTargets.containsKey("keyBlockName") ) { - setKeyBlockName( rTargets.get( "keyBlockName" ).toString() ); - } - if ( rTargets.containsKey("keyQuantity") ) { - int keyBlockQty = (Integer) rTargets.get( "keyQuantity" ); - setKeyQuantity(keyBlockQty); - } - if ( rTargets.containsKey("mininumSpigotSemanticVersion") ) { - setMininumSpigotSemanticVersion( rTargets.get( "mininumSpigotSemanticVersion" ).toString() ); - } - if ( rTargets.containsKey("enabled") ) { - setEnabled( (boolean) rTargets.get( "enabled" ) ); - } - - if ( rTargets.containsKey( "transformers") ) { - - @SuppressWarnings("unchecked") - List roTargets = (List) rTargets.get( "transformers" ); - - for ( Object roTarget : roTargets) { - - BlockConverterTarget target = new BlockConverterTarget( roTarget ); - - getTargets().add( target ); - } - } - - } - - } -// if ( rawTargets != null && rawTargets instanceof ArrayList ) { +// /** +// *

The rawTarget object is an TreeMap of objects. The +// * class variables are stored in this map, with the "transformers" +// * being stored under that key. The transformer's are an ArrayList +// * of TreeMaps, where each TreeMap represents a BlockConverterTarget object. +// *

+// * +// * @param rawTarget +// */ +// private void parseConverterTarget( Object rawTargets ) { +// +// if ( rawTargets != null && rawTargets instanceof TreeMap ) { // // @SuppressWarnings("unchecked") -// List rTargets = (List) rawTargets; +// TreeMap rTargets = (TreeMap) rawTargets; // -// for ( Object rTarget : rTargets) { +// if ( rTargets.size() >= 3 ) { +// if ( rTargets.containsKey("keyBlockName") ) { +// setKeyBlockName( rTargets.get( "keyBlockName" ).toString() ); +// } +// if ( rTargets.containsKey("keyQuantity") ) { +// int keyBlockQty = (Integer) rTargets.get( "keyQuantity" ); +// setKeyQuantity(keyBlockQty); +// } +// if ( rTargets.containsKey("mininumSpigotSemanticVersion") ) { +// setMininumSpigotSemanticVersion( rTargets.get( "mininumSpigotSemanticVersion" ).toString() ); +// } +// if ( rTargets.containsKey("enabled") ) { +// setEnabled( (boolean) rTargets.get( "enabled" ) ); +// } // -// if ( rTarget instanceof String ) { -// String temp = (String) rTarget; -// if ( temp.equals("") ) { -// setKeyBlockName( temp ); +// if ( rTargets.containsKey( "transformers") ) { +// +// @SuppressWarnings("unchecked") +// List roTargets = (List) rTargets.get( "transformers" ); +// +// for ( Object roTarget : roTargets) { +// +// BlockConverterTarget target = new BlockConverterTarget( roTarget ); +// +// getTargets().add( target ); // } // } // -// BlockConverterTarget target = new BlockConverterTarget( rTarget ); -// -// getTargets().add( target ); // } +// // } - } +//// if ( rawTargets != null && rawTargets instanceof ArrayList ) { +//// +//// @SuppressWarnings("unchecked") +//// List rTargets = (List) rawTargets; +//// +//// for ( Object rTarget : rTargets) { +//// +//// if ( rTarget instanceof String ) { +//// String temp = (String) rTarget; +//// if ( temp.equals("") ) { +//// setKeyBlockName( temp ); +//// } +//// } +//// +//// BlockConverterTarget target = new BlockConverterTarget( rTarget ); +//// +//// getTargets().add( target ); +//// } +//// } +// } - /** - *

This function converts this object in to a saveable yaml object. - * It basically undoes what parseConverterTarget does. - * The big difference is that where parseConverterTarget has a - * blockName and an Object that represents an ArrayList, this - * returns a TreeMap where the key is the blockName and the object of - * the TreeMap are all of the BlockConverterTarget objects represented - * as a yaml maps. - *

- * - *

The returned TreeMap should be added to other TreeMaps, where all of - * the keys are combined, and all of the objects are combined in to one - * TreeMap. - *

- * - * @return - */ - public TreeMap toYamlMap() { - - TreeMap results = new TreeMap<>(); - - results.put( "keyBlockName", getKeyBlockName() ); - results.put( "keyQuantity", getKeyQuantity() ); - results.put( "enabled", isEnabled() ); - - if ( getMininumSpigotSemanticVersion() != null ) { - results.put( "mininumSpigotSemanticVersion", getMininumSpigotSemanticVersion() ); - } - -// TreeMap>> results = new TreeMap<>(); - - - List> targets = new ArrayList<>(); - - for ( BlockConverterTarget target : getTargets() ) { - TreeMap rawTarget = target.toYamlMap(); - - targets.add(rawTarget); - } - - results.put( "transformers", targets ); - - return results; - } +// /** +// *

This function converts this object in to a saveable yaml object. +// * It basically undoes what parseConverterTarget does. +// * The big difference is that where parseConverterTarget has a +// * blockName and an Object that represents an ArrayList, this +// * returns a TreeMap where the key is the blockName and the object of +// * the TreeMap are all of the BlockConverterTarget objects represented +// * as a yaml maps. +// *

+// * +// *

The returned TreeMap should be added to other TreeMaps, where all of +// * the keys are combined, and all of the objects are combined in to one +// * TreeMap. +// *

+// * +// * @return +// */ +// public TreeMap toYamlMap() { +// +// TreeMap results = new TreeMap<>(); +// +// results.put( "keyBlockName", getKeyBlockName() ); +// results.put( "keyQuantity", getKeyQuantity() ); +// results.put( "enabled", isEnabled() ); +// +// if ( getMininumSpigotSemanticVersion() != null ) { +// results.put( "mininumSpigotSemanticVersion", getMininumSpigotSemanticVersion() ); +// } +// +//// TreeMap>> results = new TreeMap<>(); +// +// +// List> targets = new ArrayList<>(); +// +// for ( BlockConverterTarget target : getTargets() ) { +// TreeMap rawTarget = target.toYamlMap(); +// +// targets.add(rawTarget); +// } +// +// results.put( "transformers", targets ); +// +// return results; +// } @Override public String toString() { @@ -226,10 +229,17 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } - public List getTargets() { + public ArrayList getPermissions() { + return permissions; + } + public void setPermissions(ArrayList permissions) { + this.permissions = permissions; + } + + public ArrayList getTargets() { return targets; } - public void setTargets(List targets) { + public void setTargets(ArrayList targets) { this.targets = targets; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java index 13b55d7dc..e2865aa93 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java @@ -1,15 +1,13 @@ package tech.mcprison.prison.autofeatures; import java.util.ArrayList; -import java.util.List; -import java.util.TreeMap; public class BlockConverterTarget { private String blockName; private Integer quantity; private Double chance; - private List permissions; + private ArrayList permissions; public BlockConverterTarget( String blockName, Integer quantity ) { super(); @@ -27,109 +25,109 @@ public BlockConverterTarget( String blockName, Integer quantity, Double chance ) this.chance = chance; } - /** - * - * @param rawTarget - */ - public BlockConverterTarget( Object rawTarget ) { - super(); - - this.permissions = new ArrayList<>(); +// /** +// * +// * @param rawTarget +// */ +// public BlockConverterTarget( Object rawTarget ) { +// super(); +// +// this.permissions = new ArrayList<>(); +// +// parseConverterTarget( rawTarget ); +// } - parseConverterTarget( rawTarget ); - } - - private void parseConverterTarget( Object rawTarget ) { - - // This should be a TreeMaps of field settings. - if ( rawTarget != null && rawTarget instanceof TreeMap ) { - - @SuppressWarnings("unchecked") - TreeMap rawMaps = (TreeMap) rawTarget; - - if ( rawMaps != null ) { - if ( rawMaps.containsKey("blockName") ) { - Object raw = rawMaps.get( "blockName" ); - - if ( raw != null && raw instanceof String ) { - - setBlockName( (String) raw ); - } - } - - if ( rawMaps.containsKey("quantity") ) { - Object raw = rawMaps.get( "quantity" ); - - if ( raw != null && raw instanceof Integer ) { - - setQuantity( (Integer) raw ); - } - } - - if ( rawMaps.containsKey("chance") ) { - Object raw = rawMaps.get( "chance" ); - - if ( raw != null && raw instanceof Double ) { - - setChance( (Double) raw ); - } - } - - if ( rawMaps.containsKey("permissions") ) { - Object raw = rawMaps.get( "permissions" ); - - if ( raw != null && raw instanceof String ) { - - getPermissions().add( (String) raw ); - } - else if ( raw != null && raw instanceof ArrayList ) { - - @SuppressWarnings("unchecked") - ArrayList perms = (ArrayList) raw; - - for (String perm : perms) { - getPermissions().add(perm); - } - } - } - } - } - } +// private void parseConverterTarget( Object rawTarget ) { +// +// // This should be a TreeMaps of field settings. +// if ( rawTarget != null && rawTarget instanceof TreeMap ) { +// +// @SuppressWarnings("unchecked") +// TreeMap rawMaps = (TreeMap) rawTarget; +// +// if ( rawMaps != null ) { +// if ( rawMaps.containsKey("blockName") ) { +// Object raw = rawMaps.get( "blockName" ); +// +// if ( raw != null && raw instanceof String ) { +// +// setBlockName( (String) raw ); +// } +// } +// +// if ( rawMaps.containsKey("quantity") ) { +// Object raw = rawMaps.get( "quantity" ); +// +// if ( raw != null && raw instanceof Integer ) { +// +// setQuantity( (Integer) raw ); +// } +// } +// +// if ( rawMaps.containsKey("chance") ) { +// Object raw = rawMaps.get( "chance" ); +// +// if ( raw != null && raw instanceof Double ) { +// +// setChance( (Double) raw ); +// } +// } +// +// if ( rawMaps.containsKey("permissions") ) { +// Object raw = rawMaps.get( "permissions" ); +// +// if ( raw != null && raw instanceof String ) { +// +// getPermissions().add( (String) raw ); +// } +// else if ( raw != null && raw instanceof ArrayList ) { +// +// @SuppressWarnings("unchecked") +// ArrayList perms = (ArrayList) raw; +// +// for (String perm : perms) { +// getPermissions().add(perm); +// } +// } +// } +// } +// } +// } - /** - *

This function converts this object in to a saveable yaml object. - * It basically undoes what parseConverterTarget does. - *

- * @return - */ - public TreeMap toYamlMap() { - TreeMap results = new TreeMap<>(); - - results.put( "blockName", getBlockName() ); - results.put( "quantity", getQuantity() == null ? null : getQuantity().intValue() ); - - if ( getChance() != null ) { - results.put( "chance", getChance().doubleValue() ); - } - - if ( getPermissions() != null && getPermissions().size() > 0 ) { - results.put( "permissions", getPermissions() ); - } +// /** +// *

This function converts this object in to a saveable yaml object. +// * It basically undoes what parseConverterTarget does. +// *

+// * @return +// */ +// public TreeMap toYamlMap() { +// TreeMap results = new TreeMap<>(); // -// results.put( "blockName", new TextNode( getBlockName() ).getValue() ); -// results.put( "quantity", getQuantity() == null ? -// new NullNode().getValue() : new IntegerNode( getQuantity() ).getValue() ); +// results.put( "blockName", getBlockName() ); +// results.put( "quantity", getQuantity() == null ? null : getQuantity().intValue() ); // // if ( getChance() != null ) { -// results.put( "chance", new DoubleNode( getChance() ).getValue() ); +// results.put( "chance", getChance().doubleValue() ); // } // // if ( getPermissions() != null && getPermissions().size() > 0 ) { -// results.put( "permissions", new StringListNode( getPermissions() ).getValue() ); +// results.put( "permissions", getPermissions() ); // } - - return results; - } +//// +//// results.put( "blockName", new TextNode( getBlockName() ).getValue() ); +//// results.put( "quantity", getQuantity() == null ? +//// new NullNode().getValue() : new IntegerNode( getQuantity() ).getValue() ); +//// +//// if ( getChance() != null ) { +//// results.put( "chance", new DoubleNode( getChance() ).getValue() ); +//// } +//// +//// if ( getPermissions() != null && getPermissions().size() > 0 ) { +//// results.put( "permissions", new StringListNode( getPermissions() ).getValue() ); +//// } +// +// return results; +// } @Override public String toString() { @@ -145,7 +143,7 @@ public String toString() { if ( getPermissions().size() > 0 ) { StringBuilder sbp = new StringBuilder(); - sbp.append( " [" ); + sbp.append( " permissions= [" ); for (String perm : getPermissions() ) { if ( sbp.length() > 2 ) { @@ -188,10 +186,10 @@ public void setChance(Double chance) { this.chance = chance; } - public List getPermissions() { + public ArrayList getPermissions() { return permissions; } - public void setPermissions(List permissions) { + public void setPermissions(ArrayList permissions) { this.permissions = permissions; } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java new file mode 100644 index 000000000..f4198e1f9 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java @@ -0,0 +1,148 @@ +package tech.mcprison.prison.autofeatures; + +import java.io.File; +import java.util.TreeMap; + +import tech.mcprison.prison.Prison; +import tech.mcprison.prison.file.FileIOData; +import tech.mcprison.prison.file.JsonFileIO; +import tech.mcprison.prison.ranks.data.RankPlayer; + +public class BlockConvertersFileConfig + implements FileIOData { + + public static final String FILE_NAME__BLOCK_CONVERTS_CONFIG_JSON = "/blockConvertersConfig.json"; + + private transient File configFile; + + private TreeMap> blockConverters; + + public enum BlockConverterTypes { + aSample01, + smeltFeatures, + blockFeatures + ; + } + + public BlockConvertersFileConfig() { + super(); + + this.blockConverters = new TreeMap<>(); + + } + + /** + *

Using the RankPlayer, this will filter (remove) any BlockConverter for which a + * player would not have access to it. It should be understood that a blockConverter + * may be accessible to a player, but it could contain a BlockConverterTarger that + * they do not have access to due to permissions restrictions. + *

+ * + * @param player + * @param blockName + * @return + */ + public BlockConverter getBlockConverter( RankPlayer player, String blockName, + BlockConverterTypes bcType ) { + BlockConverter results = null; + + if ( player != null && blockName != null && bcType != null ) { + + BlockConverter temp = getBlockConverter( blockName, bcType ); + if ( temp != null && temp.getPermissions().size() == 0 ) { + results = temp; + } + else if ( temp != null ) { + for (String perm : temp.getPermissions() ) { + if ( player.hasPermission( perm ) ) { + results = temp; + break; + } + } + } + } + + return results; + } + + + /** + *

This will return a BlockConverter if there is a match on the blockName. + * The match will be based upon the blockName being converted to lowercase. + *

+ * + * @param blockName + * @param bcType + * @return + */ + public BlockConverter getBlockConverter( String blockName, BlockConverterTypes bcType ) { + BlockConverter results = null; + + if ( blockName != null && bcType != null ) { + + TreeMap bConverters = getBlockConverters().get(bcType); + + if ( bConverters.containsKey( blockName.toLowerCase() ) ) { + results = bConverters.get( blockName.toLowerCase() ); + } + } + + return results; + } + + + private boolean initialConfig() { + boolean dirty = false; + + BlockConvertersInitializer initializer = new BlockConvertersInitializer(); + + dirty = initializer.checkConfigs( getBlockConverters() ); + + + if ( initializer.validateBlockConverters( getBlockConverters() ) ) { + dirty = true; + } + + return dirty; + } + + + public File getConfigFile() { + if ( this.configFile == null ) { + + this.configFile = new File( + Prison.get().getDataFolder() + FILE_NAME__BLOCK_CONVERTS_CONFIG_JSON); + } + return configFile; + } + + public void reloadConfig() { + JsonFileIO jfio = new JsonFileIO(); + + BlockConvertersFileConfig temp = (BlockConvertersFileConfig) jfio.readJsonFile( getConfigFile(), this ); + + if ( temp != null ) { + setBlockConverters( temp.getBlockConverters() ); + } + + boolean dirty = initialConfig(); + + if ( dirty ) { + saveToJson(); + } + } + + public void saveToJson() { + JsonFileIO jfio = new JsonFileIO(); + + jfio.saveJsonFile(getConfigFile(), this ); + } + + public TreeMap> getBlockConverters() { + return blockConverters; + } + public void setBlockConverters(TreeMap> blockConverters) { + this.blockConverters = blockConverters; + } + +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java new file mode 100644 index 000000000..25feeb448 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java @@ -0,0 +1,215 @@ +package tech.mcprison.prison.autofeatures; + +import java.util.Set; +import java.util.TreeMap; + +import tech.mcprison.prison.autofeatures.BlockConvertersFileConfig.BlockConverterTypes; + +public class BlockConvertersInitializer { + + public boolean checkConfigs(TreeMap> treeMap) { + boolean isDirty = false; + + if ( treeMap != null ) { + + for ( BlockConverterTypes bcType : BlockConverterTypes.values() ) { + + if ( !treeMap.containsKey( bcType ) ) { + + TreeMap blockConverters = new TreeMap<>(); + + loadDefaultBlockConverters( bcType, blockConverters ); + + if ( blockConverters.size() > 0 ) { + + treeMap.put( bcType, blockConverters ); + isDirty = true; + } + } + } + + } + + return isDirty; + } + + + private void loadDefaultBlockConverters( BlockConverterTypes bcType, TreeMap blockConverters ) { + + switch (bcType) { + + case aSample01: + + loadDefaultBlockConverterSample01( blockConverters ); + + break; + + case blockFeatures: + + break; + + case smeltFeatures: + + loadDefaultBlockConverterSmelters( blockConverters ); + + break; + + default: + break; + } + } + + + private void loadDefaultBlockConverterSample01(TreeMap blockConverters) { + + BlockConverter bc1 = new BlockConverter( "coal_ore", 9 ); + bc1.getTargets().add( new BlockConverterTarget( "diamond", 1 )); + + + BlockConverter bc2 = new BlockConverter( "ice_block" ); + BlockConverterTarget bc2t1 = new BlockConverterTarget( "water_bucket", 2); + BlockConverterTarget bc2t2 = new BlockConverterTarget( "gravel", 1); + BlockConverterTarget bc2t3 = new BlockConverterTarget( "pufferfish", 1, 0.15 ); + bc2t3.getPermissions().add("prison.not.used.sample.pufferfish"); + bc2t3.getPermissions().add("prison.not.used.sample.admin"); + bc2.getTargets().add( bc2t1 ); + bc2.getTargets().add( bc2t2 ); + bc2.getTargets().add( bc2t3 ); + + + + blockConverters.put( bc1.getKeyBlockName(), bc1 ); + blockConverters.put( bc2.getKeyBlockName(), bc2 ); + + } + + + public void loadDefaultBlockConverterSmelters( + TreeMap blockConverters ) { + + + addSmeltBlockConverter( "cobblestone", "stone", blockConverters ); + addSmeltBlockConverter( "cobbled_deepslate", "deepslate", "1.17", blockConverters ); + + addSmeltBlockConverter( "gold_ore", "gold_ingot", blockConverters ); + addSmeltBlockConverter( "nether_gold_ore", "gold_ingot", "1.16", blockConverters ); + addSmeltBlockConverter( "deepslate_gold_ore", "gold_ingot", "1.17", blockConverters ); + addSmeltBlockConverter( "raw_gold", "gold_ingot", "1.17", blockConverters ); + + addSmeltBlockConverter( "iron_ore", "iron_ingot", blockConverters ); + addSmeltBlockConverter( "deepslate_iron_ore", "iron_ingot", "1.17", blockConverters ); + addSmeltBlockConverter( "raw_iron", "iron_ingot", "1.17", blockConverters ); + + addSmeltBlockConverter( "coal_ore", "coal", blockConverters ); + addSmeltBlockConverter( "deepslate_coal_ore", "coal", "1.17", blockConverters ); + + addSmeltBlockConverter( "diamond_ore", "diamond", blockConverters ); + addSmeltBlockConverter( "deepslate_diamond_ore", "diamond", "1.17", blockConverters ); + + addSmeltBlockConverter( "emerald_ore", "emerald", blockConverters ); + addSmeltBlockConverter( "deepslate_emerald_ore", "emerald", "1.17", blockConverters ); + + addSmeltBlockConverter( "lapis_ore", "lapis_lazuli", blockConverters ); + addSmeltBlockConverter( "deepslate_lapis_ore", "lapis_lazuli", "1.17", blockConverters ); + + // NOTE: redstone dust is called redstone within XMaterials: + addSmeltBlockConverter( "redstone_ore", "redstone", blockConverters ); + addSmeltBlockConverter( "deepslate_redstone_ore", "redstone", "1.17", blockConverters ); + + addSmeltBlockConverter( "nether_quartz_ore", "quartz", blockConverters ); + + addSmeltBlockConverterDisabled( "ancient_debris", "netherite_scrap", "1.16", blockConverters ); + + addSmeltBlockConverter( "copper_ore", "copper_ingot", "1.17", blockConverters ); + addSmeltBlockConverter( "deepslate_copper_ore", "copper_ingot", "1.17", blockConverters ); + addSmeltBlockConverter( "raw_copper", "copper_ingot", "1.17", blockConverters ); + + + addSmeltBlockConverter( "sand", "glass", blockConverters ); + addSmeltBlockConverter( "red_sand", "glass", blockConverters ); + + addSmeltBlockConverter( "clay_ball", "brick", blockConverters ); + + addSmeltBlockConverter( "netherrack", "nether_brick", blockConverters ); + addSmeltBlockConverter( "nether_brick", "cracked_nether_brick", blockConverters ); + + + addSmeltBlockConverterDisabled( "cactus", "green_dye", blockConverters ); + addSmeltBlockConverterDisabled( "sea_pickle", "lime_dye", "1.13", blockConverters ); + addSmeltBlockConverterDisabled( "chorus_fruit", "popped_chorus_fruit", "1.9", blockConverters ); + addSmeltBlockConverterDisabled( "wet_sponge", "sponge", blockConverters ); + + + addSmeltBlockConverterDisabled( "potato", "baked_potato", blockConverters ); + addSmeltBlockConverterDisabled( "kep", "dried_kelp", "1.13", blockConverters ); + + + } + + private static void addSmeltBlockConverter( + String keyBlockName, String targetName, + TreeMap blockConverters ) { + + addSmeltBlockConverter( keyBlockName, targetName, null, true, blockConverters ); + } + private static void addSmeltBlockConverterDisabled( + String keyBlockName, String targetName, + TreeMap blockConverters ) { + + addSmeltBlockConverter( keyBlockName, targetName, null, false, blockConverters ); + } + + private static void addSmeltBlockConverter( + String keyBlockName, String targetName, + String semanticVersion, + TreeMap blockConverters ) { + + addSmeltBlockConverter( keyBlockName, targetName, null, true, blockConverters ); + } + private static void addSmeltBlockConverterDisabled( + String keyBlockName, String targetName, + String semanticVersion, + TreeMap blockConverters ) { + + addSmeltBlockConverter( keyBlockName, targetName, null, false, blockConverters ); + } + + private static void addSmeltBlockConverter( + String keyBlockName, String targetName, + String semanticVersion, + boolean enabled, + TreeMap blockConverters ) { + + BlockConverter bc = new BlockConverter( keyBlockName, 1 ); + bc.getTargets().add( new BlockConverterTarget( targetName, 1 ) ); + + // All converters are auto-enabled, so only need to disable: + if ( !enabled ) { + bc.setEnabled( enabled ); + } + + if ( semanticVersion != null && semanticVersion.trim().length() > 0 ) { + bc.setMininumSpigotSemanticVersion( semanticVersion ); + } + + blockConverters.put( bc.getKeyBlockName(), bc ); + } + + + public boolean validateBlockConverters( + TreeMap> blockConverters ) { + + // The root nodes do not need to be validated since they have to be enums + Set typeKeys = blockConverters.keySet(); + for (BlockConverterTypes type : typeKeys) { + + TreeMap converters = blockConverters.get(type); + + Set converterKeys = converters.keySet(); + + } + + return false; + } + +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java index e31bbd73e..d860677d4 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersNode.java @@ -6,9 +6,9 @@ import java.util.TreeMap; public class BlockConvertersNode - extends ValueNode +// e-xtends ValueNode { - private static final long serialVersionUID = -1L; +// private static final long serialVersionUID = -1L; TreeMap value; @@ -18,11 +18,11 @@ public BlockConvertersNode() { this.value = new TreeMap<>(); } - public BlockConvertersNode( TreeMap value ) { - this(); - - this.value = value; - } +// public BlockConvertersNode( TreeMap value ) { +// this(); +// +// this.value = value; +// } @Override public String toString() { @@ -49,13 +49,13 @@ public TreeMap getValue() { return value; } - @Override - public boolean isBlockConvertersNode() { return true; } - - @Override - public NodeType getNodeType() { - return NodeType.BLOCK_CONVERTER; - } +// @Override +// public boolean isBlockConvertersNode() { return true; } +// +// @Override +// public NodeType getNodeType() { +// return NodeType.BLOCK_CONVERTER; +// } @Override @@ -79,45 +79,45 @@ public int hashCode() { return getValue().hashCode(); } - /** - *

This function takes a map of maps to construct and load the block converters. - * This process takes the keys of this map, and the related object, and then constructs - * the BlockConverter object. The BlockConverter object deals with processing it's own - * content as passed to it with the Object form this rawBlockConverters map. - *

- * - * @param rawBlockConverters - */ - public void loadFromYamlFile(TreeMap rawBlockConverters) { - - Set keys = rawBlockConverters.keySet(); - - for (String key : keys) { - Object rawBlockConverterData = rawBlockConverters.get(key); - - BlockConverter blockConverter = new BlockConverter( key, rawBlockConverterData ); - - value.put( blockConverter.getKeyBlockName(), blockConverter ); - } - } - - public TreeMap> toYamlMap() { - TreeMap> results = new TreeMap<>(); - - Set keys = getValue().keySet(); - for (String key : keys) { - BlockConverter blockConverter = getValue().get(key); - - // NOTE: The TreeMap will always have exactly ONE entry: - TreeMap rawBlockConverter = blockConverter.toYamlMap(); - String yamlKey = rawBlockConverter.get( "keyBlockName" ).toString(); - -// List> yamlBlockConverter = rawBlockConverter.firstEntry().getValue(); - - results.put( yamlKey, rawBlockConverter ); - } - - return results; - } +// /** +// *

This function takes a map of maps to construct and load the block converters. +// * This process takes the keys of this map, and the related object, and then constructs +// * the BlockConverter object. The BlockConverter object deals with processing it's own +// * content as passed to it with the Object form this rawBlockConverters map. +// *

+// * +// * @param rawBlockConverters +// */ +// public void loadFromYamlFile(TreeMap rawBlockConverters) { +// +// Set keys = rawBlockConverters.keySet(); +// +// for (String key : keys) { +// Object rawBlockConverterData = rawBlockConverters.get(key); +// +// BlockConverter blockConverter = new BlockConverter( key, rawBlockConverterData ); +// +// value.put( blockConverter.getKeyBlockName(), blockConverter ); +// } +// } +// +// public TreeMap> toYamlMap() { +// TreeMap> results = new TreeMap<>(); +// +// Set keys = getValue().keySet(); +// for (String key : keys) { +// BlockConverter blockConverter = getValue().get(key); +// +// // NOTE: The TreeMap will always have exactly ONE entry: +// TreeMap rawBlockConverter = blockConverter.toYamlMap(); +// String yamlKey = rawBlockConverter.get( "keyBlockName" ).toString(); +// +//// List> yamlBlockConverter = rawBlockConverter.firstEntry().getValue(); +// +// results.put( yamlKey, rawBlockConverter ); +// } +// +// return results; +// } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/ValueNode.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/ValueNode.java index 8ef642e21..470962764 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/ValueNode.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/ValueNode.java @@ -18,8 +18,8 @@ public enum NodeType { LONG, INTEGER, DOUBLE, - STRING_LIST, - BLOCK_CONVERTER + STRING_LIST +// BLOCK_CONVERTER ; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/file/FileIO.java b/prison-core/src/main/java/tech/mcprison/prison/file/FileIO.java index 5c9f58bf0..f6564604a 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/file/FileIO.java +++ b/prison-core/src/main/java/tech/mcprison/prison/file/FileIO.java @@ -118,20 +118,23 @@ protected String readFile( File file ) StringBuilder results = new StringBuilder(); // String results = null; - try - { - List lines = Files.readAllLines( file.toPath(), StandardCharsets.UTF_8 ); - - for ( String line : lines ) { - results.append( line ).append( "\n" ); - } + if ( file.exists() ) { + try + { + List lines = Files.readAllLines( file.toPath(), StandardCharsets.UTF_8 ); + + for ( String line : lines ) { + results.append( line ).append( "\n" ); + } + // byte[] bytes = Files.readAllBytes( file.toPath() ); // results = new String(bytes); - } - catch ( IOException e ) - { - logException( "Failed to load file", file, e ); + } + catch ( IOException e ) + { + logException( "Failed to load file", file, e ); + } } return results.toString(); 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 bc872b0e8..ff65e920a 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 @@ -26,6 +26,10 @@ public JsonFileIO(ErrorManager errorManager, ModuleStatus status) this.gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); } + public JsonFileIO() { + this( null, null ); + } + public Gson getGson() { return gson; diff --git a/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java b/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java index a141fac80..e01e17bbb 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java +++ b/prison-core/src/main/java/tech/mcprison/prison/file/YamlFileIO.java @@ -8,7 +8,6 @@ import java.util.TreeMap; import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures; -import tech.mcprison.prison.autofeatures.BlockConvertersNode; import tech.mcprison.prison.autofeatures.BooleanNode; import tech.mcprison.prison.autofeatures.DoubleNode; import tech.mcprison.prison.autofeatures.IntegerNode; @@ -82,16 +81,16 @@ public boolean saveYamlAutoFeatures( Map config ) { set( key, ((StringListNode) value).getValue() ); break; - case BLOCK_CONVERTER: - try { - set( key, ((BlockConvertersNode) value).toYamlMap() ); - } - catch (Exception e) { - Output.get().logError("YamlFileIO.saveYamlAutoFeatures " - + "Error with BLOCK_CONVERTER toYamlMap. key: " + key, e); -// e.printStackTrace(); - } - break; +// case BLOCK_CONVERTER: +// try { +// set( key, ((BlockConvertersNode) value).toYamlMap() ); +// } +// catch (Exception e) { +// Output.get().logError("YamlFileIO.saveYamlAutoFeatures " +// + "Error with BLOCK_CONVERTER toYamlMap. key: " + key, e); +//// e.printStackTrace(); +// } +// break; default: // invalid type... not supported. @@ -208,35 +207,35 @@ else if ( autoFeat.isStringList() ) { value = StringListNode.valueOf( stringListVal ); } - else if ( autoFeat.isBlockConverter() ) { - // Setup default value for block converters: - BlockConvertersNode blockConverters = new BlockConvertersNode( - autoFeat.getBlockConverters() ); - - if ( yaml.containsKey(key) ) { - - try { - - Object rawBlockConverterNode = yaml.get( key ); - - if ( rawBlockConverterNode != null && rawBlockConverterNode instanceof TreeMap ) { - - @SuppressWarnings("unchecked") - TreeMap rawBlockConverters = (TreeMap) rawBlockConverterNode; - - blockConverters.loadFromYamlFile( rawBlockConverters ); - } - } - catch (Exception e) { - Output.get().logError("YamlFileIO.loadYamlAutoFeatures " - + "Error with BLOCK_CONVERTER loadFromYamlFile. key: " + key, e); -// e.printStackTrace(); - } - - } - - value = blockConverters; - } +// else if ( autoFeat.isBlockConverter() ) { +// // Setup default value for block converters: +// BlockConvertersNode blockConverters = new BlockConvertersNode( +// autoFeat.getBlockConverters() ); +// +// if ( yaml.containsKey(key) ) { +// +// try { +// +// Object rawBlockConverterNode = yaml.get( key ); +// +// if ( rawBlockConverterNode != null && rawBlockConverterNode instanceof TreeMap ) { +// +// @SuppressWarnings("unchecked") +// TreeMap rawBlockConverters = (TreeMap) rawBlockConverterNode; +// +// blockConverters.loadFromYamlFile( rawBlockConverters ); +// } +// } +// catch (Exception e) { +// Output.get().logError("YamlFileIO.loadYamlAutoFeatures " +// + "Error with BLOCK_CONVERTER loadFromYamlFile. key: " + key, e); +//// e.printStackTrace(); +// } +// +// } +// +// value = blockConverters; +// } if ( !keys.contains( autoFeat.getKey() )) { 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 0a9429a88..1b09ac5b4 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 @@ -537,10 +537,11 @@ public void autoConfigureRanks(CommandSender sender, } - // Reload the placeholders and autoFeatures: + // Reload the placeholders: Prison.get().getPlatform().getPlaceholders().reloadPlaceholders(); - AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig().reloadConfig(); + // Reloads autoFeatures and blockConverters: + AutoFeaturesWrapper.getInstance().reloadConfigs(); // Reset all player to the first rank on the default 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 6b64cfc49..5bf5177d2 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 @@ -2016,7 +2016,10 @@ public List getActiveFeatures( boolean showLaddersAndRanks ) { + // Load the autoFeaturesConfig.yml and blockConvertersConfig.json files: AutoFeaturesWrapper afw = AutoFeaturesWrapper.getInstance(); + afw.reloadConfigs(); + boolean isAutoManagerEnabled = afw.isBoolean( AutoFeatures.isAutoManagerEnabled ); results.add( String.format("AutoManager Enabled:&b %s", isAutoManagerEnabled) ); From ff28ce2e6e04a92cf8a452c835fc6ef91b790328 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 30 May 2022 19:25:04 -0400 Subject: [PATCH 255/297] BlockConverters: add some validators to the BlockConverters. Reports various issues, fixes non-lowercase source block names, and also disables invalid settings. --- .../autofeatures/BlockConverterTarget.java | 14 ++ .../BlockConvertersInitializer.java | 132 +++++++++++++++++- 2 files changed, 145 insertions(+), 1 deletion(-) diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java index e2865aa93..25ad8c237 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java @@ -7,6 +7,7 @@ public class BlockConverterTarget { private String blockName; private Integer quantity; private Double chance; + private boolean enabled; private ArrayList permissions; public BlockConverterTarget( String blockName, Integer quantity ) { @@ -15,6 +16,7 @@ public BlockConverterTarget( String blockName, Integer quantity ) { this.blockName = blockName; this.quantity = quantity; this.chance = null; + this.enabled = true; this.permissions = new ArrayList<>(); } @@ -137,6 +139,11 @@ public String toString() { sb.append( getBlockName() ).append( " "); sb.append( getQuantity() ); + if ( !isEnabled() ) { + + sb.append( "DISABLED " ); + } + if ( getChance() != null && getChance() != 0d ) { sb.append( " " ).append( getChance() ); } @@ -186,6 +193,13 @@ public void setChance(Double chance) { this.chance = chance; } + public boolean isEnabled() { + return enabled; + } + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + public ArrayList getPermissions() { return permissions; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java index 25feeb448..583863f89 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java @@ -2,8 +2,11 @@ import java.util.Set; import java.util.TreeMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import tech.mcprison.prison.autofeatures.BlockConvertersFileConfig.BlockConverterTypes; +import tech.mcprison.prison.output.Output; public class BlockConvertersInitializer { @@ -198,6 +201,7 @@ private static void addSmeltBlockConverter( public boolean validateBlockConverters( TreeMap> blockConverters ) { + boolean dirty = false; // The root nodes do not need to be validated since they have to be enums Set typeKeys = blockConverters.keySet(); @@ -205,11 +209,137 @@ public boolean validateBlockConverters( TreeMap converters = blockConverters.get(type); + TreeMap convertersRemovable = new TreeMap<>(); + + Set converterKeys = converters.keySet(); + for (String converterKey : converterKeys) { + + BlockConverter converter = converters.get( converterKey ); + + if ( !converterKey.equals( converterKey.toLowerCase() ) ) { + Output.get().logInfo( + "BlockConverters: block converter key value must be all lowercase or they will never be " + + "accessible. Converting to lowercase and updating config. " + + "BlockConverterType: %s converterKey: %s ", + type.name(), converterKey ); + + convertersRemovable.put( converterKey, converterKey.toLowerCase() ); + dirty = true; + } + + if ( converter.getKeyQuantity() < 1 ) { + + Output.get().logInfo( + "BlockConverters: block converter keyQuantity must have a value of 1 or greater. " + + "This BlockConverter is being disabled. " + + "BlockConverterType: %s converterKey: %s keyQuantity: %d ", + type.name(), converterKey, converter.getKeyQuantity() ); + converter.setEnabled( false ); + dirty = true; + } + + if ( isSpigotVersionInvalid( converter.getMininumSpigotSemanticVersion() ) ) { + + + Output.get().logInfo( + "BlockConverters: block converter MininumSpigotSemanticVersion is invalid. " + + "This BlockConverter may not work as expected. No changes applied. " + + "BlockConverterType: %s converterKey: %s mininumSpigotSemanticVersion: %s ", + type.name(), converterKey, converter.getMininumSpigotSemanticVersion() ); +// converter.setEnabled( false ); +// dirty = true; + } + + + for ( BlockConverterTarget bcTarget : converter.getTargets() ) { + + if ( bcTarget.getChance() <= 0 ) { + + Output.get().logInfo( + "BlockConverters: block converter target has invalid chance: Cannot be zero or negative. " + + "This BlockConverter target has been disabled. " + + "BlockConverterType: %s converterKey: %s " + + "targetBlockName: %s chance: %d", + type.name(), converterKey, + bcTarget.getBlockName(), bcTarget.getChance()); + + bcTarget.setEnabled( false ); + dirty = true; + } + + if ( bcTarget.getChance() > 100 ) { + + Output.get().logInfo( + "BlockConverters: block converter target has invalid chance: Cannot be greater than 100. " + + "This BlockConverter target has been disabled. " + + "BlockConverterType: %s converterKey: %s " + + "targetBlockName: %s chance: %d", + type.name(), converterKey, + bcTarget.getBlockName(), bcTarget.getChance()); + + bcTarget.setEnabled( false ); + dirty = true; + } + + if ( bcTarget.getQuantity() <= 0 ) { + + Output.get().logInfo( + "BlockConverters: block converter target has invalid quatity: Cannot be zero or negative. " + + "This BlockConverter target has been disabled. " + + "BlockConverterType: %s converterKey: %s " + + "targetBlockName: %s quantity: %d", + type.name(), converterKey, + bcTarget.getBlockName(), bcTarget.getQuantity() ); + + bcTarget.setEnabled( false ); + dirty = true; + } + + + } + + + } + + if ( convertersRemovable.size() > 0 ) { + Set keys = convertersRemovable.keySet(); + for ( String removeableKey : keys ) { + + String newKey = convertersRemovable.get( removeableKey ); + + // Remove the old key, and add the BlockConverter back with the new key: + BlockConverter converter = converters.remove( removeableKey ); + if ( converter != null ) { + converter.setKeyBlockName( newKey ); + converters.put( newKey, converter ); + } + + } + } + + } + + return dirty; + } + + + private boolean isSpigotVersionInvalid(String mininumSpigotSemanticVersion) { + boolean invalid = false; + + if ( mininumSpigotSemanticVersion != null ) { + + // validate that the semantic value is valid + String semVerRegEx = "^((([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)" + + "(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$"; + Pattern versionPattern = Pattern.compile( semVerRegEx ); + Matcher matcher = versionPattern.matcher( mininumSpigotSemanticVersion ); + invalid = matcher.matches(); + } - return false; + return invalid; } } From 9543dc47c4447e61f35800aeb958b12f796053f9 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 30 May 2022 19:25:43 -0400 Subject: [PATCH 256/297] BlockConverters: add some validators to the BlockConverters. Reports various issues, fixes non-lowercase source block names, and also disables invalid settings. --- docs/changelog_v3.3.x.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index c872fd9b3..add2635e0 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11e 2022-05-30 +* **BlockConverters: add some validators to the BlockConverters.** +Reports various issues, fixes non-lowercase source block names, and also disables invalid settings. + + * **BlockConverters: Adjusting around how they are setup, and how they are generated.** BlockConverters are now in their own config file: blockConvertersConfig.json. They are no longer being stacked/placed in the autoFeaturesConfig.yml file, so all the conversion code is no longer required. With it being json, it now can reflect the java classes without any special considerations on the conversion process. From c308178be1720563f32737ddddc964b08787a6ea Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 30 May 2022 19:40:50 -0400 Subject: [PATCH 257/297] Romanian Locale language files were placed in the wrong location. Oreoezi provide two new language files for the Romanian Locale, but they were placed in the wrong location. They were added to "prison-core/out/production/resources/lang/core/" and ".../mines/". For them to actually work correctly, without being deleted, need to be placed within the following path: "prison-core/src/main/resources/lang/core/" and "prison-core/src/main/resources/lang/mines". These should now be usable. Also the LocaleManager now has alternatives setup to default to en_US; future alternative languages can be added in the future. --- docs/changelog_v3.3.x.md | 9 +++++++++ .../tech/mcprison/prison/localization/LocaleManager.java | 2 ++ .../main}/resources/lang/core/ro_RO.properties | 0 .../main}/resources/lang/mines/ro_RO.properties | 0 4 files changed, 11 insertions(+) rename prison-core/{out/production => src/main}/resources/lang/core/ro_RO.properties (100%) rename prison-core/{out/production => src/main}/resources/lang/mines/ro_RO.properties (100%) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index add2635e0..a4ec5a6e0 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,15 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11e 2022-05-30 +* **Romanian Locale language files were placed in the wrong location.** +Oreoezi provide two new language files for the Romanian Locale, but they were placed in the wrong location. +They were added to "prison-core/out/production/resources/lang/core/" and ".../mines/". For them to actually +work correctly, without being deleted, need to be placed within the following path: +"prison-core/src/main/resources/lang/core/" and "prison-core/src/main/resources/lang/mines". +These should now be usable. Also the LocaleManager now has alternatives setup to default to en_US; future +alternative languages can be added in the future. + + * **BlockConverters: add some validators to the BlockConverters.** Reports various issues, fixes non-lowercase source block names, and also disables invalid settings. diff --git a/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java b/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java index af418e629..6e12aa34b 100755 --- a/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java @@ -113,6 +113,8 @@ public class LocaleManager { // Portugese dialects ALTERNATIVES.put("pt_BR", Arrays.asList("pt_PT", "en_US")); ALTERNATIVES.put("pt_PT", Arrays.asList("pt_BR", "en_US")); + + ALTERNATIVES.put("ro_RO", Arrays.asList("en_US")); } private final PluginEntity module; diff --git a/prison-core/out/production/resources/lang/core/ro_RO.properties b/prison-core/src/main/resources/lang/core/ro_RO.properties similarity index 100% rename from prison-core/out/production/resources/lang/core/ro_RO.properties rename to prison-core/src/main/resources/lang/core/ro_RO.properties diff --git a/prison-core/out/production/resources/lang/mines/ro_RO.properties b/prison-core/src/main/resources/lang/mines/ro_RO.properties similarity index 100% rename from prison-core/out/production/resources/lang/mines/ro_RO.properties rename to prison-core/src/main/resources/lang/mines/ro_RO.properties From 88e5376e38c3f71ce272fe8361b5fcc7bfd59914 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 30 May 2022 23:23:53 -0400 Subject: [PATCH 258/297] BlockConversions: hooked up the code to not only filter and return the blockConversions for the player and the block, but to also return the item stacks from the results. This is just about ready to be used in the code. --- docs/changelog_v3.3.x.md | 4 + .../autofeatures/BlockConverterResults.java | 65 +++++++++++ .../BlockConvertersFileConfig.java | 104 +++++++++++++++++- .../BlockConvertersInitializer.java | 26 +++-- .../prison/internal/block/PrisonBlock.java | 8 ++ .../prison/internal/platform/Platform.java | 6 +- .../tech/mcprison/prison/TestPlatform.java | 6 + .../prison/spigot/SpigotPlatform.java | 10 ++ 8 files changed, 218 insertions(+), 11 deletions(-) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterResults.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index a4ec5a6e0..0fe409654 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11e 2022-05-30 +* **BlockConversions: hooked up the code to not only filter and return the blockConversions for the player and the block, but to also return the item stacks from the results.** +This is just about ready to be used in the code. + + * **Romanian Locale language files were placed in the wrong location.** Oreoezi provide two new language files for the Romanian Locale, but they were placed in the wrong location. They were added to "prison-core/out/production/resources/lang/core/" and ".../mines/". For them to actually diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterResults.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterResults.java new file mode 100644 index 000000000..ada1a6ecc --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterResults.java @@ -0,0 +1,65 @@ +package tech.mcprison.prison.autofeatures; + +import java.util.ArrayList; +import java.util.List; + +import tech.mcprison.prison.internal.ItemStack; + +public class BlockConverterResults { + + private String sourceBlockName; + private int sourceBlockQuantity; + + // Results: + private boolean resultsSuccess; + + private List resultsItemStack; + private int resultsQuantityConsumed; + + public BlockConverterResults( String blockName, int blockQuanty ) { + super(); + + this.sourceBlockName = blockName; + this.sourceBlockQuantity = blockQuanty; + + this.resultsSuccess = false; + this.resultsItemStack = new ArrayList<>(); + this.resultsQuantityConsumed = -1; + } + + public String getSourceBlockName() { + return sourceBlockName; + } + public void setSourceBlockName(String sourceBlockName) { + this.sourceBlockName = sourceBlockName; + } + + public int getSourceBlockQuantity() { + return sourceBlockQuantity; + } + public void setSourceBlockQuantity(int sourceBlockQuantity) { + this.sourceBlockQuantity = sourceBlockQuantity; + } + + public boolean isResultsSuccess() { + return resultsSuccess; + } + public void setResultsSuccess(boolean resultsSuccess) { + this.resultsSuccess = resultsSuccess; + } + + public List getResultsItemStack() { + return resultsItemStack; + } + public void setResultsItemStack(List resultsItemStack) { + this.resultsItemStack = resultsItemStack; + } + + public int getResultsQuantityConsumed() { + return resultsQuantityConsumed; + } + public void setResultsQuantityConsumed(int resultsQuantityConsumed) { + this.resultsQuantityConsumed = resultsQuantityConsumed; + } + +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java index f4198e1f9..f4972ca52 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java @@ -1,11 +1,15 @@ package tech.mcprison.prison.autofeatures; import java.io.File; +import java.util.ArrayList; +import java.util.List; import java.util.TreeMap; import tech.mcprison.prison.Prison; import tech.mcprison.prison.file.FileIOData; import tech.mcprison.prison.file.JsonFileIO; +import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.block.PrisonBlock; import tech.mcprison.prison.ranks.data.RankPlayer; public class BlockConvertersFileConfig @@ -30,7 +34,50 @@ public BlockConvertersFileConfig() { this.blockConverters = new TreeMap<>(); } - + + public BlockConverterResults getBlockConverterItemStacks( RankPlayer player, + String blockName, int blockQuantity, + BlockConverterTypes bcType ) { + + BlockConverterResults results = new BlockConverterResults( blockName, blockQuantity ); + + if ( blockName != null && blockQuantity >= 1 ) { + + BlockConverter bc = getBlockConverter( player, blockName, bcType ); + + if ( bc != null && blockQuantity >= bc.getKeyQuantity() ) { + + // getBlockConverterTargets applies chance, perms, etc... + List targets = getBlockConverterTargets( player, bc ); + + int multiplier = blockQuantity / bc.getKeyQuantity(); + + results.setResultsQuantityConsumed( bc.getKeyQuantity() * multiplier ); + + for (BlockConverterTarget target : targets) { + + String blkName = target.getBlockName(); + int blkQuanity = target.getQuantity(); + + PrisonBlock pBlock = Prison.get().getPlatform().getPrisonBlock( blkName ); + if ( pBlock != null ) { + + ItemStack pItemStack = pBlock.getItemStack( blkQuanity ); + + if ( pItemStack != null ) { + results.getResultsItemStack().add( pItemStack ); + } + } + } + + results.setResultsSuccess( true ); + } + } + + return results; + } + + /** *

Using the RankPlayer, this will filter (remove) any BlockConverter for which a * player would not have access to it. It should be understood that a blockConverter @@ -91,6 +138,61 @@ public BlockConverter getBlockConverter( String blockName, BlockConverterTypes b } + /** + *

Based upon the block converter, extract all valid targets for this player. + *

+ * + * @param player + * @param bc + * @return + */ + private List getBlockConverterTargets(RankPlayer player, BlockConverter bc) { + + List targets = new ArrayList<>(); + + if ( bc.getTargets() != null ) { + + for ( BlockConverterTarget bcTarget : bc.getTargets() ) { + + if ( bcTarget.isEnabled() ) { + + // If chance, and the random number is greater than the chance, then skip this target: + if ( bcTarget.getChance() != null && + bcTarget.getChance().doubleValue() > (Math.random() * 100d ) ) { + continue; + } + + // Confirm the player has perms: + if ( bcTarget.getPermissions() != null ) { + + boolean hasPerm = false; + for (String perm : bcTarget.getPermissions() ) { + if ( player.hasPermission( perm ) ) { + hasPerm = true; + break; + } + } + + // If player does not have perms to use this target, then skip this target: + if ( !hasPerm ) { + continue; + } + + } + + // Return the selected target: + targets.add( bcTarget ); + } + + } + } + + + return targets; + } + + + private boolean initialConfig() { boolean dirty = false; diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java index 583863f89..9e88f3466 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java @@ -255,21 +255,26 @@ public boolean validateBlockConverters( for ( BlockConverterTarget bcTarget : converter.getTargets() ) { - if ( bcTarget.getChance() <= 0 ) { + if ( bcTarget.getChance() != null && bcTarget.getChance() <= 0 ) { Output.get().logInfo( - "BlockConverters: block converter target has invalid chance: Cannot be zero or negative. " + "BlockConverters: block converter target has invalid chance: " + + "Cannot be zero or negative. " + "This BlockConverter target has been disabled. " + "BlockConverterType: %s converterKey: %s " - + "targetBlockName: %s chance: %d", + + "targetBlockName: %s chance: %s", type.name(), converterKey, - bcTarget.getBlockName(), bcTarget.getChance()); + bcTarget.getBlockName(), + + bcTarget.getChance() == null ? "null" : Double.toString( bcTarget.getQuantity() ) + + ); bcTarget.setEnabled( false ); dirty = true; } - if ( bcTarget.getChance() > 100 ) { + if ( bcTarget.getChance() != null && bcTarget.getChance() > 100 ) { Output.get().logInfo( "BlockConverters: block converter target has invalid chance: Cannot be greater than 100. " @@ -283,15 +288,18 @@ public boolean validateBlockConverters( dirty = true; } - if ( bcTarget.getQuantity() <= 0 ) { + if ( bcTarget.getQuantity() == null || bcTarget.getQuantity() <= 0 ) { Output.get().logInfo( - "BlockConverters: block converter target has invalid quatity: Cannot be zero or negative. " + "BlockConverters: block converter target has invalid quatity: " + + "Cannot be null, zero, or negative. " + "This BlockConverter target has been disabled. " + "BlockConverterType: %s converterKey: %s " - + "targetBlockName: %s quantity: %d", + + "targetBlockName: %s quantity: %s", type.name(), converterKey, - bcTarget.getBlockName(), bcTarget.getQuantity() ); + bcTarget.getBlockName(), + bcTarget.getQuantity() == null ? "null" : Integer.toString( bcTarget.getQuantity() ) + ); bcTarget.setEnabled( false ); dirty = true; diff --git a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java index c0ee5585f..6264743bb 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java +++ b/prison-core/src/main/java/tech/mcprison/prison/internal/block/PrisonBlock.java @@ -440,4 +440,12 @@ public List getDrops( ItemStack tool ) return null; } + + public ItemStack getItemStack( int blockQuantity ) { + + ItemStack results = Prison.get().getPlatform().getItemStack( this, blockQuantity ); + + return results; + } + } 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 e903aa9e8..f39f813cc 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 @@ -28,6 +28,7 @@ import tech.mcprison.prison.commands.PluginCommand; import tech.mcprison.prison.file.YamlFileIO; import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.PlayerUtil; import tech.mcprison.prison.internal.Scheduler; @@ -314,6 +315,9 @@ public default Optional getCommand(String label) { public PrisonBlock getPrisonBlock( String blockName ); + public ItemStack getItemStack( PrisonBlock prisonBlock, int blockQuantity ); + + public boolean linkModuleElements( ModuleElement sourceElement, ModuleElementType targetElementType, String name ); @@ -430,5 +434,5 @@ public void autoCreateMineLinerAssignment( List rankMineNames, 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 d8492350a..140d9de56 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java +++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java @@ -33,6 +33,7 @@ import tech.mcprison.prison.file.FileStorage; import tech.mcprison.prison.file.YamlFileIO; import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.PlayerUtil; import tech.mcprison.prison.internal.Scheduler; @@ -316,6 +317,11 @@ public PrisonBlock getPrisonBlock( String blockName ) { return null; } + @Override + public ItemStack getItemStack( PrisonBlock prisonBlock, int blockQuantity ) { + return null; + } + @Override public boolean linkModuleElements( ModuleElement sourceElement, ModuleElementType targetElementType, String name ) { 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 5bf5177d2..7c03f9c0d 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 @@ -62,6 +62,7 @@ import tech.mcprison.prison.file.YamlFileIO; import tech.mcprison.prison.integration.IntegrationManager; import tech.mcprison.prison.integration.IntegrationType; +import tech.mcprison.prison.internal.ItemStack; import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.PlayerUtil; import tech.mcprison.prison.internal.Scheduler; @@ -102,6 +103,7 @@ import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerTokenEnchant; import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerZenchantments; import tech.mcprison.prison.spigot.block.BlockBreakPriority; +import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.spigot.commands.PrisonSpigotSellAllCommands; import tech.mcprison.prison.spigot.compat.SpigotCompatibility; import tech.mcprison.prison.spigot.game.SpigotCommandSender; @@ -1072,6 +1074,14 @@ public PrisonBlock getPrisonBlock( String blockName ) { } + @Override + public ItemStack getItemStack( PrisonBlock prisonBlock, int blockQuantity ) { + + ItemStack results = new SpigotItemStack( blockQuantity, prisonBlock ); + + return results; + } + /** * ModuleElements are Mines or Ranks, and sometimes maybe even ladders. * From 76f21c5628f97c31db0993774b94b85fade3ce35 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 31 May 2022 00:58:26 -0400 Subject: [PATCH 259/297] BlockConverters: rename targets to outputs. --- docs/changelog_v3.3.x.md | 3 + .../prison/autofeatures/BlockConverter.java | 23 ++---- ...rTarget.java => BlockConverterOutput.java} | 6 +- .../BlockConvertersFileConfig.java | 40 +++++----- .../BlockConvertersInitializer.java | 76 +++++++++---------- 5 files changed, 72 insertions(+), 76 deletions(-) rename prison-core/src/main/java/tech/mcprison/prison/autofeatures/{BlockConverterTarget.java => BlockConverterOutput.java} (96%) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0fe409654..3f0b80d8a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11e 2022-05-30 +* **BlockConverters: rename targets to outputs.** + + * **BlockConversions: hooked up the code to not only filter and return the blockConversions for the player and the block, but to also return the item stacks from the results.** This is just about ready to be used in the code. diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java index 597562e04..34b4678d7 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverter.java @@ -18,7 +18,7 @@ public class BlockConverter { private ArrayList permissions; - private ArrayList targets; + private ArrayList outputs; public BlockConverter( String blockName, int keyQuantity ) { super(); @@ -31,7 +31,7 @@ public BlockConverter( String blockName, int keyQuantity ) { this.permissions = new ArrayList<>(); - this.targets = new ArrayList<>(); + this.outputs = new ArrayList<>(); } public BlockConverter( String blockName, int keyQuantity, String mininumSpigotSemanticVersion ) { @@ -183,9 +183,9 @@ public String toString() { sb.append( ": ["); List strList = new ArrayList<>(); - for (BlockConverterTarget bcTarget : targets) { + for (BlockConverterOutput bcOutput : outputs) { - strList.add( bcTarget.toString() ); + strList.add( bcOutput.toString() ); } sb.append( String.join( ", ", strList ) ); @@ -194,13 +194,6 @@ public String toString() { return sb.toString(); } -// public String getKey() { -// return key; -// } -// public void setKey(String key) { -// this.key = key; -// } - public String getKeyBlockName() { return keyBlockName; } @@ -236,11 +229,11 @@ public void setPermissions(ArrayList permissions) { this.permissions = permissions; } - public ArrayList getTargets() { - return targets; + public ArrayList getOutputs() { + return outputs; } - public void setTargets(ArrayList targets) { - this.targets = targets; + public void setOutputs(ArrayList outputs) { + this.outputs = outputs; } } diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterOutput.java similarity index 96% rename from prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java rename to prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterOutput.java index 25ad8c237..28ba7a506 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterTarget.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConverterOutput.java @@ -2,7 +2,7 @@ import java.util.ArrayList; -public class BlockConverterTarget { +public class BlockConverterOutput { private String blockName; private Integer quantity; @@ -10,7 +10,7 @@ public class BlockConverterTarget { private boolean enabled; private ArrayList permissions; - public BlockConverterTarget( String blockName, Integer quantity ) { + public BlockConverterOutput( String blockName, Integer quantity ) { super(); this.blockName = blockName; @@ -21,7 +21,7 @@ public BlockConverterTarget( String blockName, Integer quantity ) { this.permissions = new ArrayList<>(); } - public BlockConverterTarget( String blockName, Integer quantity, Double chance ) { + public BlockConverterOutput( String blockName, Integer quantity, Double chance ) { this( blockName, quantity ); this.chance = chance; diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java index f4972ca52..0735030b4 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java @@ -47,17 +47,17 @@ public BlockConverterResults getBlockConverterItemStacks( RankPlayer player, if ( bc != null && blockQuantity >= bc.getKeyQuantity() ) { - // getBlockConverterTargets applies chance, perms, etc... - List targets = getBlockConverterTargets( player, bc ); + // getBlockConverterOutputs applies chance, perms, etc... + List outputs = getBlockConverterOutputs( player, bc ); int multiplier = blockQuantity / bc.getKeyQuantity(); results.setResultsQuantityConsumed( bc.getKeyQuantity() * multiplier ); - for (BlockConverterTarget target : targets) { + for (BlockConverterOutput output : outputs) { - String blkName = target.getBlockName(); - int blkQuanity = target.getQuantity(); + String blkName = output.getBlockName(); + int blkQuanity = output.getQuantity(); PrisonBlock pBlock = Prison.get().getPlatform().getPrisonBlock( blkName ); if ( pBlock != null ) { @@ -139,56 +139,56 @@ public BlockConverter getBlockConverter( String blockName, BlockConverterTypes b /** - *

Based upon the block converter, extract all valid targets for this player. + *

Based upon the block converter, extract all valid outputs for this player. *

* * @param player * @param bc * @return */ - private List getBlockConverterTargets(RankPlayer player, BlockConverter bc) { + private List getBlockConverterOutputs(RankPlayer player, BlockConverter bc) { - List targets = new ArrayList<>(); + List outputs = new ArrayList<>(); - if ( bc.getTargets() != null ) { + if ( bc.getOutputs() != null ) { - for ( BlockConverterTarget bcTarget : bc.getTargets() ) { + for ( BlockConverterOutput bcOutput : bc.getOutputs() ) { - if ( bcTarget.isEnabled() ) { + if ( bcOutput.isEnabled() ) { - // If chance, and the random number is greater than the chance, then skip this target: - if ( bcTarget.getChance() != null && - bcTarget.getChance().doubleValue() > (Math.random() * 100d ) ) { + // If chance, and the random number is greater than the chance, then skip this output: + if ( bcOutput.getChance() != null && + bcOutput.getChance().doubleValue() > (Math.random() * 100d ) ) { continue; } // Confirm the player has perms: - if ( bcTarget.getPermissions() != null ) { + if ( bcOutput.getPermissions() != null ) { boolean hasPerm = false; - for (String perm : bcTarget.getPermissions() ) { + for (String perm : bcOutput.getPermissions() ) { if ( player.hasPermission( perm ) ) { hasPerm = true; break; } } - // If player does not have perms to use this target, then skip this target: + // If player does not have perms to use this output, then skip this output: if ( !hasPerm ) { continue; } } - // Return the selected target: - targets.add( bcTarget ); + // Return the selected output: + outputs.add( bcOutput ); } } } - return targets; + return outputs; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java index 9e88f3466..b79cf55c8 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java @@ -66,18 +66,18 @@ private void loadDefaultBlockConverters( BlockConverterTypes bcType, TreeMap blockConverters) { BlockConverter bc1 = new BlockConverter( "coal_ore", 9 ); - bc1.getTargets().add( new BlockConverterTarget( "diamond", 1 )); + bc1.getOutputs().add( new BlockConverterOutput( "diamond", 1 )); BlockConverter bc2 = new BlockConverter( "ice_block" ); - BlockConverterTarget bc2t1 = new BlockConverterTarget( "water_bucket", 2); - BlockConverterTarget bc2t2 = new BlockConverterTarget( "gravel", 1); - BlockConverterTarget bc2t3 = new BlockConverterTarget( "pufferfish", 1, 0.15 ); + BlockConverterOutput bc2t1 = new BlockConverterOutput( "water_bucket", 2); + BlockConverterOutput bc2t2 = new BlockConverterOutput( "gravel", 1); + BlockConverterOutput bc2t3 = new BlockConverterOutput( "pufferfish", 1, 0.15 ); bc2t3.getPermissions().add("prison.not.used.sample.pufferfish"); bc2t3.getPermissions().add("prison.not.used.sample.admin"); - bc2.getTargets().add( bc2t1 ); - bc2.getTargets().add( bc2t2 ); - bc2.getTargets().add( bc2t3 ); + bc2.getOutputs().add( bc2t1 ); + bc2.getOutputs().add( bc2t2 ); + bc2.getOutputs().add( bc2t3 ); @@ -150,41 +150,41 @@ public void loadDefaultBlockConverterSmelters( } private static void addSmeltBlockConverter( - String keyBlockName, String targetName, + String keyBlockName, String outputName, TreeMap blockConverters ) { - addSmeltBlockConverter( keyBlockName, targetName, null, true, blockConverters ); + addSmeltBlockConverter( keyBlockName, outputName, null, true, blockConverters ); } private static void addSmeltBlockConverterDisabled( - String keyBlockName, String targetName, + String keyBlockName, String outputName, TreeMap blockConverters ) { - addSmeltBlockConverter( keyBlockName, targetName, null, false, blockConverters ); + addSmeltBlockConverter( keyBlockName, outputName, null, false, blockConverters ); } private static void addSmeltBlockConverter( - String keyBlockName, String targetName, + String keyBlockName, String outputName, String semanticVersion, TreeMap blockConverters ) { - addSmeltBlockConverter( keyBlockName, targetName, null, true, blockConverters ); + addSmeltBlockConverter( keyBlockName, outputName, null, true, blockConverters ); } private static void addSmeltBlockConverterDisabled( - String keyBlockName, String targetName, + String keyBlockName, String outputName, String semanticVersion, TreeMap blockConverters ) { - addSmeltBlockConverter( keyBlockName, targetName, null, false, blockConverters ); + addSmeltBlockConverter( keyBlockName, outputName, null, false, blockConverters ); } private static void addSmeltBlockConverter( - String keyBlockName, String targetName, + String keyBlockName, String outputName, String semanticVersion, boolean enabled, TreeMap blockConverters ) { BlockConverter bc = new BlockConverter( keyBlockName, 1 ); - bc.getTargets().add( new BlockConverterTarget( targetName, 1 ) ); + bc.getOutputs().add( new BlockConverterOutput( outputName, 1 ) ); // All converters are auto-enabled, so only need to disable: if ( !enabled ) { @@ -253,55 +253,55 @@ public boolean validateBlockConverters( } - for ( BlockConverterTarget bcTarget : converter.getTargets() ) { + for ( BlockConverterOutput bcOutput : converter.getOutputs() ) { - if ( bcTarget.getChance() != null && bcTarget.getChance() <= 0 ) { + if ( bcOutput.getChance() != null && bcOutput.getChance() <= 0 ) { Output.get().logInfo( - "BlockConverters: block converter target has invalid chance: " + "BlockConverters: block converter output has an invalid chance: " + "Cannot be zero or negative. " - + "This BlockConverter target has been disabled. " + + "This BlockConverter output has been disabled. " + "BlockConverterType: %s converterKey: %s " - + "targetBlockName: %s chance: %s", + + "outputBlockName: %s chance: %s", type.name(), converterKey, - bcTarget.getBlockName(), + bcOutput.getBlockName(), - bcTarget.getChance() == null ? "null" : Double.toString( bcTarget.getQuantity() ) + bcOutput.getChance() == null ? "null" : Double.toString( bcOutput.getQuantity() ) ); - bcTarget.setEnabled( false ); + bcOutput.setEnabled( false ); dirty = true; } - if ( bcTarget.getChance() != null && bcTarget.getChance() > 100 ) { + if ( bcOutput.getChance() != null && bcOutput.getChance() > 100 ) { Output.get().logInfo( - "BlockConverters: block converter target has invalid chance: Cannot be greater than 100. " - + "This BlockConverter target has been disabled. " + "BlockConverters: block converter output has an invalid chance: Cannot be greater than 100. " + + "This BlockConverter output has been disabled. " + "BlockConverterType: %s converterKey: %s " - + "targetBlockName: %s chance: %d", + + "outputBlockName: %s chance: %d", type.name(), converterKey, - bcTarget.getBlockName(), bcTarget.getChance()); + bcOutput.getBlockName(), bcOutput.getChance()); - bcTarget.setEnabled( false ); + bcOutput.setEnabled( false ); dirty = true; } - if ( bcTarget.getQuantity() == null || bcTarget.getQuantity() <= 0 ) { + if ( bcOutput.getQuantity() == null || bcOutput.getQuantity() <= 0 ) { Output.get().logInfo( - "BlockConverters: block converter target has invalid quatity: " + "BlockConverters: block converter output has an invalid quatity: " + "Cannot be null, zero, or negative. " - + "This BlockConverter target has been disabled. " + + "This BlockConverter output has been disabled. " + "BlockConverterType: %s converterKey: %s " - + "targetBlockName: %s quantity: %s", + + "outputBlockName: %s quantity: %s", type.name(), converterKey, - bcTarget.getBlockName(), - bcTarget.getQuantity() == null ? "null" : Integer.toString( bcTarget.getQuantity() ) + bcOutput.getBlockName(), + bcOutput.getQuantity() == null ? "null" : Integer.toString( bcOutput.getQuantity() ) ); - bcTarget.setEnabled( false ); + bcOutput.setEnabled( false ); dirty = true; } From 0ad1972cba20d01ff45f0c4aa3538ce04a06200a Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 5 Jun 2022 13:10:16 -0400 Subject: [PATCH 260/297] Bug fix: Backpacks were not working properly with just ".save()" but had to add ".setChanged()" too, otherwise minepacks will not actually save the status of the backpacks. --- docs/changelog_v3.3.x.md | 5 ++++- .../spigot/integrations/IntegrationMinepacksPlugin.java | 8 ++++---- .../tech/mcprison/prison/spigot/sellall/SellAllUtil.java | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 3f0b80d8a..0ec980978 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11e 2022-05-30 +# 3.3.0-alpha.11e 2022-06-05 + + +* **Bug fix: Backpacks were not working properly with just ".save()" but had to add ".setChanged()" too, otherwise minepacks will not actually save the status of the backpacks.** * **BlockConverters: rename targets to outputs.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java index 5501f2e68..770516843 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java @@ -85,7 +85,7 @@ public HashMap addItems( Player player, HashMap addItemsBukkit( Player player, HashMap smeltItems( Player player, XMaterial so extras.putAll( addItems( player, temp ) ); -// bp.setChanged(); + bp.setChanged(); bp.save(); } @@ -199,7 +199,7 @@ public int itemStackRemoveAll(Player player, XMaterial xMat) { if ( removed > 0 ) { -// bp.setChanged(); + bp.setChanged(); bp.save(); } } 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 dca9fce25..0b7acb87d 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 @@ -569,7 +569,7 @@ private HashMap getHashMapOfPlayerInventories(Player p) { Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p); if (backpack != null) { xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, backpack.getInventory()); -// backpack.setChanged(); + backpack.setChanged(); backpack.save(); } } @@ -1470,7 +1470,7 @@ public void removeSellableItems(Player p){ Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p); if (backpack != null) { removeSellableItems(p, backpack.getInventory()); -// backpack.setChanged(); + backpack.setChanged(); backpack.save(); } } From 89ad039a8ad672622f8b3438eaa73ea14a6100e8 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 5 Jun 2022 13:13:18 -0400 Subject: [PATCH 261/297] BlockConverters: minor changes. --- .../autofeatures/AutoFeaturesFileConfig.java | 2 +- .../BlockConvertersInitializer.java | 98 +++++++++---------- 2 files changed, 48 insertions(+), 52 deletions(-) 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 3b71227da..881295c55 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 @@ -287,7 +287,7 @@ public enum AutoFeatures { smeltLimitToMines(smeltFeature, true), smeltAllBlocks(smeltFeature, true), - smeltConfigurations(smeltFeature, "see smeltFeatures in BlockConversionsConfig.json"), +// smeltConfigurations(smeltFeature, "see smeltFeatures in BlockConversionsConfig.json"), // smeltTransformer(smeltFeature, NodeType.BLOCK_CONVERTER, "smelt" ), diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java index b79cf55c8..c90584cb9 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java @@ -253,59 +253,55 @@ public boolean validateBlockConverters( } - for ( BlockConverterOutput bcOutput : converter.getOutputs() ) { - - if ( bcOutput.getChance() != null && bcOutput.getChance() <= 0 ) { - - Output.get().logInfo( - "BlockConverters: block converter output has an invalid chance: " - + "Cannot be zero or negative. " - + "This BlockConverter output has been disabled. " - + "BlockConverterType: %s converterKey: %s " - + "outputBlockName: %s chance: %s", - type.name(), converterKey, - bcOutput.getBlockName(), - - bcOutput.getChance() == null ? "null" : Double.toString( bcOutput.getQuantity() ) - - ); - - bcOutput.setEnabled( false ); - dirty = true; - } + + if ( converter.getOutputs() != null ) { - if ( bcOutput.getChance() != null && bcOutput.getChance() > 100 ) { - - Output.get().logInfo( - "BlockConverters: block converter output has an invalid chance: Cannot be greater than 100. " - + "This BlockConverter output has been disabled. " - + "BlockConverterType: %s converterKey: %s " - + "outputBlockName: %s chance: %d", - type.name(), converterKey, - bcOutput.getBlockName(), bcOutput.getChance()); - - bcOutput.setEnabled( false ); - dirty = true; - } + for (BlockConverterOutput bcOutput : converter.getOutputs()) { - if ( bcOutput.getQuantity() == null || bcOutput.getQuantity() <= 0 ) { - - Output.get().logInfo( - "BlockConverters: block converter output has an invalid quatity: " - + "Cannot be null, zero, or negative. " - + "This BlockConverter output has been disabled. " - + "BlockConverterType: %s converterKey: %s " - + "outputBlockName: %s quantity: %s", - type.name(), converterKey, - bcOutput.getBlockName(), - bcOutput.getQuantity() == null ? "null" : Integer.toString( bcOutput.getQuantity() ) - ); - - bcOutput.setEnabled( false ); - dirty = true; - } - - + if (bcOutput.getChance() != null && bcOutput.getChance() <= 0) { + + Output.get().logInfo("BlockConverters: block converter output has an invalid chance: " + + "Cannot be zero or negative. " + "This BlockConverter output has been disabled. " + + "BlockConverterType: %s converterKey: %s " + "outputBlockName: %s chance: %s", + type.name(), converterKey, bcOutput.getBlockName(), + + bcOutput.getChance() == null ? "null" : Double.toString(bcOutput.getQuantity()) + + ); + + bcOutput.setEnabled(false); + dirty = true; + } + + if (bcOutput.getChance() != null && bcOutput.getChance() > 100) { + + Output.get().logInfo( + "BlockConverters: block converter output has an invalid chance: Cannot be greater than 100. " + + "This BlockConverter output has been disabled. " + + "BlockConverterType: %s converterKey: %s " + + "outputBlockName: %s chance: %d", + type.name(), converterKey, bcOutput.getBlockName(), bcOutput.getChance()); + + bcOutput.setEnabled(false); + dirty = true; + } + + if (bcOutput.getQuantity() == null || bcOutput.getQuantity() <= 0) { + + Output.get().logInfo( + "BlockConverters: block converter output has an invalid quatity: " + + "Cannot be null, zero, or negative. " + + "This BlockConverter output has been disabled. " + + "BlockConverterType: %s converterKey: %s " + + "outputBlockName: %s quantity: %s", + type.name(), converterKey, bcOutput.getBlockName(), + bcOutput.getQuantity() == null ? "null" : Integer.toString(bcOutput.getQuantity())); + + bcOutput.setEnabled(false); + dirty = true; + } + + } } From 0b52837241253d09f586faad5158535514916651 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 6 Jun 2022 12:21:57 -0400 Subject: [PATCH 262/297] v3.3.0-alpha.11f --- docs/changelog_v3.3.x.md | 8 +++++++- gradle.properties | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 0ec980978..15de9a2ea 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,13 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11e 2022-06-05 +# 3.3.0-alpha.11f 2022-06-05 + + +* **v3.3.0-alpha.11f 2022-06-06** + + +* **BlockConverters: minor changes.** * **Bug fix: Backpacks were not working properly with just ".save()" but had to add ".setChanged()" too, otherwise minepacks will not actually save the status of the backpacks.** diff --git a/gradle.properties b/gradle.properties index bbdf249b6..279df51ec 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.11e +version=3.3.0-alpha.11f From 941e8c8032cd0cc70c40c7d126e498084ee2cc5f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 7 Jun 2022 02:33:38 -0400 Subject: [PATCH 263/297] GUI: Fixed some issues with the gui and admin perms. Added some admin perms to a few gui commands to lock them down. Found a serious issue with non-admins being able to edit rank costs and sellall item costs. The GUIs were not locked down and if the players knew the commands, they could edit the costs. --- docs/changelog_v3.3.x.md | 6 +- .../commands/PrisonSpigotGUICommands.java | 14 ++-- .../commands/PrisonSpigotSellAllCommands.java | 65 +++++++++++++------ prison-spigot/src/main/resources/plugin.yml | 4 -- 4 files changed, 58 insertions(+), 31 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 15de9a2ea..31e8af8c4 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11f 2022-06-05 +# 3.3.0-alpha.11f 2022-06-07 + + +* **GUI: Fixed some issues with the gui and admin perms. Added some admin perms to a few gui commands to lock them down.** +Found a serious issue with non-admins being able to edit rank costs and sellall item costs. The GUIs were not locked down and if the players knew the commands, they could edit the costs. * **v3.3.0-alpha.11f 2022-06-06** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUICommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUICommands.java index 77d6d5512..5bfece03a 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUICommands.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUICommands.java @@ -38,7 +38,7 @@ public class PrisonSpigotGUICommands extends PrisonSpigotBaseCommands { */ @Command( identifier = "gui", description = "The Prison's GUI", aliases = {"gui admin"}, - altPermissions = {"prison.admin", "prison.prisonmanagergui"}, + altPermissions = "prison.admin", onlyPlayers = false ) private void prisonManagerGUI(CommandSender sender) { @@ -50,7 +50,7 @@ private void prisonManagerGUI(CommandSender sender) { return; } - if (player.hasPermission("prison.admin") || player.hasPermission("prison.prisonmanagergui")) { + if (player.hasPermission("prison.admin")) { SpigotPrisonGUI gui = new SpigotPrisonGUI(player); gui.open(); return; @@ -154,6 +154,7 @@ protected void cmdPrisonManagerMines( CommandSender sender, int page, String cmd } @Command( identifier = "gui admin mines", description = "GUI Mines", + permissions = "prison.admin", onlyPlayers = true ) private void prisonManagerAdminMines(CommandSender sender, @Arg(name = "page", description = "If there are more than 45 mines, then the " + @@ -172,7 +173,7 @@ protected void cmdPrisonManagerAdminMines( CommandSender sender, int page, Strin return; } - if ( !player.hasPermission("prison.admin") && !player.hasPermission("prison.prisonmanagergui")) { + if ( !player.hasPermission("prison.admin") ) { return; } @@ -243,6 +244,7 @@ protected void cmdPrisonManagerRanks(CommandSender sender, int page, String cmdP } @Command( identifier = "gui admin ranks", description = "GUI Ranks", + permissions = "prison.admin", onlyPlayers = true ) private void prisonManagerAdminRanks(CommandSender sender, @@ -266,7 +268,7 @@ protected void cmdPrisonManagerAdminRanks(CommandSender sender, String ladder, return; } - if ( !player.hasPermission("prison.admin") && !player.hasPermission("prison.prisonmanagergui")) { + if ( !player.hasPermission("prison.admin") ) { return; } @@ -312,6 +314,7 @@ protected void cmdPrisonManagerAdminRanks(CommandSender sender, String ladder, } @Command( identifier = "gui ladders", + permissions = "prison.admin", description = "GUI Ladders. The permissions are based upon the ranks perms.", onlyPlayers = true ) private void prisonManagerLadders(CommandSender sender, @@ -370,7 +373,8 @@ protected void cmdPrisonManagerLadders(CommandSender sender, int page, String cm // Backpack GUI commands got moved to the Backpacks class so they won't be loaded if backpacks are disabled. @Command(identifier = "gui reload", description = "Reload GUIs and sellall", - permissions = "prison.admin",onlyPlayers = false, + permissions = "prison.admin", + onlyPlayers = false, aliases = {"prison reload gui", "prison reload sellall"}) public void reloadGUICommand(CommandSender sender){ SpigotGUIComponents.updateMessages(); 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 b8670c8a9..07f13d03b 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 @@ -60,7 +60,8 @@ public static PrisonSpigotSellAllCommands get() { return instance; } - @Command(identifier = "sellall set currency", description = "SellAll set currency command", onlyPlayers = false, permissions = "prison.sellall.currency") + @Command(identifier = "sellall set currency", description = "SellAll set currency command", + onlyPlayers = false, permissions = "prison.sellall.currency") private void sellAllCurrency(CommandSender sender, @Arg(name = "currency", description = "Currency name.", def = "default") @Wildcard String currency){ @@ -80,7 +81,9 @@ private void sellAllCurrency(CommandSender sender, } } - @Command(identifier = "sellall", description = "SellAll main command", onlyPlayers = false) + @Command(identifier = "sellall", description = "SellAll main command", + altPermissions = {"-none-", "prison.admin"}, + onlyPlayers = false) private void sellAllCommands(CommandSender sender) { if (!isEnabled()) return; @@ -94,7 +97,8 @@ private void sellAllCommands(CommandSender sender) { } } - @Command(identifier = "sellall delay", description = "SellAll delay.", onlyPlayers = false, permissions = "prison.sellall.delay") + @Command(identifier = "sellall delay", description = "SellAll delay.", + 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){ @@ -130,7 +134,8 @@ private void sellAllDelay(CommandSender sender, } } - @Command(identifier = "sellall set delay", description = "Edit SellAll delay.", onlyPlayers = false, permissions = "prison.sellall.delay") + @Command(identifier = "sellall set delay", description = "Edit SellAll delay.", + onlyPlayers = false, permissions = "prison.sellall.delay") private void sellAllDelaySet(CommandSender sender, @Arg(name = "delay", description = "Set delay value in seconds.", def = "0") String delay){ @@ -154,7 +159,8 @@ private void sellAllDelaySet(CommandSender sender, } } - @Command(identifier = "sellall autosell", description = "Enable SellAll AutoSell.", onlyPlayers = false, permissions = "prison.autosell.edit") + @Command(identifier = "sellall autosell", description = "Enable SellAll AutoSell.", + 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){ @@ -194,7 +200,8 @@ private void sellAllAutoSell(CommandSender sender, } } - @Command(identifier = "sellall autosell perUserToggleable", description = "Enable AutoSell perUserToggleable.", onlyPlayers = false, permissions = "prison.autosell.edit") + @Command(identifier = "sellall autosell perUserToggleable", description = "Enable AutoSell perUserToggleable.", + 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){ @@ -264,7 +271,8 @@ public void sellAllSellCommand(CommandSender sender, sellAllUtil.sellAllSell(p, false, notifications, true, true, false, true); } - @Command(identifier = "sellall hand", description = "Sell only what is in your hand if sellable.", onlyPlayers = true) + @Command(identifier = "sellall hand", description = "Sell only what is in your hand if sellable.", + onlyPlayers = true) public void sellAllSellHandCommand(CommandSender sender){ if (!isEnabled()) return; @@ -338,7 +346,8 @@ public void sellAllSell(Player p){ "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 " + - "without a notification (silently).", onlyPlayers = true) + "without a notification (silently).", + onlyPlayers = true) public void sellAllSellWithDelayCommand(CommandSender sender){ if (!isEnabled()) return; @@ -374,7 +383,8 @@ public void sellAllSellWithDelayCommand(CommandSender sender){ } - @Command(identifier = "sellall auto toggle", description = "Let the user enable or disable sellall auto", altPermissions = "prison.sellall.toggle", onlyPlayers = true) + @Command(identifier = "sellall auto toggle", description = "Let the user enable or disable sellall auto", + altPermissions = "prison.sellall.toggle", onlyPlayers = true) private void sellAllAutoEnableUser(CommandSender sender){ if (!isEnabled()) return; @@ -415,8 +425,8 @@ private void sellAllAutoEnableUser(CommandSender sender){ @Command(identifier = "sellall gui", description = "SellAll GUI command", - aliases = "gui sellall", - altPermissions = "prison.admin", onlyPlayers = true) +// aliases = "gui sellall", + permissions = "prison.admin", onlyPlayers = true) private void sellAllGuiCommand(CommandSender sender, @Arg(name = "page", description = "If there are more than 45 items, then they " + "will be shown on multiple pages. The page parameter starts with " + @@ -451,7 +461,7 @@ private void sellAllGuiCommand(CommandSender sender, @Command(identifier = "sellall gui blocks", description = "SellAll GUI Blocks command", aliases = "gui sellall", - altPermissions = "prison.admin", onlyPlayers = true) + permissions = "prison.admin", onlyPlayers = true) private void sellAllGuiBlocksCommand(CommandSender sender, @Arg(name = "page", description = "If there are more than 45 items, then they " + "will be shown on multiple pages. The page parameter starts with " + @@ -472,7 +482,8 @@ private void sellAllGuiBlocksCommand(CommandSender sender, } - @Command(identifier = "sellall add", description = "SellAll add an item to the sellAll shop.", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall add", description = "SellAll add an item to the sellAll shop.", + 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){ @@ -545,7 +556,8 @@ 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.", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall delete", description = "SellAll delete command, remove an item from shop.", + permissions = "prison.admin", onlyPlayers = false) private void sellAllDeleteCommand(CommandSender sender, @Arg(name = "Item_ID", description = "The Item_ID you want to remove.") String itemID){ if (!isEnabled()) return; @@ -573,7 +585,8 @@ private void sellAllDeleteCommand(CommandSender sender, @Arg(name = "Item_ID", d } } - @Command(identifier = "sellall edit", description = "SellAll edit command, edit an item of Shop.", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall edit", description = "SellAll edit command, edit an item of Shop.", + 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){ @@ -729,7 +742,8 @@ private void sellAllAddMultiplierCommand(CommandSender sender, } } - @Command(identifier = "sellall multiplier delete", description = "SellAll delete a multiplier.", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall multiplier delete", description = "SellAll delete a multiplier.", + permissions = "prison.admin", onlyPlayers = false) private void sellAllDeleteMultiplierCommand(CommandSender sender, @Arg(name = "Prestige", description = "Prestige hooked to the multiplier.") String prestige){ @@ -760,7 +774,10 @@ 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.", permissions = "prison.admin", onlyPlayers = false) + @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) private void sellAllToolsTriggerToggle(CommandSender sender, @Arg(name = "Boolean", description = "Enable or disable", def = "null") String enable){ @@ -801,7 +818,9 @@ private void sellAllToolsTriggerToggle(CommandSender sender, } } - @Command(identifier = "sellall Trigger add", description = "Add an Item to trigger the Shift+Right Click -> /sellall sell command.", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall 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, @Arg(name = "Item", description = "Item name") String itemID){ @@ -840,7 +859,9 @@ private void sellAllTriggerAdd(CommandSender sender, } } - @Command(identifier = "sellall Trigger delete", description = "Delete an Item from the Shift+Right Click trigger -> /sellall sell command.", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall 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, @Arg(name = "Item", description = "Item name") String itemID){ @@ -878,7 +899,8 @@ private void sellAllTriggerDelete(CommandSender sender, } } - @Command(identifier = "sellall setdefault", description = "SellAll default values ready to go.", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall setdefault", description = "SellAll default values ready to go.", + permissions = "prison.admin", onlyPlayers = false) private void sellAllSetDefaultCommand(CommandSender sender){ if (!isEnabled()) return; @@ -895,7 +917,8 @@ private void sellAllSetDefaultCommand(CommandSender sender){ } - @Command(identifier = "sellall list", description = "SellAll list all items", permissions = "prison.admin", onlyPlayers = false) + @Command(identifier = "sellall list", description = "SellAll list all items", + permissions = "prison.admin", onlyPlayers = false) private void sellAllListItems( CommandSender sender ) { if (!isEnabled()) return; diff --git a/prison-spigot/src/main/resources/plugin.yml b/prison-spigot/src/main/resources/plugin.yml index 6af87c59f..159dbda26 100644 --- a/prison-spigot/src/main/resources/plugin.yml +++ b/prison-spigot/src/main/resources/plugin.yml @@ -36,9 +36,6 @@ permissions: prison.gui: description: Opens the Prison's GUI menu. - prison.prisonmanagergui: - description: Opens the Prison's GUI menu. - prison.placeholder: description: Tools to list and test placeholders. @@ -53,7 +50,6 @@ permissions: prison.alerts.clear: true prison.alerts.clear.all: true prison.gui: true - prison.prisonmanagergui: true prison.placeholder: true # ================== From bb4a10c5e2fedcada67d083fa98d79d5dcd76458 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 7 Jun 2022 03:53:26 -0400 Subject: [PATCH 264/297] Update XSeries to v8.7.1 from v8.6.2. --- docs/changelog_v3.3.x.md | 4 ++++ prison-spigot/build.gradle | 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 31e8af8c4..02c6d9e6d 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11f 2022-06-07 +* **Update XSeries to v8.7.1 from v8.6.2.** +Note that this does not add any of the newer 1.19 blocks or items. + + * **GUI: Fixed some issues with the gui and admin perms. Added some admin perms to a few gui commands to lock them down.** Found a serious issue with non-admins being able to edit rank costs and sellall item costs. The GUIs were not locked down and if the players knew the commands, they could edit the costs. diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index 73145afbf..8a1ddee11 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -108,7 +108,7 @@ dependencies { // implementation 'com.github.cryptomorin:xseries:b95d195482' // https://mvnrepository.com/artifact/com.github.cryptomorin/XSeries - implementation 'com.github.cryptomorin:XSeries:8.6.2' + implementation 'com.github.cryptomorin:XSeries:8.7.1' @@ -197,7 +197,7 @@ shadowJar { include(dependency('me.clip:placeholderapi:2.10.9')) - include(dependency('com.github.cryptomorin:XSeries:8.6.2')) + include(dependency('com.github.cryptomorin:XSeries:8.7.1')) include(dependency('de.tr7zw:item-nbt-api-plugin:2.9.2')) From 5ddb9319823f1316cfcd6788e9d954fbc48b01be Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Thu, 9 Jun 2022 01:17:21 -0400 Subject: [PATCH 265/297] Added an entry for the sellall module in the modules.yml file. Code has been setup to check, with a default fall-back on to the sellall settings within config.yml file. The entry in config.yml has been commented out. Either will work, but the setting within modules.yml will take priority. --- docs/changelog_v3.3.x.md | 7 ++++++- prison-spigot/src/main/resources/config.yml | 4 +++- prison-spigot/src/main/resources/modules.yml | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 02c6d9e6d..14646a117 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,12 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11f 2022-06-07 +# 3.3.0-alpha.11f 2022-06-09 + + +* **Added an entry for the sellall module in the modules.yml file.** +Code has been setup to check, with a default fall-back on to the sellall settings within config.yml file. The entry in config.yml has been commented out. +Either will work, but the setting within modules.yml will take priority. * **Update XSeries to v8.7.1 from v8.6.2.** diff --git a/prison-spigot/src/main/resources/config.yml b/prison-spigot/src/main/resources/config.yml index 2958e60f8..e1c5f8f01 100644 --- a/prison-spigot/src/main/resources/config.yml +++ b/prison-spigot/src/main/resources/config.yml @@ -71,7 +71,9 @@ prison-gui-enabled: true # NEW: Enable or disable the SellAll command and sub-commands # New feature so setting to false since it will override other shop plugins. -sellall: true +#sellall: true +# Note: The settings for sellall module has been moved to the modules.yml file. + # NEW: Enable backpacks integrated within prison. diff --git a/prison-spigot/src/main/resources/modules.yml b/prison-spigot/src/main/resources/modules.yml index 4ada48eed..29c682715 100644 --- a/prison-spigot/src/main/resources/modules.yml +++ b/prison-spigot/src/main/resources/modules.yml @@ -7,6 +7,8 @@ ranks: true mines: true +sellall: true + utils: enabled: true messages: From 7284ce7854d845b01dbaf8da80ce97bdc3a7fa6f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Thu, 9 Jun 2022 01:21:55 -0400 Subject: [PATCH 266/297] There is a situation when checking for new udpates to the language files, that it needs to write the new file, but the old one has not been archived. This now checks to make sure the old one has been renamed, and if it hasn't, then it will rename it. --- docs/changelog_v3.3.x.md | 4 ++++ .../tech/mcprison/prison/localization/LocaleManager.java | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 14646a117..98a0e1b34 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11f 2022-06-09 +* **There is a situation when checking for new updates to the language files, that it needs to write the new file, but the old one has not been archived.** +This now checks to make sure the old one has been renamed, and if it hasn't, then it will rename it. + + * **Added an entry for the sellall module in the modules.yml file.** Code has been setup to check, with a default fall-back on to the sellall settings within config.yml file. The entry in config.yml has been commented out. Either will work, but the setting within modules.yml will take priority. diff --git a/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java b/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java index 6e12aa34b..bdf29f826 100755 --- a/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/localization/LocaleManager.java @@ -318,6 +318,12 @@ private void refreshLocalLocales() { File newFile = new File( localeFolder, jarResourceName ); + if ( newFile.exists() ) { + // Not really sure why the pfd would fail find a resource, but the File exists, + // so archive it since there must be an issue with it. + archiveOldPropertiesFile( newFile ); + } + Files.copy( inStream, newFile.toPath() ); Output.get().logInfo( "### LocalManager refreshLocalLocales(): Local did not exist. " + From d7c84a8edda89d4afe0b943f1b30198840e46dcf Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Thu, 9 Jun 2022 01:49:30 -0400 Subject: [PATCH 267/297] The build was failing intermittently on the continual integration (CI) pertaining to the item-nbt-api-plugin, so an entry to added to "lock it in" to the correct path within the mavenrepository.com repo. This should prevent the resource from being paired with the wrong repo. --- docs/changelog_v3.3.x.md | 5 +++++ prison-spigot/build.gradle | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 98a0e1b34..30a9014c7 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11f 2022-06-09 +* **The build was failing intermittently on the continual integration (CI)** +pertaining to the item-nbt-api-plugin, so an entry to added to "lock it in" to the correct path within the mavenrepository.com repo. +This should prevent the resource from being paired with the wrong repo. + + * **There is a situation when checking for new updates to the language files, that it needs to write the new file, but the old one has not been archived.** This now checks to make sure the old one has been renamed, and if it hasn't, then it will rename it. diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index 8a1ddee11..b11686d23 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -64,6 +64,14 @@ repositories { } + maven { + url = 'https://mvnrepository.com/artifact/de.tr7zw/item-nbt-api-plugin' + content { + includeGroup 'de.tr7zw' + } + } + + // maven { url 'https://jitpack.io' } @@ -138,7 +146,9 @@ dependencies { // compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.1' + // NOTE: This maven repo was failing to be accessable during online builds. So added to the /lib. // https://www.spigotmc.org/resources/nbt-api.7939/ + // https://mvnrepository.com/artifact/de.tr7zw/item-nbt-api-plugin implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2' From 7d5665a213b6e94f226ecd5697af5627831179cc Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Thu, 9 Jun 2022 02:01:07 -0400 Subject: [PATCH 268/297] The build was failing intermittently on the continual integration (CI) pertaining to the item-nbt-api-plugin, so an entry to added to "lock it in" to the correct path within the mavenrepository.com repo. This should prevent the resource from being paired with the wrong repo. --- build.gradle | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index fd832ddc4..7ad958577 100644 --- a/build.gradle +++ b/build.gradle @@ -119,9 +119,17 @@ subprojects { repositories { mavenCentral() - maven { url "https://maven.sk89q.com/repo/" } - maven { url "https://mvnrepository.com/artifact/org.apache.commons/commons-lang3" } + // maven { url "https://maven.sk89q.com/repo/" } + + maven { + url "https://mvnrepository.com/artifact/org.apache.commons/commons-lang3" + content { + includeGroup 'org.apache.commons' + } + } + } + configurations { deployerJars @@ -129,6 +137,7 @@ subprojects { dependencies { implementation 'org.apache.commons:commons-lang3:3.12.0' + implementation 'com.google.guava:guava:19.0' implementation 'com.google.code.gson:gson:2.8.6' testImplementation 'junit:junit:4.12' From cdcc4a234d3df3d0ac67248f1fa5a44958b86185 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 11 Jun 2022 14:24:21 -0400 Subject: [PATCH 269/297] Fix a problem when BlockConverters are disabled, and doing a reload on auto features, it's not able to find that config file so its throwing an exception. --- docs/changelog_v3.3.x.md | 5 ++++- .../main/java/tech/mcprison/prison/PrisonCommand.java | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 30a9014c7..4c749739b 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11f 2022-06-09 +# 3.3.0-alpha.11f 2022-06-11 + + +* **Fix a problem when BlockConverters are disabled, and doing a reload on auto features, it's not able to find that config file so its throwing an exception.** * **The build was failing intermittently on the continual integration (CI)** 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 b8c803d40..01deb2f71 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -841,9 +841,14 @@ public void reloadAutoFeatures(CommandSender sender ) { // Ingore } try { - String filePath = AutoFeaturesWrapper.getInstance().getBlockConvertersConfig() - .getConfigFile().getCanonicalPath(); - sender.sendMessage( filePath ); + + + File bcFile = AutoFeaturesWrapper.getInstance().getBlockConvertersConfig().getConfigFile(); + if ( bcFile != null && bcFile.exists() ) { + + String filePath = bcFile.getCanonicalPath(); + sender.sendMessage( filePath ); + } } catch ( IOException e ) { // Ingore From 69e5cbb191b9ce47acf5c6dc9456abe2667acf3f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 11 Jun 2022 14:44:01 -0400 Subject: [PATCH 270/297] Fix a problem when BlockConverters are disabled, and doing a reload on auto features, it's not able to find that config file so its throwing an exception. --- .../java/tech/mcprison/prison/PrisonCommand.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 01deb2f71..de2ca3375 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -842,13 +842,16 @@ public void reloadAutoFeatures(CommandSender sender ) { } try { - - File bcFile = AutoFeaturesWrapper.getInstance().getBlockConvertersConfig().getConfigFile(); - if ( bcFile != null && bcFile.exists() ) { + if ( AutoFeaturesWrapper.getInstance().getBlockConvertersConfig() != null ) { - String filePath = bcFile.getCanonicalPath(); - sender.sendMessage( filePath ); + File bcFile = AutoFeaturesWrapper.getInstance().getBlockConvertersConfig().getConfigFile(); + if ( bcFile != null && bcFile.exists() ) { + + String filePath = bcFile.getCanonicalPath(); + sender.sendMessage( filePath ); + } } + } catch ( IOException e ) { // Ingore From 436a106f6bcd8a58712b29e4ede432517a7845a4 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 11 Jun 2022 14:48:59 -0400 Subject: [PATCH 271/297] Disable the gui for autofeatures configs. They are so out of date, they were causing problems. Autofeatures should be manually edited. --- docs/changelog_v3.3.x.md | 4 + .../spigot/gui/ListenersPrisonManager.java | 710 +++++++++--------- .../prison/spigot/gui/SpigotPrisonGUI.java | 2 +- 3 files changed, 360 insertions(+), 356 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 4c749739b..67c9ee021 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11f 2022-06-11 +* **Disable the gui for autofeatures configs. They are so out of date, they were causing problems.** +Autofeatures should be manually edited. + + * **Fix a problem when BlockConverters are disabled, and doing a reload on auto features, it's not able to find that config file so its throwing an exception.** 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 9b4e52de0..73dfc830f 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 @@ -563,41 +563,41 @@ else if ( SpigotGUIMenuTools.getInstance().processGUIPage( p, title, e ) ) { break; } - // Check the inventory title and do the actions. - case "PrisonManager -> AutoFeatures": { - - // Call the method - autoFeaturesGUI(e, p, parts); - - break; - } - - // Check the title and do the actions. - case "AutoFeatures -> AutoPickup": { - - // Call the method - autoPickupGUI(e, p, parts); - - break; - } - - // Check the title and do the actions. - case "AutoFeatures -> AutoSmelt": { - - // Call the method - autoSmeltGUI(e, p, parts); - - break; - } +// // Check the inventory title and do the actions. +// case "PrisonManager -> AutoFeatures": { +// +// // Call the method +// autoFeaturesGUI(e, p, parts); +// +// break; +// } - // Check the title and do the actions. - case "AutoFeatures -> AutoBlock": { +// // Check the title and do the actions. +// case "AutoFeatures -> AutoPickup": { +// +// // Call the method +// autoPickupGUI(e, p, parts); +// +// break; +// } - // Call the method - autoBlockGUI(e, p, parts); +// // Check the title and do the actions. +// case "AutoFeatures -> AutoSmelt": { +// +// // Call the method +// autoSmeltGUI(e, p, parts); +// +// break; +// } - break; - } +// // Check the title and do the actions. +// case "AutoFeatures -> AutoBlock": { +// +// // Call the method +// autoBlockGUI(e, p, parts); +// +// break; +// } // Check the title and do the actions. case "SellAll -> Blocks": { @@ -1649,18 +1649,18 @@ private void prisonManagerGUI(InventoryClickEvent e, Player p, String buttonName break; } - // Check the Item display name and do open the right GUI. - case "AutoManager": { - - // Check if the autofeatures config isn't null. - if(SpigotGUIComponents.afConfig() != null) { - SpigotAutoFeaturesGUI gui = new SpigotAutoFeaturesGUI(p); - gui.open(); - } else { - Output.get().sendWarn(new SpigotPlayer(p), "Can't find an autofeatures config, maybe they're disabled."); - } - break; - } +// // Check the Item display name and do open the right GUI. +// case "AutoManager": { +// +// // Check if the autofeatures config isn't null. +// if(SpigotGUIComponents.afConfig() != null) { +// SpigotAutoFeaturesGUI gui = new SpigotAutoFeaturesGUI(p); +// gui.open(); +// } else { +// Output.get().sendWarn(new SpigotPlayer(p), "Can't find an autofeatures config, maybe they're disabled."); +// } +// break; +// } // Check the Item display name and do open the right GUI. case "Mines": { @@ -2566,277 +2566,277 @@ private void radiusGUI(InventoryClickEvent e, Player p, String[] parts) { } } - private void autoFeaturesGUI(InventoryClickEvent e, Player p, String[] parts) { - - // Get the config - AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig(); - - // Output finally the buttonname and the mode explicit out of the array - String buttonName = parts[0]; - String mode = parts[1]; - - boolean enabled = mode.equalsIgnoreCase("Enabled"); - - // Check the clickType and do the actions - if ( enabled && e.isRightClick() && e.isShiftClick() || - !enabled && e.isRightClick()){ - - if (buttonName.equalsIgnoreCase("Full-Inventory-Sound")){ - afConfig.setFeature( AutoFeatures.playSoundIfInventoryIsFull, !enabled ); - saveConfigAutoFeatures(e, p); - } - - if (buttonName.equalsIgnoreCase("Full-Inventory-ActionBar")){ - afConfig.setFeature(AutoFeatures.actionBarMessageIfInventoryIsFull, !enabled); - saveConfigAutoFeatures(e,p); - } - - if (buttonName.equalsIgnoreCase("All")){ - afConfig.setFeature(AutoFeatures.isAutoManagerEnabled, !enabled); - saveConfigAutoFeatures(e,p); - } - - } - - // Check the clickType and do the actions - if (enabled && e.isRightClick() && e.isShiftClick() || !enabled && e.isRightClick() || enabled && e.isLeftClick()){ - if (buttonName.equalsIgnoreCase("AutoPickup")){ - if (e.isLeftClick()){ - SpigotAutoPickupGUI gui = new SpigotAutoPickupGUI(p); - gui.open(); - return; - } - afConfig.setFeature(AutoFeatures.autoPickupEnabled, !enabled); - saveConfigAutoFeatures(e,p); - } - - if (buttonName.equalsIgnoreCase("AutoSmelt")){ - if (e.isLeftClick()){ - SpigotAutoSmeltGUI gui = new SpigotAutoSmeltGUI(p); - gui.open(); - return; - } - afConfig.setFeature(AutoFeatures.autoSmeltEnabled, !enabled); - saveConfigAutoFeatures(e,p); - } - - if (buttonName.equalsIgnoreCase("AutoBlock")){ - if (e.isLeftClick()){ - SpigotAutoBlockGUI gui = new SpigotAutoBlockGUI(p); - gui.open(); - return; - } - afConfig.setFeature(AutoFeatures.autoBlockEnabled, !enabled); - saveConfigAutoFeatures(e,p); - } - } - } - - private void autoPickupGUI(InventoryClickEvent e, Player p, String[] parts) { - - // Get the config - AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig(); - - // Output finally the buttonname and the mode explicit out of the array - String buttonname = parts[0]; - String mode = parts[1]; - - boolean enabled = mode.equalsIgnoreCase("Enabled"); - - // Check the click and do the actions, also the buttonName - if ( enabled && e.isRightClick() && e.isShiftClick() || - !enabled && e.isRightClick() ){ - - switch (buttonname){ - case "All_Blocks":{ - afConfig.setFeature( AutoFeatures.pickupAllBlocks, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Cobblestone":{ - afConfig.setFeature(AutoFeatures.pickupCobbleStone, !enabled); - saveConfigPickup(e,p); - break; - } - case "Gold_Ore":{ - afConfig.setFeature( AutoFeatures.pickupGoldOre, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Iron_Ore":{ - afConfig.setFeature( AutoFeatures.pickupIronOre, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Coal_Ore":{ - afConfig.setFeature( AutoFeatures.pickupCoalOre, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Diamond_Ore":{ - afConfig.setFeature( AutoFeatures.pickupDiamondOre, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Redstone_Ore":{ - afConfig.setFeature( AutoFeatures.pickupRedStoneOre, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Emerald_Ore":{ - afConfig.setFeature( AutoFeatures.pickupEmeraldOre, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Quartz_Ore":{ - afConfig.setFeature( AutoFeatures.pickupQuartzOre, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Lapis_Ore":{ - afConfig.setFeature( AutoFeatures.pickupLapisOre, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Snow_Ball":{ - afConfig.setFeature( AutoFeatures.pickupSnowBall, !enabled ); - saveConfigPickup(e, p); - break; - } - case "Glowstone_Dust":{ - afConfig.setFeature( AutoFeatures.pickupGlowstoneDust, !enabled ); - saveConfigPickup(e, p); - break; - } - default:{ - break; - } - - } - } - } - - private void autoSmeltGUI(InventoryClickEvent e, Player p, String[] parts) { - - // Get the config - AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig(); - - // Output finally the buttonname and the mode explicit out of the array - String buttonname = parts[0]; - String mode = parts[1]; - - boolean enabled = mode.equalsIgnoreCase("Enabled"); - - // Check the clickType and do the actions - if ( enabled && e.isRightClick() && e.isShiftClick() || - !enabled && e.isRightClick()){ - - switch (buttonname){ - case "Gold_Ore":{ - afConfig.setFeature( AutoFeatures.smeltGoldOre, !enabled ); - saveConfigSmelt(e, p); - break; - } - case "Iron_Ore":{ - afConfig.setFeature( AutoFeatures.smeltIronOre, !enabled ); - saveConfigSmelt(e, p); - break; - } - case "All_Ores":{ - afConfig.setFeature( AutoFeatures.smeltAllBlocks, !enabled ); - saveConfigSmelt(e, p); - break; - } - default:{ - break; - } - } - } - } - - private void autoBlockGUI(InventoryClickEvent e, Player p, String[] parts) { - - // Get the config - AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig(); - - // Output finally the buttonname and the mode explicit out of the array - String buttonname = parts[0]; - String mode = parts[1]; - - boolean enabled = mode.equalsIgnoreCase("Enabled"); - - // Check the clickType and do the actions - if ( enabled && e.isRightClick() && e.isShiftClick() || - !enabled && e.isRightClick()){ - - switch (buttonname){ - case "Gold_Block":{ - afConfig.setFeature( AutoFeatures.blockGoldBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Iron_Block":{ - afConfig.setFeature( AutoFeatures.blockIronBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Coal_Block":{ - afConfig.setFeature( AutoFeatures.blockCoalBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Diamond_Block":{ - afConfig.setFeature( AutoFeatures.blockDiamondBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Redstone_Block":{ - afConfig.setFeature( AutoFeatures.blockRedstoneBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Emerald_Block":{ - afConfig.setFeature( AutoFeatures.blockEmeraldBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Quartz_Block":{ - afConfig.setFeature( AutoFeatures.blockQuartzBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Prismarine_Block":{ - afConfig.setFeature( AutoFeatures.blockPrismarineBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Lapis_Block":{ - afConfig.setFeature( AutoFeatures.blockLapisBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Snow_Block":{ - afConfig.setFeature( AutoFeatures.blockSnowBlock, !enabled ); - saveConfigBlock(e, p); - break; - } - case "Glowstone_Block":{ - afConfig.setFeature( AutoFeatures.blockGlowstone, !enabled ); - saveConfigBlock(e, p); - break; - } - case "All_Blocks":{ - afConfig.setFeature( AutoFeatures.blockAllBlocks, !enabled ); - saveConfigBlock(e, p); - break; - } - default:{ - break; - } - } - } +// private void autoFeaturesGUI(InventoryClickEvent e, Player p, String[] parts) { +// +// // Get the config +// AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig(); +// +// // Output finally the buttonname and the mode explicit out of the array +// String buttonName = parts[0]; +// String mode = parts[1]; +// +// boolean enabled = mode.equalsIgnoreCase("Enabled"); +// +// // Check the clickType and do the actions +// if ( enabled && e.isRightClick() && e.isShiftClick() || +// !enabled && e.isRightClick()){ +// +// if (buttonName.equalsIgnoreCase("Full-Inventory-Sound")){ +// afConfig.setFeature( AutoFeatures.playSoundIfInventoryIsFull, !enabled ); +// saveConfigAutoFeatures(e, p); +// } +// +// if (buttonName.equalsIgnoreCase("Full-Inventory-ActionBar")){ +// afConfig.setFeature(AutoFeatures.actionBarMessageIfInventoryIsFull, !enabled); +// saveConfigAutoFeatures(e,p); +// } +// +// if (buttonName.equalsIgnoreCase("All")){ +// afConfig.setFeature(AutoFeatures.isAutoManagerEnabled, !enabled); +// saveConfigAutoFeatures(e,p); +// } +// +// } +// +// // Check the clickType and do the actions +// if (enabled && e.isRightClick() && e.isShiftClick() || !enabled && e.isRightClick() || enabled && e.isLeftClick()){ +// if (buttonName.equalsIgnoreCase("AutoPickup")){ +// if (e.isLeftClick()){ +// SpigotAutoPickupGUI gui = new SpigotAutoPickupGUI(p); +// gui.open(); +// return; +// } +// afConfig.setFeature(AutoFeatures.autoPickupEnabled, !enabled); +// saveConfigAutoFeatures(e,p); +// } +// +// if (buttonName.equalsIgnoreCase("AutoSmelt")){ +// if (e.isLeftClick()){ +// SpigotAutoSmeltGUI gui = new SpigotAutoSmeltGUI(p); +// gui.open(); +// return; +// } +// afConfig.setFeature(AutoFeatures.autoSmeltEnabled, !enabled); +// saveConfigAutoFeatures(e,p); +// } +// +// if (buttonName.equalsIgnoreCase("AutoBlock")){ +// if (e.isLeftClick()){ +// SpigotAutoBlockGUI gui = new SpigotAutoBlockGUI(p); +// gui.open(); +// return; +// } +// afConfig.setFeature(AutoFeatures.autoBlockEnabled, !enabled); +// saveConfigAutoFeatures(e,p); +// } +// } +// } - } +// private void autoPickupGUI(InventoryClickEvent e, Player p, String[] parts) { +// +// // Get the config +// AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig(); +// +// // Output finally the buttonname and the mode explicit out of the array +// String buttonname = parts[0]; +// String mode = parts[1]; +// +// boolean enabled = mode.equalsIgnoreCase("Enabled"); +// +// // Check the click and do the actions, also the buttonName +// if ( enabled && e.isRightClick() && e.isShiftClick() || +// !enabled && e.isRightClick() ){ +// +// switch (buttonname){ +// case "All_Blocks":{ +// afConfig.setFeature( AutoFeatures.pickupAllBlocks, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Cobblestone":{ +// afConfig.setFeature(AutoFeatures.pickupCobbleStone, !enabled); +// saveConfigPickup(e,p); +// break; +// } +// case "Gold_Ore":{ +// afConfig.setFeature( AutoFeatures.pickupGoldOre, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Iron_Ore":{ +// afConfig.setFeature( AutoFeatures.pickupIronOre, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Coal_Ore":{ +// afConfig.setFeature( AutoFeatures.pickupCoalOre, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Diamond_Ore":{ +// afConfig.setFeature( AutoFeatures.pickupDiamondOre, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Redstone_Ore":{ +// afConfig.setFeature( AutoFeatures.pickupRedStoneOre, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Emerald_Ore":{ +// afConfig.setFeature( AutoFeatures.pickupEmeraldOre, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Quartz_Ore":{ +// afConfig.setFeature( AutoFeatures.pickupQuartzOre, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Lapis_Ore":{ +// afConfig.setFeature( AutoFeatures.pickupLapisOre, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Snow_Ball":{ +// afConfig.setFeature( AutoFeatures.pickupSnowBall, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// case "Glowstone_Dust":{ +// afConfig.setFeature( AutoFeatures.pickupGlowstoneDust, !enabled ); +// saveConfigPickup(e, p); +// break; +// } +// default:{ +// break; +// } +// +// } +// } +// } +// +// private void autoSmeltGUI(InventoryClickEvent e, Player p, String[] parts) { +// +// // Get the config +// AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig(); +// +// // Output finally the buttonname and the mode explicit out of the array +// String buttonname = parts[0]; +// String mode = parts[1]; +// +// boolean enabled = mode.equalsIgnoreCase("Enabled"); +// +// // Check the clickType and do the actions +// if ( enabled && e.isRightClick() && e.isShiftClick() || +// !enabled && e.isRightClick()){ +// +// switch (buttonname){ +// case "Gold_Ore":{ +// afConfig.setFeature( AutoFeatures.smeltGoldOre, !enabled ); +// saveConfigSmelt(e, p); +// break; +// } +// case "Iron_Ore":{ +// afConfig.setFeature( AutoFeatures.smeltIronOre, !enabled ); +// saveConfigSmelt(e, p); +// break; +// } +// case "All_Ores":{ +// afConfig.setFeature( AutoFeatures.smeltAllBlocks, !enabled ); +// saveConfigSmelt(e, p); +// break; +// } +// default:{ +// break; +// } +// } +// } +// } +// +// private void autoBlockGUI(InventoryClickEvent e, Player p, String[] parts) { +// +// // Get the config +// AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig(); +// +// // Output finally the buttonname and the mode explicit out of the array +// String buttonname = parts[0]; +// String mode = parts[1]; +// +// boolean enabled = mode.equalsIgnoreCase("Enabled"); +// +// // Check the clickType and do the actions +// if ( enabled && e.isRightClick() && e.isShiftClick() || +// !enabled && e.isRightClick()){ +// +// switch (buttonname){ +// case "Gold_Block":{ +// afConfig.setFeature( AutoFeatures.blockGoldBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Iron_Block":{ +// afConfig.setFeature( AutoFeatures.blockIronBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Coal_Block":{ +// afConfig.setFeature( AutoFeatures.blockCoalBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Diamond_Block":{ +// afConfig.setFeature( AutoFeatures.blockDiamondBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Redstone_Block":{ +// afConfig.setFeature( AutoFeatures.blockRedstoneBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Emerald_Block":{ +// afConfig.setFeature( AutoFeatures.blockEmeraldBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Quartz_Block":{ +// afConfig.setFeature( AutoFeatures.blockQuartzBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Prismarine_Block":{ +// afConfig.setFeature( AutoFeatures.blockPrismarineBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Lapis_Block":{ +// afConfig.setFeature( AutoFeatures.blockLapisBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Snow_Block":{ +// afConfig.setFeature( AutoFeatures.blockSnowBlock, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "Glowstone_Block":{ +// afConfig.setFeature( AutoFeatures.blockGlowstone, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// case "All_Blocks":{ +// afConfig.setFeature( AutoFeatures.blockAllBlocks, !enabled ); +// saveConfigBlock(e, p); +// break; +// } +// default:{ +// break; +// } +// } +// } +// +// } private void modeAction(AsyncPlayerChatEvent e, Player p, String message) { @@ -2922,45 +2922,45 @@ private void rankAction(AsyncPlayerChatEvent e, Player p, String message) { isChatEventActive = false; } - /** - * Save the auto features, and then cancel the event and close the inventory. - * - * @param e - * @param player - */ - private boolean saveAutoFeatures( InventoryClickEvent e, Player player ) { - boolean success = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig().saveConf(); - e.setCancelled(true); - player.closeInventory(); - return success; - } - - - private boolean saveConfigBlock(InventoryClickEvent e, Player p) { - boolean success = saveAutoFeatures( e, p ); - SpigotAutoBlockGUI gui = new SpigotAutoBlockGUI(p); - gui.open(); - return success; - } - - private boolean saveConfigSmelt(InventoryClickEvent e, Player p) { - boolean success = saveAutoFeatures( e, p ); - SpigotAutoSmeltGUI gui = new SpigotAutoSmeltGUI(p); - gui.open(); - return success; - } - - private boolean saveConfigPickup(InventoryClickEvent e, Player p) { - boolean success = saveAutoFeatures( e, p ); - SpigotAutoPickupGUI gui = new SpigotAutoPickupGUI(p); - gui.open(); - return success; - } - - private boolean saveConfigAutoFeatures(InventoryClickEvent e, Player p) { - boolean success = saveAutoFeatures( e, p ); - SpigotAutoFeaturesGUI gui = new SpigotAutoFeaturesGUI(p); - gui.open(); - return success; - } +// /** +// * Save the auto features, and then cancel the event and close the inventory. +// * +// * @param e +// * @param player +// */ +// private boolean saveAutoFeatures( InventoryClickEvent e, Player player ) { +// boolean success = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig().saveConf(); +// e.setCancelled(true); +// player.closeInventory(); +// return success; +// } +// +// +// private boolean saveConfigBlock(InventoryClickEvent e, Player p) { +// boolean success = saveAutoFeatures( e, p ); +// SpigotAutoBlockGUI gui = new SpigotAutoBlockGUI(p); +// gui.open(); +// return success; +// } +// +// private boolean saveConfigSmelt(InventoryClickEvent e, Player p) { +// boolean success = saveAutoFeatures( e, p ); +// SpigotAutoSmeltGUI gui = new SpigotAutoSmeltGUI(p); +// gui.open(); +// return success; +// } +// +// private boolean saveConfigPickup(InventoryClickEvent e, Player p) { +// boolean success = saveAutoFeatures( e, p ); +// SpigotAutoPickupGUI gui = new SpigotAutoPickupGUI(p); +// gui.open(); +// return success; +// } +// +// private boolean saveConfigAutoFeatures(InventoryClickEvent e, Player p) { +// boolean success = saveAutoFeatures( e, p ); +// SpigotAutoFeaturesGUI gui = new SpigotAutoFeaturesGUI(p); +// gui.open(); +// return success; +// } } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java index b6504198b..3149cb2b4 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java @@ -37,7 +37,7 @@ public void open() { // Create and add buttons. gui.addButton(new Button(10, XMaterial.TRIPWIRE_HOOK, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_button_description)), "&3Ranks - Ladders" )); - gui.addButton(new Button(13, XMaterial.IRON_PICKAXE, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_autofeatures_button_description)), "&3AutoManager" )); +// gui.addButton(new Button(13, XMaterial.IRON_PICKAXE, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_autofeatures_button_description)), "&3AutoManager" )); gui.addButton(new Button(16, XMaterial.DIAMOND_ORE, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_mines_button_description)), "&3Mines" )); gui.addButton(new Button(29, XMaterial.CHEST, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_button_description)), "&3SellAll" )); From d6182e2d81491782d541780685e249c349c851a0 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:12:58 -0400 Subject: [PATCH 272/297] v3.3.0-alpha.11g - 2022-06-11 --- 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 67c9ee021..5857789cf 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11f 2022-06-11 +# 3.3.0-alpha.11g 2022-06-11 + + +**v3.3.0-alpha.11g - 2022-06-11** * **Disable the gui for autofeatures configs. They are so out of date, they were causing problems.** diff --git a/gradle.properties b/gradle.properties index 279df51ec..011191354 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.11f +version=3.3.0-alpha.11g From 7385ebc7f4d112b34140c0718fee69bb9ae796ab Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:17:10 -0400 Subject: [PATCH 273/297] BlockConverters: fix issue when block converters are not active. --- docs/changelog_v3.3.x.md | 3 +++ .../tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.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 5857789cf..8c4240eee 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11g 2022-06-11 +* **BlockConverters: fix issue when block converters are not active.** + + **v3.3.0-alpha.11g - 2022-06-11** diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.java index 52027f8f4..4131b2abf 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/AutoFeaturesWrapper.java @@ -43,7 +43,7 @@ public static AutoFeaturesWrapper getInstance() { public void reloadConfigs() { getAutoFeaturesConfig().reloadConfig(); - if ( Output.get().isDebug() ) { + if ( Output.get().isDebug() && getBlockConvertersConfig() != null ) { getBlockConvertersConfig().reloadConfig(); } From 717c9187f88c4e553308f9b17425181c5b3f75c8 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:21:16 -0400 Subject: [PATCH 274/297] Adde support for Portuguese. --- docs/changelog_v3.3.x.md | 5 + .../main/resources/lang/core/pt_PT.properties | 111 ++++++ .../resources/lang/mines/pt_PT.properties | 91 +++++ .../resources/lang/ranks/pt_PT.properties | 330 ++++++++++++++++++ 4 files changed, 537 insertions(+) create mode 100644 prison-core/src/main/resources/lang/core/pt_PT.properties create mode 100644 prison-core/src/main/resources/lang/mines/pt_PT.properties create mode 100644 prison-core/src/main/resources/lang/ranks/pt_PT.properties diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 8c4240eee..ef8e681d0 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11g 2022-06-11 + + +* **Add support for Portuguese.** + + * **BlockConverters: fix issue when block converters are not active.** diff --git a/prison-core/src/main/resources/lang/core/pt_PT.properties b/prison-core/src/main/resources/lang/core/pt_PT.properties new file mode 100644 index 000000000..035b42fe8 --- /dev/null +++ b/prison-core/src/main/resources/lang/core/pt_PT.properties @@ -0,0 +1,111 @@ +# +# Prison is a Minecraft plugin for the prison game mode. +# Copyright (C) 2021 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 . +# + +## +## Prison Supports Unicode (UTF-8) encoding in these properties files. BUt you must +## follow these instructions to ensure everything works properly. +## +## 1. You should only edit these files using a UTF-8 editor. On windows use NotePad, not WordPad. +## WordPad will save as plain text. To confirm the save was successful: save, close the editor, +## then reopen to confirm the encoding was preserved. +## +## 2. When running on Windows, you must enable utf-8 encoding in minecraft's console. Windows +## defaults to a characterpage 1252. To enable window's use of utf-8, you need to change the +## encoding prior to launching spigot/paper: +## chcp 65001 +## +## Full example of a windows script, which hooks for java debugging: +## rem Note: chcp 65001 enables utf-8 in windows, when normally windows uses characterpage 1252 +## chcp 65001 +## java -Dfile.encoding="UTF-8" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms1g -Xmx4g -jar spigot-1.8.8.jar nogui --log-strip-color +## pause +## +## 3. When viewing the logs/latest.log files you must use an editor such as NotePad instead of WordPad. +## +## 4. Unicode is properly displayed in game, in console, in the logs, and with paste.helpch.at when using +## /prison support submit. +## + + +# NOTE: A messages__version is an arbitrary integer that will be manually incremented within Prison +# when there are changes to these messages. This value represents when message content is +# changed, fixed, or added to. This value may not be increased if the change is very small and +# insignificant, such as a space or a couple of letters. +# +# messages__auto_refresh=true indicates that this file will automatically be replaced if +# Prison detects a messages__version difference. The old file will be deleted (renamed) and +# a new copy will be placed in the directory to be used. If this value is set to false, then +# Prison will not refresh this file and there could be issues with the display of other messages. +# If auto refresh is set to false, we are not held responsible for possible issues that can +# arise from inaccurate messages. If set to false, then you are responsible for maintaining +# the messages on your own. +# +# If you make changes to this file, and you have messages__auto_refresh=false, then those +# changes will be replaced when this file is updated. Since the old file is renamed, and +# not deleted, you can manually merge your changes back in to the new update. The old +# renamed files will never be deleted by prison; you can remove them when you feel like it +# is safe to do so. +# +# Please consider helping Prison, and everyone else who may use Prison, by contributing all +# translations to other languages. They should be faithful translations, and not something +# for the sake of humor or changes just for cosmetic styling. If you have something you would +# like to share, please contact a staff member on our Discord server. +#Thanks for your contributions! +# +messages__version=2 +messages__auto_refresh=true + + +core_output__prefix_template=| %1 | &7 +core_output__prefix_template_prison=Prison +core_output__prefix_template_info=Info +core_output__prefix_template_warning=Warning +core_output__prefix_template_error=Error +core_output__prefix_template_debug=Debug + +core_output__color_code_info=&3 +core_output__color_code_warning=&c +core_output__color_code_error=&c +core_output__color_code_debug=&9 + +core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure): +core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4 + + +core_prison_utf8_test=Привет! Давай поÑмотрим, работает ли? Test 01 + + +# The following are the original messages and they will eventually be replaced. + +includeError=[%1] tem um valor inválido. +excludeError=[%1] tem um valor válido. +cantAsConsole=Não podes fazer isto pela consola. +missingArgument=O argumento [%1] não está definido (não tem valor default). +missingFlagArgument=A flag -%1 não tem os parametros necessários. +undefinedFlagArgument=O argumento [%1] para a flag -%2 não está definido. +internalErrorOccurred=Um erro interno ocurreu enquanto corria o comando. +noPermission=Não tens as premissões para correr este comando. +blockParseError=O parametro [%1] não é um bloco válido. +numberParseError=O parametro [%1] não é um valor válido. +numberTooLow=O parametro [%1] tem de ser maior ou igual a %2. +numberTooHigh=O parametro [%1] tem de ser menor ou igual a %2. +numberRangeError=O parametro [%1] tem de ser maior ou igual a %2 e ser menor ou igual a %3. +tooFewCharacters=O parametro [%1] tem de ser maior ou igual a %2 characteres. +tooManyCharacters=O parametro [%1] tem de ser menor ou igual a %2 characteres. +playerNotOnline=The player %1 is not online. +worldNotFound=O mundo %1 não foi encontrado. diff --git a/prison-core/src/main/resources/lang/mines/pt_PT.properties b/prison-core/src/main/resources/lang/mines/pt_PT.properties new file mode 100644 index 000000000..199b66191 --- /dev/null +++ b/prison-core/src/main/resources/lang/mines/pt_PT.properties @@ -0,0 +1,91 @@ +# NOTE: A messages__version is an arbitrary integer that will be manually incremented within Prison +# when there are changes to these messages. This value represents when message content is +# changed, fixed, or added to. This value may not be increased if the change is very small and +# insignificant, such as a space or a couple of letters. +# +# messages__auto_refresh=true indicates that this file will automatically be replaced if +# Prison detects a messages__version difference. The old file will be deleted (renamed) and +# a new copy will be placed in the directory to be used. If this value is set to false, then +# Prison will not refresh this file and there could be issues with the display of other messages. +# If auto refresh is set to false, we are not held responsible for possible issues that can +# arise from inaccurate messages. If set to false, then you are responsible for maintaining +# the messages on your own. +# +# If you make changes to this file, and you have messages__auto_refresh=false, then those +# changes will be replaced when this file is updated. Since the old file is renamed, and +# not deleted, you can manually merge your changes back in to the new update. The old +# renamed files will never be deleted by prison; you can remove them when you feel like it +# is safe to do so. +# +# Please consider helping Prison, and everyone else who may use Prison, by contributing all +# translations to other languages. They should be faithful translations, and not something +# for the sake of humor or changes just for cosmetic styling. If you have something you would +# like to share, please contact a staff member on our Discord server. +#Thanks for your contributions! +# + +## +## Prison Supports Unicode (UTF-8) encoding in these properties files. BUt you must +## follow these instructions to ensure everything works properly. +## +## 1. You should only edit these files using a UTF-8 editor. On windows use NotePad, not WordPad. +## WordPad will save as plain text. To confirm the save was successful: save, close the editor, +## then reopen to confirm the encoding was preserved. +## +## 2. When running on Windows, you must enable utf-8 encoding in minecraft's console. Windows +## defaults to a characterpage 1252. To enable window's use of utf-8, you need to change the +## encoding prior to launching spigot/paper: +## chcp 65001 +## +## Full example of a windows script, which hooks for java debugging: +## rem Note: chcp 65001 enables utf-8 in windows, when normally windows uses characterpage 1252 +## chcp 65001 +## java -Dfile.encoding="UTF-8" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms1g -Xmx4g -jar spigot-1.8.8.jar nogui --log-strip-color +## pause +## +## 3. When viewing the logs/latest.log files you must use an editor such as NotePad instead of WordPad. +## +## 4. Unicode is properly displayed in game, in console, in the logs, and with paste.helpch.at when using +## /prison support submit. +## + + + +messages__version=2 +messages__auto_refresh=true + + + +# The following are the original messages and they will eventually be replaced. + +reset_warning=&7A Mina %1 vai resetar em &3%2&7. +reset_message=&7A mina %1 resetou. +not_allowed=&7Não podes minerar aqui. +autosmelt_enable=&bAutosmelt &7foi &aativado&7. +autosmelt_disable=&bAutosmelt &7foi &cdisativado&7. +autoblock_enable=&bAutoblock &7foi &aenabled&7. +autoblock_disable=&bAutoblock &7foi &cdisativado&7. +autopickup_enable=&bAutopickup &7foi &aenabled&7. +autopickup_disable=&bAutopickup &7foi &cdisativado&7. +teleported=&7Teleportado para a mina &3%1&7. +mine_reset=&7A mina &3%1&7 resetou. +mine_reset_fail=&7não foi possivel resetar a mina &3%1&7. &8Verifica a consola para mais detalhes. +mine_created=&7A mina foi criada com sucesso. +mine_deleted=&7A mina foi apagada com sucesso. +select_bounds=&7Tens de selecionar os limites da mina primeiro. &8Escreve /mines wand para selecionares os limites. +world_diff=&7Não podes criar uma mina entre mundos diferentes. +mine_exists=&7Já existe uma mina com esse nome. +mine_does_not_exist=&7Não existe nenhuma mina com esse nome. +spawn_set=&7O spawnpoint da mina foi defenido. +spawn_removed=&7O spawnpoint da mina foi eliminado. +spawnpoint_same_world=&7O &cspawnpoint &7tem de ser no mesmo &cmundo &7que a mina. +not_a_block=&c%1 &7não é um bloco. +block_already_added=&7Esse bloco já foi adicionado à mina. +mine_full=&cA mina vai estar cheia demais. &7Tenta baixa a precentagem deste bloco e/ou outros blocos dentro da mina para fazer espaço. +block_added=&7Bloco adicionado &3%1 &7á mina &3%2&7. +block_set=&7Trocado o bloco &3%1 &7na mina &3%2&7. +block_not_removed=&7Esse bloco não está nesta mina. +block_deleted=&7Bloco removido &3%1 &7da mina &3%2&7. +mine_redefined=&7A mina foi &3redefenida &7com sucesso. +missing_world=&7O mundo em que a mina foi criada não consegue ser encontrado. +block_search_blank=&7Insere um valor para procurar pelo bloco.&7. diff --git a/prison-core/src/main/resources/lang/ranks/pt_PT.properties b/prison-core/src/main/resources/lang/ranks/pt_PT.properties new file mode 100644 index 000000000..5ae461f60 --- /dev/null +++ b/prison-core/src/main/resources/lang/ranks/pt_PT.properties @@ -0,0 +1,330 @@ +# NOTE: A messages__version is an arbitrary integer that will be manually incremented within Prison +# when there are changes to these messages. This value represents when message content is +# changed, fixed, or added to. This value may not be increased if the change is very small and +# insignificant, such as a space or a couple of letters. +# +# messages__auto_refresh=true indicates that this file will automatically be replaced if +# Prison detects a messages__version difference. The old file will be deleted (renamed) and +# a new copy will be placed in the directory to be used. If this value is set to false, then +# Prison will not refresh this file and there could be issues with the display of other messages. +# If auto refresh is set to false, we are not held responsible for possible issues that can +# arise from inaccurate messages. If set to false, then you are responsible for maintaining +# the messages on your own. +# +# If you make changes to this file, and you have messages__auto_refresh=false, then those +# changes will be replaced when this file is updated. Since the old file is renamed, and +# not deleted, you can manually merge your changes back in to the new update. The old +# renamed files will never be deleted by prison; you can remove them when you feel like it +# is safe to do so. +# +# Please consider helping Prison, and everyone else who may use Prison, by contributing all +# translations to other languages. They should be faithful translations, and not something +# for the sake of humor or changes just for cosmetic styling. If you have something you would +# like to share, please contact a staff member on our Discord server. +#Thanks for your contributions! +# + +## +## Prison Supports Unicode (UTF-8) encoding in these properties files. BUt you must +## follow these instructions to ensure everything works properly. +## +## 1. You should only edit these files using a UTF-8 editor. On windows use NotePad, not WordPad. +## WordPad will save as plain text. To confirm the save was successful: save, close the editor, +## then reopen to confirm the encoding was preserved. +## +## 2. When running on Windows, you must enable utf-8 encoding in minecraft's console. Windows +## defaults to a characterpage 1252. To enable window's use of utf-8, you need to change the +## encoding prior to launching spigot/paper: +## chcp 65001 +## +## Full example of a windows script, which hooks for java debugging: +## rem Note: chcp 65001 enables utf-8 in windows, when normally windows uses characterpage 1252 +## chcp 65001 +## java -Dfile.encoding="UTF-8" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms1g -Xmx4g -jar spigot-1.8.8.jar nogui --log-strip-color +## pause +## +## 3. When viewing the logs/latest.log files you must use an editor such as NotePad instead of WordPad. +## +## 4. Unicode is properly displayed in game, in console, in the logs, and with paste.helpch.at when using +## /prison support submit. +## + + +messages__version=3 +messages__auto_refresh=true + +ranks_rankup__rankup_no_player_name=Tu têns +ranks_rankup__rankup_no_player_name_broadcast=Alguém +ranks_rankup__rankup_you_are=Tue és +ranks_rankup__rankup_success=Parabéns! %1 subiste para o rank '%2'. %3 +ranks_rankup__demote_success=Infelismente, %1 desceu de rank '%2'. %3 +ranks_rankup__log_rank_change=%1 iniciado alteraçao de rank: %2 +ranks_rankup__rankup_cant_afford=Não tens dinheiro suficiente para fazeres rankup. O proximo rankup custa %1 %2. +ranks_rankup__rankup_lowest=%1 já estás no rank mais baixo! +ranks_rankup__rankup_highest=%1 já estás no rank mais alto! +ranks_rankup__rankup_failure=Falha genérica no rankup. Reve os detalhes do rankup para identificar o motivo. +ranks_rankup__rankup_failed_to_load_player=Erro a carregar info do player. +ranks_rankup__rankup_failed_to_load_ladder=Erro a carregar a ladder. +ranks_rankup__rankup_failed_to_assign_rank=Erro a dar o rank. +ranks_rankup__rankup_failed_to_save_player_file=Falha ao recuperar ou gravar dados. Os teus arquivos podem estar corrompidos. Reposta a um administrador. +ranks_rankup__rankup_no_ranks=Não existe ranks nesta ladder. +ranks_rankup__rankup_rank_does_not_exist=O rank %1 não existe neste server. +ranks_rankup__rankup_rank_is_not_in_ladder=O rank %1 não existe naladder %2. +ranks_rankup__rankup_currency_is_not_supported=A economia não é suportada, %1. +ranks_rankup__rankup_ladder_removed=A ladder %1 foi removida. +ranks_rankup__rankup_failure_removing_ladder=Rankup falhou porque nao foi possivel remover o player da ladder %1. (Players cannot be removed from the 'default' ladder). +ranks_rankup__rankup_in_progress_failure=Rankup falhou ser complet corretamente. + +ranks_rankup__rankup_failure_to_get_rankplayer=Não existes! O servidor nao têm registo teu. Tenta reentrar no server ou contactar um administrador. +ranks_rankup__rankup_failure_invalid_ladder=A ladder '%1' não existe. +ranks_rankup__rankup_failure_must_be_online_player=&3Tu tens de ser um player para usares este comando, e/ou o player tem de estar online. +ranks_rankup__no_permission=Tu precisas de permissão '%1' para dares rankup nesta ladder. +ranks_rankup__cannot_run_from_console=&7 Não é possível fazer rank na consola. Veja &3/rankup para ajuda&7. +ranks_rankup__internal_failure=&7Modo invalido de rankup. Falha interna. Reporta ao admin. +ranks_rankup__error_no_default_ladder=&c[ERROR] Não existe uma ladder default! Reporta ao admin! +ranks_rankup__error_no_lower_rank=&c[ERROR] Não consgues ter rank mais baixo! Reporta ao admin! + +ranks_rankup__error_no_ladder=&c[ERROR] A ladder %1 não existe! Reporta ao admin! +ranks_rankup__error_no_lower_rank_on_ladder=&c[ERROR] A ladder %1 não tem ranks! Reporta ao admin! + +ranks_rankup__error_player_not_on_default_ladder=&c[ERROR] O player nao está numa default ladder. Player: %1 +ranks_rankup__not_at_last_rank=&cTu não estas no rank mais baixo! +ranks_rankup__not_able_to_prestige=&7[&3Sorry&7] &3Tu não conseguiste fazer &6Prestige! +ranks_rankup__not_able_to_reset_rank=&7Incapaz de resetar o rank para a default ladder. + +ranks_rankup__balance_set_to_zero=&7O teu dinheiro foi posto a 0. +ranks_rankup__prestige_successful=&7[&3Parabéns&7] &3Tu consegiste o &6Prestige&3 to %1&c! +ranks_rankup__prestige_failure=&7[&3Sorry&7] &3Não conseguiste fazer o &6Prestige&3 to %1&c! +ranks_rankup__invalid_charge_value=&3Valor inválido para chargePlayer. Os valores válidos são: %1 %2 +ranks_rankup__invalid_refund_value=&3Valor inválido para refundPlayer. Os valores válidos são: %1 %2 + + +ranks_rankutil__failure_internal=Falha ao executar rankupPlayerInternal verificar logs do servidor para stack trace: %1 +ranks_rankutil__failure_saving_player_data=Ocorreu um erro ao salvar os ficheiros do player. + + +ranks_firstJoinHandler__no_ranks_on_server=Não há ranks no servidor! Novo jogador não tem rank. +ranks_firstJoinHandler__could_not_save_player=Não foi possivel guardar as informações do player. +ranks_firstJoinHandler__success=Welcome! %1 acabou de entrar e recebeu o rank default da ladder. + + +ranks_prisonRanks__failure_no_economy_status=&cNenhum plugin de economia. +ranks_prisonRanks__failure_no_economy=PrisonRanks.enable() - Falha - Nenhum Plugin Economia Ativo - %1 +ranks_prisonRanks__failure_loading_ranks_status=&cFalha ao carregar os ficheiros de Ranks: %1 +ranks_prisonRanks__failure_loading_ranks=O ficheiro de ranks falhou ao carregar. %1 +ranks_prisonRanks__failure_loading_ladders_status=&cFalha ao carregar os ficheiros da Ladder: % 1 +ranks_prisonRanks__failure_loading_ladders=&cO ficheiro ladder falhou ao carregar. %1 +ranks_prisonRanks__failure_loading_players_status=&cFalha ao carregar os ficheiros do Player: %1 +ranks_prisonRanks__failure_loading_players=&cO ficheiro do player falhou ao carregar. %1 +ranks_prisonRanks__failed_loading_players=&cFalha a carregar jogadores: %1 +ranks_prisonRanks__failed_to_load_player_file=Um arquivo do player falhou ao carregar. %1 + +ranks_prisonRanks__status_loaded_ranks=Ranks %1 Carregado. +ranks_prisonRanks__status_loaded_ladders=Ladders %1 Carregado. +ranks_prisonRanks__status_loaded_players=Players %1 Carregado. + +ranks_prisonRanks__failure_with_ladder=&cFalha ao %1 uma nova %2 ladder, uma pré-existente não foi encontrada. +ranks_prisonRanks__failure_with_ladder_create=create +ranks_prisonRanks__failure_with_ladder_save=save +ranks_prisonRanks__failure_with_ladder_default=default +ranks_prisonRanks__failure_with_ladder_prestiges=prestiges + +ranks_prisonRanks__added_new_player=&7Prisão: &cNovo jogador adicionado &7à Prison: &3%1 &7foi encontrado no servidor. +ranks_prisonRanks__added_and_fixed_players=Prison Rank Loader: Adicionados %1 jogadores à prison. Corrigidos %2 jogadores que não tinham um rank na default ladder. + + +ranks_rank__failure_loading_ranks=&aFalha: A Carregar Ranks! &7Exceção analisando documentos de classificação. Rank ID= %1 nome= %2 [%3] + +ranks_rankManager__failure_loading_rankManager=&aFalha: A carregar ladder %1 (ID da ladder: %2): &7Não é possível carregar o RankManager, portanto não é possível acessar nenhum rank. +ranks_rankManager__failure_duplicate_rank=&aFailure: Falha ao carregar RankLadder: Rank '%1' já estava ligado à ladder '%2', mas tentou-se adicionar à ladder '%3'. Este rank não será vinculada à ladder '%4' + + +ranks_rankManager__remove_rank_warning=Remove Rank Warning: No fallback rank exists so players with the rank that is being removed will have no rank on that ladder. +ranks_rankManager__cannot_save_player_file=RemoveRank: Não foi possível salvar o ficheiro do player. +ranks_rankManager__player_is_now=Player %1 is now %2 +ranks_rankManager__cannot_save_ladder_file=RemoveRank: Não foi possível salvar a ladder %1. +ranks_rankManager__failure_no_economy=Falha na Economia: &7A moeda &a%1&7 foi registrada com o rank &a%2&7, mas não é suportada por nenhuma integração da Economia. +ranks_rankManager__ranks_by_ladders=&7Ranks by ladders: + + +ranks_ladderManager__cannot_save_ladder_file=&cLadderManager.saveLadder: Falha ao salvar a ladder. &7%1 &3Erro= [&7%2&3]" + + +ranks_playerManager__cannot_save_player_file=Ocorreu um erro ao salvar os ficheiros do player: %1 +ranks_playerManager__cannot_add_new_player=PlayerManager.getPlayer(): Falha ao adicionar novo nome de jogador: %1. %2 +ranks_playerManager__cannot_save_new_player_file=Falha ao criar novo ficheiro de dados do jogador para o jogador %1 nome do ficheiro de destino: %2 +ranks_playerManager__no_player_name_available= +ranks_playerManager__cannot_load_player_file=Não foi possível carregar o jogador: % 1 +ranks_playerManager__failed_to_load_economy_currency=Falha ao carregar Economia para obter o saldo do jogador %1 com uma moeda de %2. +ranks_playerManager__failed_to_load_economy=Falha ao carregar Economia para obter o saldo do jogador %1. +ranks_playerManager__last_rank_message_for__prison_rankup_rank_tag_default= + + + +ranks_commandCommands__command_add_cannot_use_percent_symbols=&7Cannot use percent symbols as placeholder escape characters; must use { } instead. +ranks_commandCommands__command_add_placeholders=&7Custom placeholders for rank commands are: &3%1 +ranks_commandCommands__rank_does_not_exist=The rank '%1' does not exist. +ranks_commandCommands__command_add_duplicate=Duplicate command '%1' was not added to the rank '%2'. +ranks_commandCommands__command_add_success=Added command '%1' to the rank '%2'. + +ranks_commandCommands__command_remove_sucess=Removed command '%1' from the rank '%2'. +ranks_commandCommands__command_remove_failed=The rank doesn't contain that command. Nothing was changed. + +ranks_commandCommands__command_list_contains_none=The rank '%1' contains no commands. +ranks_commandCommands__command_list_cmd_header=RankUpCommands for rank %1 +ranks_commandCommands__command_list_click_cmd_to_remove=&8Click a command to remove it. +ranks_commandCommands__command_list_click_to_remove=Click to remove. +ranks_commandCommands__command_list_add_button=&7[&a+&7] Add a new Command +ranks_commandCommands__command_list_add_new_command_tool_tip=&7Add a new Command. +ranks_commandCommands__command_row_number_must_be_greater_than_zero=&7Please provide a valid row number greater than zero. Was row=[&b%1&7] +ranks_commandCommands__command_row_number_too_high=&7Please provide a valid row number no greater than &b%d&7. Was row=[&b%1&7] + + + +ranks_commandCommands__ladder_command_add_placeholders=&7Custom placeholders for ladder commands are: &3%1 +ranks_commandCommands__ladder_ladder_does_not_exist=The ladder '%1' does not exist. +ranks_commandCommands__ladder_command_add_duplicate=Duplicate command '%1' was not added to the ladder '%2'. +ranks_commandCommands__ladder_command_add_success=Added command '%1' to the ladder '%2'. + +ranks_commandCommands__ladder_command_remove_sucess=Removed command '%1' from the ladder '%2'. +ranks_commandCommands__ladder_command_remove_failed=The ladder doesn't contain that command. Nothing was changed. + +ranks_commandCommands__ladder_command_list_contains_none=The ladder '%1' contains no commands. +ranks_commandCommands__ladder_command_list_cmd_header=RankUpCommands for the %1 ladder + + + +ranks_LadderCommands__ladder_already_exists=A ladder with the name '%1' already exists. +ranks_LadderCommands__ladder_creation_error=An error occurred while creating your ladder '%1'. &8Check the console for details. +ranks_LadderCommands__ladder_created=The ladder '%1' has been created. +ranks_LadderCommands__ladder_could_not_save=Could not save ladder. +ranks_LadderCommands__ladder_does_not_exist=The ladder '%1' doesn't exist. +ranks_LadderCommands__rank_does_not_exist=The rank '%1' doesn't exist. +ranks_LadderCommands__ladder_already_has_rank=The ladder '%1' already contains the rank '%2'. +ranks_LadderCommands__ladder_added_rank=Added rank '%1' to ladder '%2' in position %3. +ranks_LadderCommands__ladder_deleted=The ladder '%1' has been deleted. +ranks_LadderCommands__ladder_cannot_delete_default=You cannot delete the default ladder. It's needed. +ranks_LadderCommands__ladder_cannot_delete_prestiges=You cannot delete the prestiges ladder. It's needed. +ranks_LadderCommands__ladder_cannot_delete_with_ranks=Cannot delete a ladder if it still has ranks tied to it. Remove all ranks and try again. +ranks_LadderCommands__ladder_error=An error occurred while removing your ladder. &8Check the console for details. +ranks_LadderCommands__ladder_error_adding=An error occurred while adding a rank to your ladder. &8Check the console for details. +ranks_LadderCommands__ladder_error_removing=An error occurred while removing a rank from your ladder. &8Check the console for details. +ranks_LadderCommands__ladder_error_saving=Error while saving ladder. +ranks_LadderCommands__move_rank_notice=Attempting to remove the specified rank from it's original ladder, then it will be added back to the target ladder at the spcified location. The rank will not be lost. +ranks_LadderCommands__ladder_removed_rank_from_ladder=Removed rank '%1' from ladder '%2'. + + +ranks_LadderCommands__ladder_has_ranks=&7This ladder contains the following ranks: +ranks_LadderCommands__ladder_default_rank=&b(&9Default Rank&b) &7- +ranks_LadderCommands__ladder_see_ranks_list=&3See &f/ranks list &b[ladderName] &3for more details on ranks. +ranks_LadderCommands__ladder_has_no_perms=&3The ladder '&7%1&3' contains no permissions or permission groups. +ranks_LadderCommands__ladder_set_rank_cost_multiplier=&3The ladder '&7%1&3' was saved. The Rank Cost Multiplier is now [%2]; was [%3]. +ranks_LadderCommands__ladder_rank_cost_multiplier_no_change=&3The ladder '&7%1&3' was not updated. The supplied Rank Cost Multiplier did not change.[%2] +ranks_LadderCommands__ladder_rank_cost_multiplier_out_of_range=&3The Rank Cost Multiplier is out of range. It must be between -100% and 100%. [%1] + + +ranks_rankCommands__rank_already_exists=&3The rank named &7%1 &3already exists. Try a different name. +ranks_rankCommands__rank_name_required=&3A rank name is required and cannot contain formatting codes. +ranks_rankCommands__ladder_does_not_exist=&3A ladder by the name of '&7%1&3' does not exist. +ranks_rankCommands__ladder_has_no_ranks=&3The ladder '&7%1&3' does not have any ranks. +ranks_rankCommands__ladder_has_no_ranks_text=&3--- This ladder has no Ranks --- +ranks_rankCommands__rank_does_not_exist=&3The rank '&7%1&3' does not exist. +ranks_rankCommands__rank_cannot_be_created=&3The rank could not be created. +ranks_rankCommands__rank_created_successfully=&3Your new rank, '&7%1&3', was created in the ladder '&7%2&3', using the tag value of '&7%3&3' +ranks_rankCommands__error_saving_ladder=&3The '&7%1&3' ladder could not be saved to disk. Check the console for details. +ranks_rankCommands__error_writting_ladder=&3The '&7%1&3' ladder could not be saved to disk. Check the console for details. + + +ranks_rankCommands__auto_config_preexisting_warning=&3You are trying to run &7/ranks autoConfigure&3 with ranks or mines already setup. Rank count = &7%1&3. Mine count = &7%2&3. Please run this command with the &7help&3 keyword for more information and other customization options: &7/ranks autoConfigure help&3. It's best to run this command from the &7console&3 due to the volume of data it generates. Add the option '&7force&3' to force this process to run. If there is a conflict with a preexisting rank or mine, this process will do it's best to merge the new ranks and mines with what already exist. There is the risk something may not merge correctly. When merging, all blocks will be replaced, but in the console the original block list will be printed for reference if you want to recreate them. Please backup your &7plugins/Prison/&3 directory before running to be safe. +ranks_rankCommands__auto_config_force_warning=&aWarning! &3Running autoConfigure with &7force&3 enabled. Not responsible if mines or ranks collide. +ranks_rankCommands__auto_config_invalid_options=&3Invalid options. Use %1&3. Was: &3%2 +ranks_rankCommands__auto_config_skip_rank_warning=&aWarning! &3Rank &7%1 &3already exists and is being skipped along with generating the mine if enabled, along with all of the other features. + +ranks_rankCommands__auto_config_no_ranks_created=Ranks autoConfigure: No ranks were created. +ranks_rankCommands__auto_config_ranks_created=Ranks autoConfigure: %1 ranks were created. +ranks_rankCommands__auto_config_no_rank_cmds_created=Ranks autoConfigure: No rank commands were created. +ranks_rankCommands__auto_config_ladder_rank_cost_multiplier_info=The 'prestiges' ladder has been enabled to apply a Base Rank Cost Multiplier of %1 that will be applied to 'all' rank costs. This multiplier will be increased with each rank on the ladder. +ranks_rankCommands__auto_config_ladder_rank_cost_multiplier_command_example=The Base Rank Cost Multiplier can be adjusted, or disabled, with the command: '/ranks ladder rankCostMultiplier +ranks_rankCommands__auto_config_rank_cmds_created=Ranks autoConfigure: %1 rank commands were created. + +ranks_rankCommands__auto_config_no_mines_created=Ranks autoConfigure: No mines were created. +ranks_rankCommands__auto_config_mines_created=Ranks autoConfigure: %1 mines were created. + +ranks_rankCommands__auto_config_no_linkage=Ranks autoConfigure: No mines and no ranks were linked. +ranks_rankCommands__auto_config_linkage_count=Ranks autoConfigure: %1 ranks and mines were linked. + + +ranks_rankCommands__rank_cannot_remove=You can't remove this rank because it's the only rank in the default ladder. +ranks_rankCommands__rank_was_removed=The rank '%1' has been removed successfully. +ranks_rankCommands__rank_delete_error=The rank '%1' could not be deleted due to an error. + + +ranks_rankCommands__ranks_list_header=&3Ranks in the &7%1 &3Ladder +ranks_rankCommands__ranks_list_ladder_cost_multplier=&3 Ladder Rank Cost Multiplier per Rank: &7%1 +ranks_rankCommands__ranks_list_ladder_edit_cost_multplier=Edit this Ladder's Rank Cost Multiplier. + +ranks_rankCommands__ranks_list_click_to_edit=&7Click on a rank's name to view more info. +ranks_rankCommands__ranks_list_command_count= &cCmds: &3%1 +ranks_rankCommands__ranks_list_currency= &3Currency: &2%1 +ranks_rankCommands__ranks_list_click_to_view=&7Click to view info. +ranks_rankCommands__ranks_list_click_to_view2=&7Click to view. +ranks_rankCommands__ranks_list_create_new_rank=&7Create a new rank. +ranks_rankCommands__ranks_list_you_may_try=&8You may also try + + + +ranks_rankCommands__ranks_info_header=Rank %1 +ranks_rankCommands__ranks_info_name=&3Rank Name: &7%1 +ranks_rankCommands__ranks_info_tag=&3Rank Tag: &7%1 &3Raw: &7\Q%2\E +ranks_rankCommands__ranks_info_ladder=&3Ladder: &7%1 +ranks_rankCommands__ranks_info_not_linked_to_mines=&3This rank is not linked to any mines +ranks_rankCommands__ranks_info_linked_mines=&3Mines linked to this rank: %1 +ranks_rankCommands__ranks_info_cost=&3Cost: &7$%1 +ranks_rankCommands__ranks_info_currency=&3Currency: &7<&a%1&7> +ranks_rankCommands__ranks_info_players_with_rank=&7Players with this rank: %1 +ranks_rankCommands__ranks_info_rank_id=&6Rank ID: &7%1 +ranks_rankCommands__ranks_info_rank_delete_message=&7[&c-&7] Delete +ranks_rankCommands__ranks_info_rank_delete_tool_tip=&7Click to delete this rank.\n&cThis action cannot be undone. + + +ranks_rankCommands__rank_set_cost_success=Successfully set the cost of rank '%1' to %2 + + +ranks_rankCommands__set_currency_not_specified=A currency name must be specified, or must be 'none'. '%1' is invalid. +ranks_rankCommands__set_currency_no_currency_to_clear=The rank '%1' does not have a currency so it cannot be cleared. +ranks_rankCommands__set_currency_cleared=Successfully cleared the currency for the rank '%1'. This rank no longer has a custom currency. +ranks_rankCommands__set_currency_no_active_support=No active economy supports the currency named '%1'. +ranks_rankCommands__set_currency_successful=Successfully set the currency for the rank '%1' to %2 + + +ranks_rankCommands__set_tag_invalid=&cTag name must be a valid value. To remove use a value of &anone&c. +ranks_rankCommands__set_tag_no_change=&cThe new tag name is the same as what it was. No change was made. +ranks_rankCommands__set_tag_cleared=&cThe tag name was cleared for the rank %1. +ranks_rankCommands__set_tag_success=&cThe tag name was changed to %1 for the rank %2. + + +ranks_rankCommands__player_must_be_online=&3You must be a player in the game to run this command, and/or the player must be online. +ranks_rankCommands__player_ladder_info=&7Ladder: &b%1 &7Rank Atual: &b%2 +ranks_rankCommands__player_ladder_highest_rank= É o rank mais alto! +ranks_rankCommands__player_ladder_next_rank=&7 Proximo rank: &b%1&7 &c$&b%2 +ranks_rankCommands__player_ladder_next_rank_currency=&7 Moeda: &2%1 +ranks_rankCommands__player_balance_default=&7O dinheiro de momento de &b%1 &7é &b%2 +ranks_rankCommands__player_balance_others=&7O dinheiro de momento de &b%1 &7é &b%2 &2%3 +ranks_rankCommands__player_perms_offline=&7 Notice: &3The player is offline so permissions are not available nor accurate. +ranks_rankCommands__player_sellall_multiplier=&7 Multiplicador Sellall: &b%1 %2 +ranks_rankCommands__player_not_accurate=&5(&2Not Accurate&5) +ranks_rankCommands__player_admin_only=&8[Admin Only] +ranks_rankCommands__player_past_names=&7Past Player Names and Date Changed: +ranks_rankCommands__player_perms=&7Player Perms: +ranks_rankCommands__player_op=&cOP +ranks_rankCommands__player_player=&3Player +ranks_rankCommands__player_online=&3Online +ranks_rankCommands__player_offline=&3Offline +ranks_rankCommands__player_prison_offline_player=&3PrisonOfflinePlayer +ranks_rankCommands__player_prison_player=&3PrisonPlayer +ranks_rankCommands__player_no_ranks_found=&3Nenhun rank encontrado para &c%1 + + +ranks_rankCommands__players_invalid_ladder=The ladder '%1' doesn't exist, or was not 'ALL'. +ranks_rankCommands__players_invalid_action=The action '%1' is invalid. [players, all, full] + From 955616e76499fbf09a8aaf66b228e5f1f8057b63 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:43:05 -0400 Subject: [PATCH 275/297] * **Prison Placeholders: Major rewrite the handling of placeholders.** Prison's placeholder handling was completely rewritten to better handle the matching of a placeholder text with the actual placeholder objects. Over the last few years, many new features were added to prison's placeholders, but the way they were implemented were through patching existing code. This rewrite starts from scratch on how placeholder are decoded. Placeholders are now only decoded once instead of being decoded when attempting to match each internal placeholder. The results are significant performance improvements and eliminates a lot of redundant code. Some new features were add, such as supporting more than one placeholder attribute at a time. Also it streamlines how parameters and data is passed from the outer most layers of prison to where the placeholders are calculated. Another major benefit of this rewrite, beside reduction of code complexity and performance improvements, is that it opens the door to being able to implement an internal placeholder cache. Some plugins request placeholder data once per tick, or 20 times per second. Multiply that by 50 online players, and you got prison performing the same calculation 1000 times per second. Caching could help reduce that to only one calculation per second (assuming a cache time to live value of 1 second. Caching will not always be so simple, or possible, or every placeholder. Player-based placeholders can't be cached like static mine placeholders (mine names and mine tags as an example). --- docs/changelog_v3.3.x.md | 6 +- .../java/tech/mcprison/prison/Prison.java | 4 + .../BlockConvertersFileConfig.java | 5 +- .../BlockConvertersInitializer.java | 55 + .../prison/internal/platform/Platform.java | 2 + .../prison/placeholders/PlaceHolderKey.java | 2 +- .../placeholders/PlaceholderAttributeBar.java | 4 + .../PlaceholderAttributeNumberFormat.java | 7 + .../PlaceholderAttributeText.java | 7 + .../placeholders/PlaceholderIdentifier.java | 305 ++++ .../placeholders/PlaceholderManager.java | 480 +++---- .../placeholders/PlaceholderManagerUtils.java | 398 ++++++ .../placeholders/PlaceholderResults.java | 20 +- .../tech/mcprison/prison/TestPlatform.java | 5 + .../PlaceholderIdentifierTest.java | 198 +++ .../prison/mines/managers/MineManager.java | 607 ++++---- .../prison/ranks/managers/PlayerManager.java | 381 ++--- .../prison/ranks/managers/RankManager.java | 1232 ++++++++++++----- .../prison/spigot/SpigotPlatform.java | 5 + .../prison/spigot/game/SpigotPlayerUtil.java | 8 + .../MVdWPlaceholderIntegration.java | 72 +- .../placeholder/SpigotPlaceholders.java | 383 +++-- 22 files changed, 2946 insertions(+), 1240 deletions(-) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java create mode 100644 prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManagerUtils.java create mode 100644 prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceholderIdentifierTest.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index ef8e681d0..8bdb44de5 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,9 +11,13 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11g 2022-06-11 +# 3.3.0-alpha.11g 2022-06-13 +* **Prison Placeholders: Major rewrite the handling of placeholders.** +Prison's placeholder handling was completely rewritten to better handle the matching of a placeholder text with the actual placeholder objects. Over the last few years, many new features were added to prison's placeholders, but the way they were implemented were through patching existing code. This rewrite starts from scratch on how placeholder are decoded. Placeholders are now only decoded once instead of being decoded when attempting to match each internal placeholder. The results are significant performance improvements and eliminates a lot of redundant code. Some new features were add, such as supporting more than one placeholder attribute at a time. Also it streamlines how parameters and data is passed from the outer most layers of prison to where the placeholders are calculated. + +Another major benefit of this rewrite, beside reduction of code complexity and performance improvements, is that it opens the door to being able to implement an internal placeholder cache. Some plugins request placeholder data once per tick, or 20 times per second. Multiply that by 50 online players, and you got prison performing the same calculation 1000 times per second. Caching could help reduce that to only one calculation per second (assuming a cache time to live value of 1 second. Caching will not always be so simple, or possible, or every placeholder. Player-based placeholders can't be cached like static mine placeholders (mine names and mine tags as an example). * **Add support for Portuguese.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/Prison.java b/prison-core/src/main/java/tech/mcprison/prison/Prison.java index 396216ca1..fbda21369 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/Prison.java +++ b/prison-core/src/main/java/tech/mcprison/prison/Prison.java @@ -164,6 +164,10 @@ public File getModuleDataFolder() { return moduleDataFolder; } + public void setupJUnitInstance( Platform platform ) { + this.platform = platform; + } + /** * Initializes prison-core. In the implementations, this should be called when the plugin is * enabled. After this is called, every getter in this class will return a value. diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java index 0735030b4..472c4a990 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersFileConfig.java @@ -23,8 +23,9 @@ public class BlockConvertersFileConfig public enum BlockConverterTypes { aSample01, - smeltFeatures, - blockFeatures + autoPickupFeatures, + blockFeatures, + smeltFeatures ; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java index c90584cb9..3a9502cbb 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java +++ b/prison-core/src/main/java/tech/mcprison/prison/autofeatures/BlockConvertersInitializer.java @@ -47,6 +47,11 @@ private void loadDefaultBlockConverters( BlockConverterTypes bcType, TreeMap blockConverters) { + + addSAutoPickupBlockConverter("cobblestone", blockConverters); + addSAutoPickupBlockConverter("stone", blockConverters); + + addSAutoPickupBlockConverter("gold_ore", blockConverters); + addSAutoPickupBlockConverter("iron_ore", blockConverters); + addSAutoPickupBlockConverter("coal_ore", blockConverters); + addSAutoPickupBlockConverter("diamond_ore", blockConverters); + + addSAutoPickupBlockConverter("redstone_ore", blockConverters); + addSAutoPickupBlockConverter("emerald_ore", blockConverters); + addSAutoPickupBlockConverter("quartz_ore", blockConverters); + addSAutoPickupBlockConverter("lapis_ore", blockConverters); + + addSAutoPickupBlockConverter("snowball", blockConverters); + addSAutoPickupBlockConverter("glowstone_dust", blockConverters); + + } + + + private static void addSAutoPickupBlockConverter(String keyBlockName, + TreeMap blockConverters) { + + addSAutoPickupBlockConverter(keyBlockName, null, true, blockConverters); + } + + private static void addSAutoPickupBlockConverter(String keyBlockName, + String semanticVersion, + boolean enabled, + TreeMap blockConverters) { + + BlockConverter bc = new BlockConverter(keyBlockName, 1); + + // All converters are auto-enabled, so only need to disable: + if (!enabled) { + bc.setEnabled(enabled); + } + + if (semanticVersion != null && semanticVersion.trim().length() > 0) { + bc.setMininumSpigotSemanticVersion(semanticVersion); + } + + blockConverters.put(bc.getKeyBlockName(), bc); + } + private static void addSmeltBlockConverter( String keyBlockName, String outputName, 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 f39f813cc..bbb96b5a1 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 @@ -385,6 +385,8 @@ public void autoCreateMineLinerAssignment( List rankMineNames, public PlayerUtil getPlayerUtil( UUID playerUuid ); + public PlayerUtil getPlayerUtil( Player player ); + /** *

Some information on events... diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java index c5ca5ca9e..08d311faf 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java @@ -239,7 +239,7 @@ public String toString() { sb.append( "PlaceHolderKey: key=" ).append( getKey() ) .append( " placeholder=" ).append( getPlaceholder().name() ) - .append( " isPriamary=" ).append( isPrimary() ) + .append( " isPrimary=" ).append( isPrimary() ) .append( " data=" ).append( getData() == null ? "" : getData() ); return sb.toString(); diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeBar.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeBar.java index 181066644..29e77c688 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeBar.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeBar.java @@ -147,6 +147,10 @@ else if ( isHex() ) { } + @Override + public String toString() { + return getRaw(); + } public ArrayList getParts() { return parts; diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeNumberFormat.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeNumberFormat.java index 93fd03bd9..3a43e1d82 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeNumberFormat.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeNumberFormat.java @@ -142,6 +142,13 @@ public PlaceholderAttributeNumberFormat( ArrayList parts, String raw ) { // this.debug = debug; } + + @Override + public String toString() { + return getRaw(); + } + + @Override public String format( String value ) { String results = null; diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeText.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeText.java index 10b341b7e..919493408 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeText.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderAttributeText.java @@ -67,6 +67,13 @@ public PlaceholderAttributeText( ArrayList parts, String raw ) { } + + @Override + public String toString() { + return getRaw(); + } + + @Override public String format( String value ) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java new file mode 100644 index 000000000..09e5d9354 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java @@ -0,0 +1,305 @@ +package tech.mcprison.prison.placeholders; + +import java.util.ArrayList; +import java.util.UUID; + +import tech.mcprison.prison.Prison; +import tech.mcprison.prison.internal.Player; + + +public class PlaceholderIdentifier { + + /** + *

The identifierRaw is the original placeholder text that is sent to prison, + * which needs to be decoded. It also contains one or more placeholder attributes, + * if they are provided. + *

+ */ + private String identifierRaw; + + + /** + *

This identifier contains the raw identifier text, minus any placeholder attributes. + */ + private String identifier; + + + private ArrayList attributes; + + + private boolean hasSequence; + private int sequence; + private String sequencePattern; + + private String escapeLeft; + private String escapeRight; + + private Player player; + + private boolean foundAMatch; + private PlaceHolderKey placeholderKey; + private String text; + + + public PlaceholderIdentifier( String identifier ) { + super(); + + this.identifierRaw = identifier; + this.identifier = ""; + + this.attributes = new ArrayList<>(); + + this.hasSequence = false; + this.sequence = -1; + this.sequencePattern = null; + + + this.escapeLeft = null; + this.escapeRight = null; + + this.player = null; + + this.foundAMatch = false; + this.placeholderKey = null; + this.text = null; + + intialize(); + + } + + private void intialize() { + + if ( identifierRaw == null ) { + + this.identifierRaw = ""; + } + else { + + this.identifierRaw = identifierRaw.trim(); + } + + // If the placeholderRaw has escape characters, strip the off and record them: + PlaceholderManagerUtils.getInstance().convertPlaceholderEscapeCharacters( this ); + + + if ( identifierRaw.length() > 0 ) { + + this.identifier = identifierRaw.toLowerCase(); + + // Extract the placeholder value from the identifierRaw... prefix of "prison_" is not used: + this.identifier = PlaceholderManagerUtils.getInstance().extractPlaceholder( identifierRaw ); + + // Some plugins that handle the placeholders omit the prefix. If that's the case, then + // add it back. + if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) { + identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; + } + + + // Extract the placeholder attributes from the identifierRaw: + this.attributes = PlaceholderManagerUtils.getInstance().extractPlaceholderAttributes( identifierRaw ); + + + // Sets the hasSequence, sequence, and sequencePattern: + PlaceholderManagerUtils.getInstance().convertPlaceholderSequence( this ); + + + // Not sure at this point if the results "text" needs to be set... probably shouldn't since + // if there isn't a match, then since if it is a valid placeholder, then it should be blank: +// this.text = this.identifier; + } + + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + for (PlaceholderAttribute attr : getAttributes() ) { + sb.append( "[" ).append( attr.toString() ).append( "]" ); + } + + return getOriginalIdentifier() + + ( getText() != null ? " \"" + getText() + "\"" : "" ) + + ( getPlayer() != null ? " " + getPlayer().getName() : "" ) + + ( hasSequence() ? " Seq: " + getSequence() : "" ) + + ( sb.length() > 0 ? " " + sb.toString() : ""); + } + + + public String getOriginalIdentifier() { + + return (getEscapeLeft() == null ? "" : getEscapeLeft()) + + getIdentifierRaw() + + (getEscapeRight() == null ? "" : getEscapeRight()); + } + + public boolean checkPlaceholderKey(PlaceHolderKey placeHolderKey) { + boolean results = false; + + String key = placeHolderKey.getKey().toLowerCase(); + + if ( getIdentifier().equalsIgnoreCase( key ) ) { + + setPlaceholderKey( placeHolderKey ); + results = true; + + } + + return results; + } + + public void setPlayer( UUID playerUuid, String playerName ) { + Player player = null; + + if ( playerUuid != null ) { + + player = Prison.get().getPlatform().getPlayer( playerUuid ).orElse( null ); + } + + if ( player == null && playerName != null ) { + + player = Prison.get().getPlatform().getPlayer( playerName ).orElse( null ); + } + + if ( player == null && playerUuid != null ) { + + player = Prison.get().getPlatform().getOfflinePlayer( playerUuid ).orElse( null ); + } + + if ( player == null && playerName != null ) { + + player = Prison.get().getPlatform().getOfflinePlayer( playerName ).orElse( null ); + } + + + if ( player != null ) { + setPlayer(player); + } + } + + public PlaceholderAttributeBar getAttributeBar() { + PlaceholderAttributeBar phAttribute = null; + + for (PlaceholderAttribute placeholderAttribute : getAttributes() ) { + if ( placeholderAttribute instanceof PlaceholderAttributeBar ) { + phAttribute = (PlaceholderAttributeBar) placeholderAttribute; + break; + } + } + + return phAttribute; + } + + public PlaceholderAttributeNumberFormat getAttributeNFormat() { + PlaceholderAttributeNumberFormat phAttribute = null; + + for (PlaceholderAttribute placeholderAttribute : getAttributes() ) { + if ( placeholderAttribute instanceof PlaceholderAttributeNumberFormat ) { + phAttribute = (PlaceholderAttributeNumberFormat) placeholderAttribute; + break; + } + } + + return phAttribute; + } + + public PlaceholderAttributeText getAttributeText() { + PlaceholderAttributeText phAttribute = null; + + for (PlaceholderAttribute placeholderAttribute : getAttributes() ) { + if ( placeholderAttribute instanceof PlaceholderAttributeText ) { + phAttribute = (PlaceholderAttributeText) placeholderAttribute; + break; + } + } + + return phAttribute; + } + + public String getIdentifierRaw() { + return identifierRaw; + } + public void setIdentifierRaw(String identifierRaw) { + this.identifierRaw = identifierRaw; + } + + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public ArrayList getAttributes() { + return attributes; + } + public void setAttributes(ArrayList attributes) { + this.attributes = attributes; + } + + public boolean hasSequence() { + return hasSequence; + } + public void setHasSequence(boolean hasSequence) { + this.hasSequence = hasSequence; + } + + public int getSequence() { + return sequence; + } + public void setSequence(int sequence) { + this.sequence = sequence; + } + + public String getSequencePattern() { + return sequencePattern; + } + public void setSequencePattern(String sequencePattern) { + this.sequencePattern = sequencePattern; + } + + public String getEscapeLeft() { + return escapeLeft; + } + public void setEscapeLeft(String escapeLeft) { + this.escapeLeft = escapeLeft; + } + + public String getEscapeRight() { + return escapeRight; + } + public void setEscapeRight(String escapeRight) { + this.escapeRight = escapeRight; + } + + public Player getPlayer() { + return player; + } + public void setPlayer(Player player) { + this.player = player; + } + + public boolean isFoundAMatch() { + return foundAMatch; + } + public void setFoundAMatch(boolean foundAMatch) { + this.foundAMatch = foundAMatch; + } + + public PlaceHolderKey getPlaceholderKey() { + return placeholderKey; + } + public void setPlaceholderKey(PlaceHolderKey placeholderKey) { + this.placeholderKey = placeholderKey; + } + + public String getText() { + return text; + } + public void setText(String text) { + this.text = text; + } + + +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java index b636426e6..4cf37259b 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java @@ -1,11 +1,8 @@ package tech.mcprison.prison.placeholders; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; - -import tech.mcprison.prison.Prison; -import tech.mcprison.prison.output.Output; +import java.util.regex.Pattern; public class PlaceholderManager { @@ -22,7 +19,14 @@ public class PlaceholderManager { PRISON_PLACEHOLDER_ATTRIBUTE_FIELD_SEPARATOR + PRISON_PLACEHOLDER_ATTRIBUTE_FIELD_SEPARATOR; - private PlaceholderProgressBarConfig progressBarConfig; + // NOTE: Pattern is thread safe so make it static. Matcher is not thead safe. + public static Pattern PLACEHOLDER_SEQUENCE_PATTERN = Pattern.compile( "(\\_([0-9]+)\\_)" ); + + public static Pattern PLACEHOLDER_ESCAPE_CHARACTER_LEFT_PATTERN = Pattern.compile( "(^\\p{Punct})" ); + public static Pattern PLACEHOLDER_ESCAPE_CHARACTER_RIGHT_PATTERN = Pattern.compile( "(\\p{Punct}$)" ); + + +// private PlaceholderProgressBarConfig progressBarConfig; public enum placeholderFlagType { supress, @@ -807,78 +811,78 @@ private static String getAllChatTexts( boolean omitSuppressable) { } - /** - *

This will extract attributes from dynamic placeholders and will return. - *

- * - *

Planning on using : as separators. :: for identifying each attribute, and then - * within each attribute : will separate the individual fields and values. - * For example it a number format attribute could look like this: - *

- * - *
::nFormat:0.00{unit}
for no spaces. - *
::nFormat:#,##0.0+{unit}
for spaces since + will be converted to spaces. - * - * @param placeholder - * @return - */ - public PlaceholderAttribute extractPlaceholderExtractAttribute( String placeholder ) { - PlaceholderAttribute attribute = null; - - if ( placeholder != null ) { - String[] attributes = placeholder.split( PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR ); - - // attributes[0] will be the placeholder, so ignore: - if ( attributes != null && attributes.length > 1 ) { - for ( int i = 1; i < attributes.length ; i++ ) { - String rawAttribute = attributes[i]; - - if ( rawAttribute != null ) { - attribute = attributeFactory( rawAttribute ); - break; - } - } - } - } - - return attribute; - } +// /** +// *

This will extract attributes from dynamic placeholders and will return. +// *

+// * +// *

Planning on using : as separators. :: for identifying each attribute, and then +// * within each attribute : will separate the individual fields and values. +// * For example it a number format attribute could look like this: +// *

+// * +// *
::nFormat:0.00{unit}
for no spaces. +// *
::nFormat:#,##0.0+{unit}
for spaces since + will be converted to spaces. +// * +// * @param placeholder +// * @return +// */ +// public PlaceholderAttribute extractPlaceholderExtractAttribute( String placeholder ) { +// PlaceholderAttribute attribute = null; +// +// if ( placeholder != null ) { +// String[] attributes = placeholder.split( PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR ); +// +// // attributes[0] will be the placeholder, so ignore: +// if ( attributes != null && attributes.length > 1 ) { +// for ( int i = 1; i < attributes.length ; i++ ) { +// String rawAttribute = attributes[i]; +// +// if ( rawAttribute != null ) { +// attribute = attributeFactory( rawAttribute ); +// break; +// } +// } +// } +// } +// +// return attribute; +// } - private PlaceholderAttribute attributeFactory( String rawAttribute ) { - PlaceholderAttribute attribute = null; - - if ( rawAttribute != null && !rawAttribute.isEmpty() ) { - ArrayList parts = new ArrayList<>(); - parts.addAll( Arrays.asList( rawAttribute.split( PRISON_PLACEHOLDER_ATTRIBUTE_FIELD_SEPARATOR )) ); - - if ( parts.size() > 1 ) { - PlaceholderAttributePrefixes pap = PlaceholderAttributePrefixes.fromString( parts.get( 0 ) ); - - switch ( pap ) - { - case nFormat: - attribute = new PlaceholderAttributeNumberFormat( parts, rawAttribute ); - break; - - case bar: - attribute = new PlaceholderAttributeBar( parts, getProgressBarConfig(), rawAttribute ); - break; - - case text: - attribute = new PlaceholderAttributeText( parts, rawAttribute ); - break; - - default: - break; - } - - } - - } - - return attribute; - } +// private PlaceholderAttribute attributeFactory( String rawAttribute ) { +// PlaceholderAttribute attribute = null; +// +// if ( rawAttribute != null && !rawAttribute.isEmpty() ) { +// ArrayList parts = new ArrayList<>(); +// parts.addAll( Arrays.asList( rawAttribute.split( PRISON_PLACEHOLDER_ATTRIBUTE_FIELD_SEPARATOR )) ); +// +// if ( parts.size() > 1 ) { +// PlaceholderAttributePrefixes pap = PlaceholderAttributePrefixes.fromString( parts.get( 0 ) ); +// +// switch ( pap ) +// { +// case nFormat: +// attribute = new PlaceholderAttributeNumberFormat( parts, rawAttribute ); +// break; +// +// case bar: +// attribute = new PlaceholderAttributeBar( parts, getProgressBarConfig(), rawAttribute ); +// break; +// +// case text: +// attribute = new PlaceholderAttributeText( parts, rawAttribute ); +// break; +// +// default: +// break; +// } +// +// } +// +// } +// +// return attribute; +// } public String extractPlaceholderString( String identifier ) { @@ -897,169 +901,169 @@ public String extractPlaceholderString( String identifier ) { return results; } - public void reloadPlaceholderBarConfig() { - setProgressBarConfig( loadPlaceholderBarConfig() ); - } - - public PlaceholderProgressBarConfig loadPlaceholderBarConfig() { - PlaceholderProgressBarConfig config = null; - - String barSegmentsStr = Prison.get().getPlatform().getConfigString( - "placeholder.bar-segments" ); - String barPositiveColor = Prison.get().getPlatform().getConfigString( - "placeholder.bar-positive-color" ); - String barPositiveSegment = Prison.get().getPlatform().getConfigString( - "placeholder.bar-positive-segment" ); - String barNegativeColor = Prison.get().getPlatform().getConfigString( - "placeholder.bar-negative-color" ); - String barNegativeSegment = Prison.get().getPlatform().getConfigString( - "placeholder.bar-negative-segment" ); - - - // All 5 must not be null: - if ( barSegmentsStr != null && barPositiveColor != null && barPositiveSegment != null && - barNegativeColor != null && barNegativeSegment != null ) { - - int barSegments = 20; - - try { - barSegments = Integer.parseInt( barSegmentsStr ); - } - catch ( NumberFormatException e ) { - Output.get().logWarn( - "IntegrationManager.loadPlaceholderBarConfigs(): Failure to convert the" + - "/plugins/Prison/config.yml prison-placeholder-configs.progress-bar.bar-segments " + - "to a valid integer. Defaulting to a value of 20 " + - "[" + barSegmentsStr + "] " + e.getMessage() ); - - } - - config = new PlaceholderProgressBarConfig( barSegments, - barPositiveColor, barPositiveSegment, - barNegativeColor, barNegativeSegment ); - } - - if ( config == null ) { - // go with default values because the config.yml is not up to date with - // the default values - - config = new PlaceholderProgressBarConfig( - 20, "&2", "#", "&4", "=" -// 20, "&2", "â–Š", "&4", "â–’" - ); - - Output.get().logInfo( "The /plugins/Prison/config.yml does not contain the " + - "default values for the Placeholder Progress Bar." ); - Output.get().logInfo( "Default values are " + - "being used. To customize the bar, rename the config.yml and it will be " + - "regenerated and then edit to restore prior values."); - - } - - return config; - } - - public PlaceholderProgressBarConfig getProgressBarConfig() { - if ( progressBarConfig == null ) { - progressBarConfig = loadPlaceholderBarConfig(); - } - return progressBarConfig; - } - public void setProgressBarConfig( PlaceholderProgressBarConfig progressBarConfig ) { - this.progressBarConfig = progressBarConfig; - } - - /** - *

This function uses the settings within the config.yml to construct a progress - * bar. It takes two numeric values and constructs it upon those parameters. - * The parameter

value
is the value that changes, and is the value that - * sets where the bar changes. The parameter
valueTotal
is the max value - * of where the
value
is increasing to. - *

- * - *

The lowest range is always zero and

value
will be set to zero if - * it is negative. If
value
is greater than
valueTotal
- * then it will be set to that value. The valid range for this function is only 0 percent - * to 100 percent. - *

- * - *

If the progress bar is moving in the wrong direction, then set the parameter - *

reverse
to true and then the
value
will be inverted by subtracting - * its value from
valueTotal
. - *

- * - * @param value A value that is changing. Will be set to zero if negative. Will be - * set to valueTotal if greater than that amount. - * @param valueTotal The target value that is non-changing. - * @param reverse Changes the growth direction of the progress bar. - * @param attribute - * @return - */ - public String getProgressBar( double value, double valueTotal, boolean reverse, - PlaceholderAttribute attribute ) { - StringBuilder sb = new StringBuilder(); - - // value cannot be greater than valueTotal: - if ( value > valueTotal ) { - value = valueTotal; - } - else if ( value < 0 ) { - value = 0; - } - - // If reverse, then the new value is subtracted from valueTotal: - if ( reverse ) { - value = valueTotal - value; - } - - double percent = valueTotal == 0 ? 100d : value / valueTotal * 100.0; - - PlaceholderAttributeBar barAttribute = attribute == null || - !(attribute instanceof PlaceholderAttributeBar) ? null : - (PlaceholderAttributeBar) attribute; - -// Output.get().logInfo( "### @@@ ### getProgressBar: barAttribute: " + -// ( barAttribute != null ? "true" : "false")); - - PlaceholderProgressBarConfig barConfig = - barAttribute != null ? barAttribute.getBarConfig() : - getProgressBarConfig(); - - String lastColorCode = null; - int segments = barConfig.getSegments(); - for ( int i = 0; i < segments; i++ ) { - double pct = i / ((double)barConfig.getSegments()) * 100.0; - - // If the calculated percent is less than the threshold and as long as it's not the last - // segment, then show a positive. If it's the last segment an it's still less than - // the percent, then show a negative no matter what to indicate it's not yet there. - if ( pct < percent && (percent == 100d || percent < 100d && i < segments - 1)) { - if ( lastColorCode == null || - !barConfig.getPositiveColor().equalsIgnoreCase( lastColorCode )) { - sb.append( barConfig.getPositiveColor() ); - lastColorCode = barConfig.getPositiveColor(); - } - sb.append( barConfig.getPositiveSegment() ); - } - else { - if ( lastColorCode == null || - !barConfig.getNegativeColor().equalsIgnoreCase( lastColorCode )) { - sb.append( barConfig.getNegativeColor() ); - lastColorCode = barConfig.getNegativeColor(); - } - sb.append( barConfig.getNegativeSegment() ); - - } - } - - - if ( barConfig.isReverse() ) { - sb.reverse(); - } - - - return sb.toString(); - } +// public void reloadPlaceholderBarConfig() { +// setProgressBarConfig( loadPlaceholderBarConfig() ); +// } +// +// public PlaceholderProgressBarConfig loadPlaceholderBarConfig() { +// PlaceholderProgressBarConfig config = null; +// +// String barSegmentsStr = Prison.get().getPlatform().getConfigString( +// "placeholder.bar-segments" ); +// String barPositiveColor = Prison.get().getPlatform().getConfigString( +// "placeholder.bar-positive-color" ); +// String barPositiveSegment = Prison.get().getPlatform().getConfigString( +// "placeholder.bar-positive-segment" ); +// String barNegativeColor = Prison.get().getPlatform().getConfigString( +// "placeholder.bar-negative-color" ); +// String barNegativeSegment = Prison.get().getPlatform().getConfigString( +// "placeholder.bar-negative-segment" ); +// +// +// // All 5 must not be null: +// if ( barSegmentsStr != null && barPositiveColor != null && barPositiveSegment != null && +// barNegativeColor != null && barNegativeSegment != null ) { +// +// int barSegments = 20; +// +// try { +// barSegments = Integer.parseInt( barSegmentsStr ); +// } +// catch ( NumberFormatException e ) { +// Output.get().logWarn( +// "IntegrationManager.loadPlaceholderBarConfigs(): Failure to convert the" + +// "/plugins/Prison/config.yml prison-placeholder-configs.progress-bar.bar-segments " + +// "to a valid integer. Defaulting to a value of 20 " + +// "[" + barSegmentsStr + "] " + e.getMessage() ); +// +// } +// +// config = new PlaceholderProgressBarConfig( barSegments, +// barPositiveColor, barPositiveSegment, +// barNegativeColor, barNegativeSegment ); +// } +// +// if ( config == null ) { +// // go with default values because the config.yml is not up to date with +// // the default values +// +// config = new PlaceholderProgressBarConfig( +// 20, "&2", "#", "&4", "=" +//// 20, "&2", "â–Š", "&4", "â–’" +// ); +// +// Output.get().logInfo( "The /plugins/Prison/config.yml does not contain the " + +// "default values for the Placeholder Progress Bar." ); +// Output.get().logInfo( "Default values are " + +// "being used. To customize the bar, rename the config.yml and it will be " + +// "regenerated and then edit to restore prior values."); +// +// } +// +// return config; +// } +// +// public PlaceholderProgressBarConfig getProgressBarConfig() { +// if ( progressBarConfig == null ) { +// progressBarConfig = loadPlaceholderBarConfig(); +// } +// return progressBarConfig; +// } +// public void setProgressBarConfig( PlaceholderProgressBarConfig progressBarConfig ) { +// this.progressBarConfig = progressBarConfig; +// } +// +// /** +// *

This function uses the settings within the config.yml to construct a progress +// * bar. It takes two numeric values and constructs it upon those parameters. +// * The parameter

value
is the value that changes, and is the value that +// * sets where the bar changes. The parameter
valueTotal
is the max value +// * of where the
value
is increasing to. +// *

+// * +// *

The lowest range is always zero and

value
will be set to zero if +// * it is negative. If
value
is greater than
valueTotal
+// * then it will be set to that value. The valid range for this function is only 0 percent +// * to 100 percent. +// *

+// * +// *

If the progress bar is moving in the wrong direction, then set the parameter +// *

reverse
to true and then the
value
will be inverted by subtracting +// * its value from
valueTotal
. +// *

+// * +// * @param value A value that is changing. Will be set to zero if negative. Will be +// * set to valueTotal if greater than that amount. +// * @param valueTotal The target value that is non-changing. +// * @param reverse Changes the growth direction of the progress bar. +// * @param attribute +// * @return +// */ +// public String getProgressBar( double value, double valueTotal, boolean reverse, +// PlaceholderAttribute attribute ) { +// StringBuilder sb = new StringBuilder(); +// +// // value cannot be greater than valueTotal: +// if ( value > valueTotal ) { +// value = valueTotal; +// } +// else if ( value < 0 ) { +// value = 0; +// } +// +// // If reverse, then the new value is subtracted from valueTotal: +// if ( reverse ) { +// value = valueTotal - value; +// } +// +// double percent = valueTotal == 0 ? 100d : value / valueTotal * 100.0; +// +// PlaceholderAttributeBar barAttribute = attribute == null || +// !(attribute instanceof PlaceholderAttributeBar) ? null : +// (PlaceholderAttributeBar) attribute; +// +//// Output.get().logInfo( "### @@@ ### getProgressBar: barAttribute: " + +//// ( barAttribute != null ? "true" : "false")); +// +// PlaceholderProgressBarConfig barConfig = +// barAttribute != null ? barAttribute.getBarConfig() : +// getProgressBarConfig(); +// +// String lastColorCode = null; +// int segments = barConfig.getSegments(); +// for ( int i = 0; i < segments; i++ ) { +// double pct = i / ((double)barConfig.getSegments()) * 100.0; +// +// // If the calculated percent is less than the threshold and as long as it's not the last +// // segment, then show a positive. If it's the last segment an it's still less than +// // the percent, then show a negative no matter what to indicate it's not yet there. +// if ( pct < percent && (percent == 100d || percent < 100d && i < segments - 1)) { +// if ( lastColorCode == null || +// !barConfig.getPositiveColor().equalsIgnoreCase( lastColorCode )) { +// sb.append( barConfig.getPositiveColor() ); +// lastColorCode = barConfig.getPositiveColor(); +// } +// sb.append( barConfig.getPositiveSegment() ); +// } +// else { +// if ( lastColorCode == null || +// !barConfig.getNegativeColor().equalsIgnoreCase( lastColorCode )) { +// sb.append( barConfig.getNegativeColor() ); +// lastColorCode = barConfig.getNegativeColor(); +// } +// sb.append( barConfig.getNegativeSegment() ); +// +// } +// } +// +// +// if ( barConfig.isReverse() ) { +// sb.reverse(); +// } +// +// +// return sb.toString(); +// } diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManagerUtils.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManagerUtils.java new file mode 100644 index 000000000..f6c3bff67 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManagerUtils.java @@ -0,0 +1,398 @@ +package tech.mcprison.prison.placeholders; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.regex.Matcher; + +import tech.mcprison.prison.Prison; +import tech.mcprison.prison.internal.platform.Platform; +import tech.mcprison.prison.output.Output; +import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderAttributePrefixes; + +public class PlaceholderManagerUtils { + + private static PlaceholderManagerUtils instance = null; + + private PlaceholderManagerUtils() { + super(); + } + + public static PlaceholderManagerUtils getInstance() { + + if ( instance == null ) { + synchronized ( PlaceholderManagerUtils.class ) { + if ( instance == null ) { + instance = new PlaceholderManagerUtils(); + } + } + } + + return instance; + } + + public String extractPlaceholder( String placeholder ) { + String results = null; + + if ( placeholder != null ) { + String[] parts = placeholder.split( PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR ); + + // parts[0] will be the placeholder we need to return: + if ( parts != null && parts.length > 0 ) { + results = parts[0]; + } + } + + return results; + } + + + private PlaceholderProgressBarConfig progressBarConfig; + + /** + *

This will extract attributes from dynamic placeholders and will return them either in an + * empty array list (none), or one or more attributes. + *

+ * + *

Planning on using : as separators. :: for identifying each attribute, and then + * within each attribute : will separate the individual fields and values. + * For example it a number format attribute could look like this: + *

+ * + * NOTE: Not actual examples: + * + *
::nFormat:0.00{unit}
for no spaces. + *
::nFormat:#,##0.0+{unit}
for spaces since + will be converted to spaces. + * + * @param placeholder + * @return + */ + public ArrayList extractPlaceholderAttributes( String placeholder ) { + ArrayList attributes = new ArrayList<>(); + + if ( placeholder != null ) { + String[] parts = placeholder.split( PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR ); + + // parts[0] will be the placeholder, so ignore: + if ( parts != null && parts.length > 1 ) { + for ( int i = 1; i < parts.length ; i++ ) { + String rawAttribute = parts[i]; + + if ( rawAttribute != null ) { + PlaceholderAttribute attribute = attributeFactory( rawAttribute ); + + if ( attribute != null ) { + + attributes.add( attribute ); + } + } + } + } + } + + return attributes; + } + + private PlaceholderAttribute attributeFactory( String rawAttribute ) { + PlaceholderAttribute attribute = null; + + if ( rawAttribute != null && !rawAttribute.isEmpty() ) { + ArrayList parts = new ArrayList<>(); + parts.addAll( Arrays.asList( rawAttribute.split( PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_FIELD_SEPARATOR )) ); + + if ( parts.size() >= 0 ) { + PlaceholderAttributePrefixes pap = PlaceholderAttributePrefixes.fromString( parts.get( 0 ) ); + + if ( pap != null ) { + + switch ( pap ) + { + case nFormat: + attribute = new PlaceholderAttributeNumberFormat( parts, rawAttribute ); + break; + + case bar: + attribute = new PlaceholderAttributeBar( parts, getProgressBarConfig(), rawAttribute ); + break; + + case text: + attribute = new PlaceholderAttributeText( parts, rawAttribute ); + break; + + default: + break; + } + + } + } + + } + + return attribute; + } + + public void reloadPlaceholderBarConfig() { + setProgressBarConfig( loadPlaceholderBarConfig() ); + } + + public PlaceholderProgressBarConfig loadPlaceholderBarConfig() { + PlaceholderProgressBarConfig config = null; + + Platform platform = Prison.get().getPlatform(); + + if ( platform != null ) { + + String barSegmentsStr = platform.getConfigString( + "placeholder.bar-segments" ); + String barPositiveColor = Prison.get().getPlatform().getConfigString( + "placeholder.bar-positive-color" ); + String barPositiveSegment = Prison.get().getPlatform().getConfigString( + "placeholder.bar-positive-segment" ); + String barNegativeColor = Prison.get().getPlatform().getConfigString( + "placeholder.bar-negative-color" ); + String barNegativeSegment = Prison.get().getPlatform().getConfigString( + "placeholder.bar-negative-segment" ); + + + // All 5 must not be null: + if ( barSegmentsStr != null && barPositiveColor != null && barPositiveSegment != null && + barNegativeColor != null && barNegativeSegment != null ) { + + int barSegments = 20; + + try { + barSegments = Integer.parseInt( barSegmentsStr ); + } + catch ( NumberFormatException e ) { + Output.get().logWarn( + "IntegrationManager.loadPlaceholderBarConfigs(): Failure to convert the" + + "/plugins/Prison/config.yml prison-placeholder-configs.progress-bar.bar-segments " + + "to a valid integer. Defaulting to a value of 20 " + + "[" + barSegmentsStr + "] " + e.getMessage() ); + + } + + config = new PlaceholderProgressBarConfig( barSegments, + barPositiveColor, barPositiveSegment, + barNegativeColor, barNegativeSegment ); + } + } + + if ( config == null ) { + // go with default values because the config.yml is not up to date with + // the default values + + config = new PlaceholderProgressBarConfig( + 20, "&2", "#", "&4", "=" +// 20, "&2", "â–Š", "&4", "â–’" + ); + + Output.get().logInfo( "The /plugins/Prison/config.yml does not contain the " + + "default values for the Placeholder Progress Bar." ); + Output.get().logInfo( "Default values are " + + "being used. To customize the bar, rename the config.yml and it will be " + + "regenerated and then edit to restore prior values."); + + } + + return config; + } + + public PlaceholderProgressBarConfig getProgressBarConfig() { + if ( progressBarConfig == null ) { + progressBarConfig = loadPlaceholderBarConfig(); + } + return progressBarConfig; + } + public void setProgressBarConfig( PlaceholderProgressBarConfig progressBarConfig ) { + this.progressBarConfig = progressBarConfig; + } + + /** + *

This function uses the settings within the config.yml to construct a progress + * bar. It takes two numeric values and constructs it upon those parameters. + * The parameter

value
is the value that changes, and is the value that + * sets where the bar changes. The parameter
valueTotal
is the max value + * of where the
value
is increasing to. + *

+ * + *

The lowest range is always zero and

value
will be set to zero if + * it is negative. If
value
is greater than
valueTotal
+ * then it will be set to that value. The valid range for this function is only 0 percent + * to 100 percent. + *

+ * + *

If the progress bar is moving in the wrong direction, then set the parameter + *

reverse
to true and then the
value
will be inverted by subtracting + * its value from
valueTotal
. + *

+ * + * @param value A value that is changing. Will be set to zero if negative. Will be + * set to valueTotal if greater than that amount. + * @param valueTotal The target value that is non-changing. + * @param reverse Changes the growth direction of the progress bar. + * @param attribute + * @return + */ + public String getProgressBar( double value, double valueTotal, boolean reverse, + PlaceholderAttributeBar attributeBar ) { + StringBuilder sb = new StringBuilder(); + + // value cannot be greater than valueTotal: + if ( value > valueTotal ) { + value = valueTotal; + } + else if ( value < 0 ) { + value = 0; + } + + // If reverse, then the new value is subtracted from valueTotal: + if ( reverse ) { + value = valueTotal - value; + } + + double percent = valueTotal == 0 ? 100d : value / valueTotal * 100.0; + +// PlaceholderAttributeBar barAttribute = attribute == null || +// !(attribute instanceof PlaceholderAttributeBar) ? null : +// (PlaceholderAttributeBar) attribute; + +// Output.get().logInfo( "### @@@ ### getProgressBar: barAttribute: " + +// ( barAttribute != null ? "true" : "false")); + + PlaceholderProgressBarConfig barConfig = + attributeBar != null ? attributeBar.getBarConfig() : + getProgressBarConfig(); + + String lastColorCode = null; + int segments = barConfig.getSegments(); + for ( int i = 0; i < segments; i++ ) { + double pct = i / ((double)barConfig.getSegments()) * 100.0; + + // If the calculated percent is less than the threshold and as long as it's not the last + // segment, then show a positive. If it's the last segment an it's still less than + // the percent, then show a negative no matter what to indicate it's not yet there. + if ( pct < percent && (percent == 100d || percent < 100d && i < segments - 1)) { + if ( lastColorCode == null || + !barConfig.getPositiveColor().equalsIgnoreCase( lastColorCode )) { + sb.append( barConfig.getPositiveColor() ); + lastColorCode = barConfig.getPositiveColor(); + } + sb.append( barConfig.getPositiveSegment() ); + } + else { + if ( lastColorCode == null || + !barConfig.getNegativeColor().equalsIgnoreCase( lastColorCode )) { + sb.append( barConfig.getNegativeColor() ); + lastColorCode = barConfig.getNegativeColor(); + } + sb.append( barConfig.getNegativeSegment() ); + + } + } + + + if ( barConfig.isReverse() ) { + sb.reverse(); + } + + + return sb.toString(); + } + + protected void convertPlaceholderSequence( PlaceholderIdentifier pIdentifier ) { + + Matcher matcher = PlaceholderManager.PLACEHOLDER_SEQUENCE_PATTERN.matcher( pIdentifier.getIdentifier() ); + if ( matcher.find() ) { + + pIdentifier.setHasSequence( true ); + + //String group0 = matcher.group( 0 ); + String group1 = matcher.group( 1 ); + String group2 = matcher.group( 2 ); + + pIdentifier.setIdentifier( pIdentifier.getIdentifier().replace( group1, "_nnn_" ) ); + +// Output.get().logInfo( "### PlaceHolderKey: seq pattern detected: " + placeholder.name() + +// " group0= " + group0 + " group1= " + group1 + " group2= " + group2 + " replacedText: " + textLowercase ); + + pIdentifier.setSequencePattern( group1 ); + + // a value of -1 indicates it was not able to be parsed: + int parsed = -1; + + try { + parsed = Integer.parseInt( group2 ); + } + catch ( NumberFormatException e ) { + // Not a number so ignore... but based upon matcher.find() it should be... Hmm... + } + + pIdentifier.setSequence( parsed ); + + } + } + + /** + *

This function checks to see if the raw identifier (placeholder) has any escape characters. If it does, + * then it stores them within escapeLeft and escapeRight and removes them from the identifierRaw. + *

+ * + *

If the "original" raw identifier is needed, then the + * @param pIdentifier + */ + protected void convertPlaceholderEscapeCharacters( PlaceholderIdentifier pIdentifier ) { + + if ( pIdentifier.getIdentifierRaw().startsWith( "%" ) ) { + pIdentifier.setEscapeLeft( "%" ); + pIdentifier.setIdentifierRaw( pIdentifier.getIdentifierRaw().substring(1) ); + + if ( pIdentifier.getIdentifierRaw().endsWith( "%" ) ) { + pIdentifier.setEscapeRight( "%" ); + + int len = pIdentifier.getIdentifierRaw().length(); + pIdentifier.setIdentifierRaw( pIdentifier.getIdentifierRaw().substring(0, len - 1) ); + } + } + + else if ( pIdentifier.getIdentifierRaw().startsWith( "{" ) ) { + pIdentifier.setEscapeLeft( "{" ); + pIdentifier.setIdentifierRaw( pIdentifier.getIdentifierRaw().substring(1) ); + + if ( pIdentifier.getIdentifierRaw().endsWith( "}" ) ) { + pIdentifier.setEscapeRight( "}" ); + + int len = pIdentifier.getIdentifierRaw().length(); + pIdentifier.setIdentifierRaw( pIdentifier.getIdentifierRaw().substring(0, len - 1) ); + } + } + + else { + Matcher matcher = PlaceholderManager.PLACEHOLDER_ESCAPE_CHARACTER_LEFT_PATTERN.matcher( pIdentifier.getIdentifierRaw() ); + + if ( matcher.find() ) { + + String group0 = matcher.group( 0 ); + + pIdentifier.setEscapeLeft( group0 ); + pIdentifier.setIdentifierRaw( pIdentifier.getIdentifierRaw().substring(1) ); + + Matcher matcherRight = PlaceholderManager.PLACEHOLDER_ESCAPE_CHARACTER_RIGHT_PATTERN.matcher( pIdentifier.getIdentifierRaw() ); + + if ( matcherRight.find() ) { + + String group0Right = matcherRight.group( 0 ); + + pIdentifier.setEscapeRight( group0Right ); + + int len = pIdentifier.getIdentifierRaw().length(); + pIdentifier.setIdentifierRaw( pIdentifier.getIdentifierRaw().substring(0, len - group0Right.length() ) ); + } + + } + + } + + } + + +} diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java index ad8d805d1..18e367561 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java @@ -1,7 +1,16 @@ package tech.mcprison.prison.placeholders; + +/** + *

This class is used to store the data of mapping an identifier to the correct + * PlaceHolderKey. + *

+ * + */ public class PlaceholderResults { + private String identifier; + private PlaceHolderKey placeholder; private String escapeLeft; private String esccapeRight; @@ -9,7 +18,7 @@ public class PlaceholderResults private String numericSequencePattern; private int numericSequence = -1; - private String identifier; + private String text; @@ -23,6 +32,8 @@ public PlaceholderResults( PlaceHolderKey placeholder, String text ) { super(); this.placeholder = placeholder; + + this.text = text; } @@ -32,8 +43,11 @@ public String toString() { if ( getPlaceholder() != null ) { sb.append( getPlaceholder().getPlaceholder().name() ) - .append( " " ).append( getEscapeLeft() ).append( getEsccapeRight() ) - .append( " " ).append( getIdentifier() == null ? "" : getIdentifier() ); + .append( " " ) + .append( getEscapeLeft() == null ? "" : getEscapeLeft() ) + .append( getEsccapeRight() == null ? "" : getEsccapeRight() ) + .append( " " ) + .append( getIdentifier() == null ? "" : getIdentifier() ); } else { 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 140d9de56..62916e6c1 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java +++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java @@ -448,6 +448,11 @@ public PlayerUtil getPlayerUtil( UUID playerUuid ) { return null; } + @Override + public PlayerUtil getPlayerUtil( Player player ) { + return null; + } + @Override public List dumpEventListenersList( String eventType, HandlerList handlerList ) { diff --git a/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceholderIdentifierTest.java b/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceholderIdentifierTest.java new file mode 100644 index 000000000..84e58997c --- /dev/null +++ b/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceholderIdentifierTest.java @@ -0,0 +1,198 @@ +package tech.mcprison.prison.placeholders; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import tech.mcprison.prison.Prison; +import tech.mcprison.prison.TestPlatform; + +public class PlaceholderIdentifierTest { + + public PlaceholderIdentifierTest() { + super(); + } + + /** + *

Test to confirm the PlaceholderIdentifier.getIdentifier() is correct. + *

+ */ + @Test + public void testPlaceholders() { + + PlaceholderIdentifier t1 = new PlaceholderIdentifier(null); + + assertNotNull( t1.getIdentifier() ); + assertEquals( "", t1.getIdentifier() ); + assertEquals( "", t1.getOriginalIdentifier() ); + + PlaceholderIdentifier t2 = new PlaceholderIdentifier( "" ); + + assertNotNull( t2.getIdentifier() ); + assertEquals( "", t2.getIdentifier() ); + assertEquals( "", t2.getOriginalIdentifier() ); + + PlaceholderIdentifier t3 = new PlaceholderIdentifier( "prison_simple" ); + + assertNotNull( t3.getIdentifier() ); + assertEquals( "prison_simple", t3.getIdentifier() ); + assertNull( t3.getEscapeLeft() ); + assertNull( t3.getEscapeRight() ); + assertEquals( "prison_simple", t3.getOriginalIdentifier() ); + + PlaceholderIdentifier t4 = new PlaceholderIdentifier( "simple" ); + + assertNotNull( t4.getIdentifier() ); + assertEquals( "prison_simple", t4.getIdentifier() ); + assertEquals( "simple", t4.getOriginalIdentifier() ); + + PlaceholderIdentifier t5 = new PlaceholderIdentifier( "{prison_simple}" ); + + assertNotNull( t5.getIdentifier() ); + assertEquals( "prison_simple", t5.getIdentifier() ); + assertEquals( "{", t5.getEscapeLeft() ); + assertEquals( "}", t5.getEscapeRight() ); + assertEquals( "{prison_simple}", t5.getOriginalIdentifier() ); + + PlaceholderIdentifier t6 = new PlaceholderIdentifier( "{simple}" ); + + assertNotNull( t6.getIdentifier() ); + assertEquals( "prison_simple", t6.getIdentifier() ); + assertEquals( "{", t6.getEscapeLeft() ); + assertEquals( "}", t6.getEscapeRight() ); + assertEquals( "{simple}", t6.getOriginalIdentifier() ); + + PlaceholderIdentifier t7 = new PlaceholderIdentifier( "%prison_simple%" ); + + assertNotNull( t7.getIdentifier() ); + assertEquals( "prison_simple", t7.getIdentifier() ); + assertEquals( "%", t7.getEscapeLeft() ); + assertEquals( "%", t7.getEscapeRight() ); + assertEquals( "%prison_simple%", t7.getOriginalIdentifier() ); + + // test to validate an invalid escape character will result in no mapping: + PlaceholderIdentifier t8 = new PlaceholderIdentifier( "#prison_simple#" ); + + assertNotNull( t8.getIdentifier() ); + assertEquals( "prison_simple", t8.getIdentifier() ); + assertNotNull( t8.getEscapeLeft() ); + assertNotNull( t8.getEscapeRight() ); + assertEquals( "#", t8.getEscapeLeft() ); + assertEquals( "#", t8.getEscapeRight() ); + assertEquals( "#prison_simple#", t8.getOriginalIdentifier() ); + + // It should be noted that "any" punction could be used, but is not a good idea. + // It should also be noted that the left and right escape characters do not have + // to match, but that is not prison's problem if the placeholder plugin sends + // prison an unmatched placeholder escape characters. + PlaceholderIdentifier t9 = new PlaceholderIdentifier( "]prison_simple^" ); + + assertNotNull( t9.getIdentifier() ); + assertEquals( "prison_simple", t9.getIdentifier() ); + assertNotNull( t9.getEscapeLeft() ); + assertNotNull( t9.getEscapeRight() ); + assertEquals( "]", t9.getEscapeLeft() ); + assertEquals( "^", t9.getEscapeRight() ); + assertEquals( "]prison_simple^", t9.getOriginalIdentifier() ); + + } + + + /** + *

This tests for the proper extraction of the placeholder attributes. + * The first three are duplicates from the prior unit test above, so only need + * to check for attributes. + *

+ */ + @Test + public void testPlaceholderAttributes() { + + // Setup the test Prison platform: + Prison.get().setupJUnitInstance( new TestPlatform( null, true) ); + + PlaceholderIdentifier t1 = new PlaceholderIdentifier(null); + assertEquals( 0, t1.getAttributes().size() ); + + PlaceholderIdentifier t2 = new PlaceholderIdentifier( "" ); + assertEquals( 0, t2.getAttributes().size() ); + + PlaceholderIdentifier t3 = new PlaceholderIdentifier( "prison_simple" ); + assertEquals( 0, t3.getAttributes().size() ); + + PlaceholderIdentifier t4 = new PlaceholderIdentifier( "prison_simple::nFormat" ); + assertEquals( 1, t4.getAttributes().size() ); + + + // failure because it's not a double colon: + PlaceholderIdentifier t5 = new PlaceholderIdentifier( "prison_simple:nFormat" ); + assertEquals( 0, t5.getAttributes().size() ); + + + // Test with 3 placeholder attributes + PlaceholderIdentifier t6 = new PlaceholderIdentifier( "prison_simple::nFormat::bar::text" ); + assertEquals( 3, t6.getAttributes().size() ); + + + // Test with 3 placeholder attributes between "junk" + PlaceholderIdentifier t7 = new PlaceholderIdentifier( "prison_simple::junk1::nFormat::junk2::bar::junk3::text:junk4" ); + assertEquals( 3, t7.getAttributes().size() ); + + + } + + /** + *

This tests for the proper extraction of the placeholder sequence. + * The first four are duplicates from the prior unit tests above, so only need + * to check for sequences not being found. + *

+ */ + @Test + public void testPlaceholderSequences() { + + + PlaceholderIdentifier t1 = new PlaceholderIdentifier(null); + assertFalse( t1.hasSequence() ); + assertEquals( -1, t1.getSequence() ); + + PlaceholderIdentifier t2 = new PlaceholderIdentifier( "" ); + assertFalse( t2.hasSequence() ); + assertEquals( -1, t2.getSequence() ); + + PlaceholderIdentifier t3 = new PlaceholderIdentifier( "prison_simple" ); + assertFalse( t3.hasSequence() ); + assertEquals( -1, t3.getSequence() ); + + PlaceholderIdentifier t4 = new PlaceholderIdentifier( "prison_simple::nFormat" ); + assertFalse( t4.hasSequence() ); + assertEquals( -1, t4.getSequence() ); + + + // NOTE: Sequences never are at the end of a placeholder so this is an invalid placeholder: + PlaceholderIdentifier t5 = new PlaceholderIdentifier( "prison_simple_001" ); + assertFalse( t5.hasSequence() ); + assertEquals( -1, t5.getSequence() ); + + + PlaceholderIdentifier t6 = new PlaceholderIdentifier( "prison_simple_001_test" ); + assertTrue( t6.hasSequence() ); + assertEquals( 1, t6.getSequence() ); + + PlaceholderIdentifier t7 = new PlaceholderIdentifier( "prison_simple_12345_test::nFormat::text" ); + assertTrue( t7.hasSequence() ); + assertEquals( 12345, t7.getSequence() ); + assertEquals( 2, t7.getAttributes().size() ); + + PlaceholderIdentifier t8 = new PlaceholderIdentifier( "prison_simple_3_test::nFormat:junk::text" ); + assertTrue( t8.hasSequence() ); + assertEquals( 3, t8.getSequence() ); + assertEquals( 2, t8.getAttributes().size() ); + + + } + + +} \ No newline at end of file diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java index 88fc48225..64153d350 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java @@ -42,12 +42,14 @@ import tech.mcprison.prison.placeholders.ManagerPlaceholders; import tech.mcprison.prison.placeholders.PlaceHolderKey; import tech.mcprison.prison.placeholders.PlaceholderAttribute; +import tech.mcprison.prison.placeholders.PlaceholderAttributeBar; import tech.mcprison.prison.placeholders.PlaceholderAttributeNumberFormat; import tech.mcprison.prison.placeholders.PlaceholderAttributeText; +import tech.mcprison.prison.placeholders.PlaceholderIdentifier; import tech.mcprison.prison.placeholders.PlaceholderManager; import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags; import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; -import tech.mcprison.prison.placeholders.PlaceholderResults; +import tech.mcprison.prison.placeholders.PlaceholderManagerUtils; import tech.mcprison.prison.placeholders.PlaceholdersUtil; import tech.mcprison.prison.store.Collection; import tech.mcprison.prison.store.Document; @@ -741,76 +743,108 @@ public List getUnavailableWorldsListings() { return results; } - public String getTranslateMinesPlaceHolder( String identifier ) { - String results = null; - List placeHolderKeys = getTranslatedPlaceHolderKeys(); +// public String getTranslateMinesPlaceHolder( String identifier ) { +// String results = null; +// List placeHolderKeys = getTranslatedPlaceHolderKeys(); +// +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } +// +// // placeholder Attributes: +//// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +//// String placeholder = pman.extractPlaceholderString( identifier ); +// //PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// +// +// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { +// +// PlaceholderResults phResults = placeHolderKey.getIdentifier( identifier ); +// +// if ( phResults != null && phResults.hasResults() ) { +// +// //Mine mine = getMine( placeHolderKey.getData() ); +// +// results = getTranslateMinesPlaceHolder( placeHolderKey, +// phResults.getIdentifier(), phResults.getNumericSequence() ); +// break; +// } +// } +// +// return results; +// } + + +// public String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, String identifier, int sequence ) { +// String results = null; +// +// if ( placeHolderKey != null && identifier != null ) { +// +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } +// +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// //String placeholder = pman.extractPlaceholderString( identifier ); +// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// +// +// Mine mine = getMine( placeHolderKey.getData() ); +// +// results = getTranslateMinesPlaceHolder( placeHolderKey, mine, attribute, sequence ); +// } +// +// return results; +// } +// +// public String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, +// int sequence ) { +// Mine mine = getMine( placeHolderKey.getData() ); +// return getTranslateMinesPlaceHolder( placeHolderKey, mine, attribute, sequence ); +// } +// +// private String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, Mine mine, +// PlaceholderAttribute attribute, int sequence ) { +// Player player = null; +// return getTranslateMinesPlaceHolder( player, placeHolderKey, mine, attribute, sequence ); +// +// } + + + + + public String getTranslateMinesPlaceholder( PlaceholderIdentifier identifier ) { - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); + + Player player = identifier.getPlayer(); + + PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); - // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// String placeholder = pman.extractPlaceholderString( identifier ); - //PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - - for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { - - PlaceholderResults phResults = placeHolderKey.getIdentifier( identifier ); - - if ( phResults != null && phResults.hasResults() ) { - - //Mine mine = getMine( placeHolderKey.getData() ); + Mine mine = null; + if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) ) { + + mine = getMine( placeHolderKey.getData() ); + } + else { + + if ( player != null && player.getLocation() != null ) { - results = getTranslateMinesPlaceHolder( placeHolderKey, - phResults.getIdentifier(), phResults.getNumericSequence() ); - break; + mine = PrisonMines.getInstance().findMineLocation( player ); } } - return results; - } - - - public String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, String identifier, int sequence ) { - String results = null; - - if ( placeHolderKey != null && identifier != null ) { - - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } - - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); - //String placeholder = pman.extractPlaceholderString( identifier ); - PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - - - Mine mine = getMine( placeHolderKey.getData() ); - - results = getTranslateMinesPlaceHolder( placeHolderKey, mine, attribute, sequence ); - } - return results; - } - - public String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, - int sequence ) { - Mine mine = getMine( placeHolderKey.getData() ); - return getTranslateMinesPlaceHolder( placeHolderKey, mine, attribute, sequence ); - } - - private String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, Mine mine, - PlaceholderAttribute attribute, int sequence ) { - Player player = null; - return getTranslateMinesPlaceHolder( player, placeHolderKey, mine, attribute, sequence ); + PlaceholderAttributeBar attributeBar = identifier.getAttributeBar(); + PlaceholderAttributeNumberFormat attributeNFormat = identifier.getAttributeNFormat(); + PlaceholderAttributeText attributeText = identifier.getAttributeText(); + + int sequence = identifier.getSequence(); - } - - private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey placeHolderKey, Mine mine, - PlaceholderAttribute attribute, int sequence ) { String results = null; @@ -826,6 +860,8 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place DecimalFormat iFmt = new DecimalFormat("#,##0"); // DecimalFormat fFmt = new DecimalFormat("#,##0.00"); + identifier.setFoundAMatch( true ); + switch ( placeHolderKey.getPlaceholder() ) { case prison_mn_minename: case prison_mines_name_minename: @@ -847,10 +883,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place case prison_mi_pm: case prison_mines_interval_playermines: { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) mine.getResetTime() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) mine.getResetTime() ); } else { @@ -866,10 +901,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place case prison_mines_interval_formatted_playermines: { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) mine.getResetTime() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) mine.getResetTime() ); } else { @@ -887,10 +921,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place if ( !mine.isVirtual() ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) mine.getRemainingTimeSec() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) mine.getRemainingTimeSec() ); } else { results = dFmt.format( mine.getRemainingTimeSec() ); @@ -904,7 +937,7 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place case prison_mines_timeleft_bar_playermines: // NOTE: timeleft can vary based upon server loads: if ( !mine.isVirtual() ) { - results = getRemainingTimeBar( mine, attribute ); + results = getRemainingTimeBar( mine, attributeBar ); } break; @@ -917,10 +950,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place if ( !mine.isVirtual() ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) mine.getRemainingTimeSec() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) mine.getRemainingTimeSec() ); } else { double timeMtlf = mine.getRemainingTimeSec(); @@ -936,10 +968,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place if ( !mine.isVirtual() ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) mine.getBounds().getTotalBlockCount() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) mine.getBounds().getTotalBlockCount() ); } else { @@ -958,10 +989,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place int remainingBlocks = mine.getRemainingBlockCount(); { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) remainingBlocks ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) remainingBlocks ); } else { @@ -982,9 +1012,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place int totalBlocks = mine.getBounds().getTotalBlockCount(); int blocksRemaining = mine.getRemainingBlockCount(); - results = Prison.get().getPlaceholderManager(). + results = PlaceholderManagerUtils.getInstance(). getProgressBar( ((double) blocksRemaining), ((double) totalBlocks), - false, attribute ); + false, attributeBar ); } break; @@ -1007,10 +1037,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place case prison_mines_player_count_playermines: if ( !mine.isVirtual() ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) mine.getPlayerCount() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) mine.getPlayerCount() ); } else { @@ -1025,10 +1054,11 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place case prison_mines_blocks_mined_playermines: if ( !mine.isVirtual() ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( mine.getTotalBlocksMined() ); +// getBlockBreakCount(); + + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( mine.getTotalBlocksMined() ); } else { @@ -1043,10 +1073,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place case prison_mrc_pm: case prison_mines_reset_count_playermines: { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) mine.getResetCount() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) mine.getResetCount() ); } else { @@ -1153,10 +1182,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place PrisonBlock block = blocks.get( sequence - 1 ); if ( block != null ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) block.getChance() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) block.getChance() ); } else { @@ -1176,10 +1204,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place PrisonBlock block = blocks.get( sequence - 1 ); if ( block != null ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) block.getBlockPlacedCount() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) block.getBlockPlacedCount() ); } else { @@ -1199,10 +1226,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place PrisonBlock block = blocks.get( sequence - 1 ); if ( block != null ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) block.getBlockPlacedCount() - block.getBlockCountUnsaved() ); } else { @@ -1226,9 +1252,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place int placed = block.getBlockPlacedCount(); long removed = block.getBlockCountUnsaved(); - results = Prison.get().getPlaceholderManager(). + results = PlaceholderManagerUtils.getInstance(). getProgressBar( ((double) removed), ((double) placed), - false, attribute ); + false, attributeBar ); } } } @@ -1243,10 +1269,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place PrisonBlock block = blocks.get( sequence - 1 ); if ( block != null ) { - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( (long) block.getBlockCountTotal() ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( (long) block.getBlockCountTotal() ); } else { @@ -1264,10 +1289,8 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place // { // long blocksTotal = PlayerCache.getInstance().getPlayerBlocksTotal( player ); // -// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { -// PlaceholderAttributeNumberFormat attributeNF = -// (PlaceholderAttributeNumberFormat) attribute; -// results = attributeNF.format( blocksTotal ); +// if ( attributeNFormat != null ) { +// results = attributeNFormat.format( blocksTotal ); // } // else { // @@ -1290,10 +1313,9 @@ private String getTranslateMinesPlaceHolder( Player player, PlaceHolderKey place placeHolderKey.getPlaceholder() == PrisonPlaceHolders.prison_player_blocks_total_raw_minename ) { results = Long.toString( blocksTotalByMine ); } - else if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( blocksTotalByMine ); + else if ( attributeNFormat != null ) { + + results = attributeNFormat.format( blocksTotalByMine ); } else { @@ -1317,10 +1339,9 @@ else if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFo placeHolderKey.getPlaceholder() == PrisonPlaceHolders.prison_player_total_blocks_raw__blockname ) { results = Long.toString( blockCount ); } - else if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( blockCount ); + else if ( attributeNFormat != null ) { + + results = attributeNFormat.format( blockCount ); } else { @@ -1331,11 +1352,18 @@ else if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFo break; default: + identifier.setFoundAMatch( false ); + + Output.get().logInfo( + "MineManager translateMinesPlaceholder: Warning: a placeholder '%s' was selected " + + "to be processed in this manager, but the placeholder is not included in the swich. " + + "Please report to support team.", + identifier.getPlaceholderKey().getPlaceholder().name() ); + break; } - if ( results != null && attribute != null && attribute instanceof PlaceholderAttributeText ) { - PlaceholderAttributeText attributeText = (PlaceholderAttributeText) attribute; + if ( results != null && attributeText != null ) { results = attributeText.format( results ); } @@ -1343,6 +1371,13 @@ else if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFo } + // If results is null, but a PLAYERMINES then must return an empty string: + if ( results == null && placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) ) { + results = ""; + } + + identifier.setText(results); + return results; } @@ -1390,29 +1425,41 @@ public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String player List placeHolderKeys = getTranslatedPlaceHolderKeys(); - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } + + PlaceholderIdentifier phIdentifier = new PlaceholderIdentifier( identifier ); + phIdentifier.setPlayer(playerUuid, playerName); + - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); - String placeholder = pman.extractPlaceholderString( identifier ); - PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// String placeholder = pman.extractPlaceholderString( identifier ); +// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { - if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { - - // Use this ONLY to get the numeric sequence!!! We already have the correct placeholder. - PlaceholderResults phResults = placeHolderKey.getIdentifier( placeholder ); + + if ( phIdentifier.checkPlaceholderKey(placeHolderKey) ) { + + results = getTranslateMinesPlaceholder( phIdentifier ); - results = getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, - placeHolderKey, attribute, - phResults.getNumericSequence()); break; } +// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { +// +// // Use this ONLY to get the numeric sequence!!! We already have the correct placeholder. +// PlaceholderResults phResults = placeHolderKey.getIdentifier( placeholder ); +// +// results = getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, +// placeHolderKey, attribute, +// phResults.getNumericSequence()); +// break; +// } + // if ( phResults != null && phResults.hasResults() ) { @@ -1437,147 +1484,149 @@ public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String player } - /** - * - * @param playerUuid - * @param playerName - * @param placeHolderKey - * @param identifier - * @param position - * @return - */ - public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String playerName, - PlaceHolderKey placeHolderKey, String identifier, int position ) { - String results = null; - - identifier = identifier.toLowerCase(); - - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } - - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); - //String placeholder = pman.extractPlaceholderString( identifier ); - PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - - - results = getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, placeHolderKey, - attribute, position ); - - if ( results == null ) { - results = ""; - } - - return results; - } +// /** +// * +// * @param playerUuid +// * @param playerName +// * @param placeHolderKey +// * @param identifier +// * @param position +// * @return +// */ +// public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String playerName, +// PlaceHolderKey placeHolderKey, String identifier, int position ) { +// String results = null; +// +// identifier = identifier.toLowerCase(); +// +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } +// +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// //String placeholder = pman.extractPlaceholderString( identifier ); +// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// +// +// results = getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, placeHolderKey, +// attribute, position ); +// +// if ( results == null ) { +// results = ""; +// } +// +// return results; +// } - /** - * We must have a player to process these placeholders. - * - * @param playerUuid - * @param playerName - * @param placeHolderKey - * @return - */ - public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String playerName, - PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, int position ) { - String results = null; - - // there is no data stored for PLAYERMINES: -// String data = placeHolderKey.getData(); - - Player player = null; - Mine mine = null; - - if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) ) { - - mine = getMine( placeHolderKey.getData() ); - } - else { - - player = getPlayer(playerUuid, playerName); - - if ( player != null && player.getLocation() != null ) { - - mine = PrisonMines.getInstance().findMineLocation( player ); - } - } - -// Output.get().logInfo( "### ### MineManager.getTranslated... : 1 in mine? %s player: %s %s %s", -// (mine == null ? "-- NO --" : "-- YES == " + mine.getName()), -// (player == null ? "(null)" : player.getName()), placeHolderKey.getPlaceholder().name(), -// player.getLocation().toBlockCoordinates() ); - - results = getTranslateMinesPlaceHolder( player, placeHolderKey, mine, - attribute, position ); - - // If results is null, but a PLAYERMINES then must return an empty string: - if ( results == null && placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) ) { - results = ""; - } - - return results; - } +// /** +// * We must have a player to process these placeholders. +// * +// * @param playerUuid +// * @param playerName +// * @param placeHolderKey +// * @return +// */ +// public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String playerName, +// PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, int position ) { +// String results = null; +// +// // there is no data stored for PLAYERMINES: +//// String data = placeHolderKey.getData(); +// +// Player player = null; +// Mine mine = null; +// +// if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) ) { +// +// mine = getMine( placeHolderKey.getData() ); +// } +// else { +// +// player = getPlayer(playerUuid, playerName); +// +// if ( player != null && player.getLocation() != null ) { +// +// mine = PrisonMines.getInstance().findMineLocation( player ); +// } +// } +// +//// Output.get().logInfo( "### ### MineManager.getTranslated... : 1 in mine? %s player: %s %s %s", +//// (mine == null ? "-- NO --" : "-- YES == " + mine.getName()), +//// (player == null ? "(null)" : player.getName()), placeHolderKey.getPlaceholder().name(), +//// player.getLocation().toBlockCoordinates() ); +// +// results = getTranslateMinesPlaceHolder( player, placeHolderKey, mine, +// attribute, position ); +// +// // If results is null, but a PLAYERMINES then must return an empty string: +// if ( results == null && placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) ) { +// results = ""; +// } +// +// return results; +// } - /** - * Get the Player based first on UUID, then on name. - * - * @param playerUuid - * @param playerName - * @return - */ - private Player getPlayer( UUID playerUuid, String playerName ) { - Player player = null; - Player playerAlt = null; - - if ( playerUuid != null ) { - - // First try to match on UUID - for ( Player p : Prison.get().getPlatform().getOnlinePlayers() ) { - if ( p.getUUID().compareTo( playerUuid ) == 0 ) { - player = p; - break; - } - else if ( p.getName().equalsIgnoreCase( playerName ) ) { - // If we get a hit on the name, save it as an alt... - playerAlt = p; - } - } - } - - if ( player == null ) { - for ( Player p : Prison.get().getPlatform().getOfflinePlayers() ) { - if ( playerUuid != null && p.getUUID() != null && - p.getUUID().compareTo( playerUuid ) == 0 ) { - player = p; - break; - } - else if ( p.getName().equalsIgnoreCase( playerName ) ) { - // If we get a hit on the name, save it as an alt... - playerAlt = p; - } - } - - } - - // if player is null, and we have a playerAlt, then use it: - if ( player == null && playerAlt != null ) { - player = playerAlt; - } - return player; - } +// /** +// * Get the Player based first on UUID, then on name. +// * +// * @param playerUuid +// * @param playerName +// * @return +// */ +// private Player getPlayer( UUID playerUuid, String playerName ) { +// Player player = null; +// Player playerAlt = null; +// +// if ( playerUuid != null ) { +// +// // First try to match on UUID +// for ( Player p : Prison.get().getPlatform().getOnlinePlayers() ) { +// if ( p.getUUID().compareTo( playerUuid ) == 0 ) { +// player = p; +// break; +// } +// else if ( p.getName().equalsIgnoreCase( playerName ) ) { +// // If we get a hit on the name, save it as an alt... +// playerAlt = p; +// } +// } +// } +// +// if ( player == null ) { +// for ( Player p : Prison.get().getPlatform().getOfflinePlayers() ) { +// if ( playerUuid != null && p.getUUID() != null && +// p.getUUID().compareTo( playerUuid ) == 0 ) { +// player = p; +// break; +// } +// else if ( p.getName().equalsIgnoreCase( playerName ) ) { +// // If we get a hit on the name, save it as an alt... +// playerAlt = p; +// } +// } +// +// } +// +// // if player is null, and we have a playerAlt, then use it: +// if ( player == null && playerAlt != null ) { +// player = playerAlt; +// } +// return player; +// } private String getRemainingTimeBar( Mine mine, PlaceholderAttribute attribute ) { + PlaceholderAttributeBar attributeBar = ( attribute instanceof PlaceholderAttributeBar ? (PlaceholderAttributeBar) attribute : null ); + double timeRemaining = mine.getRemainingTimeSec(); int time = mine.getResetTime(); - return Prison.get().getPlaceholderManager(). - getProgressBar( timeRemaining, ((double) time), true, attribute ); + return PlaceholderManagerUtils.getInstance(). + getProgressBar( timeRemaining, ((double) time), true, attributeBar ); } @@ -1759,4 +1808,6 @@ public void reloadPlaceholders() { } + + } diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index 584fcd702..69e75ef48 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -38,13 +38,14 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.placeholders.ManagerPlaceholders; import tech.mcprison.prison.placeholders.PlaceHolderKey; -import tech.mcprison.prison.placeholders.PlaceholderAttribute; +import tech.mcprison.prison.placeholders.PlaceholderAttributeBar; import tech.mcprison.prison.placeholders.PlaceholderAttributeNumberFormat; import tech.mcprison.prison.placeholders.PlaceholderAttributeText; +import tech.mcprison.prison.placeholders.PlaceholderIdentifier; import tech.mcprison.prison.placeholders.PlaceholderManager; import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags; import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; -import tech.mcprison.prison.placeholders.PlaceholderResults; +import tech.mcprison.prison.placeholders.PlaceholderManagerUtils; import tech.mcprison.prison.placeholders.PlaceholdersUtil; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.data.PlayerRank; @@ -447,7 +448,7 @@ public String getPlayerRankName( RankPlayer rankPlayer, String ladderName ) { public String getPlayerRankNumber( RankPlayer rankPlayer, String ladderName, - PlaceholderAttribute attribute ) { + PlaceholderAttributeNumberFormat attributeNFormat ) { StringBuilder sb = new StringBuilder(); if ( !rankPlayer.getLadderRanks().isEmpty()) { @@ -461,10 +462,9 @@ public String getPlayerRankNumber( RankPlayer rankPlayer, String ladderName, int rankNumber = rankNumber(entry.getValue().getRank()); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - sb.append( attributeNF.format( (long) rankNumber ) ); + if ( attributeNFormat != null ) { + + sb.append( attributeNFormat.format( (long) rankNumber ) ); } else { sb.append( Integer.toString( rankNumber ) ); @@ -569,7 +569,7 @@ public List getPlayerNextRanks( RankPlayer rankPlayer ) { } public String getPlayerNextRankCost( RankPlayer rankPlayer, String ladderName, - boolean formatted, PlaceholderAttribute attribute ) { + boolean formatted, PlaceholderAttributeNumberFormat attributeNFormat ) { StringBuilder sb = new StringBuilder(); if ( !rankPlayer.getLadderRanks().isEmpty()) { @@ -605,10 +605,9 @@ public String getPlayerNextRankCost( RankPlayer rankPlayer, String ladderName, double cost = nextPRank.getRankCost(); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - sb.append( attributeNF.format( cost ) ); + if ( attributeNFormat != null ) { + + sb.append( attributeNFormat.format( cost ) ); } else if ( formatted ) { sb.append( PlaceholdersUtil.formattedMetricSISize( cost )); @@ -724,7 +723,7 @@ public String getPlayerNextRankCostPercent( RankPlayer rankPlayer, String ladder } public String getPlayerNextRankCostBar( RankPlayer rankPlayer, String ladderName, - PlaceholderAttribute attribute ) { + PlaceholderAttributeBar attributeBar ) { StringBuilder sb = new StringBuilder(); // Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); @@ -780,8 +779,8 @@ public String getPlayerNextRankCostBar( RankPlayer rankPlayer, String ladderName // double balance = getPlayerBalance(prisonPlayer,nextRank); - sb.append( Prison.get().getPlaceholderManager(). - getProgressBar( balance, cost, false, attribute )); + sb.append( PlaceholderManagerUtils.getInstance(). + getProgressBar( balance, cost, false, attributeBar )); } } @@ -805,7 +804,7 @@ public String getPlayerNextRankCostBar( RankPlayer rankPlayer, String ladderName * @return */ public String getPlayerNextRankCostRemaining( RankPlayer rankPlayer, String ladderName, - boolean formatted, PlaceholderAttribute attribute ) { + boolean formatted, PlaceholderAttributeNumberFormat attributeNFormat ) { StringBuilder sb = new StringBuilder(); // Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); @@ -869,10 +868,8 @@ public String getPlayerNextRankCostRemaining( RankPlayer rankPlayer, String ladd remaining = 0; } - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - sb.append( attributeNF.format( remaining ) ); + if ( attributeNFormat != null ) { + sb.append( attributeNFormat.format( remaining ) ); } else if ( formatted ) { @@ -968,7 +965,7 @@ public String getPlayerNextRankCostRemainingPercent( RankPlayer rankPlayer, Stri } public String getPlayerNextRankCostRemainingBar( RankPlayer rankPlayer, String ladderName, - PlaceholderAttribute attribute ) { + PlaceholderAttributeBar attributeBar ) { StringBuilder sb = new StringBuilder(); // Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); @@ -1037,8 +1034,8 @@ public String getPlayerNextRankCostRemainingBar( RankPlayer rankPlayer, String l // ); // sb.append( dFmt.format( percent )); - sb.append( Prison.get().getPlaceholderManager(). - getProgressBar( remaining, cost, false, attribute )); + sb.append( PlaceholderManagerUtils.getInstance(). + getProgressBar( remaining, cost, false, attributeBar )); } } @@ -1063,7 +1060,7 @@ public String getPlayerNextRankCostRemainingBar( RankPlayer rankPlayer, String l * @return */ private String getPlayerBalance( RankPlayer rankPlayer, String ladderName, - boolean formatted, PlaceholderAttribute attribute ) { + boolean formatted, PlaceholderAttributeNumberFormat attributeNFormat ) { StringBuilder sb = new StringBuilder(); // Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); @@ -1101,10 +1098,9 @@ private String getPlayerBalance( RankPlayer rankPlayer, String ladderName, double balance = rankPlayer.getBalance( rank.getCurrency() ); // double balance = getPlayerBalance(prisonPlayer,rank); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - sb.append( attributeNF.format( balance ) ); + if ( attributeNFormat != null ) { + + sb.append( attributeNFormat.format( balance ) ); } else if ( formatted ) { @@ -1121,7 +1117,7 @@ else if ( formatted ) { return sb.toString(); } private String getPlayerAverageEarningsPerMinute( RankPlayer rankPlayer, String ladderName, - boolean formatted, PlaceholderAttribute attribute ) { + boolean formatted, PlaceholderAttributeNumberFormat attributeNFormat ) { StringBuilder sb = new StringBuilder(); @@ -1130,10 +1126,9 @@ private String getPlayerAverageEarningsPerMinute( RankPlayer rankPlayer, String double epm = PlayerCache.getInstance().getPlayerEarningsPerMinute( rankPlayer ); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - sb.append( attributeNF.format( epm ) ); + if ( attributeNFormat != null ) { + + sb.append( attributeNFormat.format( epm ) ); } else if ( formatted ) { @@ -1150,17 +1145,16 @@ else if ( formatted ) { private String getPlayerTokenBalance( RankPlayer rankPlayer, - int formatMode, PlaceholderAttribute attribute ) { + int formatMode, PlaceholderAttributeNumberFormat attributeNFormat ) { StringBuilder sb = new StringBuilder(); DecimalFormat dFmt = new DecimalFormat("#,##0"); long tokens = rankPlayer.getPlayerCachePlayerData().getTokens(); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - sb.append( attributeNF.format( tokens ) ); + if ( attributeNFormat != null ) { + + sb.append( attributeNFormat.format( tokens ) ); } else { @@ -1198,7 +1192,7 @@ private String getPlayerTokenBalance( RankPlayer rankPlayer, private String getPlayerTokenAverageEarningsPerMinute( RankPlayer rankPlayer, - boolean formatted, PlaceholderAttribute attribute ) { + boolean formatted, PlaceholderAttributeNumberFormat attributeNFormat ) { StringBuilder sb = new StringBuilder(); @@ -1208,10 +1202,9 @@ private String getPlayerTokenAverageEarningsPerMinute( RankPlayer rankPlayer, double tpm = rankPlayer.getPlayerCachePlayerData().getAverageTokensPerMinute(); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - sb.append( attributeNF.format( tpm ) ); + if ( attributeNFormat != null ) { + + sb.append( attributeNFormat.format( tpm ) ); } else if ( formatted ) { @@ -1383,13 +1376,12 @@ public String getPlayerNextRankTag( RankPlayer rankPlayer, String ladderName ) { } - private String getPlayerSellallMultiplier( RankPlayer rankPlayer, PlaceholderAttribute attribute ) { + private String getPlayerSellallMultiplier( RankPlayer rankPlayer, PlaceholderAttributeNumberFormat attributeNFormat ) { String results; double multiplier = rankPlayer.getSellAllMultiplier(); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( multiplier ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( multiplier ); } else { results = Double.toString( multiplier ); @@ -1398,95 +1390,128 @@ private String getPlayerSellallMultiplier( RankPlayer rankPlayer, PlaceholderAtt } - /** - *

Entry point for translating placeholders. - *

- * @param playerUuid - * @param playerName - * @param identifier - * @return - */ - public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, String identifier ) { - String results = null; +// /** +// *

Entry point for translating placeholders. +// *

+// * @param playerUuid +// * @param playerName +// * @param identifier +// * @return +// */ +// public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, String identifier ) { +// String results = null; +// +// if ( playerUuid != null && identifier != null ) { +// +// List placeHolderKeys = getTranslatedPlaceHolderKeys(); +// +// identifier = identifier.toLowerCase(); +// +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } +// +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// String placeholder = pman.extractPlaceholderString( identifier ); +// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// +// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { +// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { +// results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, attribute ); +// break; +// } +// } +// } +// +// return results; +// } + +// public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, PlaceholderResults placeholderResults ) { +// String results = null; +// +// if ( playerUuid != null && placeholderResults.hasResults() ) { +// +// List placeHolderKeys = getTranslatedPlaceHolderKeys(); +// +// String identifier = placeholderResults.getIdentifier(); +// +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } +// +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// String placeholder = pman.extractPlaceholderString( identifier ); +// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// +// if ( placeholderResults.getPlaceholder() != null ) { +// results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeholderResults.getPlaceholder(), attribute ); +// } +// else { +// // Need to hunt for the placeholder: +// +// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { +// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { +// results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, attribute ); +// break; +// } +// } +// } +// +// } +// +// return results; +// } + + + +// public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, +// PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute ) { +// String results = null; + + public String getTranslatePlayerPlaceHolder( PlaceholderIdentifier identifier ) { + + + Player player = identifier.getPlayer(); + + PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); + RankPlayer rankPlayer = pm.getPlayer( player ); + + PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); + + + // From RankManager which does not apply here: +// String rankName = placeHolderKey.getData(); +// Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); - if ( playerUuid != null && identifier != null ) { - - List placeHolderKeys = getTranslatedPlaceHolderKeys(); - - identifier = identifier.toLowerCase(); - - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } - - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); - String placeholder = pman.extractPlaceholderString( identifier ); - PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - - for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { - if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { - results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, attribute ); - break; - } - } - } - return results; - } - public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, PlaceholderResults placeholderResults ) { - String results = null; - if ( playerUuid != null && placeholderResults.hasResults() ) { - - List placeHolderKeys = getTranslatedPlaceHolderKeys(); - - String identifier = placeholderResults.getIdentifier(); - - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } - - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); - String placeholder = pman.extractPlaceholderString( identifier ); - PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - - if ( placeholderResults.getPlaceholder() != null ) { - results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeholderResults.getPlaceholder(), attribute ); - } - else { - // Need to hunt for the placeholder: - - for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { - if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { - results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, attribute ); - break; - } - } - } - - } + PlaceholderAttributeBar attributeBar = identifier.getAttributeBar(); + PlaceholderAttributeNumberFormat attributeNFormat = identifier.getAttributeNFormat(); + PlaceholderAttributeText attributeText = identifier.getAttributeText(); + + int sequence = identifier.getSequence(); - return results; - } - - - - public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, - PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute ) { + String results = null; + PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); + + - if ( playerUuid != null ) { + if ( rankPlayer != null ) { +// if ( playerUuid != null ) { - PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); +// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); String ladderName = placeHolderKey.getData(); - RankPlayer rankPlayer = getPlayer(playerUuid, playerName); +// RankPlayer rankPlayer = getPlayer(playerUuid, playerName); if ( rankPlayer != null ) { + identifier.setFoundAMatch( true ); + switch ( placeHolder ) { case prison_r: case prison_rank: @@ -1499,7 +1524,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_rank_number: case prison_rn_laddername: case prison_rank_number_laddername: - results = getPlayerRankNumber( rankPlayer, ladderName, attribute ); + results = getPlayerRankNumber( rankPlayer, ladderName, attributeNFormat ); break; case prison_rt: @@ -1529,14 +1554,14 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_rankup_cost: case prison_rc_laddername: case prison_rankup_cost_laddername: - results = getPlayerNextRankCost( rankPlayer, ladderName, false, attribute ); + results = getPlayerNextRankCost( rankPlayer, ladderName, false, attributeNFormat ); break; case prison_rcf: case prison_rankup_cost_formatted: case prison_rcf_laddername: case prison_rankup_cost_formatted_laddername: - results = getPlayerNextRankCost( rankPlayer, ladderName, true, attribute ); + results = getPlayerNextRankCost( rankPlayer, ladderName, true, attributeNFormat ); break; case prison_rcp: @@ -1550,7 +1575,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_rankup_cost_bar: case prison_rcb_laddername: case prison_rankup_cost_bar_laddername: - results = getPlayerNextRankCostBar( rankPlayer, ladderName, attribute ); + results = getPlayerNextRankCostBar( rankPlayer, ladderName, attributeBar ); break; @@ -1558,14 +1583,14 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_rankup_cost_remaining: case prison_rcr_laddername: case prison_rankup_cost_remaining_laddername: - results = getPlayerNextRankCostRemaining( rankPlayer, ladderName, false, attribute ); + results = getPlayerNextRankCostRemaining( rankPlayer, ladderName, false, attributeNFormat ); break; case prison_rcrf: case prison_rankup_cost_remaining_formatted: case prison_rcrf_laddername: case prison_rankup_cost_remaining_formatted_laddername: - results = getPlayerNextRankCostRemaining( rankPlayer, ladderName, true, attribute ); + results = getPlayerNextRankCostRemaining( rankPlayer, ladderName, true, attributeNFormat ); break; case prison_rcrp: @@ -1579,7 +1604,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_rankup_cost_remaining_bar: case prison_rcrb_laddername: case prison_rankup_cost_remaining_bar_laddername: - results = getPlayerNextRankCostRemainingBar( rankPlayer, ladderName, attribute ); + results = getPlayerNextRankCostRemainingBar( rankPlayer, ladderName, attributeBar ); break; @@ -1601,60 +1626,60 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_balance: case prison_pb_laddername: case prison_player_balance_laddername: - results = getPlayerBalance( rankPlayer, ladderName, false, attribute ); + results = getPlayerBalance( rankPlayer, ladderName, false, attributeNFormat ); break; case prison_pbf: case prison_player_balance_formatted: case prison_pbf_laddername: case prison_player_balance_formatted_laddername: - results = getPlayerBalance( rankPlayer, ladderName, true, attribute ); + results = getPlayerBalance( rankPlayer, ladderName, true, attributeNFormat ); break; case prison_pb_epm: case prison_player_balance_earnings_per_minute: - results = getPlayerAverageEarningsPerMinute( rankPlayer, ladderName, false, attribute ); + results = getPlayerAverageEarningsPerMinute( rankPlayer, ladderName, false, attributeNFormat ); break; case prison_pb_epmf: case prison_player_balance_earnings_per_minute_formatted: - results = getPlayerAverageEarningsPerMinute( rankPlayer, ladderName, true, attribute ); + results = getPlayerAverageEarningsPerMinute( rankPlayer, ladderName, true, attributeNFormat ); break; case prison_ptb: case prison_player_token_balance: - results = getPlayerTokenBalance( rankPlayer, 0, attribute ); + results = getPlayerTokenBalance( rankPlayer, 0, attributeNFormat ); break; case prison_ptbf: case prison_player_token_balance_formatted: - results = getPlayerTokenBalance( rankPlayer, 1, attribute ); + results = getPlayerTokenBalance( rankPlayer, 1, attributeNFormat ); break; case prison_ptbfm: case prison_player_token_balance_formatted_metric: - results = getPlayerTokenBalance( rankPlayer, 2, attribute ); + results = getPlayerTokenBalance( rankPlayer, 2, attributeNFormat ); break; case prison_ptbfk: case prison_player_token_balance_formatted_kmbt: - results = getPlayerTokenBalance( rankPlayer, 3, attribute ); + results = getPlayerTokenBalance( rankPlayer, 3, attributeNFormat ); break; case prison_ptb_epm: case prison_player_token_balance_earnings_per_minute: - results = getPlayerTokenAverageEarningsPerMinute( rankPlayer, false, attribute ); + results = getPlayerTokenAverageEarningsPerMinute( rankPlayer, false, attributeNFormat ); break; case prison_ptb_epmf: case prison_player_token_balance_earnings_per_minute_formatted: - results = getPlayerTokenAverageEarningsPerMinute( rankPlayer, true, attribute ); + results = getPlayerTokenAverageEarningsPerMinute( rankPlayer, true, attributeNFormat ); break; @@ -1662,7 +1687,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_psm: case prison_player_sellall_multiplier: - results = getPlayerSellallMultiplier( rankPlayer, attribute ); + results = getPlayerSellallMultiplier( rankPlayer, attributeNFormat ); break; @@ -1672,10 +1697,9 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_blocks_total_formatted: long blocksTotal = PlayerCache.getInstance().getPlayerBlocksTotal( rankPlayer ); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( blocksTotal ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( blocksTotal ); } else { if ( placeHolder == PrisonPlaceHolders.prison_pbtf || @@ -1698,7 +1722,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_ptid: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = pUtil.getItemInHandDisplayID(); } break; @@ -1707,7 +1731,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_ptn: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = pUtil.getItemInHandDisplayName(); } break; @@ -1715,7 +1739,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_material_type: case prison_ptmt: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = pUtil.getItemInHandItemMaterial(); } break; @@ -1723,7 +1747,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_type: case prison_ptt: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = pUtil.getItemInHandItemType(); } break; @@ -1739,7 +1763,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_lore: case prison_ptlore: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = pUtil.getItemInHandLore(); } break; @@ -1748,7 +1772,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_durability_used: case prison_ptdu: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandDurabilityUsed() ); } break; @@ -1756,7 +1780,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_durability_max: case prison_ptdm: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandDurabilityMax() ); } break; @@ -1764,34 +1788,34 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_durability_remaining: case prison_ptdr: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandDurabilityRemaining() ); } break; case prison_player_tool_durability_percent: case prison_ptdp: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Double.toString( pUtil.getItemInHandDurabilityPercent() ); } break; case prison_player_tool_durability_bar: case prison_ptdb: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); int max = pUtil.getItemInHandDurabilityMax(); int used = pUtil.getItemInHandDurabilityUsed(); - results = Prison.get().getPlaceholderManager(). - getProgressBar( used, max, false, attribute ); + results = PlaceholderManagerUtils.getInstance(). + getProgressBar( used, max, false, attributeBar ); } break; case prison_player_tool_enchantment_fortune: case prison_ptef: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandEnchantmentFortune() ); } break; @@ -1799,7 +1823,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_enchantment_efficency: case prison_ptee: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandEnchantmentEfficency() ); } break; @@ -1807,7 +1831,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_enchantment_silktouch: case prison_ptes: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandEnchantmentSilkTouch() ); } break; @@ -1815,7 +1839,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_enchantment_unbreaking: case prison_pteu: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandEnchantmentUnbreaking() ); } break; @@ -1823,7 +1847,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_enchantment_luck: case prison_ptel: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandEnchantmentLuck() ); } break; @@ -1831,7 +1855,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_tool_enchantment_mending: case prison_ptem: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getItemInHandEnchantmentMending() ); } break; @@ -1839,7 +1863,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_health: case prison_ph: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Double.toString( pUtil.getHealth() ); } break; @@ -1847,7 +1871,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_health_max: case prison_phm: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Double.toString( pUtil.getMaxHealth() ); } break; @@ -1855,7 +1879,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_air_max: case prison_pam: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getMaximumAir() ); } break; @@ -1863,7 +1887,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_air_remaining: case prison_par: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getRemainingAir() ); } break; @@ -1871,7 +1895,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_food_level: case prison_pfl: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getFoodLevel() ); } break; @@ -1879,7 +1903,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_food_exhaustion: case prison_pfe: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Double.toString( pUtil.getFoodExhaustion() ); } break; @@ -1887,7 +1911,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_food_saturation: case prison_pfs: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Double.toString( pUtil.getFoodSaturation() ); } break; @@ -1895,7 +1919,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_level: case prison_pl: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Integer.toString( pUtil.getLevel() ); } break; @@ -1903,7 +1927,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_walk_speed: case prison_pws: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Double.toString( pUtil.getWalkSpeed() ); } break; @@ -1911,7 +1935,7 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_xp: case prison_pxp: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Double.toString( pUtil.getExp() ); } break; @@ -1919,23 +1943,26 @@ public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, case prison_player_xp_to_level: case prison_pxptl: { - PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( playerUuid ); + PlayerUtil pUtil = Prison.get().getPlatform().getPlayerUtil( player ); results = Double.toString( pUtil.getExpToLevel() ); } break; default: + identifier.setFoundAMatch( false ); + break; } - if ( attribute != null && attribute instanceof PlaceholderAttributeText ) { - PlaceholderAttributeText attributeText = (PlaceholderAttributeText) attribute; + if ( attributeText != null && results != null ) { results = attributeText.format( results ); } } } + + identifier.setText(results); 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 bf9c667ae..866599eb6 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 @@ -23,24 +23,24 @@ import java.util.List; import java.util.Optional; import java.util.TreeMap; -import java.util.UUID; -import tech.mcprison.prison.Prison; import tech.mcprison.prison.PrisonAPI; import tech.mcprison.prison.integration.EconomyCurrencyIntegration; import tech.mcprison.prison.internal.CommandSender; +import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.localization.Localizable; import tech.mcprison.prison.modules.ModuleElement; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.placeholders.ManagerPlaceholders; import tech.mcprison.prison.placeholders.PlaceHolderKey; -import tech.mcprison.prison.placeholders.PlaceholderAttribute; +import tech.mcprison.prison.placeholders.PlaceholderAttributeBar; import tech.mcprison.prison.placeholders.PlaceholderAttributeNumberFormat; import tech.mcprison.prison.placeholders.PlaceholderAttributeText; +import tech.mcprison.prison.placeholders.PlaceholderIdentifier; import tech.mcprison.prison.placeholders.PlaceholderManager; -import tech.mcprison.prison.placeholders.PlaceholderResults; import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags; import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; +import tech.mcprison.prison.placeholders.PlaceholderManagerUtils; import tech.mcprison.prison.placeholders.PlaceholdersUtil; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.commands.CommandCommands; @@ -673,16 +673,14 @@ private void rankByLadderOutput( CommandSender sender, String ranksByLadder ) { } - private String getRankCost( Rank rank, PlaceholderAttribute attribute, boolean formatted ) + private String getRankCost( Rank rank, PlaceholderAttributeNumberFormat attributeNFormat, boolean formatted ) { double cost = rank.getRawRankCost(); String resultsx = null; DecimalFormat dFmt = new DecimalFormat("#,##0"); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - resultsx = attributeNF.format( cost ); + if ( attributeNFormat != null ) { + resultsx = attributeNFormat.format( cost ); } else if ( formatted ) { resultsx = PlaceholdersUtil.formattedMetricSISize( cost ); @@ -693,343 +691,225 @@ else if ( formatted ) { return resultsx; } - public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, String identifier ) { - String results = null; - - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); - String placeholder = pman.extractPlaceholderString( identifier ); - - List placeHolderKeys = getTranslatedPlaceHolderKeys(); - - PlaceHolderKey placeholderKey = null; - for ( PlaceHolderKey phk : placeHolderKeys ) { - - if ( phk.getKey().equalsIgnoreCase( placeholder )) { - placeholderKey = phk; - break; - } - } - - if ( placeholderKey != null ) { - - PlaceholderResults placeholderResults = placeholderKey.getIdentifier(identifier); - - results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeholderResults ); - } - - return results; - } +// public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, String identifier ) { +// String results = null; +// +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// String placeholder = pman.extractPlaceholderString( identifier ); +// +// List placeHolderKeys = getTranslatedPlaceHolderKeys(); +// +// PlaceHolderKey placeholderKey = null; +// for ( PlaceHolderKey phk : placeHolderKeys ) { +// +// if ( phk.getKey().equalsIgnoreCase( placeholder )) { +// placeholderKey = phk; +// break; +// } +// } +// +// if ( placeholderKey != null ) { +// +// PlaceholderResults placeholderResults = placeholderKey.getIdentifier(identifier); +// +// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeholderResults ); +// } +// +// return results; +// } - public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, - PlaceholderResults placeholderResults ) { - String results = null; - - if ( playerUuid != null && placeholderResults != null ) { - -// List placeHolderKeys = getTranslatedPlaceHolderKeys(); - - String identifier = placeholderResults.getIdentifier().toLowerCase(); - - - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } - - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// String placeholder = pman.extractPlaceholderString( identifier ); - PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - - PlaceHolderKey placeHolderKey = placeholderResults.getPlaceholder(); - - results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, - placeHolderKey, attribute, placeholderResults ); - -// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { +// public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, +// PlaceholderResults placeholderResults ) { +// String results = null; +// +// if ( playerUuid != null && placeholderResults != null ) { +// +//// List placeHolderKeys = getTranslatedPlaceHolderKeys(); +// +// String identifier = placeholderResults.getIdentifier().toLowerCase(); +// +// +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } +// +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +//// String placeholder = pman.extractPlaceholderString( identifier ); +// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// +// PlaceHolderKey placeHolderKey = placeholderResults.getPlaceholder(); +// +// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, +// placeHolderKey, attribute, placeholderResults ); +// +//// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { +//// +//// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { +//// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, +//// placeHolderKey, attribute, placeholderResults ); +//// break; +//// } +//// } +// } +// +// return results; +// } + +// public String getTranslateRanksPlaceHolder( String identifier ) { +// String results = null; +// List placeHolderKeys = getTranslatedPlaceHolderKeys(); +// +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } +// +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// String placeholder = pman.extractPlaceholderString( identifier ); +// //PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// +// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { +// +//// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); +// +// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { +// +// //Mine mine = getMine( placeHolderKey.getData() ); +// +// results = getTranslateRanksPlaceHolder( placeHolderKey, identifier, 0 ); +// break; +// } +// } +// +// return results; +// } + +// public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, +// String identifier, int numericSequence ) { +// String results = null; +// +// if ( identifier == null ) { +// identifier = placeHolderKey.getKey(); +// } +// +// if ( placeHolderKey != null && identifier != null ) { +// +// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } +// +// // placeholder Attributes: +// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// //String placeholder = pman.extractPlaceholderString( identifier ); +// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); +// +// +// if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { +// +// UUID playerUuid = null; +// String playerName = null; +// +// PlaceholderResults placeholderResults = placeHolderKey.getIdentifier(identifier); +// +// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, +// placeHolderKey, attribute, placeholderResults ); // -// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { -// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, -// placeHolderKey, attribute, placeholderResults ); -// break; -// } // } - } - - return results; - } +// else +// { +// +// String rankName = placeHolderKey.getData(); +// Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); +// +// +// results = getTranslateRanksPlaceHolder( placeHolderKey, rank, attribute ); +// } +// +// +// } +// +// return results; +// } + - public String getTranslateRanksPlaceHolder( String identifier ) { - String results = null; - List placeHolderKeys = getTranslatedPlaceHolderKeys(); + +// public String getTranslateMinesPlaceholder( PlaceholderIdentifier identifier ) { +// +//// // placeholder Attributes: +//// PlaceholderManager pman = Prison.get().getPlaceholderManager(); +// +// Player player = identifier.getPlayer(); +// +// PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); +// +// +// Mine mine = null; +// if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) ) { +// +// mine = getMine( placeHolderKey.getData() ); +// } +// else { +// +// if ( player != null && player.getLocation() != null ) { +// +// mine = PrisonMines.getInstance().findMineLocation( player ); +// } +// } +// +// +// PlaceholderAttributeBar attributeBar = identifier.getAttributeBar(); +// PlaceholderAttributeNumberFormat attributeNFormat = identifier.getAttributeNFormat(); +// PlaceholderAttributeText attributeText = identifier.getAttributeText(); +// +// int sequence = identifier.getSequence(); +// +// +// String results = null; +// } +// +// public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, +// Rank rank, PlaceholderAttribute attribute ) { +// String results = null; +// +// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); + + public String getTranslateRanksPlaceHolder( PlaceholderIdentifier identifier ) { - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); - String placeholder = pman.extractPlaceholderString( identifier ); - //PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - - for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { - -// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); - - if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { - - //Mine mine = getMine( placeHolderKey.getData() ); - - results = getTranslateRanksPlaceHolder( placeHolderKey, identifier, 0 ); - break; - } - } + Player player = identifier.getPlayer(); - return results; - } - - public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, - String identifier, int numericSequence ) { - String results = null; + PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); + RankPlayer rankPlayer = pm.getPlayer( player ); - if ( identifier == null ) { - identifier = placeHolderKey.getKey(); - } - - if ( placeHolderKey != null && identifier != null ) { - - if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } - - // placeholder Attributes: - PlaceholderManager pman = Prison.get().getPlaceholderManager(); - //String placeholder = pman.extractPlaceholderString( identifier ); - PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); - - - if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { - - UUID playerUuid = null; - String playerName = null; - - PlaceholderResults placeholderResults = placeHolderKey.getIdentifier(identifier); - - results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, - placeHolderKey, attribute, placeholderResults ); - - } - else - { - - String rankName = placeHolderKey.getData(); - Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); - - - results = getTranslateRanksPlaceHolder( placeHolderKey, rank, attribute ); - } - - - } + PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); - return results; - } - - public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, - Rank rank, PlaceholderAttribute attribute ) { - String results = null; - - PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); - - DecimalFormat dFmt = new DecimalFormat("#,##0"); - - if ( rank != null ) { - - switch ( placeHolder ) { - - - case prison_rank__name_rankname: - case prison_r_n_rankname: - results = rank.getName(); - break; - - case prison_rank__tag_rankname: - case prison_r_t_rankname: - results = (rank.getTag() == null ? "" : rank.getTag()); - break; - - case prison_rank__ladder_rankname: - case prison_r_l_rankname: - results = rank.getLadder() == null ? "" : rank.getLadder().getName(); - break; - - case prison_rank__ladder_position_rankname: - case prison_r_lp_rankname: - results = Integer.toString( rank.getPosition() ); - break; - - case prison_rank__cost_rankname: - case prison_r_c_rankname: - results = getRankCost( rank, attribute, false ); - break; - - case prison_rank__cost_formatted_rankname: - case prison_r_cf_rankname: - results = getRankCost( rank, attribute, true ); - break; - - case prison_rank__cost_multiplier_rankname: - case prison_r_cm_rankname: - - RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); - PlayerRank pRank = rankPlayerFactory.createPlayerRank( rank ); - - results = Double.toString( pRank.getLadderBasedRankMultiplier() ); - break; - - - case prison_rank__currency_rankname: - case prison_r_cu_rankname: - results = rank.getCurrency() == null ? "default" : rank.getCurrency(); - break; - - case prison_rank__id_rankname: - case prison_r_id_rankname: - results = Integer.toString( rank.getId() ); - break; - - case prison_rank__player_count_rankname: - case prison_r_pc_rankname: - int playerCount = rank.getPlayers().size(); - -// List players = -// PrisonRanks.getInstance().getPlayerManager().getPlayers().stream() -// .filter(rPlayer -> rPlayer.getLadderRanks().values().contains(rank)) -// .collect(Collectors.toList()); - - results = Integer.toString( playerCount ); - break; - - case prison_rank__linked_mines_rankname: - case prison_r_lm_rankname: - StringBuilder sb = new StringBuilder(); - for ( ModuleElement mine : rank.getMines() ) { - if ( sb.length() > 0 ) { - sb.append( ", " ); - } - sb.append( mine.getName() ); - } - - results = sb.toString(); - break; - - - case prison_top_rank_balance_name_nnn_rankname: - case prison_trbn_nnn_rankname: - { - StatsRankPlayerBalanceData stats = rank.getStatsPlayerBlance().getTopStats( 1 ); - if ( stats != null ) { - - results = stats.getPlayer() == null ? "" : stats.getPlayer().getName(); - } - else { - results = ""; - } - } - - break; - - case prison_top_rank_balance_score_nnn_rankname: - case prison_trbs_nnn_rankname: - { - StatsRankPlayerBalanceData stats = rank.getStatsPlayerBlance().getTopStats( 1 ); - if ( stats != null ) { - - results = dFmt.format( stats.getScore()); - } - else { - results = ""; - } - } - - break; - - case prison_top_rank_balance_balance_nnn_rankname: - case prison_trbb_nnn_rankname: - { - StatsRankPlayerBalanceData stats = rank.getStatsPlayerBlance().getTopStats( 1 ); - if ( stats != null ) { - - results = stats.getPlayer() == null ? "" : - dFmt.format( stats.getPlayer().getBalance( rank.getCurrency()) ); - } - else { - results = ""; - } - } - - break; - + + String rankName = placeHolderKey.getData(); + Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); - default: - break; - } - - if ( attribute != null && attribute instanceof PlaceholderAttributeText ) { - PlaceholderAttributeText attributeText = (PlaceholderAttributeText) attribute; - - results = attributeText.format( results ); - } - } + + + PlaceholderAttributeBar attributeBar = identifier.getAttributeBar(); + PlaceholderAttributeNumberFormat attributeNFormat = identifier.getAttributeNFormat(); + PlaceholderAttributeText attributeText = identifier.getAttributeText(); - return results; - } - - -// public String getTranslateRanksPlaceHolderTopPlayer( PlaceHolderKey placeHolderKey, -// PlaceholderAttribute attribute, int numericSequence ) { -// String results = null; -// -// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); -// -//// DecimalFormat dFmt = new DecimalFormat("#,##0"); -// -// switch ( placeHolder ) { -// -// case prison_tpl1_nnn_tp: -// case prison_top_player_line1_nnn_tp: -// { -//// placeHolderKey.get -// lll -// -// } -// -// default: -// break; -// -// } -// -// return results; -// } - - public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerName, - PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, PlaceholderResults placeholderResults ) { - String results = null; + int sequence = identifier.getSequence(); + + String results = null; PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); - String rankName = placeHolderKey.getData(); - Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); - - - PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); - RankPlayer rankPlayer = pm.getPlayer(playerUuid, playerName); - DecimalFormat dFmt = new DecimalFormat("#,##0"); + if ( !placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) && rank != null && rankPlayer != null ) { + identifier.setFoundAMatch( true ); + switch ( placeHolder ) { case prison_rank__player_cost_rankname: @@ -1037,10 +917,9 @@ public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerN { double cost = calculateRankCost( rankPlayer, rank ); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( cost ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( cost ); } else { @@ -1054,10 +933,9 @@ public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerN { double cost = calculateRankCost( rankPlayer, rank ); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( cost ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( cost ); } else { @@ -1080,10 +958,9 @@ public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerN remaining = 0; } - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( remaining ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( remaining ); } else { @@ -1105,10 +982,9 @@ public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerN remaining = 0; } - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( remaining ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( remaining ); } else { @@ -1143,20 +1019,32 @@ public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerN double balance = rankPlayer.getBalance( rank.getCurrency() ); // double balance = pm.getPlayerBalance( rankPlayer, rank); - results = Prison.get().getPlaceholderManager(). - getProgressBar( balance, cost, false, attribute ); + results = PlaceholderManagerUtils.getInstance(). + getProgressBar( balance, cost, false, attributeBar ); } break; default: + + identifier.setFoundAMatch( false ); + + Output.get().logInfo( + "RankManager TranslateRanksPlaceHolder: Warning: a placeholder '%s' (%s) was selected " + + "to be processed in this manager, but the placeholder is not included in the swich. " + + "Please report to support team.", + identifier.getPlaceholderKey().getPlaceholder().name(), + PlaceholderFlags.STATSPLAYERS.name() ); + break; } } else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { + identifier.setFoundAMatch( true ); + switch ( placeHolder ) { case prison_top_player_line1_headers_nnn_tp: @@ -1169,11 +1057,11 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { case prison_tpl1_nnn_tp: case prison_top_player_line1_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { - results = topRankPlayer.printRankScoreLine1( placeholderResults.getNumericSequence() ); + results = topRankPlayer.printRankScoreLine1( sequence ); } else { results = ""; @@ -1191,11 +1079,11 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { case prison_top_player_line2_nnn_tp: case prison_tpl2_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { - results = topRankPlayer.printRankScoreLine2( placeholderResults.getNumericSequence() ); + results = topRankPlayer.printRankScoreLine2( sequence ); } else { results = ""; @@ -1206,7 +1094,7 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { case prison_top_player_name_nnn_tp: case prison_tpn_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { @@ -1221,7 +1109,7 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { case prison_top_player_rank_prestiges_nnn_tp: case prison_tprp_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { @@ -1236,7 +1124,7 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { case prison_top_player_rank_default_nnn_tp: case prison_tprd_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { @@ -1255,7 +1143,7 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { case prison_top_player_balance_raw_nnn_tp: case prison_tpbr_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { @@ -1265,10 +1153,8 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { bal = 0; } - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( bal ); + if ( attributeNFormat != null ) { + results = attributeNFormat.format( bal ); } else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_formatted_nnn_tp || placeHolder == PrisonPlaceHolders.prison_tpbf_nnn_tp ) { @@ -1296,16 +1182,15 @@ else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_raw_nnn_tp case prison_top_player_rank_score_nnn_tp: case prison_tprs_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { double rankScore = topRankPlayer.getRankScore(); - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( rankScore ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( rankScore ); } else { results = dFmt.format(rankScore); @@ -1321,14 +1206,14 @@ else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_raw_nnn_tp case prison_top_player_rank_score_bar_nnn_tp: case prison_tprsb_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { double rankScore = topRankPlayer.getRankScore(); - results = Prison.get().getPlaceholderManager(). - getProgressBar( rankScore, 100.0d, false, attribute ); + results = PlaceholderManagerUtils.getInstance(). + getProgressBar( rankScore, 100.0d, false, attributeBar ); } else { results = ""; @@ -1343,7 +1228,7 @@ else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_raw_nnn_tp case prison_top_player_penalty_raw_nnn_tp: case prison_tppr_nnn_tp: { - RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); + RankPlayer topRankPlayer = getTopNRankPlayer( sequence ); if ( topRankPlayer != null ) { @@ -1353,10 +1238,9 @@ else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_raw_nnn_tp rsPenalty = 0; } - if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { - PlaceholderAttributeNumberFormat attributeNF = - (PlaceholderAttributeNumberFormat) attribute; - results = attributeNF.format( rsPenalty ); + if ( attributeNFormat != null ) { + + results = attributeNFormat.format( rsPenalty ); } else if ( placeHolder == PrisonPlaceHolders.prison_top_player_penalty_formatted_nnn_tp || placeHolder == PrisonPlaceHolders.prison_tppf_nnn_tp ) { @@ -1383,35 +1267,621 @@ else if ( placeHolder == PrisonPlaceHolders.prison_top_player_penalty_raw_nnn_tp default: + + identifier.setFoundAMatch( false ); + break; } - if ( attribute != null && attribute instanceof PlaceholderAttributeText ) { - PlaceholderAttributeText attributeText = (PlaceholderAttributeText) attribute; + if ( attributeText != null ) { results = attributeText.format( results ); + + Output.get().logInfo( + "RankManager TranslateRanksPlaceHolder: Warning: a placeholder '%s' (%s) was selected " + + "to be processed in this manager, but the placeholder is not included in the swich. " + + "Please report to support team.", + identifier.getPlaceholderKey().getPlaceholder().name(), + PlaceholderFlags.STATSPLAYERS.name() ); + } + } + + else if ( rank != null ) { + + identifier.setFoundAMatch( true ); + + switch ( placeHolder ) { + + + case prison_rank__name_rankname: + case prison_r_n_rankname: + results = rank.getName(); + break; + + case prison_rank__tag_rankname: + case prison_r_t_rankname: + results = (rank.getTag() == null ? "" : rank.getTag()); + break; + + case prison_rank__ladder_rankname: + case prison_r_l_rankname: + results = rank.getLadder() == null ? "" : rank.getLadder().getName(); + break; + + case prison_rank__ladder_position_rankname: + case prison_r_lp_rankname: + results = Integer.toString( rank.getPosition() ); + break; + + case prison_rank__cost_rankname: + case prison_r_c_rankname: + results = getRankCost( rank, attributeNFormat, false ); + break; + + case prison_rank__cost_formatted_rankname: + case prison_r_cf_rankname: + results = getRankCost( rank, attributeNFormat, true ); + break; + + case prison_rank__cost_multiplier_rankname: + case prison_r_cm_rankname: + + RankPlayerFactory rankPlayerFactory = new RankPlayerFactory(); + PlayerRank pRank = rankPlayerFactory.createPlayerRank( rank ); + + results = Double.toString( pRank.getLadderBasedRankMultiplier() ); + break; + + + case prison_rank__currency_rankname: + case prison_r_cu_rankname: + results = rank.getCurrency() == null ? "default" : rank.getCurrency(); + break; + + case prison_rank__id_rankname: + case prison_r_id_rankname: + results = Integer.toString( rank.getId() ); + break; + + case prison_rank__player_count_rankname: + case prison_r_pc_rankname: + int playerCount = rank.getPlayers().size(); + +// List players = +// PrisonRanks.getInstance().getPlayerManager().getPlayers().stream() +// .filter(rPlayer -> rPlayer.getLadderRanks().values().contains(rank)) +// .collect(Collectors.toList()); + + results = Integer.toString( playerCount ); + break; + + case prison_rank__linked_mines_rankname: + case prison_r_lm_rankname: + StringBuilder sb = new StringBuilder(); + for ( ModuleElement mine : rank.getMines() ) { + if ( sb.length() > 0 ) { + sb.append( ", " ); + } + sb.append( mine.getName() ); + } + + results = sb.toString(); + break; + + + case prison_top_rank_balance_name_nnn_rankname: + case prison_trbn_nnn_rankname: + { + StatsRankPlayerBalanceData stats = rank.getStatsPlayerBlance().getTopStats( 1 ); + if ( stats != null ) { + + results = stats.getPlayer() == null ? "" : stats.getPlayer().getName(); + } + else { + results = ""; + } + } + + break; + + case prison_top_rank_balance_score_nnn_rankname: + case prison_trbs_nnn_rankname: + { + StatsRankPlayerBalanceData stats = rank.getStatsPlayerBlance().getTopStats( 1 ); + if ( stats != null ) { + + results = dFmt.format( stats.getScore()); + } + else { + results = ""; + } + } + + break; + + case prison_top_rank_balance_balance_nnn_rankname: + case prison_trbb_nnn_rankname: + { + StatsRankPlayerBalanceData stats = rank.getStatsPlayerBlance().getTopStats( 1 ); + if ( stats != null ) { + + results = stats.getPlayer() == null ? "" : + dFmt.format( stats.getPlayer().getBalance( rank.getCurrency()) ); + } + else { + results = ""; + } + } + + break; + + + default: + + identifier.setFoundAMatch( false ); + + Output.get().logInfo( + "RankManager TranslateRanksPlaceHolder: Warning: a placeholder '%s' was selected " + + "to be processed in this manager, but the placeholder is not included in the swich. " + + "Please report to support team.", + identifier.getPlaceholderKey().getPlaceholder().name() ); + + + break; } + + } + + if ( attributeText != null && results != null ) { + + results = attributeText.format( results ); } + identifier.setText(results); + return results; } + + +// public String getTranslateRanksPlaceHolderTopPlayer( PlaceHolderKey placeHolderKey, +// PlaceholderAttribute attribute, int numericSequence ) { +// String results = null; +// +// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); +// +//// DecimalFormat dFmt = new DecimalFormat("#,##0"); +// +// switch ( placeHolder ) { +// +// case prison_tpl1_nnn_tp: +// case prison_top_player_line1_nnn_tp: +// { +//// placeHolderKey.get +// lll +// +// } +// +// default: +// break; +// +// } +// +// return results; +// } + +// public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerName, +// PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, PlaceholderResults placeholderResults ) { +// String results = null; +// +// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); +// +// String rankName = placeHolderKey.getData(); +// Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); +// +// +// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); +// RankPlayer rankPlayer = pm.getPlayer(playerUuid, playerName); +// +// DecimalFormat dFmt = new DecimalFormat("#,##0"); +// +// if ( !placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) && +// rank != null && rankPlayer != null ) { +// +// switch ( placeHolder ) { +// +// case prison_rank__player_cost_rankname: +// case prison_r_pcst_rankname: +// { +// double cost = calculateRankCost( rankPlayer, rank ); +// +// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { +// PlaceholderAttributeNumberFormat attributeNF = +// (PlaceholderAttributeNumberFormat) attribute; +// results = attributeNF.format( cost ); +// } +// else { +// +// results = dFmt.format( cost ); +// } +// } +// break; +// +// case prison_rank__player_cost_formatted_rankname: +// case prison_r_pcf_rankname: +// { +// double cost = calculateRankCost( rankPlayer, rank ); +// +// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { +// PlaceholderAttributeNumberFormat attributeNF = +// (PlaceholderAttributeNumberFormat) attribute; +// results = attributeNF.format( cost ); +// } +// else { +// +// results = PlaceholdersUtil.formattedMetricSISize( cost ); +// } +// } +// break; +// +// +// case prison_rank__player_cost_remaining_rankname: +// case prison_r_pcr_rankname: +// { +// double cost = calculateRankCost( rankPlayer, rank ); +// double balance = rankPlayer.getBalance( rank.getCurrency() ); +//// double balance = pm.getPlayerBalance( rankPlayer, rank); +// +// double remaining = cost - balance; +// +// if ( remaining < 0 ) { +// remaining = 0; +// } +// +// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { +// PlaceholderAttributeNumberFormat attributeNF = +// (PlaceholderAttributeNumberFormat) attribute; +// results = attributeNF.format( remaining ); +// } +// else { +// +// results = dFmt.format( remaining ); +// } +// } +// break; +// +// case prison_rank__player_cost_remaining_formatted_rankname: +// case prison_r_pcrf_rankname: +// { +// double cost = calculateRankCost( rankPlayer, rank ); +// double balance = rankPlayer.getBalance( rank.getCurrency() ); +//// double balance = pm.getPlayerBalance( rankPlayer, rank); +// +// double remaining = cost - balance; +// +// if ( remaining < 0 ) { +// remaining = 0; +// } +// +// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { +// PlaceholderAttributeNumberFormat attributeNF = +// (PlaceholderAttributeNumberFormat) attribute; +// results = attributeNF.format( remaining ); +// } +// else { +// +// results = PlaceholdersUtil.formattedMetricSISize( remaining ); +// } +// +// } +// break; +// +// +// +// +// case prison_rank__player_cost_percent_rankname: +// case prison_r_pcp_rankname: +// { +// double cost = calculateRankCost( rankPlayer, rank ); +// double balance = rankPlayer.getBalance( rank.getCurrency() ); +//// double balance = pm.getPlayerBalance( rankPlayer, rank); +// +// double percent = (balance < 0 ? 0 : +// (cost == 0.0d || balance > cost ? 100.0 : +// balance / cost * 100.0 ) +// ); +// results = dFmt.format( percent ); +// } +// break; +// +// case prison_rank__player_cost_bar_rankname: +// case prison_r_pcb_rankname: +// { +// double cost = calculateRankCost( rankPlayer, rank ); +// double balance = rankPlayer.getBalance( rank.getCurrency() ); +//// double balance = pm.getPlayerBalance( rankPlayer, rank); +// +// results = Prison.get().getPlaceholderManager(). +// getProgressBar( balance, cost, false, attribute ); +// } +// break; +// +// +// +// default: +// break; +// } +// } +// +// else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { +// +// switch ( placeHolder ) { +// +// case prison_top_player_line1_headers_nnn_tp: +// case prison_tpl1h_nnn_tp: +// { +// results = RankPlayer.printRankScoreLine1Header(); +// } +// break; +// +// case prison_tpl1_nnn_tp: +// case prison_top_player_line1_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// results = topRankPlayer.printRankScoreLine1( placeholderResults.getNumericSequence() ); +// } +// else { +// results = ""; +// } +// } +// break; +// +// case prison_top_player_line2_headers_nnn_tp: +// case prison_tpl2h_nnn_tp: +// { +// results = RankPlayer.printRankScoreLine2Header(); +// } +// break; +// +// case prison_top_player_line2_nnn_tp: +// case prison_tpl2_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// results = topRankPlayer.printRankScoreLine2( placeholderResults.getNumericSequence() ); +// } +// else { +// results = ""; +// } +// } +// break; +// +// case prison_top_player_name_nnn_tp: +// case prison_tpn_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// results = topRankPlayer.getName(); +// } +// else { +// results = ""; +// } +// } +// break; +// +// case prison_top_player_rank_prestiges_nnn_tp: +// case prison_tprp_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// results = topRankPlayer.getPlayerRankPrestiges().getRank().getTag(); +// } +// else { +// results = ""; +// } +// } +// break; +// +// case prison_top_player_rank_default_nnn_tp: +// case prison_tprd_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// results = topRankPlayer.getPlayerRankDefault().getRank().getTag(); +// } +// else { +// results = ""; +// } +// } +// break; +// +// case prison_top_player_balance_nnn_tp: +// case prison_tpb_nnn_tp: +// case prison_top_player_balance_formatted_nnn_tp: +// case prison_tpbf_nnn_tp: +// case prison_top_player_balance_raw_nnn_tp: +// case prison_tpbr_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// double bal = topRankPlayer.getBalance(); +// +// if ( bal < 0 ) { +// bal = 0; +// } +// +// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { +// PlaceholderAttributeNumberFormat attributeNF = +// (PlaceholderAttributeNumberFormat) attribute; +// results = attributeNF.format( bal ); +// } +// else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_formatted_nnn_tp || +// placeHolder == PrisonPlaceHolders.prison_tpbf_nnn_tp ) { +// +// results = PlaceholdersUtil.formattedMetricSISize( bal ); +// } +// else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_raw_nnn_tp || +// placeHolder == PrisonPlaceHolders.prison_tpbr_nnn_tp ) { +// +// results = Double.toString(bal); +// } +// else { +// results = dFmt.format(bal); +// } +// +// } +// else { +// results = ""; +// } +// } +// break; +// +// +// +// case prison_top_player_rank_score_nnn_tp: +// case prison_tprs_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// double rankScore = topRankPlayer.getRankScore(); +// +// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { +// PlaceholderAttributeNumberFormat attributeNF = +// (PlaceholderAttributeNumberFormat) attribute; +// results = attributeNF.format( rankScore ); +// } +// else { +// results = dFmt.format(rankScore); +// } +// } +// else { +// results = ""; +// } +// } +// break; +// +// +// case prison_top_player_rank_score_bar_nnn_tp: +// case prison_tprsb_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// double rankScore = topRankPlayer.getRankScore(); +// +// results = Prison.get().getPlaceholderManager(). +// getProgressBar( rankScore, 100.0d, false, attribute ); +// } +// else { +// results = ""; +// } +// } +// break; +// +// case prison_top_player_penalty_nnn_tp: +// case prison_tpp_nnn_tp: +// case prison_top_player_penalty_formatted_nnn_tp: +// case prison_tppf_nnn_tp: +// case prison_top_player_penalty_raw_nnn_tp: +// case prison_tppr_nnn_tp: +// { +// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); +// +// if ( topRankPlayer != null ) { +// +// double rsPenalty = topRankPlayer.getRankScorePenalty(); +// +// if ( rsPenalty < 0 ) { +// rsPenalty = 0; +// } +// +// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { +// PlaceholderAttributeNumberFormat attributeNF = +// (PlaceholderAttributeNumberFormat) attribute; +// results = attributeNF.format( rsPenalty ); +// } +// else if ( placeHolder == PrisonPlaceHolders.prison_top_player_penalty_formatted_nnn_tp || +// placeHolder == PrisonPlaceHolders.prison_tppf_nnn_tp ) { +// +// results = PlaceholdersUtil.formattedMetricSISize( rsPenalty ); +// } +// else if ( placeHolder == PrisonPlaceHolders.prison_top_player_penalty_raw_nnn_tp || +// placeHolder == PrisonPlaceHolders.prison_tppr_nnn_tp ) { +// +// results = Double.toString(rsPenalty); +// } +// else { +// results = dFmt.format(rsPenalty); +// } +// +// } +// else { +// results = ""; +// } +// } +// break; +// +// +// +// +// default: +// break; +// } +// +// if ( attributeText != null ) { +// +// results = attributeText.format( results ); +// } +// } +// +// identifier.setText(results); +// +// return results; +// } - private RankPlayer getTopNRankPlayer( PlaceholderResults placeholderResults ) { + private RankPlayer getTopNRankPlayer( int rankPosition ) { RankPlayer topRankPlayer = null; - if ( placeholderResults != null ) { + PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); + if ( rankPosition >= 0 && rankPosition < pm.getPlayersByTop().size() ) { - int rankPosition = placeholderResults.getNumericSequence(); - - PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); - if ( rankPosition >= 0 && rankPosition < pm.getPlayersByTop().size() ) { - - topRankPlayer = pm.getPlayersByTop().get(rankPosition); - } + topRankPlayer = pm.getPlayersByTop().get(rankPosition); } return topRankPlayer; } + +// private RankPlayer getTopNRankPlayer( PlaceholderResults placeholderResults ) { +// RankPlayer topRankPlayer = null; +// +// if ( placeholderResults != null ) { +// +// int rankPosition = placeholderResults.getNumericSequence(); +// +// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); +// if ( rankPosition >= 0 && rankPosition < pm.getPlayersByTop().size() ) { +// +// topRankPlayer = pm.getPlayersByTop().get(rankPosition); +// } +// } +// +// return topRankPlayer; +// } private double calculateRankCost( RankPlayer rankPlayer, Rank rank ) { 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 7c03f9c0d..31ff7da59 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 @@ -2423,6 +2423,11 @@ public PlayerUtil getPlayerUtil( UUID playerUuid ) { return new SpigotPlayerUtil( playerUuid ); } + @Override + public PlayerUtil getPlayerUtil( Player player ) { + return new SpigotPlayerUtil( player ); + } + @Override public String dumpEventListenersBlockBreakEvents() { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java index c7eb06425..5fb7637ad 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java @@ -7,6 +7,7 @@ import tech.mcprison.prison.Prison; import tech.mcprison.prison.internal.ItemStack; +import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.PlayerUtil; import tech.mcprison.prison.spigot.block.SpigotItemStack; import tech.mcprison.prison.spigot.compat.Compatibility; @@ -25,6 +26,13 @@ public SpigotPlayerUtil( UUID playerUuid ) { this.spigotPlayer = (SpigotPlayer) p; } } + public SpigotPlayerUtil( Player player ) { + super( player.getUUID() ); + + if ( player != null && player instanceof SpigotPlayer ) { + this.spigotPlayer = (SpigotPlayer) player; + } + } @Override public boolean isActive() { diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegration.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegration.java index 0f20ca184..e479e9630 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegration.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegration.java @@ -11,10 +11,11 @@ import tech.mcprison.prison.mines.managers.MineManager; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.placeholders.PlaceHolderKey; -import tech.mcprison.prison.placeholders.PlaceholderAttribute; +import tech.mcprison.prison.placeholders.PlaceholderIdentifier; import tech.mcprison.prison.placeholders.PlaceholderIntegration; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.managers.PlayerManager; +import tech.mcprison.prison.ranks.managers.RankManager; import tech.mcprison.prison.util.Text; /** @@ -88,18 +89,58 @@ public void deferredInitialization() { boolean registered = false; if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { + PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); if ( pm != null ) { List placeholderPlayerKeys = pm.getTranslatedPlaceHolderKeys(); for ( PlaceHolderKey placeHolderKey : placeholderPlayerKeys ) { if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { - registerPlaceholder(placeHolderKey.getKey(), - player -> Text.translateAmpColorCodes( - pm.getTranslatePlayerPlaceHolder( - player.getUUID(), player.getName(), - placeHolderKey, null ) - )); + + + registerPlaceholder(placeHolderKey.getKey(), + player -> { + + PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeHolderKey.getPlaceholder().name() ); + identifier.setPlayer( player.getUUID(), player.getName() ); + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + pm.getTranslatePlayerPlaceHolder( identifier ); + } + + + return Text.translateAmpColorCodes( identifier.getText() ); + }); + if ( !registered ) { + registered = true; + } + } + } + } + + RankManager rm = PrisonRanks.getInstance().getRankManager(); + if ( rm != null ) { + List placeholderPlayerKeys = rm.getTranslatedPlaceHolderKeys(); + + for ( PlaceHolderKey placeHolderKey : placeholderPlayerKeys ) { + if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { + + + registerPlaceholder(placeHolderKey.getKey(), + player -> { + + PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeHolderKey.getPlaceholder().name() ); + identifier.setPlayer( player.getUUID(), player.getName() ); + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + rm.getTranslateRanksPlaceHolder( identifier ); + } + + + return Text.translateAmpColorCodes( identifier.getText() ); + }); if ( !registered ) { registered = true; } @@ -116,11 +157,20 @@ public void deferredInitialization() for ( PlaceHolderKey placeHolderKey : placeholderMinesKeys ) { if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { + registerPlaceholder(placeHolderKey.getKey(), - player -> Text.translateAmpColorCodes( - mm.getTranslateMinesPlaceHolder( placeHolderKey, - (PlaceholderAttribute) null, -1 ) - )); + player -> { + + PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeHolderKey.getPlaceholder().name() ); + identifier.setPlayer( player.getUUID(), player.getName() ); + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + mm.getTranslateMinesPlaceholder( identifier ); + } + + return Text.translateAmpColorCodes( identifier.getText() ); + } ); if ( !registered ) { registered = true; } 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 906787895..fcc2375ef 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 @@ -14,14 +14,17 @@ import tech.mcprison.prison.output.Output; import tech.mcprison.prison.placeholders.PlaceHolderKey; import tech.mcprison.prison.placeholders.PlaceholderAttribute; +import tech.mcprison.prison.placeholders.PlaceholderIdentifier; import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags; import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; +import tech.mcprison.prison.placeholders.PlaceholderManagerUtils; import tech.mcprison.prison.placeholders.PlaceholderResults; import tech.mcprison.prison.placeholders.Placeholders; import tech.mcprison.prison.ranks.PrisonRanks; 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 { @@ -172,48 +175,57 @@ public int getPlaceholderRegistrationCount() { * */ @Override - public String placeholderTranslate(UUID playerUuid, String playerName, String identifier) { - String results = null; - - if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() && - playerUuid != null ) { - PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); - if ( pm != null ) { - results = pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, identifier ); - } - - RankManager rm = PrisonRanks.getInstance().getRankManager(); - if ( rm != null && results == null ) { - results = rm.getTranslateRanksPlaceHolder( identifier ); - - if ( results == null ) { - - results = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, identifier ); - } - } - } - - // If it did not match on a player placeholder, then try mines: - if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() && - results == null ) { - MineManager mm = PrisonMines.getInstance().getMineManager(); - if ( mm != null ) { - results = mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, identifier ); + public String placeholderTranslate( UUID playerUuid, String playerName, String text ) { + PlaceholderIdentifier identifier = new PlaceholderIdentifier( text ); + identifier.setPlayer(playerUuid, playerName); + + return placeholderTranslateText( identifier ); + + // String results = null; + - if ( results == null ) { - results = mm.getTranslateMinesPlaceHolder( identifier ); - } - } - - } - -// if ( results == null ) { -// Output.get().logInfo( "### ### SpigotPlaceholders.placeholderTranslate: " + -// "could not translate identifyer: %s playerUuid: %s playerName: %s", -// (identifier == null ? "(null)" : identifier), playerUuid, playerName ); +// if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() && +// playerUuid != null ) { +// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); +// if ( pm != null ) { +// text = pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, text ); +// } +// +// RankManager rm = PrisonRanks.getInstance().getRankManager(); +// if ( rm != null && text == null ) { +// text = rm.getTranslateRanksPlaceHolder( text ); +// +// if ( text == null ) { +// +// text = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, text ); +// } +// } // } - - return results; +// +// // If it did not match on a player placeholder, then try mines: +// if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() && +// text == null ) { +// MineManager mm = PrisonMines.getInstance().getMineManager(); +// if ( mm != null ) { +// +// mm.getTranslateMinesPlaceholder( identifier ); +// +//// text = mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, text ); +//// +//// if ( text == null ) { +//// text = mm.getTranslateMinesPlaceHolder( text ); +//// } +// } +// +// } +// +//// if ( results == null ) { +//// Output.get().logInfo( "### ### SpigotPlaceholders.placeholderTranslate: " + +//// "could not translate identifyer: %s playerUuid: %s playerName: %s", +//// (identifier == null ? "(null)" : identifier), playerUuid, playerName ); +//// } +// +// return identifier.getText(); } /** @@ -224,10 +236,17 @@ public String placeholderTranslate(UUID playerUuid, String playerName, String id */ @Override public String placeholderTranslateText( String text) { - String results = text; + PlaceholderIdentifier identifier = new PlaceholderIdentifier( text ); + + + return placeholderTranslateText( identifier ); + } + + public String placeholderTranslateText( PlaceholderIdentifier identifier ) { +// String results = text; - if ( results != null && PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { + if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { MineManager mm = PrisonMines.getInstance().getMineManager(); if ( mm != null ) { @@ -236,44 +255,72 @@ public String placeholderTranslateText( String text) { for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { - PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); + if ( identifier.checkPlaceholderKey( placeHolderKey ) ) { + mm.getTranslateMinesPlaceholder( identifier ); + break; + } - - if ( results != null && identifier != null && identifier.hasResults() ) { - - results = placeholderReplace( results, identifier.getEscapedIdentifier(), - mm.getTranslateMinesPlaceHolder( placeHolderKey, - identifier.getIdentifier(), identifier.getNumericSequence() ) ); - } +// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); +// +// +// if ( results != null && identifier != null && identifier.hasResults() ) { +// +// results = placeholderReplace( results, identifier.getEscapedIdentifier(), +// mm.getTranslateMinesPlaceHolder( placeHolderKey, +// identifier.getIdentifier(), identifier.getNumericSequence() ) ); +// } } } } - if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { + if ( !identifier.isFoundAMatch() && !identifier.isFoundAMatch() && + PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { + PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); + if ( pm != null ) { + + List placeholderKeys = pm.getTranslatedPlaceHolderKeys(); + + for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { + + if ( identifier.checkPlaceholderKey( placeHolderKey ) ) { + pm.getTranslatePlayerPlaceHolder( identifier ); + break; + } + + } + } + + RankManager rm = PrisonRanks.getInstance().getRankManager(); - if ( rm != null ) { + if ( !identifier.isFoundAMatch() && rm != null ) { List placeholderKeys = rm.getTranslatedPlaceHolderKeys(); for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { - PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); + if ( identifier.checkPlaceholderKey( placeHolderKey ) ) { + rm.getTranslateRanksPlaceHolder( identifier ); + break; + } - if ( results != null && identifier != null && identifier.hasResults() ) { - - results = placeholderReplace( results, identifier.getEscapedIdentifier(), - rm.getTranslateRanksPlaceHolder( placeHolderKey, identifier.getIdentifier(), - identifier.getNumericSequence()) ); - } +// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); +// +// if ( results != null && identifier != null && identifier.hasResults() ) { +// +// results = placeholderReplace( results, identifier.getEscapedIdentifier(), +// rm.getTranslateRanksPlaceHolder( placeHolderKey, identifier.getIdentifier(), +// identifier.getNumericSequence()) ); +// } } } } - return results; + + return identifier.getText(); } /** @@ -282,9 +329,11 @@ public String placeholderTranslateText( String text) { * String target = "FOOBar"; * target = target.replaceAll("(?i)foo", ""); * - * @param text - * @param placeholder - * @param target + * @param text The full text that contains one or more placeholders. This is also the value that + * will be returned, with the replacement of the contained placeholder. + * @param placeholder The individual placeholder that should be replaced. This should be the + * raw value of the identifier, including escape chaacters and placeholder attributes. + * @param target The text that should replace the whole placeholder. * @return */ private String placeholderReplace( String text, String placeholder, String target ) { @@ -309,83 +358,104 @@ private String placeholderReplace( String text, String placeholder, String targe */ @Override public String placeholderTranslateText( UUID playerUuid, String playerName, String text) { - String results = text; - // First the player specific placeholder, which must have a UUID: - if ( text != null && PrisonRanks.getInstance() != null && - PrisonRanks.getInstance().isEnabled() && playerUuid != null ) { - - PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); - List placeholderKeys = pm.getTranslatedPlaceHolderKeys(); - - for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { - - PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); - - if ( results != null && identifier != null && identifier.hasResults() ) { - - - results = placeholderReplace( results, identifier.getEscapedIdentifier(), - pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, identifier.getIdentifier() ) ); - } - } - - - RankManager rm = PrisonRanks.getInstance().getRankManager(); - placeholderKeys = rm.getTranslatedPlaceHolderKeys(); - - for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { - - PlaceholderResults pResults = placeHolderKey.getIdentifier( results ); - - if ( results != null && pResults != null && pResults.hasResults() ) { - - - results = placeholderReplace( results, pResults.getEscapedIdentifier(), - rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, pResults ) ); - } - } - } + PlaceholderIdentifier identifier = new PlaceholderIdentifier( text ); + identifier.setPlayer(playerUuid, playerName); + return placeholderTranslateText( identifier ); - // Check the mine's playerMines placeholders: - if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { - - MineManager mm = PrisonMines.getInstance().getMineManager(); - if ( mm != null ) { - - List placeholderKeys = mm.getTranslatedPlaceHolderKeys(); - - for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { - - PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); - - if ( identifier.hasResults() ) { - - results = placeholderReplace( results, identifier.getEscapedIdentifier(), - mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, - placeHolderKey, identifier.getIdentifier(), - identifier.getNumericSequence() ) ); - - } - - } - } - - } - - - // Then translate any remaining non-player (mine) related placeholders: - results = placeholderTranslateText( results); - - return results; +// String results = text; +// +// +// // First the player specific placeholder, which must have a UUID: +// if ( text != null && PrisonRanks.getInstance() != null && +// PrisonRanks.getInstance().isEnabled() && playerUuid != null ) { +// +// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); +// List placeholderKeys = pm.getTranslatedPlaceHolderKeys(); +// +// for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { +// +// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); +// +// if ( results != null && identifier != null && identifier.hasResults() ) { +// +// +// results = placeholderReplace( results, identifier.getEscapedIdentifier(), +// pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, identifier.getIdentifier() ) ); +// } +// } +// +// +// RankManager rm = PrisonRanks.getInstance().getRankManager(); +// placeholderKeys = rm.getTranslatedPlaceHolderKeys(); +// +// for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { +// +// PlaceholderResults pResults = placeHolderKey.getIdentifier( results ); +// +// if ( results != null && pResults != null && pResults.hasResults() ) { +// +// +// results = placeholderReplace( results, pResults.getEscapedIdentifier(), +// rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, pResults ) ); +// } +// } +// } +// +// +// +// // Check the mine's playerMines placeholders: +// if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { +// +// MineManager mm = PrisonMines.getInstance().getMineManager(); +// if ( mm != null ) { +// +// List placeholderKeys = mm.getTranslatedPlaceHolderKeys(); +// +// for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { +// +// if ( identifier.checkPlaceholderKey( placeHolderKey ) ) { +// mm.getTranslateMinesPlaceholder( identifier ); +// break; +// } +//// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); +//// +//// if ( identifier.hasResults() ) { +//// +//// results = placeholderReplace( results, identifier.getEscapedIdentifier(), +//// mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, +//// placeHolderKey, identifier.getIdentifier(), +//// identifier.getNumericSequence() ) ); +//// +//// } +// +// } +// } +// +// } +// +// +// // Then translate any remaining non-player (mine) related placeholders: +// results = placeholderTranslateText( results); +// +// return results; } + + /** + *

This is used with the command `/prison placeholders search` and the patterns may be any + * fragment of a placeholder, and any number of them.\ + *

+ * + */ @Override public List placeholderSearch( UUID playerUuid, String playerName, String[] patterns ) { List results = new ArrayList<>(); + + TreeMap placeholderKeys = new TreeMap<>(); @@ -415,6 +485,11 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin placeholderKeyContains(placeHolderKey, patterns) ) { String placeholder = "{" + placeHolderKey.getKey() + "}"; + PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeholder ); + identifier.setPlayer(playerUuid, playerName); + + + // String key1 = "{" + placeHolderKey.getKey(); // String key2 = "}"; // @@ -430,33 +505,45 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin // Note: STATSMINES will not work here since the sequence is not being addressed. if ( mm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ))) { - PlaceholderAttribute attribute = null; - value = mm.getTranslateMinesPlaceHolder( placeHolderKey, attribute, -1 ); - } - if ( mm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) )) { - PlaceholderAttribute attribute = null; - value = mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, placeHolderKey, - attribute, -1 ); + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + value = mm.getTranslateMinesPlaceholder(identifier); + } + +// PlaceholderAttribute attribute = null; +// value = mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, placeHolderKey, +// attribute, -1 ); } else if ( pm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ))) { - value = pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, null ); - } - else if ( rm != null && placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) ) { - value = rm.getTranslateRanksPlaceHolder( placeHolderKey, null, 0 ); + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + value = pm.getTranslatePlayerPlaceHolder( identifier ); + } + +// value = pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, null ); } - else if ( rm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || + else if ( rm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) ) { - String searchPatterns = String.join("_", patterns); - - PlaceholderResults pResults = placeHolderKey.getIdentifier( searchPatterns ); + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + value = rm.getTranslateRanksPlaceHolder( identifier ); + } - value = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeHolderKey, null, pResults ); +// String searchPatterns = String.join("_", patterns); +// +// PlaceholderResults pResults = placeHolderKey.getIdentifier( searchPatterns ); +// +// value = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeHolderKey, null, pResults ); } String placeholderAlias = ( placeHolderKey.getAliasName() == null ? null : @@ -523,7 +610,7 @@ public void reloadPlaceholders() { Prison.get().getPlatform().reloadConfig(); - Prison.get().getPlaceholderManager().reloadPlaceholderBarConfig(); + PlaceholderManagerUtils.getInstance().reloadPlaceholderBarConfig(); if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); From 5a301b0bddb2733615018aa4be44915ae1673372 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:12:35 -0400 Subject: [PATCH 276/297] Prison Placeholders: General clean up of obsolete code. Since the new placeholder system is working well with the new class PlaceholderIdentifier, obsolete code that was commented out has been removed. The obsolete class that used to be the key component to identifying placeholders was PlaceholderResults and is no longer used anywhere. It's core components were moved to PlaceholderIdentifier and therefore all references to this obsolete class has been eliminated. At this time, PlaceholderResults has not been deleted, but will be at some future time. --- docs/changelog_v3.3.x.md | 8 +- .../prison/placeholders/PlaceHolderKey.java | 365 +++++------ .../placeholders/PlaceholderResults.java | 5 + .../placeholders/PlaceHolderKeyTest.java | 143 ++-- .../prison/mines/managers/MineManager.java | 271 -------- .../prison/ranks/managers/PlayerManager.java | 166 +---- .../prison/ranks/managers/RankManager.java | 616 +----------------- ...eHolderAPIIntegrationUppercaseWrapper.java | 12 +- .../PlaceHolderAPIIntegrationWrapper.java | 11 - .../placeholder/SpigotPlaceholders.java | 203 +----- 10 files changed, 284 insertions(+), 1516 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 8bdb44de5..93a82e196 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,13 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11g 2022-06-13 +# 3.3.0-alpha.11g 2022-06-14 + + +* **Prison Placeholders: General clean up of obsolete code.** +Since the new placeholder system is working well with the new class PlaceholderIdentifier, obsolete code that was commented out has been removed. +The obsolete class that used to be the key component to identifying placeholders was PlaceholderResults and is no longer used anywhere. It's core components were moved to PlaceholderIdentifier and therefore all references to this obsolete class has been eliminated. +At this time, PlaceholderResults has not been deleted, but will be at some future time. * **Prison Placeholders: Major rewrite the handling of placeholders.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java index 08d311faf..8215c6e73 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceHolderKey.java @@ -1,8 +1,5 @@ package tech.mcprison.prison.placeholders; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; public class PlaceHolderKey { @@ -14,8 +11,8 @@ public class PlaceHolderKey { private String aliasName; - // NOTE: Pattern is thread safe so make it static. Matcher is not thead safe. - public static Pattern PLACEHOLDER_SEQUENCE_PATTERN = Pattern.compile( "(\\_([0-9]+)\\_)" ); +// // NOTE: Pattern is thread safe so make it static. Matcher is not thead safe. +// public static Pattern PLACEHOLDER_SEQUENCE_PATTERN = Pattern.compile( "(\\_([0-9]+)\\_)" ); public PlaceHolderKey( String key, PrisonPlaceHolders placeholder ) { @@ -35,203 +32,203 @@ public PlaceHolderKey( String key, PrisonPlaceHolders placeholder, String data, this.data = data; } - /** - *

This function will take a full text String and apply the placeholder that - * this PlaceHolderKey represents and tries to match it to the provided text. If it - * is found within the text, then this function will return the identifier, which is - * full text, including any placeholder attributes, but without the escape characters. - *

- * - * @param text - * @return - */ - public PlaceholderResults getIdentifier( String text ) { - PlaceholderResults results = new PlaceholderResults(this, text); - - - String textLowercase = text.toLowerCase(); - String key = getKey().toLowerCase(); - - - // For placeholders with sequence numbers, such as _nnn_, will need to search - // for 1 to 3 digits and replace the number in the "text" with _nnn_ and also - // need to store that numeric value in the PlaceholderResults object. - if ( getPlaceholder().hasSequence() ) { - - Matcher matcher = PLACEHOLDER_SEQUENCE_PATTERN.matcher( textLowercase ); - if ( matcher.find() ) { - - //String group0 = matcher.group( 0 ); - String group1 = matcher.group( 1 ); - String group2 = matcher.group( 2 ); - - textLowercase = textLowercase.replace( group1, "_nnn_" ); - -// Output.get().logInfo( "### PlaceHolderKey: seq pattern detected: " + placeholder.name() + -// " group0= " + group0 + " group1= " + group1 + " group2= " + group2 + " replacedText: " + textLowercase ); - - results.setNumericSequencePattern( group1 ); - - // a value of -1 indicates it was not able to be parsed: - int parsed = -1; - - try { - parsed = Integer.parseInt( group2 ); - } - catch ( NumberFormatException e ) { - // Not a number so ignore... but based upon matcher.find() it should be... Hmm... - } - - results.setNumericSequence( parsed ); - - - // DO something more: - - } - } - - - // If the text is an exact match to the key (no escape characters): - if ( textLowercase.equalsIgnoreCase( key ) ) { - - results.setIdentifier( textLowercase ); - results.setPlaceholder( this ); - - } - else { - - checkIdentifier( key, text, textLowercase, "{", "}", results ); - - if ( textLowercase.equalsIgnoreCase( key ) || - textLowercase.contains( key ) || - checkIdentifier( key, text, textLowercase, "{", "}", results ) || - checkIdentifier( key, text, textLowercase, "%", "%", results ) - ) { - - - - // Nothing to do, since it was already done within this if statement. - - -// // Performing all the String searching and indexing can be expensive, especially -// // since there can be thousands of PlaceHolderKeys on a server. So to provide -// // a quick proof to see if additional, more complex calculations should be -// // performed, we'll just see if the text input contains a hit on the key: -// -// // Rank in to an issue with placeholders: prison_mbm_minename and prison_mbm_pm, -// // because the mine P has a placeholder prison_mbm_p which gets hit for the -// // prison_mbm_pm. So to zero in on the correct placeholder, but bracket the end -// // of the placeholder with either } or :: to ensure the correct association. -// String test1 = "{" + key + "}"; -// String test2 = "{" + key + -// PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR; +// /** +// *

This function will take a full text String and apply the placeholder that +// * this PlaceHolderKey represents and tries to match it to the provided text. If it +// * is found within the text, then this function will return the identifier, which is +// * full text, including any placeholder attributes, but without the escape characters. +// *

+// * +// * @param text +// * @return +// */ +// public PlaceholderResults getIdentifier( String text ) { +// PlaceholderResults results = new PlaceholderResults(this, text); +// +// +// String textLowercase = text.toLowerCase(); +// String key = getKey().toLowerCase(); +// +// +// // For placeholders with sequence numbers, such as _nnn_, will need to search +// // for 1 to 3 digits and replace the number in the "text" with _nnn_ and also +// // need to store that numeric value in the PlaceholderResults object. +// if ( getPlaceholder().hasSequence() ) { // -// if ( textLowercase.contains( test1 ) || textLowercase.contains( test2 ) ) { +// Matcher matcher = PLACEHOLDER_SEQUENCE_PATTERN.matcher( textLowercase ); +// if ( matcher.find() ) { +// +// //String group0 = matcher.group( 0 ); +// String group1 = matcher.group( 1 ); +// String group2 = matcher.group( 2 ); +// +// textLowercase = textLowercase.replace( group1, "_nnn_" ); // -// // The key1 and key2 helps ensure that the full placeholder, -// // including the attribute, is replaced: -// String key1 = "{" + key; -// String key2 = "}"; +//// Output.get().logInfo( "### PlaceHolderKey: seq pattern detected: " + placeholder.name() + +//// " group0= " + group0 + " group1= " + group1 + " group2= " + group2 + " replacedText: " + textLowercase ); // -// int idx = textLowercase.indexOf( key1 ); -// int idx2 = ( idx == -1 ? -1 : textLowercase.indexOf( key2, idx + key1.length() - 1 ) ); -// if ( idx > -1 && idx2 > -1 ) { -// -// String identifier = text.substring( idx + 1, idx2 ); -// results.setIdentifier( identifier ); -//// results = results.replace("{" + identifier + "}", -//// pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, identifier ) ); +// results.setNumericSequencePattern( group1 ); +// +// // a value of -1 indicates it was not able to be parsed: +// int parsed = -1; +// +// try { +// parsed = Integer.parseInt( group2 ); +// } +// catch ( NumberFormatException e ) { +// // Not a number so ignore... but based upon matcher.find() it should be... Hmm... // } +// +// results.setNumericSequence( parsed ); +// +// +// // DO something more: +// // } - - } - } - - - return results; - } +// } +// +// +// // If the text is an exact match to the key (no escape characters): +// if ( textLowercase.equalsIgnoreCase( key ) ) { +// +// results.setIdentifier( textLowercase ); +// results.setPlaceholder( this ); +// +// } +// else { +// +// checkIdentifier( key, text, textLowercase, "{", "}", results ); +// +// if ( textLowercase.equalsIgnoreCase( key ) || +// textLowercase.contains( key ) || +// checkIdentifier( key, text, textLowercase, "{", "}", results ) || +// checkIdentifier( key, text, textLowercase, "%", "%", results ) +// ) { +// +// +// +// // Nothing to do, since it was already done within this if statement. +// +// +//// // Performing all the String searching and indexing can be expensive, especially +//// // since there can be thousands of PlaceHolderKeys on a server. So to provide +//// // a quick proof to see if additional, more complex calculations should be +//// // performed, we'll just see if the text input contains a hit on the key: +//// +//// // Rank in to an issue with placeholders: prison_mbm_minename and prison_mbm_pm, +//// // because the mine P has a placeholder prison_mbm_p which gets hit for the +//// // prison_mbm_pm. So to zero in on the correct placeholder, but bracket the end +//// // of the placeholder with either } or :: to ensure the correct association. +//// String test1 = "{" + key + "}"; +//// String test2 = "{" + key + +//// PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR; +//// +//// if ( textLowercase.contains( test1 ) || textLowercase.contains( test2 ) ) { +//// +//// // The key1 and key2 helps ensure that the full placeholder, +//// // including the attribute, is replaced: +//// String key1 = "{" + key; +//// String key2 = "}"; +//// +//// int idx = textLowercase.indexOf( key1 ); +//// int idx2 = ( idx == -1 ? -1 : textLowercase.indexOf( key2, idx + key1.length() - 1 ) ); +//// if ( idx > -1 && idx2 > -1 ) { +//// +//// String identifier = text.substring( idx + 1, idx2 ); +//// results.setIdentifier( identifier ); +////// results = results.replace("{" + identifier + "}", +////// pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, identifier ) ); +//// } +//// } +// +// } +// } +// +// +// return results; +// } - private boolean checkIdentifier( String key, String text, String textLowercase, - String escLeft, String escRight, PlaceholderResults results ) { - boolean foundIdentifier = false; - - // Performing all the String searching and indexing can be expensive, especially - // since there can be thousands of PlaceHolderKeys on a server. So to provide - // a quick proof to see if additional, more complex calculations should be - // performed, we'll just see if the text input contains a hit on the key: - - // Rank in to an issue with placeholders: prison_mbm_minename and prison_mbm_pm, - // because the mine P has a placeholder prison_mbm_p which gets hit for the - // prison_mbm_pm. So to zero in on the correct placeholder, but bracket the end - // of the placeholder with either } or :: to ensure the correct association. - String test1 = escLeft + key + escRight; - String test2 = escLeft + key + - PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR; - - int adjustment = 0; - // If the text contains a sequence, then calculate the adjustment position based upon - // the length of '_nnn_' compared to the original value. - // These adjustments will align properly with 'text'. - if ( results.getNumericSequence() >= 0 && results.getNumericSequencePattern() != null ) { - adjustment = 5 - results.getNumericSequencePattern().length(); - } - - // Warning this is not case insensitive in the results: - if ( textLowercase.contains( test1 ) ) { - - int idx = textLowercase.indexOf( test1 ); - int idxStart = idx + 1; - - - int idxEnd = idx + test1.length() - 1 - adjustment; - String identifier = text.substring( idxStart, idxEnd); - - results.setIdentifier( identifier, escLeft, escRight ); - results.setPlaceholder( this ); - -// results.setIdentifier( key, escLeft, escRight ); - foundIdentifier = true; - } - else if ( text.contains( test2 ) ) { - - // The key1 and key2 helps ensure that the full placeholder, - // including the attribute, is replaced: - String key1 = test2; - String key2 = escRight; - - int idx = text.indexOf( key1 ); - int idx2 = ( idx == -1 ? -1 : text.indexOf( key2, idx + key1.length() - 1 ) ) - adjustment; - if ( idx > -1 && idx2 > -1 ) { - - String identifier = text.substring( idx + 1, idx2 ); - - results.setIdentifier( identifier, escLeft, escRight ); - results.setPlaceholder( this ); - - foundIdentifier = true; -// results = results.replace("{" + identifier + "}", -// pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, identifier ) ); - } - } -// else if ( textLowercase.contains( key ) ) { +// private boolean checkIdentifier( String key, String text, String textLowercase, +// String escLeft, String escRight, PlaceholderResults results ) { +// boolean foundIdentifier = false; +// +// // Performing all the String searching and indexing can be expensive, especially +// // since there can be thousands of PlaceHolderKeys on a server. So to provide +// // a quick proof to see if additional, more complex calculations should be +// // performed, we'll just see if the text input contains a hit on the key: +// +// // Rank in to an issue with placeholders: prison_mbm_minename and prison_mbm_pm, +// // because the mine P has a placeholder prison_mbm_p which gets hit for the +// // prison_mbm_pm. So to zero in on the correct placeholder, but bracket the end +// // of the placeholder with either } or :: to ensure the correct association. +// String test1 = escLeft + key + escRight; +// String test2 = escLeft + key + +// PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_SEPARATOR; +// +// int adjustment = 0; +// // If the text contains a sequence, then calculate the adjustment position based upon +// // the length of '_nnn_' compared to the original value. +// // These adjustments will align properly with 'text'. +// if ( results.getNumericSequence() >= 0 && results.getNumericSequencePattern() != null ) { +// adjustment = 5 - results.getNumericSequencePattern().length(); +// } +// +// // Warning this is not case insensitive in the results: +// if ( textLowercase.contains( test1 ) ) { // -// int idx = textLowercase.indexOf( key ); +// int idx = textLowercase.indexOf( test1 ); // int idxStart = idx + 1; // // -// int idxEnd = idx + key.length() - 1 - adjustment; +// int idxEnd = idx + test1.length() - 1 - adjustment; // String identifier = text.substring( idxStart, idxEnd); // -// results.setIdentifier( identifier, "", "" ); +// results.setIdentifier( identifier, escLeft, escRight ); // results.setPlaceholder( this ); // //// results.setIdentifier( key, escLeft, escRight ); // foundIdentifier = true; // } - - return foundIdentifier; - } +// else if ( text.contains( test2 ) ) { +// +// // The key1 and key2 helps ensure that the full placeholder, +// // including the attribute, is replaced: +// String key1 = test2; +// String key2 = escRight; +// +// int idx = text.indexOf( key1 ); +// int idx2 = ( idx == -1 ? -1 : text.indexOf( key2, idx + key1.length() - 1 ) ) - adjustment; +// if ( idx > -1 && idx2 > -1 ) { +// +// String identifier = text.substring( idx + 1, idx2 ); +// +// results.setIdentifier( identifier, escLeft, escRight ); +// results.setPlaceholder( this ); +// +// foundIdentifier = true; +//// results = results.replace("{" + identifier + "}", +//// pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, identifier ) ); +// } +// } +//// else if ( textLowercase.contains( key ) ) { +//// +//// int idx = textLowercase.indexOf( key ); +//// int idxStart = idx + 1; +//// +//// +//// int idxEnd = idx + key.length() - 1 - adjustment; +//// String identifier = text.substring( idxStart, idxEnd); +//// +//// results.setIdentifier( identifier, "", "" ); +//// results.setPlaceholder( this ); +//// +////// results.setIdentifier( key, escLeft, escRight ); +//// foundIdentifier = true; +//// } +// +// return foundIdentifier; +// } @Override public String toString() { diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java index 18e367561..c6cf0ae9c 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderResults.java @@ -2,11 +2,16 @@ /** + *

This class is obsolete and no longer used. Please see PlaceholderIdentifier for its + * replacement. This class will be deleted shortly. + *

+ * *

This class is used to store the data of mapping an identifier to the correct * PlaceHolderKey. *

* */ +@Deprecated public class PlaceholderResults { private String identifier; diff --git a/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceHolderKeyTest.java b/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceHolderKeyTest.java index 0d1631ad6..87ec837a7 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceHolderKeyTest.java +++ b/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceHolderKeyTest.java @@ -1,14 +1,7 @@ package tech.mcprison.prison.placeholders; -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; - import org.junit.Test; -import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; - public class PlaceHolderKeyTest //extends PlaceHolderKey { @@ -17,6 +10,8 @@ public PlaceHolderKeyTest() { } + // NOTE: Because PlaceholderResults is no longer used in the project, then these tests are obsolete and no + // longer apply. @Test public void test() { @@ -26,78 +21,78 @@ public void test() */ - List placeHolderKeys = new ArrayList<>(); - - PlaceHolderKey key1 = new PlaceHolderKey( PrisonPlaceHolders.prison_rank.name(), PrisonPlaceHolders.prison_rank, true ); - PlaceHolderKey key2 = new PlaceHolderKey( PrisonPlaceHolders.prison_rank_tag.name(), PrisonPlaceHolders.prison_rank_tag, true ); - - placeHolderKeys.add( key1 ); - placeHolderKeys.add( key2 ); - - String testText1 = "<{prison_rank_tag}{prison_rank}>"; - String testText2 = "<{prison_rank_tag}{prison_r}>"; - String testText3 = "<{prison_rank_default}{prison_rank_tag}>"; - - String testText4 = "<{prison_rank_tag}{prison_rank::some:annotation:goes:here}>"; - - String testText5 = "<{prison_rank_tag}{Prison_Rank}>"; - String testText6 = "<{prison_rank_tag}{PRISON_RANK}>"; +// List placeHolderKeys = new ArrayList<>(); +// +// PlaceHolderKey key1 = new PlaceHolderKey( PrisonPlaceHolders.prison_rank.name(), PrisonPlaceHolders.prison_rank, true ); +// PlaceHolderKey key2 = new PlaceHolderKey( PrisonPlaceHolders.prison_rank_tag.name(), PrisonPlaceHolders.prison_rank_tag, true ); +// +// placeHolderKeys.add( key1 ); +// placeHolderKeys.add( key2 ); +// +// String testText1 = "<{prison_rank_tag}{prison_rank}>"; +// String testText2 = "<{prison_rank_tag}{prison_r}>"; +// String testText3 = "<{prison_rank_default}{prison_rank_tag}>"; +// +// String testText4 = "<{prison_rank_tag}{prison_rank::some:annotation:goes:here}>"; +// +// String testText5 = "<{prison_rank_tag}{Prison_Rank}>"; +// String testText6 = "<{prison_rank_tag}{PRISON_RANK}>"; // String testText7 = "<{prison_rank_tag}{prison_rank}{prison_r}{prison_rank_default}" + // "{PRISON_RANK}{PRISON_RANK_TAG}[{prison_rc} {prison_rcp}"; - PlaceholderResults results1 = key1.getIdentifier( testText1 ); - PlaceholderResults results2 = key1.getIdentifier( testText2 ); - PlaceholderResults results3 = key1.getIdentifier( testText3 ); - - assertTrue( results1.hasResults() ); - assertEquals( "prison_rank", results1.getIdentifier() ); - - assertFalse( results2.hasResults() ); - assertNull( results2.getIdentifier() ); - - assertFalse( results3.hasResults() ); - assertNull( results3.getIdentifier() ); - - - - PlaceholderResults results4 = key2.getIdentifier( testText3 ); - - assertTrue( results4.hasResults() ); - assertEquals( "prison_rank_tag", results4.getIdentifier() ); - - - - PlaceholderResults results5 = key1.getIdentifier( testText4 ); - - assertTrue( results5.hasResults() ); - assertEquals( "prison_rank::some:annotation:goes:here", results5.getIdentifier() ); - - - PlaceholderResults results6 = key1.getIdentifier( testText5 ); - PlaceholderResults results7 = key1.getIdentifier( testText6 ); - - assertTrue( results6.hasResults() ); - assertEquals( "Prison_Rank", results6.getIdentifier() ); - - assertTrue( results7.hasResults() ); - assertEquals( "PRISON_RANK", results7.getIdentifier() ); - - - - String testText10 = "<{prison_rANk_tag}{prison_rank_default}{PRISON_RANK}[{prison_rc} {prison_rcp}]"; - - PlaceholderResults results10a = key1.getIdentifier( testText10 ); - PlaceholderResults results10b = key2.getIdentifier( testText10 ); - - - assertTrue( results10a.hasResults() ); - assertEquals( "PRISON_RANK", results10a.getIdentifier() ); - - - assertTrue( results10b.hasResults() ); - assertEquals( "prison_rANk_tag", results10b.getIdentifier() ); +// PlaceholderResults results1 = key1.getIdentifier( testText1 ); +// PlaceholderResults results2 = key1.getIdentifier( testText2 ); +// PlaceholderResults results3 = key1.getIdentifier( testText3 ); +// +// assertTrue( results1.hasResults() ); +// assertEquals( "prison_rank", results1.getIdentifier() ); +// +// assertFalse( results2.hasResults() ); +// assertNull( results2.getIdentifier() ); +// +// assertFalse( results3.hasResults() ); +// assertNull( results3.getIdentifier() ); +// +// +// +// PlaceholderResults results4 = key2.getIdentifier( testText3 ); +// +// assertTrue( results4.hasResults() ); +// assertEquals( "prison_rank_tag", results4.getIdentifier() ); +// +// +// +// PlaceholderResults results5 = key1.getIdentifier( testText4 ); +// +// assertTrue( results5.hasResults() ); +// assertEquals( "prison_rank::some:annotation:goes:here", results5.getIdentifier() ); +// +// +// PlaceholderResults results6 = key1.getIdentifier( testText5 ); +// PlaceholderResults results7 = key1.getIdentifier( testText6 ); +// +// assertTrue( results6.hasResults() ); +// assertEquals( "Prison_Rank", results6.getIdentifier() ); +// +// assertTrue( results7.hasResults() ); +// assertEquals( "PRISON_RANK", results7.getIdentifier() ); +// +// +// +// String testText10 = "<{prison_rANk_tag}{prison_rank_default}{PRISON_RANK}[{prison_rc} {prison_rcp}]"; +// +// PlaceholderResults results10a = key1.getIdentifier( testText10 ); +// PlaceholderResults results10b = key2.getIdentifier( testText10 ); +// +// +// assertTrue( results10a.hasResults() ); +// assertEquals( "PRISON_RANK", results10a.getIdentifier() ); +// +// +// assertTrue( results10b.hasResults() ); +// assertEquals( "prison_rANk_tag", results10b.getIdentifier() ); } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java index 64153d350..441d300a6 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java @@ -743,74 +743,7 @@ public List getUnavailableWorldsListings() { return results; } -// public String getTranslateMinesPlaceHolder( String identifier ) { -// String results = null; -// List placeHolderKeys = getTranslatedPlaceHolderKeys(); -// -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } -// -// // placeholder Attributes: -//// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -//// String placeholder = pman.extractPlaceholderString( identifier ); -// //PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); -// -// -// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { -// -// PlaceholderResults phResults = placeHolderKey.getIdentifier( identifier ); -// -// if ( phResults != null && phResults.hasResults() ) { -// -// //Mine mine = getMine( placeHolderKey.getData() ); -// -// results = getTranslateMinesPlaceHolder( placeHolderKey, -// phResults.getIdentifier(), phResults.getNumericSequence() ); -// break; -// } -// } -// -// return results; -// } - -// public String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, String identifier, int sequence ) { -// String results = null; -// -// if ( placeHolderKey != null && identifier != null ) { -// -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } -// -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// //String placeholder = pman.extractPlaceholderString( identifier ); -// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); -// -// -// Mine mine = getMine( placeHolderKey.getData() ); -// -// results = getTranslateMinesPlaceHolder( placeHolderKey, mine, attribute, sequence ); -// } -// -// return results; -// } -// -// public String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, -// int sequence ) { -// Mine mine = getMine( placeHolderKey.getData() ); -// return getTranslateMinesPlaceHolder( placeHolderKey, mine, attribute, sequence ); -// } -// -// private String getTranslateMinesPlaceHolder( PlaceHolderKey placeHolderKey, Mine mine, -// PlaceholderAttribute attribute, int sequence ) { -// Player player = null; -// return getTranslateMinesPlaceHolder( player, placeHolderKey, mine, attribute, sequence ); -// -// } - @@ -1382,42 +1315,6 @@ else if ( attributeNFormat != null ) { } -// private String xgetTranslateMinesPlaceHolder( Player player, PlaceHolderKey placeHolderKey, Mine mine, -// PlaceholderAttribute attribute, int sequence ) { -// String results = null; -// -// if ( placeHolderKey != null ) { -// -// // If the mine is not provided, try to get it from the placeholder data: -// if ( mine == null && -// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) && -// placeHolderKey.getData() != null ) { -// mine = getMine( placeHolderKey.getData() ); -// } -// -// if ( mine != null ) { -// //DecimalFormat dFmt = new DecimalFormat("#,##0.00"); -// DecimalFormat iFmt = new DecimalFormat("#,##0"); -// //DecimalFormat fFmt = new DecimalFormat("#,##0.00"); -// -// switch ( placeHolderKey.getPlaceholder() ) { -// -// -// default: -// break; -// } -// -// if ( attribute != null && attribute instanceof PlaceholderAttributeText ) { -// PlaceholderAttributeText attributeText = (PlaceholderAttributeText) attribute; -// -// results = attributeText.format( results ); -// } -// } -// } -// -// return results; -// } - public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String playerName, String identifier ) { String results = null; @@ -1425,19 +1322,11 @@ public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String player List placeHolderKeys = getTranslatedPlaceHolderKeys(); -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } PlaceholderIdentifier phIdentifier = new PlaceholderIdentifier( identifier ); phIdentifier.setPlayer(playerUuid, playerName); - -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// String placeholder = pman.extractPlaceholderString( identifier ); -// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { @@ -1449,34 +1338,6 @@ public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String player break; } -// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { -// -// // Use this ONLY to get the numeric sequence!!! We already have the correct placeholder. -// PlaceholderResults phResults = placeHolderKey.getIdentifier( placeholder ); -// -// results = getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, -// placeHolderKey, attribute, -// phResults.getNumericSequence()); -// break; -// } - - - -// if ( phResults != null && phResults.hasResults() ) { -// -// //Mine mine = getMine( placeHolderKey.getData() ); -// -// results = getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, -// placeHolderKey, attribute, -// phResults.getNumericSequence() ); -// break; -// } - -// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { -// results = getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, placeHolderKey, -// attribute, position ); -// break; -// } } } @@ -1484,138 +1345,6 @@ public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String player } -// /** -// * -// * @param playerUuid -// * @param playerName -// * @param placeHolderKey -// * @param identifier -// * @param position -// * @return -// */ -// public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String playerName, -// PlaceHolderKey placeHolderKey, String identifier, int position ) { -// String results = null; -// -// identifier = identifier.toLowerCase(); -// -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } -// -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// //String placeholder = pman.extractPlaceholderString( identifier ); -// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); -// -// -// results = getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, placeHolderKey, -// attribute, position ); -// -// if ( results == null ) { -// results = ""; -// } -// -// return results; -// } - -// /** -// * We must have a player to process these placeholders. -// * -// * @param playerUuid -// * @param playerName -// * @param placeHolderKey -// * @return -// */ -// public String getTranslatePlayerMinesPlaceHolder( UUID playerUuid, String playerName, -// PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, int position ) { -// String results = null; -// -// // there is no data stored for PLAYERMINES: -//// String data = placeHolderKey.getData(); -// -// Player player = null; -// Mine mine = null; -// -// if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || -// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) ) { -// -// mine = getMine( placeHolderKey.getData() ); -// } -// else { -// -// player = getPlayer(playerUuid, playerName); -// -// if ( player != null && player.getLocation() != null ) { -// -// mine = PrisonMines.getInstance().findMineLocation( player ); -// } -// } -// -//// Output.get().logInfo( "### ### MineManager.getTranslated... : 1 in mine? %s player: %s %s %s", -//// (mine == null ? "-- NO --" : "-- YES == " + mine.getName()), -//// (player == null ? "(null)" : player.getName()), placeHolderKey.getPlaceholder().name(), -//// player.getLocation().toBlockCoordinates() ); -// -// results = getTranslateMinesPlaceHolder( player, placeHolderKey, mine, -// attribute, position ); -// -// // If results is null, but a PLAYERMINES then must return an empty string: -// if ( results == null && placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) ) { -// results = ""; -// } -// -// return results; -// } - - -// /** -// * Get the Player based first on UUID, then on name. -// * -// * @param playerUuid -// * @param playerName -// * @return -// */ -// private Player getPlayer( UUID playerUuid, String playerName ) { -// Player player = null; -// Player playerAlt = null; -// -// if ( playerUuid != null ) { -// -// // First try to match on UUID -// for ( Player p : Prison.get().getPlatform().getOnlinePlayers() ) { -// if ( p.getUUID().compareTo( playerUuid ) == 0 ) { -// player = p; -// break; -// } -// else if ( p.getName().equalsIgnoreCase( playerName ) ) { -// // If we get a hit on the name, save it as an alt... -// playerAlt = p; -// } -// } -// } -// -// if ( player == null ) { -// for ( Player p : Prison.get().getPlatform().getOfflinePlayers() ) { -// if ( playerUuid != null && p.getUUID() != null && -// p.getUUID().compareTo( playerUuid ) == 0 ) { -// player = p; -// break; -// } -// else if ( p.getName().equalsIgnoreCase( playerName ) ) { -// // If we get a hit on the name, save it as an alt... -// playerAlt = p; -// } -// } -// -// } -// -// // if player is null, and we have a playerAlt, then use it: -// if ( player == null && playerAlt != null ) { -// player = playerAlt; -// } -// return player; -// } private String getRemainingTimeBar( Mine mine, PlaceholderAttribute attribute ) { diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java index 69e75ef48..4ee6189a9 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/PlayerManager.java @@ -658,20 +658,6 @@ private Rank getNextPrestigeRank( RankPlayer rankPlayer, boolean isDefault, Rank public String getPlayerNextRankCostPercent( RankPlayer rankPlayer, String ladderName ) { StringBuilder sb = new StringBuilder(); -// Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); -// if( prisonPlayer == null ) { -// -// String errorMessage = cannotLoadPlayerFile( rankPlayer.getUUID().toString() ); -// -// String message = "getPlayerNextRankCostPercent: " + errorMessage; -// -// if ( !getPlayerErrors().contains( message ) ) { -// getPlayerErrors().add( message ); -// Output.get().logError( message ); -// } -//// return "0"; -// } - if ( !rankPlayer.getLadderRanks().isEmpty()) { DecimalFormat dFmt = new DecimalFormat("#,##0.00"); @@ -726,21 +712,6 @@ public String getPlayerNextRankCostBar( RankPlayer rankPlayer, String ladderName PlaceholderAttributeBar attributeBar ) { StringBuilder sb = new StringBuilder(); -// Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); -// if( prisonPlayer == null ) { -// -// String errorMessage = cannotLoadPlayerFile( rankPlayer.getUUID().toString() ); -// -// String message = "getPlayerNextRankCostBar: " + errorMessage; -// -// if ( !getPlayerErrors().contains( message ) ) { -// getPlayerErrors().add( message ); -// Output.get().logError( message ); -// } -// -// // return "0"; -// } - if ( !rankPlayer.getLadderRanks().isEmpty()) { // DecimalFormat dFmt = new DecimalFormat("#,##0.00"); @@ -807,21 +778,6 @@ public String getPlayerNextRankCostRemaining( RankPlayer rankPlayer, String ladd boolean formatted, PlaceholderAttributeNumberFormat attributeNFormat ) { StringBuilder sb = new StringBuilder(); -// Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); -// if( prisonPlayer == null ) { -// -// String errorMessage = cannotLoadPlayerFile( rankPlayer.getUUID().toString() ); -// -// String message = "getPlayerNextRankCostRemaining: " + errorMessage; -// -// if ( !getPlayerErrors().contains( message ) ) { -// getPlayerErrors().add( message ); -// Output.get().logError( message ); -// } -// -//// return "0"; -// } - if ( !rankPlayer.getLadderRanks().isEmpty()) { DecimalFormat dFmt = new DecimalFormat("#,##0.00"); @@ -891,20 +847,6 @@ else if ( formatted ) { public String getPlayerNextRankCostRemainingPercent( RankPlayer rankPlayer, String ladderName ) { StringBuilder sb = new StringBuilder(); -// Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); -// if( prisonPlayer == null ) { -// -// String errorMessage = cannotLoadPlayerFile( rankPlayer.getUUID().toString() ); -// -// String message = "getPlayerNextRankCostPercent: " + errorMessage; -// -// if ( !getPlayerErrors().contains( message ) ) { -// getPlayerErrors().add( message ); -// Output.get().logError( message ); -// } -//// return "0"; -// } - if ( !rankPlayer.getLadderRanks().isEmpty()) { DecimalFormat dFmt = new DecimalFormat("#,##0"); @@ -968,20 +910,6 @@ public String getPlayerNextRankCostRemainingBar( RankPlayer rankPlayer, String l PlaceholderAttributeBar attributeBar ) { StringBuilder sb = new StringBuilder(); -// Player prisonPlayer = PrisonAPI.getPlayer(rankPlayer.getUUID()).orElse(null); -// if( prisonPlayer == null ) { -// -// String errorMessage = cannotLoadPlayerFile( rankPlayer.getUUID().toString() ); -// -// String message = "getPlayerNextRankCostPercent: " + errorMessage; -// -// if ( !getPlayerErrors().contains( message ) ) { -// getPlayerErrors().add( message ); -// Output.get().logError( message ); -// } -//// return "0"; -// } - if ( !rankPlayer.getLadderRanks().isEmpty()) { // DecimalFormat dFmt = new DecimalFormat("#,##0"); @@ -1389,90 +1317,10 @@ private String getPlayerSellallMultiplier( RankPlayer rankPlayer, PlaceholderAtt return results; } - -// /** -// *

Entry point for translating placeholders. -// *

-// * @param playerUuid -// * @param playerName -// * @param identifier -// * @return -// */ -// public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, String identifier ) { -// String results = null; -// -// if ( playerUuid != null && identifier != null ) { -// -// List placeHolderKeys = getTranslatedPlaceHolderKeys(); -// -// identifier = identifier.toLowerCase(); -// -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } -// -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// String placeholder = pman.extractPlaceholderString( identifier ); -// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); -// -// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { -// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { -// results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, attribute ); -// break; -// } -// } -// } -// -// return results; -// } - -// public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, PlaceholderResults placeholderResults ) { -// String results = null; -// -// if ( playerUuid != null && placeholderResults.hasResults() ) { -// -// List placeHolderKeys = getTranslatedPlaceHolderKeys(); -// -// String identifier = placeholderResults.getIdentifier(); -// -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } -// -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// String placeholder = pman.extractPlaceholderString( identifier ); -// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); -// -// if ( placeholderResults.getPlaceholder() != null ) { -// results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeholderResults.getPlaceholder(), attribute ); -// } -// else { -// // Need to hunt for the placeholder: -// -// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { -// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { -// results = getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, attribute ); -// break; -// } -// } -// } -// -// } -// -// return results; -// } - - -// public String getTranslatePlayerPlaceHolder( UUID playerUuid, String playerName, -// PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute ) { -// String results = null; public String getTranslatePlayerPlaceHolder( PlaceholderIdentifier identifier ) { - Player player = identifier.getPlayer(); PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); @@ -1480,34 +1328,22 @@ public String getTranslatePlayerPlaceHolder( PlaceholderIdentifier identifier ) PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); - - // From RankManager which does not apply here: -// String rankName = placeHolderKey.getData(); -// Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); - - PlaceholderAttributeBar attributeBar = identifier.getAttributeBar(); PlaceholderAttributeNumberFormat attributeNFormat = identifier.getAttributeNFormat(); PlaceholderAttributeText attributeText = identifier.getAttributeText(); - int sequence = identifier.getSequence(); +// int sequence = identifier.getSequence(); String results = null; PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); - if ( rankPlayer != null ) { -// if ( playerUuid != null ) { - -// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); String ladderName = placeHolderKey.getData(); -// RankPlayer rankPlayer = getPlayer(playerUuid, playerName); - if ( rankPlayer != null ) { identifier.setFoundAMatch( true ); 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 866599eb6..baa5db815 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 @@ -691,190 +691,7 @@ else if ( formatted ) { return resultsx; } -// public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, String identifier ) { -// String results = null; -// -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// String placeholder = pman.extractPlaceholderString( identifier ); -// -// List placeHolderKeys = getTranslatedPlaceHolderKeys(); -// -// PlaceHolderKey placeholderKey = null; -// for ( PlaceHolderKey phk : placeHolderKeys ) { -// -// if ( phk.getKey().equalsIgnoreCase( placeholder )) { -// placeholderKey = phk; -// break; -// } -// } -// -// if ( placeholderKey != null ) { -// -// PlaceholderResults placeholderResults = placeholderKey.getIdentifier(identifier); -// -// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeholderResults ); -// } -// -// return results; -// } -// public String getTranslateRankPlayersPlaceHolder( UUID playerUuid, String playerName, -// PlaceholderResults placeholderResults ) { -// String results = null; -// -// if ( playerUuid != null && placeholderResults != null ) { -// -//// List placeHolderKeys = getTranslatedPlaceHolderKeys(); -// -// String identifier = placeholderResults.getIdentifier().toLowerCase(); -// -// -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } -// -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -//// String placeholder = pman.extractPlaceholderString( identifier ); -// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); -// -// PlaceHolderKey placeHolderKey = placeholderResults.getPlaceholder(); -// -// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, -// placeHolderKey, attribute, placeholderResults ); -// -//// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { -//// -//// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { -//// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, -//// placeHolderKey, attribute, placeholderResults ); -//// break; -//// } -//// } -// } -// -// return results; -// } - -// public String getTranslateRanksPlaceHolder( String identifier ) { -// String results = null; -// List placeHolderKeys = getTranslatedPlaceHolderKeys(); -// -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } -// -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// String placeholder = pman.extractPlaceholderString( identifier ); -// //PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); -// -// for ( PlaceHolderKey placeHolderKey : placeHolderKeys ) { -// -//// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); -// -// if ( placeHolderKey.getKey().equalsIgnoreCase( placeholder )) { -// -// //Mine mine = getMine( placeHolderKey.getData() ); -// -// results = getTranslateRanksPlaceHolder( placeHolderKey, identifier, 0 ); -// break; -// } -// } -// -// return results; -// } - -// public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, -// String identifier, int numericSequence ) { -// String results = null; -// -// if ( identifier == null ) { -// identifier = placeHolderKey.getKey(); -// } -// -// if ( placeHolderKey != null && identifier != null ) { -// -// if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED )) { -// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; -// } -// -// // placeholder Attributes: -// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// //String placeholder = pman.extractPlaceholderString( identifier ); -// PlaceholderAttribute attribute = pman.extractPlaceholderExtractAttribute( identifier ); -// -// -// if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { -// -// UUID playerUuid = null; -// String playerName = null; -// -// PlaceholderResults placeholderResults = placeHolderKey.getIdentifier(identifier); -// -// results = getTranslateRankPlayersPlaceHolder( playerUuid, playerName, -// placeHolderKey, attribute, placeholderResults ); -// -// } -// else -// { -// -// String rankName = placeHolderKey.getData(); -// Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); -// -// -// results = getTranslateRanksPlaceHolder( placeHolderKey, rank, attribute ); -// } -// -// -// } -// -// return results; -// } - - - -// public String getTranslateMinesPlaceholder( PlaceholderIdentifier identifier ) { -// -//// // placeholder Attributes: -//// PlaceholderManager pman = Prison.get().getPlaceholderManager(); -// -// Player player = identifier.getPlayer(); -// -// PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); -// -// -// Mine mine = null; -// if ( placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || -// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) ) { -// -// mine = getMine( placeHolderKey.getData() ); -// } -// else { -// -// if ( player != null && player.getLocation() != null ) { -// -// mine = PrisonMines.getInstance().findMineLocation( player ); -// } -// } -// -// -// PlaceholderAttributeBar attributeBar = identifier.getAttributeBar(); -// PlaceholderAttributeNumberFormat attributeNFormat = identifier.getAttributeNFormat(); -// PlaceholderAttributeText attributeText = identifier.getAttributeText(); -// -// int sequence = identifier.getSequence(); -// -// -// String results = null; -// } -// -// public String getTranslateRanksPlaceHolder( PlaceHolderKey placeHolderKey, -// Rank rank, PlaceholderAttribute attribute ) { -// String results = null; -// -// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); public String getTranslateRanksPlaceHolder( PlaceholderIdentifier identifier ) { @@ -1347,11 +1164,6 @@ else if ( rank != null ) { case prison_r_pc_rankname: int playerCount = rank.getPlayers().size(); -// List players = -// PrisonRanks.getInstance().getPlayerManager().getPlayers().stream() -// .filter(rPlayer -> rPlayer.getLadderRanks().values().contains(rank)) -// .collect(Collectors.toList()); - results = Integer.toString( playerCount ); break; @@ -1443,416 +1255,7 @@ else if ( rank != null ) { } -// public String getTranslateRanksPlaceHolderTopPlayer( PlaceHolderKey placeHolderKey, -// PlaceholderAttribute attribute, int numericSequence ) { -// String results = null; -// -// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); -// -//// DecimalFormat dFmt = new DecimalFormat("#,##0"); -// -// switch ( placeHolder ) { -// -// case prison_tpl1_nnn_tp: -// case prison_top_player_line1_nnn_tp: -// { -//// placeHolderKey.get -// lll -// -// } -// -// default: -// break; -// -// } -// -// return results; -// } - -// public String getTranslateRankPlayersPlaceHolder(UUID playerUuid, String playerName, -// PlaceHolderKey placeHolderKey, PlaceholderAttribute attribute, PlaceholderResults placeholderResults ) { -// String results = null; -// -// PrisonPlaceHolders placeHolder = placeHolderKey.getPlaceholder(); -// -// String rankName = placeHolderKey.getData(); -// Rank rank = PrisonRanks.getInstance().getRankManager().getRank( rankName ); -// -// -// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); -// RankPlayer rankPlayer = pm.getPlayer(playerUuid, playerName); -// -// DecimalFormat dFmt = new DecimalFormat("#,##0"); -// -// if ( !placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) && -// rank != null && rankPlayer != null ) { -// -// switch ( placeHolder ) { -// -// case prison_rank__player_cost_rankname: -// case prison_r_pcst_rankname: -// { -// double cost = calculateRankCost( rankPlayer, rank ); -// -// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { -// PlaceholderAttributeNumberFormat attributeNF = -// (PlaceholderAttributeNumberFormat) attribute; -// results = attributeNF.format( cost ); -// } -// else { -// -// results = dFmt.format( cost ); -// } -// } -// break; -// -// case prison_rank__player_cost_formatted_rankname: -// case prison_r_pcf_rankname: -// { -// double cost = calculateRankCost( rankPlayer, rank ); -// -// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { -// PlaceholderAttributeNumberFormat attributeNF = -// (PlaceholderAttributeNumberFormat) attribute; -// results = attributeNF.format( cost ); -// } -// else { -// -// results = PlaceholdersUtil.formattedMetricSISize( cost ); -// } -// } -// break; -// -// -// case prison_rank__player_cost_remaining_rankname: -// case prison_r_pcr_rankname: -// { -// double cost = calculateRankCost( rankPlayer, rank ); -// double balance = rankPlayer.getBalance( rank.getCurrency() ); -//// double balance = pm.getPlayerBalance( rankPlayer, rank); -// -// double remaining = cost - balance; -// -// if ( remaining < 0 ) { -// remaining = 0; -// } -// -// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { -// PlaceholderAttributeNumberFormat attributeNF = -// (PlaceholderAttributeNumberFormat) attribute; -// results = attributeNF.format( remaining ); -// } -// else { -// -// results = dFmt.format( remaining ); -// } -// } -// break; -// -// case prison_rank__player_cost_remaining_formatted_rankname: -// case prison_r_pcrf_rankname: -// { -// double cost = calculateRankCost( rankPlayer, rank ); -// double balance = rankPlayer.getBalance( rank.getCurrency() ); -//// double balance = pm.getPlayerBalance( rankPlayer, rank); -// -// double remaining = cost - balance; -// -// if ( remaining < 0 ) { -// remaining = 0; -// } -// -// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { -// PlaceholderAttributeNumberFormat attributeNF = -// (PlaceholderAttributeNumberFormat) attribute; -// results = attributeNF.format( remaining ); -// } -// else { -// -// results = PlaceholdersUtil.formattedMetricSISize( remaining ); -// } -// -// } -// break; -// -// -// -// -// case prison_rank__player_cost_percent_rankname: -// case prison_r_pcp_rankname: -// { -// double cost = calculateRankCost( rankPlayer, rank ); -// double balance = rankPlayer.getBalance( rank.getCurrency() ); -//// double balance = pm.getPlayerBalance( rankPlayer, rank); -// -// double percent = (balance < 0 ? 0 : -// (cost == 0.0d || balance > cost ? 100.0 : -// balance / cost * 100.0 ) -// ); -// results = dFmt.format( percent ); -// } -// break; -// -// case prison_rank__player_cost_bar_rankname: -// case prison_r_pcb_rankname: -// { -// double cost = calculateRankCost( rankPlayer, rank ); -// double balance = rankPlayer.getBalance( rank.getCurrency() ); -//// double balance = pm.getPlayerBalance( rankPlayer, rank); -// -// results = Prison.get().getPlaceholderManager(). -// getProgressBar( balance, cost, false, attribute ); -// } -// break; -// -// -// -// default: -// break; -// } -// } -// -// else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { -// -// switch ( placeHolder ) { -// -// case prison_top_player_line1_headers_nnn_tp: -// case prison_tpl1h_nnn_tp: -// { -// results = RankPlayer.printRankScoreLine1Header(); -// } -// break; -// -// case prison_tpl1_nnn_tp: -// case prison_top_player_line1_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// results = topRankPlayer.printRankScoreLine1( placeholderResults.getNumericSequence() ); -// } -// else { -// results = ""; -// } -// } -// break; -// -// case prison_top_player_line2_headers_nnn_tp: -// case prison_tpl2h_nnn_tp: -// { -// results = RankPlayer.printRankScoreLine2Header(); -// } -// break; -// -// case prison_top_player_line2_nnn_tp: -// case prison_tpl2_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// results = topRankPlayer.printRankScoreLine2( placeholderResults.getNumericSequence() ); -// } -// else { -// results = ""; -// } -// } -// break; -// -// case prison_top_player_name_nnn_tp: -// case prison_tpn_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// results = topRankPlayer.getName(); -// } -// else { -// results = ""; -// } -// } -// break; -// -// case prison_top_player_rank_prestiges_nnn_tp: -// case prison_tprp_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// results = topRankPlayer.getPlayerRankPrestiges().getRank().getTag(); -// } -// else { -// results = ""; -// } -// } -// break; -// -// case prison_top_player_rank_default_nnn_tp: -// case prison_tprd_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// results = topRankPlayer.getPlayerRankDefault().getRank().getTag(); -// } -// else { -// results = ""; -// } -// } -// break; -// -// case prison_top_player_balance_nnn_tp: -// case prison_tpb_nnn_tp: -// case prison_top_player_balance_formatted_nnn_tp: -// case prison_tpbf_nnn_tp: -// case prison_top_player_balance_raw_nnn_tp: -// case prison_tpbr_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// double bal = topRankPlayer.getBalance(); -// -// if ( bal < 0 ) { -// bal = 0; -// } -// -// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { -// PlaceholderAttributeNumberFormat attributeNF = -// (PlaceholderAttributeNumberFormat) attribute; -// results = attributeNF.format( bal ); -// } -// else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_formatted_nnn_tp || -// placeHolder == PrisonPlaceHolders.prison_tpbf_nnn_tp ) { -// -// results = PlaceholdersUtil.formattedMetricSISize( bal ); -// } -// else if ( placeHolder == PrisonPlaceHolders.prison_top_player_balance_raw_nnn_tp || -// placeHolder == PrisonPlaceHolders.prison_tpbr_nnn_tp ) { -// -// results = Double.toString(bal); -// } -// else { -// results = dFmt.format(bal); -// } -// -// } -// else { -// results = ""; -// } -// } -// break; -// -// -// -// case prison_top_player_rank_score_nnn_tp: -// case prison_tprs_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// double rankScore = topRankPlayer.getRankScore(); -// -// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { -// PlaceholderAttributeNumberFormat attributeNF = -// (PlaceholderAttributeNumberFormat) attribute; -// results = attributeNF.format( rankScore ); -// } -// else { -// results = dFmt.format(rankScore); -// } -// } -// else { -// results = ""; -// } -// } -// break; -// -// -// case prison_top_player_rank_score_bar_nnn_tp: -// case prison_tprsb_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// double rankScore = topRankPlayer.getRankScore(); -// -// results = Prison.get().getPlaceholderManager(). -// getProgressBar( rankScore, 100.0d, false, attribute ); -// } -// else { -// results = ""; -// } -// } -// break; -// -// case prison_top_player_penalty_nnn_tp: -// case prison_tpp_nnn_tp: -// case prison_top_player_penalty_formatted_nnn_tp: -// case prison_tppf_nnn_tp: -// case prison_top_player_penalty_raw_nnn_tp: -// case prison_tppr_nnn_tp: -// { -// RankPlayer topRankPlayer = getTopNRankPlayer( placeholderResults ); -// -// if ( topRankPlayer != null ) { -// -// double rsPenalty = topRankPlayer.getRankScorePenalty(); -// -// if ( rsPenalty < 0 ) { -// rsPenalty = 0; -// } -// -// if ( attribute != null && attribute instanceof PlaceholderAttributeNumberFormat ) { -// PlaceholderAttributeNumberFormat attributeNF = -// (PlaceholderAttributeNumberFormat) attribute; -// results = attributeNF.format( rsPenalty ); -// } -// else if ( placeHolder == PrisonPlaceHolders.prison_top_player_penalty_formatted_nnn_tp || -// placeHolder == PrisonPlaceHolders.prison_tppf_nnn_tp ) { -// -// results = PlaceholdersUtil.formattedMetricSISize( rsPenalty ); -// } -// else if ( placeHolder == PrisonPlaceHolders.prison_top_player_penalty_raw_nnn_tp || -// placeHolder == PrisonPlaceHolders.prison_tppr_nnn_tp ) { -// -// results = Double.toString(rsPenalty); -// } -// else { -// results = dFmt.format(rsPenalty); -// } -// -// } -// else { -// results = ""; -// } -// } -// break; -// -// -// -// -// default: -// break; -// } -// -// if ( attributeText != null ) { -// -// results = attributeText.format( results ); -// } -// } -// -// identifier.setText(results); -// -// return results; -// } + private RankPlayer getTopNRankPlayer( int rankPosition ) { RankPlayer topRankPlayer = null; @@ -1866,23 +1269,8 @@ private RankPlayer getTopNRankPlayer( int rankPosition ) { return topRankPlayer; } -// private RankPlayer getTopNRankPlayer( PlaceholderResults placeholderResults ) { -// RankPlayer topRankPlayer = null; -// -// if ( placeholderResults != null ) { -// -// int rankPosition = placeholderResults.getNumericSequence(); -// -// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); -// if ( rankPosition >= 0 && rankPosition < pm.getPlayersByTop().size() ) { -// -// topRankPlayer = pm.getPlayersByTop().get(rankPosition); -// } -// } -// -// return topRankPlayer; -// } + private double calculateRankCost( RankPlayer rankPlayer, Rank rank ) { double cost = 0; diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java index 0408ace64..8a8196780 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java @@ -84,17 +84,7 @@ public String onRequest(OfflinePlayer player, String identifier) { UUID playerUuid = player.getUniqueId(); String results = Prison.get().getPlatform().getPlaceholders() .placeholderTranslate( playerUuid, player.getName(), identifier ); - -// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); -// if ( pm != null ) { -// results = pm.getTranslatePlayerPlaceHolder( playerUuid, identifier ); -// } -// -// // If it did not match on a player placeholder, then try mines: -// if ( results == null ) { -// MineManager mm = PrisonMines.getInstance().getMineManager(); -// results = mm.getTranslateMinesPlaceHolder( identifier ); -// } + return results; } diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java index b5b683b34..9ae3b0a1c 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java @@ -84,17 +84,6 @@ public String onRequest(OfflinePlayer player, String identifier) { String results = Prison.get().getPlatform().getPlaceholders() .placeholderTranslate( playerUuid, player.getName(), identifier ); -// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); -// if ( pm != null ) { -// results = pm.getTranslatePlayerPlaceHolder( playerUuid, identifier ); -// } -// -// // If it did not match on a player placeholder, then try mines: -// if ( results == null ) { -// MineManager mm = PrisonMines.getInstance().getMineManager(); -// results = mm.getTranslateMinesPlaceHolder( identifier ); -// } - return results; } } 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 fcc2375ef..ab75074c4 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 @@ -6,25 +6,21 @@ import java.util.Set; import java.util.TreeMap; import java.util.UUID; -import java.util.regex.Pattern; import tech.mcprison.prison.Prison; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.managers.MineManager; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.placeholders.PlaceHolderKey; -import tech.mcprison.prison.placeholders.PlaceholderAttribute; import tech.mcprison.prison.placeholders.PlaceholderIdentifier; import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags; import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; import tech.mcprison.prison.placeholders.PlaceholderManagerUtils; -import tech.mcprison.prison.placeholders.PlaceholderResults; import tech.mcprison.prison.placeholders.Placeholders; import tech.mcprison.prison.ranks.PrisonRanks; 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 { @@ -180,52 +176,6 @@ public String placeholderTranslate( UUID playerUuid, String playerName, String t identifier.setPlayer(playerUuid, playerName); return placeholderTranslateText( identifier ); - - // String results = null; - - -// if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() && -// playerUuid != null ) { -// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); -// if ( pm != null ) { -// text = pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, text ); -// } -// -// RankManager rm = PrisonRanks.getInstance().getRankManager(); -// if ( rm != null && text == null ) { -// text = rm.getTranslateRanksPlaceHolder( text ); -// -// if ( text == null ) { -// -// text = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, text ); -// } -// } -// } -// -// // If it did not match on a player placeholder, then try mines: -// if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() && -// text == null ) { -// MineManager mm = PrisonMines.getInstance().getMineManager(); -// if ( mm != null ) { -// -// mm.getTranslateMinesPlaceholder( identifier ); -// -//// text = mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, text ); -//// -//// if ( text == null ) { -//// text = mm.getTranslateMinesPlaceHolder( text ); -//// } -// } -// -// } -// -//// if ( results == null ) { -//// Output.get().logInfo( "### ### SpigotPlaceholders.placeholderTranslate: " + -//// "could not translate identifyer: %s playerUuid: %s playerName: %s", -//// (identifier == null ? "(null)" : identifier), playerUuid, playerName ); -//// } -// -// return identifier.getText(); } /** @@ -260,16 +210,6 @@ public String placeholderTranslateText( PlaceholderIdentifier identifier ) { break; } -// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); -// -// -// if ( results != null && identifier != null && identifier.hasResults() ) { -// -// results = placeholderReplace( results, identifier.getEscapedIdentifier(), -// mm.getTranslateMinesPlaceHolder( placeHolderKey, -// identifier.getIdentifier(), identifier.getNumericSequence() ) ); -// } - } } } @@ -306,15 +246,6 @@ public String placeholderTranslateText( PlaceholderIdentifier identifier ) { break; } -// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); -// -// if ( results != null && identifier != null && identifier.hasResults() ) { -// -// results = placeholderReplace( results, identifier.getEscapedIdentifier(), -// rm.getTranslateRanksPlaceHolder( placeHolderKey, identifier.getIdentifier(), -// identifier.getNumericSequence()) ); -// } - } } } @@ -323,24 +254,24 @@ public String placeholderTranslateText( PlaceholderIdentifier identifier ) { return identifier.getText(); } - /** - * This provides for a case insensitive replacement of placeholders. - * - * String target = "FOOBar"; - * target = target.replaceAll("(?i)foo", ""); - * - * @param text The full text that contains one or more placeholders. This is also the value that - * will be returned, with the replacement of the contained placeholder. - * @param placeholder The individual placeholder that should be replaced. This should be the - * raw value of the identifier, including escape chaacters and placeholder attributes. - * @param target The text that should replace the whole placeholder. - * @return - */ - private String placeholderReplace( String text, String placeholder, String target ) { - - return text == null || placeholder == null || target == null ? - text : text.replaceAll( "(?i)" + Pattern.quote(placeholder) , target ); - } +// /** +// * This provides for a case insensitive replacement of placeholders. +// * +// * String target = "FOOBar"; +// * target = target.replaceAll("(?i)foo", ""); +// * +// * @param text The full text that contains one or more placeholders. This is also the value that +// * will be returned, with the replacement of the contained placeholder. +// * @param placeholder The individual placeholder that should be replaced. This should be the +// * raw value of the identifier, including escape chaacters and placeholder attributes. +// * @param target The text that should replace the whole placeholder. +// * @return +// */ +// private String placeholderReplace( String text, String placeholder, String target ) { +// +// return text == null || placeholder == null || target == null ? +// text : text.replaceAll( "(?i)" + Pattern.quote(placeholder) , target ); +// } /** @@ -363,84 +294,6 @@ public String placeholderTranslateText( UUID playerUuid, String playerName, Stri identifier.setPlayer(playerUuid, playerName); return placeholderTranslateText( identifier ); - - -// String results = text; -// -// -// // First the player specific placeholder, which must have a UUID: -// if ( text != null && PrisonRanks.getInstance() != null && -// PrisonRanks.getInstance().isEnabled() && playerUuid != null ) { -// -// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); -// List placeholderKeys = pm.getTranslatedPlaceHolderKeys(); -// -// for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { -// -// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); -// -// if ( results != null && identifier != null && identifier.hasResults() ) { -// -// -// results = placeholderReplace( results, identifier.getEscapedIdentifier(), -// pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, identifier.getIdentifier() ) ); -// } -// } -// -// -// RankManager rm = PrisonRanks.getInstance().getRankManager(); -// placeholderKeys = rm.getTranslatedPlaceHolderKeys(); -// -// for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { -// -// PlaceholderResults pResults = placeHolderKey.getIdentifier( results ); -// -// if ( results != null && pResults != null && pResults.hasResults() ) { -// -// -// results = placeholderReplace( results, pResults.getEscapedIdentifier(), -// rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, pResults ) ); -// } -// } -// } -// -// -// -// // Check the mine's playerMines placeholders: -// if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { -// -// MineManager mm = PrisonMines.getInstance().getMineManager(); -// if ( mm != null ) { -// -// List placeholderKeys = mm.getTranslatedPlaceHolderKeys(); -// -// for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { -// -// if ( identifier.checkPlaceholderKey( placeHolderKey ) ) { -// mm.getTranslateMinesPlaceholder( identifier ); -// break; -// } -//// PlaceholderResults identifier = placeHolderKey.getIdentifier( results ); -//// -//// if ( identifier.hasResults() ) { -//// -//// results = placeholderReplace( results, identifier.getEscapedIdentifier(), -//// mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, -//// placeHolderKey, identifier.getIdentifier(), -//// identifier.getNumericSequence() ) ); -//// -//// } -// -// } -// } -// -// } -// -// -// // Then translate any remaining non-player (mine) related placeholders: -// results = placeholderTranslateText( results); -// -// return results; } @@ -489,17 +342,6 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin identifier.setPlayer(playerUuid, playerName); - -// String key1 = "{" + placeHolderKey.getKey(); -// String key2 = "}"; -// -// int idx = newFormat.indexOf( key1 ); -// if ( idx > -1 && newFormat.indexOf( key2, idx ) > -1 ) { -// -// String identifier = newFormat.substring( idx + 1, newFormat.indexOf( key2, idx ) ); -// -// } - String value = null; // Note: STATSMINES will not work here since the sequence is not being addressed. @@ -514,9 +356,6 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin value = mm.getTranslateMinesPlaceholder(identifier); } -// PlaceholderAttribute attribute = null; -// value = mm.getTranslatePlayerMinesPlaceHolder( playerUuid, playerName, placeHolderKey, -// attribute, -1 ); } else if ( pm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ))) { @@ -526,7 +365,6 @@ else if ( pm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFla value = pm.getTranslatePlayerPlaceHolder( identifier ); } -// value = pm.getTranslatePlayerPlaceHolder( playerUuid, playerName, placeHolderKey, null ); } else if ( rm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || @@ -539,11 +377,6 @@ else if ( rm != null && value = rm.getTranslateRanksPlaceHolder( identifier ); } -// String searchPatterns = String.join("_", patterns); -// -// PlaceholderResults pResults = placeHolderKey.getIdentifier( searchPatterns ); -// -// value = rm.getTranslateRankPlayersPlaceHolder( playerUuid, playerName, placeHolderKey, null, pResults ); } String placeholderAlias = ( placeHolderKey.getAliasName() == null ? null : From 9785b2aaa9fc023444eb067ab5855e3557ee2ffc Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 14 Jun 2022 22:39:34 -0400 Subject: [PATCH 277/297] v3.3.0-alpha.11h 2022-06-14 --- 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 93a82e196..911f3039a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11g 2022-06-14 +# 3.3.0-alpha.11h 2022-06-14 + + +* **v3.3.0-alpha.11h 2022-06-14** * **Prison Placeholders: General clean up of obsolete code.** diff --git a/gradle.properties b/gradle.properties index 011191354..b0c79be61 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.11g +version=3.3.0-alpha.11h From 5c39732d46404b253b70b81eee7bc4b8cafe9e0c Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Tue, 14 Jun 2022 22:41:22 -0400 Subject: [PATCH 278/297] Updated item-nbt-api-plugin from v2.9.2 to v2.10.0. --- docs/changelog_v3.3.x.md | 3 +++ prison-spigot/build.gradle | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 911f3039a..bab96ca63 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11h 2022-06-14 +* **Updated item-nbt-api-plugin from v2.9.2 to v2.10.0.** + + * **v3.3.0-alpha.11h 2022-06-14** diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index b11686d23..9fc0c533d 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -149,7 +149,8 @@ dependencies { // NOTE: This maven repo was failing to be accessable during online builds. So added to the /lib. // https://www.spigotmc.org/resources/nbt-api.7939/ // https://mvnrepository.com/artifact/de.tr7zw/item-nbt-api-plugin - implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2' + implementation 'de.tr7zw:item-nbt-api-plugin:2.10.0' +// implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2' compileOnly fileTree(dir: 'lib', include: ['*.jar'], @@ -209,7 +210,7 @@ shadowJar { include(dependency('com.github.cryptomorin:XSeries:8.7.1')) - include(dependency('de.tr7zw:item-nbt-api-plugin:2.9.2')) + include(dependency('de.tr7zw:item-nbt-api-plugin:2.10.0')) //include(dependency('org.inventivetalent.spiget-update:bukkit:1.4.2-SNAPSHOT')) //include(dependency('me.badbones69:crazyenchantments-plugin:1.8-Dev-Build-v8')) From 5806e92d07b646767aa3eac82c0390694ded2167 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Thu, 16 Jun 2022 23:54:20 -0400 Subject: [PATCH 279/297] Update XSeries to v8.8.0 to better support the newest blocks. --- docs/changelog_v3.3.x.md | 5 ++++- prison-spigot/build.gradle | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index bab96ca63..3ae4b4237 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,10 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11h 2022-06-14 +# 3.3.0-alpha.11h 2022-06-16 + + +* **Update XSeries from v8.7.1 to v8.8.0 to better support the newest blocks.** * **Updated item-nbt-api-plugin from v2.9.2 to v2.10.0.** diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle index 9fc0c533d..c92ce18ff 100644 --- a/prison-spigot/build.gradle +++ b/prison-spigot/build.gradle @@ -116,7 +116,7 @@ dependencies { // implementation 'com.github.cryptomorin:xseries:b95d195482' // https://mvnrepository.com/artifact/com.github.cryptomorin/XSeries - implementation 'com.github.cryptomorin:XSeries:8.7.1' + implementation 'com.github.cryptomorin:XSeries:8.8.0' @@ -208,7 +208,7 @@ shadowJar { include(dependency('me.clip:placeholderapi:2.10.9')) - include(dependency('com.github.cryptomorin:XSeries:8.7.1')) + include(dependency('com.github.cryptomorin:XSeries:8.8.0')) include(dependency('de.tr7zw:item-nbt-api-plugin:2.10.0')) From b25997b5683a90d0d1909bfe65330ce11f5942ef Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Thu, 16 Jun 2022 23:57:50 -0400 Subject: [PATCH 280/297] GUI MInes: Update support for custom lore support within the gui configs. --- docs/changelog_v3.3.x.md | 3 + .../prison/spigot/configs/GuiConfig.java | 47 +++++++++++++++- .../spigot/gui/mine/SpigotPlayerMinesGUI.java | 55 ++++++++++++++++++- 3 files changed, 100 insertions(+), 5 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 3ae4b4237..17ddbd3c5 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11h 2022-06-16 +* **GUI MInes: Update support for custom lore support within the gui configs.** + + * **Update XSeries from v8.7.1 to v8.8.0 to better support the newest blocks.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/GuiConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/GuiConfig.java index 4b0beb1d3..938920fa6 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/GuiConfig.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/GuiConfig.java @@ -72,8 +72,13 @@ public void initialize() { lore.add("&8-----------------------"); lore.add("&7GUI Placeholders are only the following and they are evaluated first "); lore.add("&7so they can be nested in the prison placeholders: "); - lore.add("&7 {rankName} {rankTag} {rankPrice} {rankMultiplier} {ladderName} {linkedMines}"); - lore.add("&7 Not yet available: {mineName} {mineTag} "); + lore.add("&7 "); + lore.add("&7 For Ranks ONLY: "); + lore.add("&7 {rankName} {rankTag} {rankPrice} {rankMultiplier} {ladderName} {linkedMines}"); + lore.add("&7 Not yet available in Ranks: {mineName} {mineTag} "); + lore.add("&7 "); + lore.add("&7 For Mines ONLY: "); + lore.add("&7 {mineName} {mineTag} {mineSize} {mineVolume} {mineRemaining} {mineRemaingPercent} "); lore.add("&8-----------------------"); lore.add("&7Prison placeholders can include any that are within these placeholder "); lore.add("&7Groups: PLAYER, RANKS, RANKPLAYERS, MINES, STATSMINES, and STATSRANKS"); @@ -130,6 +135,44 @@ public void initialize() { changeCount++; } + if (conf.getList("EditableLore.Mines") == null){ + List lore = new ArrayList<>(); + lore.add(" "); + lore.add("&8-----------------------"); + lore.add("&3Mine: &a{mineName} &r{mineTag}"); + lore.add(" "); + lore.add("&3Size: &a{mineSize}"); + lore.add("&3Volume: &a{mineVolume}"); + lore.add("&3Blocks Remaining: &a{mineRemaining} &a{mineRemainingPercent}%"); + lore.add(" "); + lore.add("&8-----------------------"); + + conf.set("EditableLore.Mines", lore); + changeCount++; + } + + + if (conf.getList("EditableLore.Mine.A") == null){ + List lore = new ArrayList<>(); + lore.add(" "); + lore.add("&8-----------------------"); + lore.add("&3Where new players start their awesome adventure!"); + lore.add("&8-----------------------"); + + conf.set("EditableLore.Mine.A", lore); + changeCount++; + } + + if (conf.getList("EditableLore.Mine.Z") == null){ + List lore = new ArrayList<>(); + lore.add(" "); + lore.add("&8-----------------------"); + lore.add("&3Time to get ready to prestige, and restart the fun adventure!"); + lore.add("&8-----------------------"); + + conf.set("EditableLore.Mine.Z", lore); + changeCount++; + } // Count and save diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java index ceed2fb34..3be0b0b33 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java @@ -1,11 +1,15 @@ package tech.mcprison.prison.spigot.gui.mine; +import java.text.DecimalFormat; +import java.util.ArrayList; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.cryptomorin.xseries.XMaterial; +import me.clip.placeholderapi.PlaceholderAPI; import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.mines.data.PrisonSortableResults; @@ -40,6 +44,11 @@ public class SpigotPlayerMinesGUI extends SpigotGUIComponents { private String cmdPage; private String cmdReturn; + private final boolean placeholderAPINotNull = + Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null || + Bukkit.getPluginManager().getPlugin("PlaceholdersAPI") != null; + + public SpigotPlayerMinesGUI(Player p, int page, String cmdPage, String cmdReturn ) { this.p = p; @@ -82,24 +91,36 @@ public void open() { // return; // } + GuiConfig guiConfigClass = new GuiConfig(); + guiConfig = guiConfigClass.getFileGuiConfig(); + String permission = Text.translateAmpColorCodes(permissionWarpPlugin); + // Create GUI. PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), guiConfig.getString("Options.Titles.PlayerMinesGUI")); + + List configCustomLore = guiConfig.getStringList("EditableLore.Mines"); + + // Make the buttons for every Mine with info for (Mine m : minesDisplay) { // for (Mine m : mines.getSortedList()) { // Init the lore array with default values for ladders ButtonLore minesLore = new ButtonLore(); + + + String mineLoreKey = "EditableLore.Mine." + m.getName(); + List mineLore = new ArrayList<>( configCustomLore ); + List mineLore2 = guiConfig.getStringList( mineLoreKey ); + mineLore.addAll( mineLore2 ); + XMaterial xMat = XMaterial.REDSTONE_BLOCK; // Bug: Cannot safely use Material due to variants prior to bukkit v1.13: // Material material; - GuiConfig guiConfigClass = new GuiConfig(); - guiConfig = guiConfigClass.getFileGuiConfig(); - String permission = Text.translateAmpColorCodes(permissionWarpPlugin); // Get Mine Name. String mineName = m.getName(); @@ -157,6 +178,34 @@ public void open() { mineTag = m.getTag(); } + DecimalFormat iFmt = new DecimalFormat( "#,##0" ); + + for (String stringValue : mineLore) { + + double volume = m.getBounds().getArea(); + double remaining = volume * m.getPercentRemainingBlockCount() / 100.0; + + stringValue = stringValue.replace( "{mineName}", m.getName() ); + stringValue = stringValue.replace( "{mineTag}", mineTag ); + stringValue = stringValue.replace( "{mineSize}", m.getBounds().getDimensions() ); + stringValue = stringValue.replace( "{mineVolume}", iFmt.format( volume )); + stringValue = stringValue.replace( "{mineRemaining}", iFmt.format( remaining )); + stringValue = stringValue.replace( "{mineRemainingPercent}", iFmt.format( m.getPercentRemainingBlockCount() )); + + + minesLore.addLineLoreAction( stringValue ); + } + + if ( placeholderAPINotNull ) { + + List lores = PlaceholderAPI.setPlaceholders( + Bukkit.getOfflinePlayer( p.getUniqueId()), + minesLore.getLoreAction()); + + minesLore.setLoreAction( lores ); + } + + // Add the button to the inventory. gui.addButton(new Button(null, xMat, minesLore, "&3" + mineTag)); From ca11846863cf2be6eae59a59482d1d1305c65b6b Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 17 Jun 2022 00:04:06 -0400 Subject: [PATCH 281/297] Placeholders: changed the two top_player line placeholders that are the headings since they originally had _nnn_ pattern that is geting messed up in some settings. So removal of the nnn helped to getting it working. --- docs/changelog_v3.3.x.md | 5 +++++ .../placeholders/PlaceholderManager.java | 20 ++++++++++++------- .../prison/ranks/managers/RankManager.java | 8 ++++---- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 17ddbd3c5..7503e2db2 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11h 2022-06-16 + +* **Placeholders: changed the two top_player line placeholders that are the headings** + since they originally had _nnn_ pattern that is getting messed up in some settings. So removal of the nnn helped to getting it working. + + * **GUI MInes: Update support for custom lore support within the gui configs.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java index 4cf37259b..5c525d890 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java @@ -36,18 +36,24 @@ public enum placeholderFlagType { public enum PlaceholderFlags { + // PlayerManager PLAYER, LADDERS, + + + // RankManager RANKS, RANKPLAYERS, + STATSRANKS( true ), + STATSPLAYERS( true ), + + // MineManager MINES, MINEPLAYERS, PLAYERBLOCKS, - STATSMINES( true ), - STATSRANKS( true ), - STATSPLAYERS( true ), + SUPRESS, @@ -578,8 +584,8 @@ public enum PrisonPlaceHolders { prison_tpl1_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), prison_tpl2_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), - prison_tpl1h_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), - prison_tpl2h_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpl1h__tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), + prison_tpl2h__tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), prison_tpn_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), prison_tprp_nnn_tp( PlaceholderFlags.STATSPLAYERS, PlaceholderFlags.ALIAS ), @@ -595,8 +601,8 @@ public enum PrisonPlaceHolders { prison_top_player_line1_nnn_tp( prison_tpl1_nnn_tp, PlaceholderFlags.STATSPLAYERS ), prison_top_player_line2_nnn_tp( prison_tpl2_nnn_tp, PlaceholderFlags.STATSPLAYERS ), - prison_top_player_line1_headers_nnn_tp( prison_tpl1h_nnn_tp, PlaceholderFlags.STATSPLAYERS ), - prison_top_player_line2_headers_nnn_tp( prison_tpl2h_nnn_tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_line1_headers__tp( prison_tpl1h__tp, PlaceholderFlags.STATSPLAYERS ), + prison_top_player_line2_headers__tp( prison_tpl2h__tp, PlaceholderFlags.STATSPLAYERS ), prison_top_player_name_nnn_tp( prison_tpn_nnn_tp, PlaceholderFlags.STATSPLAYERS ), prison_top_player_rank_prestiges_nnn_tp( prison_tprp_nnn_tp, PlaceholderFlags.STATSPLAYERS ), 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 baa5db815..3bd6f03ba 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 @@ -864,8 +864,8 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { switch ( placeHolder ) { - case prison_top_player_line1_headers_nnn_tp: - case prison_tpl1h_nnn_tp: + case prison_top_player_line1_headers__tp: + case prison_tpl1h__tp: { results = RankPlayer.printRankScoreLine1Header(); } @@ -886,8 +886,8 @@ else if ( placeHolder.hasFlag( PlaceholderFlags.STATSPLAYERS ) ) { } break; - case prison_top_player_line2_headers_nnn_tp: - case prison_tpl2h_nnn_tp: + case prison_top_player_line2_headers__tp: + case prison_tpl2h__tp: { results = RankPlayer.printRankScoreLine2Header(); } From 96eda63fd93d53c653177b4eb53f37957811516a Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 17 Jun 2022 01:13:38 -0400 Subject: [PATCH 282/297] Placeholder stats: A new feature that is tracking usage counts with placeholders. This is not a placeholder cache that caches the results, but it caches the placeholder that is associated with text placeholder. The stats currently only tracks the total number of hits, and the average run time to calculate the placeholder. The pre-cache will reduce some overhead costs. This also provides the framework to hooking up a formal placeholder cache. --- docs/changelog_v3.3.x.md | 6 +- .../tech/mcprison/prison/PrisonCommand.java | 19 ++ .../placeholders/PlaceholderIdentifier.java | 4 + .../placeholders/PlaceholderStatsData.java | 68 ++++ .../placeholders/PlaceholdersStats.java | 128 +++++++ .../placeholder/SpigotPlaceholders.java | 317 +++++++++++------- 6 files changed, 420 insertions(+), 122 deletions(-) create mode 100644 prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderStatsData.java create mode 100644 prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 7503e2db2..8506bcd30 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,9 +11,13 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11h 2022-06-16 +# 3.3.0-alpha.11h 2022-06-17 +* **Placeholder stats: A new feature that is tracking usage counts with placeholders.** +This is not a placeholder cache that caches the results, but it caches the placeholder that is associated with text placeholder. The stats currently only tracks the total number of hits, and the average run time to calculate the placeholder. +The pre-cache will reduce some overhead costs. This also provides the framework to hooking up a formal placeholder cache. + * **Placeholders: changed the two top_player line placeholders that are the headings** since they originally had _nnn_ pattern that is getting messed up in some settings. So removal of the nnn helped to getting it working. 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 de2ca3375..8558117a2 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -50,6 +50,7 @@ import tech.mcprison.prison.output.DisplayComponent; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.output.Output.DebugTarget; +import tech.mcprison.prison.placeholders.PlaceholdersStats; import tech.mcprison.prison.troubleshoot.TroubleshootResult; import tech.mcprison.prison.troubleshoot.Troubleshooter; import tech.mcprison.prison.util.JumboTextFont; @@ -783,6 +784,24 @@ public void placeholdersListCommand(CommandSender sender } + @Command(identifier = "prison placeholders stats", + description = "List all placeholders that have been requested since server startup.", + onlyPlayers = false, permissions = "prison.placeholder") + public void placeholdersStatsCommand(CommandSender sender + ) { + + ChatDisplay display = new ChatDisplay("Placeholders List"); + + ArrayList stats = PlaceholdersStats.getInstance().generatePlaceholderReport(); + + for (String stat : stats) { + display.addText( stat ); + } + + + display.send(sender); + } + @Command(identifier = "prison reload placeholders", description = "Placeholder reload: Regenerates all placeholders and reregisters them.", onlyPlayers = false, permissions = "prison.placeholder") diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java index 09e5d9354..dcff79187 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java @@ -20,6 +20,10 @@ public class PlaceholderIdentifier { /** *

This identifier contains the raw identifier text, minus any placeholder attributes. + * This also can serve as a unique key for the placeholder. In most conditions, it should + * be able to match the placeholder enum. + *

+ * */ private String identifier; diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderStatsData.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderStatsData.java new file mode 100644 index 000000000..a7eb7d4c1 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderStatsData.java @@ -0,0 +1,68 @@ +package tech.mcprison.prison.placeholders; + +public class PlaceholderStatsData { + + private String placeholderId; + + private PlaceHolderKey placeholderKey; +// private PrisonPlaceHolders placeholder; + + private int hits = 0; + + private long totalDurationNanos = 0L; + + private transient final Object lock; + + public PlaceholderStatsData( String placeholderId ) { + super(); + + this.lock = new Object(); + + this.placeholderId = placeholderId; + + } + + public void logHit( long nanoStart, long nanoEnd ) { + long durationNano = nanoEnd - nanoStart; + + synchronized ( lock ) { + hits++; + totalDurationNanos += durationNano; + } + } + + public double getAverageDurationMs() { + double avgMs = totalDurationNanos / hits / 1000000.0d; + + return avgMs; + } + + public String getPlaceholderId() { + return placeholderId; + } + public void setPlaceholderId(String placeholderId) { + this.placeholderId = placeholderId; + } + + public PlaceHolderKey getPlaceholderKey() { + return placeholderKey; + } + public void setPlaceholderKey(PlaceHolderKey placeholderKey) { + this.placeholderKey = placeholderKey; + } + + public int getHits() { + return hits; + } + public void setHits(int hits) { + this.hits = hits; + } + + public long getTotalDurationNanos() { + return totalDurationNanos; + } + public void setTotalDurationNanos(long totalDurationNanos) { + this.totalDurationNanos = totalDurationNanos; + } + +} 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 new file mode 100644 index 000000000..f3277efe7 --- /dev/null +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java @@ -0,0 +1,128 @@ +package tech.mcprison.prison.placeholders; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.TreeMap; + +public class PlaceholdersStats { + + private static PlaceholdersStats stats; + + TreeMap placeholders; + + private PlaceholdersStats() { + super(); + + + this.placeholders = new TreeMap<>(); + } + + public static PlaceholdersStats getInstance() { + + if ( stats == null ) { + synchronized ( PlaceholdersStats.class ) { + if ( stats == null ) { + stats = new PlaceholdersStats(); + } + } + } + + return stats; + } + + + public PlaceholderStatsData getStats( PlaceholderIdentifier pId ) { + PlaceholderStatsData results = null; + + + if ( pId != null ) { + String key = pId.getIdentifier(); + + if ( getPlaceholders().containsKey(key) ) { + results = getPlaceholders().get( key ); + + if ( results.getPlaceholderKey() != null ) { + pId.setPlaceholderKey( results.getPlaceholderKey() ); + } + + } + else { + results = new PlaceholderStatsData( key ); + getPlaceholders().put( key, results ); + } + + } + + return results; + } + + public PlaceholderStatsData setStats( PlaceholderIdentifier pId, PlaceholderStatsData stats, + long nanoStart, long nanoEnd ) { + PlaceholderStatsData results = null; + + + if ( pId != null && stats != null ) { + String key = pId.getIdentifier(); + + if ( stats.getPlaceholderKey() == null && pId.getPlaceholderKey() != null ) { + stats.setPlaceholderKey( pId.getPlaceholderKey() ); + } + + stats.logHit( nanoStart, nanoEnd ); + + // If it contains + if ( !getPlaceholders().containsKey(key) ) { + + + } + + } + + return results; + } + + + public ArrayList generatePlaceholderReport() { + ArrayList results = new ArrayList<>(); + + DecimalFormat iFmt = new DecimalFormat( "#,##0" ); + DecimalFormat dFmt = new DecimalFormat( "#,##0.0000" ); + + results.add( + "&7 Hits Avg/Hit ms Placeholder" ); + + ArrayList keys = new ArrayList<>( getPlaceholders().keySet() ); + Collections.sort( keys ); + for (String key : keys) { + PlaceholderStatsData stats = getPlaceholders().get(key); + + int hits = stats.getHits(); + long totalDurationNano = stats.getTotalDurationNanos(); + double avgMs = totalDurationNano / (double) hits / 1000000d; + + boolean valid = stats.getPlaceholderKey() != null; + + String message = String.format( + "&3%10s %10s %s %s", + iFmt.format( hits ), + dFmt.format( avgMs ), + key, + ( valid ? "" : "&cInvalid: No match.") + ); + results.add( message ); + + } + + return results; + } + + public TreeMap getPlaceholders() { + return placeholders; + } + public void setPlaceholders(TreeMap placeholders) { + this.placeholders = placeholders; + } + + +} 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 ab75074c4..7bc28385d 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 @@ -16,7 +16,9 @@ import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags; import tech.mcprison.prison.placeholders.PlaceholderManager.PrisonPlaceHolders; import tech.mcprison.prison.placeholders.PlaceholderManagerUtils; +import tech.mcprison.prison.placeholders.PlaceholderStatsData; import tech.mcprison.prison.placeholders.Placeholders; +import tech.mcprison.prison.placeholders.PlaceholdersStats; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.managers.PlayerManager; import tech.mcprison.prison.ranks.managers.RankManager; @@ -25,6 +27,35 @@ public class SpigotPlaceholders implements Placeholders { + private MineManager mm = null; + private PlayerManager pm = null; + private RankManager rm = null; + + public SpigotPlaceholders() { + super(); + + } + + + /** + *

After the modules have been loaded, then need to initialize the references to the managers that + * handles the placeholders. + *

+ */ + private void initializePlaceholderManagers() { + + if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { + this.mm = PrisonMines.getInstance().getMineManager(); + } + + if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { + + this.pm = PrisonRanks.getInstance().getPlayerManager(); + + this.rm = PrisonRanks.getInstance().getRankManager(); + } + } + @Override public Map getPlaceholderDetailCounts() { @@ -32,25 +63,18 @@ public Map getPlaceholderDetailCounts() { List placeholders = new ArrayList<>(); - - if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { - PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); - if ( pm != null ) { - placeholders.addAll( pm.getTranslatedPlaceHolderKeys() ); - } - RankManager rm = PrisonRanks.getInstance().getRankManager(); - if ( rm != null ) { - placeholders.addAll( rm.getTranslatedPlaceHolderKeys() ); - } + if ( pm != null ) { + placeholders.addAll( pm.getTranslatedPlaceHolderKeys() ); } - - if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { - MineManager mm = PrisonMines.getInstance().getMineManager(); - if ( mm != null ) { - placeholders.addAll( mm.getTranslatedPlaceHolderKeys() ); - } + + if ( rm != null ) { + placeholders.addAll( rm.getTranslatedPlaceHolderKeys() ); } + if ( mm != null ) { + placeholders.addAll( mm.getTranslatedPlaceHolderKeys() ); + } + for ( PlaceHolderKey phKey : placeholders ) { for ( PlaceholderFlags flag : phKey.getPlaceholder().getFlags() ) { @@ -71,29 +95,21 @@ public Map getPlaceholderDetailCounts() { public int getPlaceholderCount() { int placeholdersRawCount = 0; - if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { - PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); - if ( pm != null ) { - List placeholderPlayerKeys = pm.getTranslatedPlaceHolderKeys(); - placeholdersRawCount += placeholderPlayerKeys.size(); - - } - RankManager rm = PrisonRanks.getInstance().getRankManager(); - if ( rm != null ) { - List placeholderPlayerKeys = rm.getTranslatedPlaceHolderKeys(); - placeholdersRawCount += placeholderPlayerKeys.size(); - - } + if ( pm != null ) { + List placeholderPlayerKeys = pm.getTranslatedPlaceHolderKeys(); + placeholdersRawCount += placeholderPlayerKeys.size(); + } - - if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { - MineManager mm = PrisonMines.getInstance().getMineManager(); - if ( mm != null ) { - List placeholderMinesKeys = mm.getTranslatedPlaceHolderKeys(); - placeholdersRawCount += placeholderMinesKeys.size(); - - } + if ( rm != null ) { + List placeholderPlayerKeys = rm.getTranslatedPlaceHolderKeys(); + placeholdersRawCount += placeholderPlayerKeys.size(); + + } + + if ( mm != null ) { + List placeholderMinesKeys = mm.getTranslatedPlaceHolderKeys(); + placeholdersRawCount += placeholderMinesKeys.size(); } @@ -104,43 +120,34 @@ public int getPlaceholderCount() { public int getPlaceholderRegistrationCount() { int placeholdersRegistered = 0; - if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { - PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); - if ( pm != null ) { - List placeholderPlayerKeys = pm.getTranslatedPlaceHolderKeys(); - - for ( PlaceHolderKey placeHolderKey : placeholderPlayerKeys ) { - if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { - placeholdersRegistered++; - } + if ( pm != null ) { + List placeholderPlayerKeys = pm.getTranslatedPlaceHolderKeys(); + + for ( PlaceHolderKey placeHolderKey : placeholderPlayerKeys ) { + if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { + placeholdersRegistered++; } } - RankManager rm = PrisonRanks.getInstance().getRankManager(); - if ( rm != null ) { - List placeholderPlayerKeys = rm.getTranslatedPlaceHolderKeys(); - - for ( PlaceHolderKey placeHolderKey : placeholderPlayerKeys ) { - if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { - placeholdersRegistered++; - } + } + + if ( rm != null ) { + List placeholderPlayerKeys = rm.getTranslatedPlaceHolderKeys(); + + for ( PlaceHolderKey placeHolderKey : placeholderPlayerKeys ) { + if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { + placeholdersRegistered++; } } - } - - if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { - MineManager mm = PrisonMines.getInstance().getMineManager(); - if ( mm != null ) { - List placeholderMinesKeys = mm.getTranslatedPlaceHolderKeys(); - - for ( PlaceHolderKey placeHolderKey : placeholderMinesKeys ) { - if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { - placeholdersRegistered++; - } + if ( mm != null ) { + List placeholderMinesKeys = mm.getTranslatedPlaceHolderKeys(); + + for ( PlaceHolderKey placeHolderKey : placeholderMinesKeys ) { + if ( !placeHolderKey.getPlaceholder().isSuppressed() ) { + placeholdersRegistered++; } } - } return placeholdersRegistered; @@ -193,31 +200,50 @@ public String placeholderTranslateText( String text) { } public String placeholderTranslateText( PlaceholderIdentifier identifier ) { + + long nanoStart = System.nanoTime(); + + PlaceholderStatsData stats = PlaceholdersStats.getInstance().getStats( identifier ); + + String results = null; + + if ( identifier.getPlaceholderKey() == null ) { + + results = placeholderTranslateTextSearchForPlaceholder( identifier ); + } + else { + + results = placeholderTranslateTextHavePlaceholder( identifier ); + } + + long nanoEnd = System.nanoTime(); + + PlaceholdersStats.getInstance().setStats( identifier, stats, nanoStart, nanoEnd ); + + return results; + } + + public String placeholderTranslateTextSearchForPlaceholder( PlaceholderIdentifier identifier ) { // String results = text; - if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { - MineManager mm = PrisonMines.getInstance().getMineManager(); - - if ( mm != null ) { - - List placeholderKeys = mm.getTranslatedPlaceHolderKeys(); - - for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { - - if ( identifier.checkPlaceholderKey( placeHolderKey ) ) { - mm.getTranslateMinesPlaceholder( identifier ); - break; - } - - } - } - } + if ( mm != null ) { + + List placeholderKeys = mm.getTranslatedPlaceHolderKeys(); + + for ( PlaceHolderKey placeHolderKey : placeholderKeys ) { + + if ( identifier.checkPlaceholderKey( placeHolderKey ) ) { + mm.getTranslateMinesPlaceholder( identifier ); + break; + } + + } + } + - if ( !identifier.isFoundAMatch() && !identifier.isFoundAMatch() && - PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { + if ( !identifier.isFoundAMatch() ) { - PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); if ( pm != null ) { List placeholderKeys = pm.getTranslatedPlaceHolderKeys(); @@ -232,8 +258,6 @@ public String placeholderTranslateText( PlaceholderIdentifier identifier ) { } } - - RankManager rm = PrisonRanks.getInstance().getRankManager(); if ( !identifier.isFoundAMatch() && rm != null ) { @@ -254,6 +278,51 @@ public String placeholderTranslateText( PlaceholderIdentifier identifier ) { return identifier.getText(); } + public String placeholderTranslateTextHavePlaceholder( PlaceholderIdentifier identifier ) { + + PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); + + if ( mm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) + )) { + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + mm.getTranslateMinesPlaceholder(identifier); + } + + } + else if ( pm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ) + )) { + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + pm.getTranslatePlayerPlaceHolder( identifier ); + } + + } + else if ( rm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) + )) { + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + rm.getTranslateRanksPlaceHolder( identifier ); + } + + } + + + return identifier.getText(); + } + // /** // * This provides for a case insensitive replacement of placeholders. // * @@ -342,42 +411,42 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin identifier.setPlayer(playerUuid, playerName); - String value = null; + String value = placeholderTranslateTextHavePlaceholder( identifier ); // Note: STATSMINES will not work here since the sequence is not being addressed. - if ( mm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) - )) { - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { - - value = mm.getTranslateMinesPlaceholder(identifier); - } - - } - else if ( pm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ))) { - - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { - - value = pm.getTranslatePlayerPlaceHolder( identifier ); - } - - } - else if ( rm != null && - (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) ) { - - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { - - value = rm.getTranslateRanksPlaceHolder( identifier ); - } - - } +// if ( mm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) +// )) { +// if ( identifier.checkPlaceholderKey(placeHolderKey) ) { +// +// value = mm.getTranslateMinesPlaceholder(identifier); +// } +// +// } +// else if ( pm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ))) { +// +// if ( identifier.checkPlaceholderKey(placeHolderKey) ) { +// +// value = pm.getTranslatePlayerPlaceHolder( identifier ); +// } +// +// } +// else if ( rm != null && +// (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || +// placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) ) ) { +// +// if ( identifier.checkPlaceholderKey(placeHolderKey) ) { +// +// value = rm.getTranslateRanksPlaceHolder( identifier ); +// } +// +// } String placeholderAlias = ( placeHolderKey.getAliasName() == null ? null : "{" + placeHolderKey.getAliasName() + "}"); @@ -444,12 +513,18 @@ public void reloadPlaceholders() { PlaceholderManagerUtils.getInstance().reloadPlaceholderBarConfig(); + + initializePlaceholderManagers(); if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) { PlayerManager pm = PrisonRanks.getInstance().getPlayerManager(); if ( pm != null ) { pm.reloadPlaceholders(); } + + if ( rm != null ) { + rm.reloadPlaceholders(); + } } if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) { From e84918e0e4b081a087737ebe252f92f7a97c912a Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 17 Jun 2022 20:58:07 -0400 Subject: [PATCH 283/297] v3.3.0-alpha.11i --- docs/changelog_v3.3.x.md | 3 +++ gradle.properties | 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 8506bcd30..e492b8494 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,6 +13,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11h 2022-06-17 +* **v3.3.0-alpha.11i** +Getting ready to release alpha.12. + * **Placeholder stats: A new feature that is tracking usage counts with placeholders.** This is not a placeholder cache that caches the results, but it caches the placeholder that is associated with text placeholder. The stats currently only tracks the total number of hits, and the average run time to calculate the placeholder. diff --git a/gradle.properties b/gradle.properties index b0c79be61..925e902de 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.11h +version=3.3.0-alpha.11i From 6b73f9fa2c621366c933c1a6b943d7cc2a204ce6 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 17 Jun 2022 21:02:40 -0400 Subject: [PATCH 284/297] Updates to the prison placeholder handler. This fixes a bug with chat messages return a null value. These changes also allows the pre-cache to track invalid placeholders now, so it can fast-fail them so it does not have to waste CPU time trying to look up which placeholder key they are tied to. --- docs/changelog_v3.3.x.md | 5 + .../tech/mcprison/prison/PrisonCommand.java | 2 +- .../placeholders/PlaceholderIdentifier.java | 27 ++- .../placeholders/PlaceholderStatsData.java | 11 + .../prison/placeholders/Placeholders.java | 6 +- .../placeholders/PlaceholdersStats.java | 40 +++- .../PlaceholderIdentifierTest.java | 4 +- .../placeholder/SpigotPlaceholders.java | 188 ++++++++++++------ 8 files changed, 206 insertions(+), 77 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index e492b8494..2ead85783 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -13,6 +13,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11h 2022-06-17 + +* **Updates to the prison placeholder handler. This fixes a bug with chat messages return a null value.** +These changes also allows the pre-cache to track invalid placeholders now, so it can fast-fail them so it does not have to waste CPU time trying to look up which placeholder key they are tied to. + + * **v3.3.0-alpha.11i** Getting ready to release alpha.12. 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 8558117a2..bae6c2bd7 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java +++ b/prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java @@ -795,7 +795,7 @@ public void placeholdersStatsCommand(CommandSender sender ArrayList stats = PlaceholdersStats.getInstance().generatePlaceholderReport(); for (String stat : stats) { - display.addText( stat ); + display.addText( stat.replace( "%", "%%") ); } diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java index dcff79187..1d48eee65 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java @@ -41,6 +41,8 @@ public class PlaceholderIdentifier { private Player player; private boolean foundAMatch; + private boolean missingPrisonPrefix; + private PlaceHolderKey placeholderKey; private String text; @@ -64,6 +66,8 @@ public PlaceholderIdentifier( String identifier ) { this.player = null; this.foundAMatch = false; + this.missingPrisonPrefix = false; + this.placeholderKey = null; this.text = null; @@ -96,7 +100,12 @@ private void intialize() { // Some plugins that handle the placeholders omit the prefix. If that's the case, then // add it back. if ( !identifier.startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; + + this.missingPrisonPrefix = true; + + // Do not modify the identifier... will adjust the identifier when comparing to the + // PlaceholderKey object: +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; } @@ -143,11 +152,16 @@ public boolean checkPlaceholderKey(PlaceHolderKey placeHolderKey) { String key = placeHolderKey.getKey().toLowerCase(); - if ( getIdentifier().equalsIgnoreCase( key ) ) { + // If the placeholder was missing the Prison prefix ( prison_ ) then add it before + // checking to see if there is a match: + String adjustedIdentifier = (isMissingPrisonPrefix() ? + PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED : "") + + getIdentifier(); + + if ( adjustedIdentifier.equalsIgnoreCase( key ) ) { setPlaceholderKey( placeHolderKey ); results = true; - } return results; @@ -291,6 +305,13 @@ public void setFoundAMatch(boolean foundAMatch) { this.foundAMatch = foundAMatch; } + public boolean isMissingPrisonPrefix() { + return missingPrisonPrefix; + } + public void setMissingPrisonPrefix(boolean missingPrisonPrefix) { + this.missingPrisonPrefix = missingPrisonPrefix; + } + public PlaceHolderKey getPlaceholderKey() { return placeholderKey; } diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderStatsData.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderStatsData.java index a7eb7d4c1..250f7f034 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderStatsData.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderStatsData.java @@ -11,6 +11,8 @@ public class PlaceholderStatsData { private long totalDurationNanos = 0L; + private boolean failedMatch; + private transient final Object lock; public PlaceholderStatsData( String placeholderId ) { @@ -20,6 +22,7 @@ public PlaceholderStatsData( String placeholderId ) { this.placeholderId = placeholderId; + this.failedMatch = false; } public void logHit( long nanoStart, long nanoEnd ) { @@ -65,4 +68,12 @@ public void setTotalDurationNanos(long totalDurationNanos) { this.totalDurationNanos = totalDurationNanos; } + public boolean isFailedMatch() { + return failedMatch; + } + public void setFailedMatch(boolean failedMatch) { + this.failedMatch = failedMatch; + } + + } diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/Placeholders.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/Placeholders.java index 331bd1849..dc970203a 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/Placeholders.java +++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/Placeholders.java @@ -8,6 +8,10 @@ public interface Placeholders { + +// public void initializePlaceholderManagers(); + + public Map getPlaceholderDetailCounts(); @@ -20,7 +24,7 @@ public interface Placeholders { public String placeholderTranslate(UUID playerUuid, String playerName, String identifier); - public String placeholderTranslateText( String text); +// pu-blic String placeholderTranslateText( String text); public String placeholderTranslateText( UUID playerUuid, String playerName, String text); 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 f3277efe7..716de89b7 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 @@ -50,6 +50,11 @@ public PlaceholderStatsData getStats( PlaceholderIdentifier pId ) { else { results = new PlaceholderStatsData( key ); getPlaceholders().put( key, results ); + + // Store this new stats object in the cache. If there is a placeholder fail, then + // this will help prevent going through all of the calculations for future + // hits. + getPlaceholders().put( key, results ); } } @@ -57,13 +62,29 @@ public PlaceholderStatsData getStats( PlaceholderIdentifier pId ) { return results; } + + /** + *

This function will record the stats, which is the nano runtime, and also store the + * PlaceholderKey in the Stats if it's not null. + *

+ * + *

The stats object has already been stored in the cache so there is no reason to + * add it again. + *

+ * + * @param pId + * @param stats + * @param nanoStart + * @param nanoEnd + * @return + */ public PlaceholderStatsData setStats( PlaceholderIdentifier pId, PlaceholderStatsData stats, long nanoStart, long nanoEnd ) { PlaceholderStatsData results = null; if ( pId != null && stats != null ) { - String key = pId.getIdentifier(); + //String key = pId.getIdentifier(); if ( stats.getPlaceholderKey() == null && pId.getPlaceholderKey() != null ) { stats.setPlaceholderKey( pId.getPlaceholderKey() ); @@ -71,12 +92,18 @@ public PlaceholderStatsData setStats( PlaceholderIdentifier pId, PlaceholderStat stats.logHit( nanoStart, nanoEnd ); - // If it contains - if ( !getPlaceholders().containsKey(key) ) { - + if ( !pId.isFoundAMatch() ) { + stats.setFailedMatch( true ); } + +// // If it contains +// if ( !getPlaceholders().containsKey(key) ) { +// +// +// } + } return results; @@ -108,7 +135,10 @@ public ArrayList generatePlaceholderReport() { iFmt.format( hits ), dFmt.format( avgMs ), key, - ( valid ? "" : "&cInvalid: No match.") + ( valid ? "" : + stats.isFailedMatch() ? + "&cInvalid: bypassing lookups." : + "&cInvalid: No match.") ); results.add( message ); diff --git a/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceholderIdentifierTest.java b/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceholderIdentifierTest.java index 84e58997c..ff3cfa30b 100644 --- a/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceholderIdentifierTest.java +++ b/prison-core/src/test/java/tech/mcprison/prison/placeholders/PlaceholderIdentifierTest.java @@ -47,7 +47,7 @@ public void testPlaceholders() { PlaceholderIdentifier t4 = new PlaceholderIdentifier( "simple" ); assertNotNull( t4.getIdentifier() ); - assertEquals( "prison_simple", t4.getIdentifier() ); + assertEquals( "simple", t4.getIdentifier() ); assertEquals( "simple", t4.getOriginalIdentifier() ); PlaceholderIdentifier t5 = new PlaceholderIdentifier( "{prison_simple}" ); @@ -61,7 +61,7 @@ public void testPlaceholders() { PlaceholderIdentifier t6 = new PlaceholderIdentifier( "{simple}" ); assertNotNull( t6.getIdentifier() ); - assertEquals( "prison_simple", t6.getIdentifier() ); + assertEquals( "simple", t6.getIdentifier() ); assertEquals( "{", t6.getEscapeLeft() ); assertEquals( "}", t6.getEscapeRight() ); assertEquals( "{simple}", t6.getOriginalIdentifier() ); 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 7bc28385d..c8cce41f1 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 @@ -6,6 +6,8 @@ import java.util.Set; import java.util.TreeMap; import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import tech.mcprison.prison.Prison; import tech.mcprison.prison.mines.PrisonMines; @@ -31,6 +33,18 @@ public class SpigotPlaceholders private PlayerManager pm = null; private RankManager rm = null; + + // NOTE: These patterns are from: + // https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java + + // We want to include the placeholder escape characters in group 1: + private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("([%]([^%]+)[%])"); + private static final Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("([{]([^{}]+)[}])"); + +// private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]"); +// private static final Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("[{]([^{}]+)[}]"); + + public SpigotPlaceholders() { super(); @@ -178,28 +192,29 @@ public int getPlaceholderRegistrationCount() { * */ @Override - public String placeholderTranslate( UUID playerUuid, String playerName, String text ) { - PlaceholderIdentifier identifier = new PlaceholderIdentifier( text ); + public String placeholderTranslate( UUID playerUuid, String playerName, String placeholderText ) { + PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeholderText ); identifier.setPlayer(playerUuid, playerName); - return placeholderTranslateText( identifier ); + return processPlaceholderIdentifier( identifier ); } - - /** - *

This function is used in this class's placeholderTranslateText() and - * also in tech.mcprison.prison.mines.MinesChatHandler.onPlayerChat(). - *

- * - */ - @Override - public String placeholderTranslateText( String text) { - PlaceholderIdentifier identifier = new PlaceholderIdentifier( text ); - - - return placeholderTranslateText( identifier ); - } + + // NOTE: This is obsolete since the player should always be included: +// /** +// *

This function is used in this class's placeholderTranslateText() and +// * also in tech.mcprison.prison.mines.MinesChatHandler.onPlayerChat(). +// *

+// * +// */ +// @Override +// public String placeholderTranslateText( String text) { +// PlaceholderIdentifier identifier = new PlaceholderIdentifier( text ); +// +// +// return placeholderTranslateText( identifier ); +// } - public String placeholderTranslateText( PlaceholderIdentifier identifier ) { + private String processPlaceholderIdentifier( PlaceholderIdentifier identifier ) { long nanoStart = System.nanoTime(); @@ -207,23 +222,28 @@ public String placeholderTranslateText( PlaceholderIdentifier identifier ) { String results = null; - if ( identifier.getPlaceholderKey() == null ) { + if ( !stats.isFailedMatch() ) { - results = placeholderTranslateTextSearchForPlaceholder( identifier ); - } - else { + if ( identifier.getPlaceholderKey() == null ) { + + results = processPlaceholderSearchForPlaceholderKey( identifier ); + } + else { + + results = processPlaceholderHavePlaceholderKey( identifier ); + } - results = placeholderTranslateTextHavePlaceholder( identifier ); } - + long nanoEnd = System.nanoTime(); PlaceholdersStats.getInstance().setStats( identifier, stats, nanoStart, nanoEnd ); - return results; + + return results == null ? "" : results; } - public String placeholderTranslateTextSearchForPlaceholder( PlaceholderIdentifier identifier ) { + private String processPlaceholderSearchForPlaceholderKey( PlaceholderIdentifier identifier ) { // String results = text; @@ -278,7 +298,7 @@ public String placeholderTranslateTextSearchForPlaceholder( PlaceholderIdentifie return identifier.getText(); } - public String placeholderTranslateTextHavePlaceholder( PlaceholderIdentifier identifier ) { + private String processPlaceholderHavePlaceholderKey( PlaceholderIdentifier identifier ) { PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); @@ -288,37 +308,38 @@ public String placeholderTranslateTextHavePlaceholder( PlaceholderIdentifier ide placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) )) { - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { - mm.getTranslateMinesPlaceholder(identifier); - } + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + mm.getTranslateMinesPlaceholder(identifier); + } - } - else if ( pm != null && - (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ) - )) { - - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + } + else if ( pm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ) + )) { + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + pm.getTranslatePlayerPlaceHolder( identifier ); + } - pm.getTranslatePlayerPlaceHolder( identifier ); } - - } - else if ( rm != null && - (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) - )) { - - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + else if ( rm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) + )) { + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + rm.getTranslateRanksPlaceHolder( identifier ); + } - rm.getTranslateRanksPlaceHolder( identifier ); } - - } - + return identifier.getText(); } @@ -344,26 +365,63 @@ else if ( rm != null && /** - *

Since a player UUID is provided, first translate for any possible - * player specific placeholder, then try to translate for any mine - * related placeholder. + *

The rawText passed to this function may have zero, one, or more placeholders included + * in the String. The rawText will mostly contain more than just placeholders, and must be + * returned. *

* - *

This function is used with the command: /prison placeholders test - *

+ *

This function is used in the following locations:

+ *
    + *
  • + * With the command: /prison placeholders test + *
  • + *
  • + * tech.mcprison.prison.mines.MinesChatHandler.onPlayerChat(); + *
  • + *
  • + * The Rank chat handler + *
  • + *
* * @param playerUuid * @param text * @return */ @Override - public String placeholderTranslateText( UUID playerUuid, String playerName, String text) { - - PlaceholderIdentifier identifier = new PlaceholderIdentifier( text ); - identifier.setPlayer(playerUuid, playerName); - - return placeholderTranslateText( identifier ); - } + public String placeholderTranslateText(UUID playerUuid, String playerName, String rawText) { + String results = rawText; + + // First check for % % placeholders: + + final Matcher matcher = PLACEHOLDER_PATTERN.matcher(results); + + results = replaceAllPlaceholders( playerUuid, playerName, results, matcher ); + + final Matcher matcher2 = BRACKET_PLACEHOLDER_PATTERN.matcher(results); + + results = replaceAllPlaceholders( playerUuid, playerName, results, matcher2 ); + + return results; + } + + + private String replaceAllPlaceholders(UUID playerUuid, String playerName, String rawText, final Matcher matcher) { + String results = rawText; + + while (matcher.find()) { + final String placeholderText = matcher.group(1); + + PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeholderText ); + identifier.setPlayer(playerUuid, playerName); + + String replacementText = processPlaceholderIdentifier(identifier); + if ( identifier.isFoundAMatch() ) { + results = results.replace( placeholderText, replacementText ); + } + + } + return results; + } /** @@ -411,7 +469,7 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin identifier.setPlayer(playerUuid, playerName); - String value = placeholderTranslateTextHavePlaceholder( identifier ); + String value = processPlaceholderHavePlaceholderKey( identifier ); // Note: STATSMINES will not work here since the sequence is not being addressed. From fcf4ac597bb4d95371603e9f880da479f1e93430 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 17 Jun 2022 21:09:04 -0400 Subject: [PATCH 285/297] Since the chat event is handled within the spigot module, and since ranks and mines would just duplicate the processing since they both will hit the SpigotPlaceholder class, it made sense to handle the chat event directly within the spigot module. --- docs/changelog_v3.3.x.md | 3 ++ .../prison/mines/MinesChatHandler.java | 11 ++++++- .../prison/spigot/SpigotListener.java | 29 ++++++++++++++----- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 2ead85783..e736d2fdf 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11h 2022-06-17 +* **Since the chat event is handled within the spigot module, and since ranks and mines would just duplicate the processing since they both will hit the SpigotPlaceholder class, it made sense to handle the chat event directly within the spigot module.** + + * **Updates to the prison placeholder handler. This fixes a bug with chat messages return a null value.** These changes also allows the pre-cache to track invalid placeholders now, so it can fast-fail them so it does not have to waste CPU time trying to look up which placeholder key they are tied to. diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/MinesChatHandler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/MinesChatHandler.java index 7d11051b7..21c561ba7 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/MinesChatHandler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/MinesChatHandler.java @@ -3,6 +3,7 @@ import com.google.common.eventbus.Subscribe; import tech.mcprison.prison.Prison; +import tech.mcprison.prison.internal.Player; import tech.mcprison.prison.internal.events.player.PlayerChatEvent; public class MinesChatHandler { @@ -14,11 +15,19 @@ public MinesChatHandler() { @Subscribe public void onPlayerChat(PlayerChatEvent e) { +// String message = e.getMessage(); String newFormat = e.getFormat(); + Player player = e.getPlayer(); + // Now translates + String translated = Prison.get().getPlatform().getPlaceholders() - .placeholderTranslateText( newFormat ); + .placeholderTranslateText( player.getUUID(), player.getName(), newFormat ); + + +// String translated = Prison.get().getPlatform().getPlaceholders() +// .placeholderTranslateText( newFormat ); e.setFormat( translated ); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java index 7d1be0f33..f4bdcb071 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotListener.java @@ -58,6 +58,7 @@ import tech.mcprison.prison.spigot.game.SpigotWorld; import tech.mcprison.prison.util.ChatColor; import tech.mcprison.prison.util.Location; +import tech.mcprison.prison.util.Text; /** * Posts Prison's internal events. @@ -302,15 +303,27 @@ public class OnPlayerChatListener @EventHandler(priority=EventPriority.NORMAL) public void onPlayerChat(AsyncPlayerChatEvent e) { - PlayerChatEvent event = - new PlayerChatEvent(new SpigotPlayer(e.getPlayer()), e.getMessage(), e.getFormat()); - - Prison.get().getEventBus().post(event); - - e.setFormat(ChatColor.translateAlternateColorCodes('&', event.getFormat() + "&r")); - e.setMessage(event.getMessage()); + String message = e.getMessage(); + String format = e.getFormat(); + + SpigotPlayer p = new SpigotPlayer( e.getPlayer() ); + + String results = Prison.get().getPlatform().getPlaceholders() + .placeholderTranslateText( p.getUUID(), p.getName(), format ); + + + String translated = Text.translateAmpColorCodes( results + "&r" ); + e.setFormat( translated ); + +// PlayerChatEvent event = +// new PlayerChatEvent(new SpigotPlayer(e.getPlayer()), message, format); +// +// Prison.get().getEventBus().post(event); - doCancelIfShould(event, e); +// e.setFormat(ChatColor.translateAlternateColorCodes('&', event.getFormat() + "&r")); +// e.setMessage(event.getMessage()); +// +// doCancelIfShould(event, e); } } From c124d8369ab33c4fb54fa523c372f98bc6c34154 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 17 Jun 2022 21:16:32 -0400 Subject: [PATCH 286/297] v3.3.0-alpha.11j 2022-06-17 --- 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 e736d2fdf..2384676c4 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11h 2022-06-17 +# 3.3.0-alpha.11j 2022-06-17 + + + +* **v3.3.0-alpha.11j** * **Since the chat event is handled within the spigot module, and since ranks and mines would just duplicate the processing since they both will hit the SpigotPlaceholder class, it made sense to handle the chat event directly within the spigot module.** diff --git a/gradle.properties b/gradle.properties index 925e902de..9af9cc69d 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.11i +version=3.3.0-alpha.11j From b27d9bd78108100874735afff3b74e3ec5f7b09a Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Fri, 17 Jun 2022 21:32:40 -0400 Subject: [PATCH 287/297] Update some of the docs on setting up luckperms and tracks. --- docs/changelog_v3.3.x.md | 3 + ...prison_docs_030_LuckPerms_Groups_Tracks.md | 263 +++++++++++++++++- 2 files changed, 259 insertions(+), 7 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 2384676c4..9380ef976 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -15,6 +15,9 @@ These build logs represent the work that has been going on within prison. +* **Update some of the docs on setting up luckperms and tracks.** + + * **v3.3.0-alpha.11j** diff --git a/docs/prison_docs_030_LuckPerms_Groups_Tracks.md b/docs/prison_docs_030_LuckPerms_Groups_Tracks.md index 57f445b3e..eabfd3b5e 100644 --- a/docs/prison_docs_030_LuckPerms_Groups_Tracks.md +++ b/docs/prison_docs_030_LuckPerms_Groups_Tracks.md @@ -7,7 +7,7 @@ This document provides an overview to help setup LuckPerms groups and tracks. -*Documented updated: 2021-12-19* +*Documented updated: 2022-06-17*
@@ -21,7 +21,8 @@ Setup LuckPerms as needed. Information on where to download it can be found her [Setting Up LuckPerms](prison_docs_020_setting_up_luckperms.md) -Other plugin... +Below are detailed steps on how to configure both Prison and LuckPerms. +
@@ -44,7 +45,7 @@ Since Prison needs to use their own ranks, and is not directly tied to LuckPerms
-# Using Prison Rank Commands with Groups and Tracks +# Using Prison Rank Commands with Groups and Tracks - An Overview Since LuckPerm Groups and Tracks must be synchronized with Prison Ranks, the Prison Rank Commands are used to provide this linkage through Prison Rank Commands. This allows the player to control when they rankup within Prison, which then synchronizes the LuckPerms' Track. @@ -62,6 +63,21 @@ As a quick review, to get more help about the prison rank commands. The `help` ``` /ranks command add help /ranks command add placeholders +/ranks ladder command add help +/ranks ladder command add placeholders +``` + + +Prison has various commands, such as Rank Commands, Ladder Commands, Mine Reset Commands, Block Even Commands, and etc.. Each type of command set has it own unique combination of command placeholders. It's very important to review the list of placeholders since they can be used to inject those values in to the commands before prison runs them. + +Here is an example of the placeholders for Rank and Ladder Commands: + +``` +{player} {player_uid} {msg} {broadcast} {title} {actionBar} +{inline} {inlinePlayer} {sync} {syncPlayer} {firstJoin} +{promote} {demote} {balanceInitial} {balanceFinal} {currency} +{originalRankCost} {rankupCost} {ladder} {rank} {rankTag} +{targetRank} {targetRankTag} ``` @@ -74,7 +90,7 @@ The following is how you would setup a Prison rank command to use tracks. Setting up these rank commands, will cause Prison to run these commands when the player ranks up. -So in review, this are two examples of rankup commands for a player who joins the server for the first time, are demoted back to A, or the prestiged and are reset to rank A. The Prison rank is named `A` and so is the LuckPerms group. The first command is for setups with no tracks, and the second is for tracks; insert the track's name for `[track]`. If you name your track `PrisonRanks`, with the Track's Groups named the same as the Prison Ranks. +So in review, these are two examples of rankup commands for a player who joins the server for the first time, are demoted back to A, or the prestiged and are reset to rank A. The Prison rank is named `A` and so is the LuckPerms group. The first command is for setups with no tracks, and the second is for tracks; insert the track's name for `[track]`. If you name your track `PrisonRanks`, with the Track's Groups named the same as the Prison Ranks. ``` @@ -107,20 +123,246 @@ For example, where `P1` is the Prestige 1 rank:
-# The Suggested Way to Setup LuckPerms Groups and Tracks +# The Suggested Way to Setup LuckPerms Groups and Tracks - An Overview -Although there are many ways to configure any plugin, these suggestions tries to keep things simple through using the same names as the counter parts between Prison and LuckPerms. It may be slightly confusion which is which, as far as Prison or LuckPerms, but it makes it easier by being consistent with the same names for the similar parts. +Although there are many ways to configure any plugin, these suggestions tries to keep things simple by using the same names as the counter parts between Prison and LuckPerms. It may be slightly confusion which is which, as far as Prison or LuckPerms, but it makes it easier by being consistent with the same names for the similar parts. The best way to setup LuckPerms Groups is to make 1 group for every Prison Rank. Then use the Rank Commands to assign users to that group automatically when they rankup. Then to tie things together within LuckPerms, place these created LuckPerms Groups on a LuckPerms Track. +**Step 1 : Configure Prison's Ranks and Mines** + If you have not done so already, the best option to get started with Prison, is to run `/ranks autoConfigure`. That provides so much of the basic configurations and can save you hours just trying to get the basics setup. You can always change the default settings later to fine tune your setup. The command `/ranks autoConfigure` will create Ranks and Mines with names from A through Z. It will also create the first 10 Prestige ranks with the names P01 through P10. +Prison will name the ranks with one letter, and it they will be upper case. Therefore, when defining the groups within LuckPerms, name the groups exactly the same way as the ranks. LuckPerms does not allow the group name to use any upper case characters, so they will be lower case, which is perfectly fine. + + +Prison will also link each Mine to the Rank of the same name. Prison will also enable **Mine Access by Rank**, and **TP Access by Rank** too. This is very important. + +If you did not run `/ranks autoconfigure`, you can auto link the mines and ranks, assuming they both have the same name, with the following commands: + +``` +/mines set rank help +/mines set mineaccessbyrank help +/mines set tpaccessbyrank help + +/mines set rank a a +/mines set rank b b +(repeat for all mines and ranks) + +/mines set mineaccessbyrank *all* enable +/mines set tpaccessbyrank *all* enable + +``` + + + +**Step 2 : Create the LuckPerms Groups using the LP Editor** + +Create a new group in LuckPerms for each Rank within Prison. + + +We suggest that you should use the LP editor, which makes it easier to perform admin tasks. To open a new editor session, use the command `/lp editor` then click on the hyperlink, or copy and paste it to your browser. + + +Within the LP Web Permissions Editor, to the left of the page is a left-navigation section with expandable topics of: Tracks, Groups, and Users. To the right of the Groups section is a plus sign "+", click on that to add a new group. + + +To create your first group, give it a name of "a" and a display name of "A". The display name is not intended for using color codes, or anything fancy. Click on "Add Group" to create the group. + +(screen print: ) + +Then create group b. But this time, have it list Group A as the parent. + +(screen print: ) + + +Repeat creating all the groups, where group z will be the last one. +. + +Save it. Click the save icon in the upper right hand corner. It will give you a code to apply the changes. Click the code to copy it to your clipboard, then paste it in game, or in the server's console. Close the browser window for that editor (once you apply the changes, never use the same editor session again... create a new one). + + + +**Step 2 : Create the LuckPerms Group using Commands** + +NOTE: Ignore these steps if you are using the LP Editor. + +You can use the `/lp creategroup ` command. Create a group for A, then when you create a group for B, you will have to set group A as the parent for Group B. Setting a display name is optional and not needed, but is shown here to "mirror" what is being generated within the LP Web Permission Editor. + + +Here are the commands: + +``` +/lp creategroup a +/lp group a setdisplayname A + +/lp creategroup b +/lp group b setdisplayname B +/lp group b parent add a + +/lp creategroup c +/lp group c setdisplayname C +/lp group c parent add b + +... etc ... + +/lp creategroup z +/lp group z setdisplayname Z +/lp group z parent add y +``` + + +**Step 3: Create LP Tracks using LP Editor** + + +Open a new LP Web Permission editor: `/lp editor`. + + +Click the plus (+) button to the right of the heading **Tracks** to create a new LP track. + +Name the new track "mine-ranks". It will be shown in all upper case: MINE-RANKS. + +(screen print) + +You "must" click on each rank in alphabetical order to add it to the track's list. You can also drag-n-drop. Review the list of ranks and ensure they are in alphabetical order. Notice it shows the groups in order, with arrows identifying the flow of the track. + +(screen print) + + +When finished, click on "Add Track" to keep it. + + +Click the save icon in the upper right hand corner, then copy and paste the code in game or in to the console to apply it. + + + +**Step 3: Create LP Tracks using Commands** + +NOTE: Ignore these steps if you are using the LP Editor. + + +Create the track, then add the groups in the correct order: + + +``` +/lp createtrack mine-ranks +/op track mine-ranks append a +/op track mine-ranks append b +/op track mine-ranks append c +... etc ... +/op track mine-ranks append z + +``` + +**Step 4 - Setting up Ladder Commands to link LuckPerms to prison** + + +If you're familiar with Prison's rank commands, you'll know you can do a lot of powerful things when a player ranks up, including running commands from other plugins. But the downside, is that each rank will need to be configured with the same commands, which can be a pain and a risk for bugs. What if you skipped a rank or had a typo in a command? What if there was something even better than Rank commands? + + +Prison actually has Ladder Commands. They are similar to Rank Commands, but a ladder command is applied to all ranks on that ladder. That means you only create one ladder command, instead of 26 rank commands. A huge savings. + + +Ladder commands make use of ladder placeholders so you can inject rank names, or other values, in to the command when it is ran. This prevents the need to copy rank commands just to provide the correct rank name. Please review the list of placeholders to better understand how ladder commands can adjust for various ranks. See the commands below. + + +So the final step in setting up LuckPerms Tracks is to create just one Ladder Command. That ladder command will run this LP command: `lp user [playerName] parent settrack [track] [LP-group]`. See the command below with prison's Ladder placeholders and LP track name inserted. + +``` +/ranks ladder command add help +/ranks ladder command add placeholders + +/ranks ladder command add default lp user {player} parent settrack mine-ranks {targetRank} +``` + +Let's review the parts of that command: + +* `/ranks ladder command add` - The command prison's command-handler runs. 4 words to identify 1 command. +* `default` - Identifies which ladder to add the command to. This is the "default" ladder. +* `lp user` - Identifies a LP User command is being used. +* `{player}` - This is a Ladder command placeholder which will inject the player's name before running the command. +* `parent settrack` - Sets the player's parent to use a track. +* `mine-ranks` - The LP Track name that we defined that contains all of the LP Groups. +* `{targetRank}`- This is a Ladder Command placeholder that will inject the new rank for the player. + + +**Step 5 - Testing** + +Time to test. + + +Make sure the player you're testing with is not OP'd. + + +You can use `/rankup` to change ranks, but it will cost you. + +Or you can use `/ranks promote help` and `/ranks demote help` to rankup and to rank-down. Check out these commands, since you can force a player to pay for the promote, or even give a refund on a demote. + + + +You can also use `/ranks set rank help` to jump over a number of ranks in either direction. But this could be dangerous if there is a rank command that needs to be set, or removed, at each rank. + + + +To test the teleportation to the mines, you can use `/mines tp`, or the alias `/mtp`. If you did not setup each mine's spawn points yet, then it will teleport you to the top-center of the mine. + + + +To review a player's rank within LP use `/lp user info` and . + + +To review a player's rank within prison use `/ranks player `. + + + + +
+ + +# Special Variation: Players can only Access the Mine tied to their Rank by using Permissions + +One special variation in configuring your server, would be if players can "only" access mines that are tied to their current rank. For example, if a player is at Rank C, then they cannot access the prior mines A nor B. This is a very restrictive configuration, which requires managing the permissions. + + +If you are using permissions for access, then the two you need to know about are: `mines.` and `mine..tp`. Such that mine A would require: `mines.a` and `mines.a.tp`. + +Add these two perms to all LuckPerm groups. You can use the LP editor, or manually with the following commands. Repeat for all groups. + +``` +/lp group a permission set mines.a true +/lp group a permission set mines.a.tp true +``` + + +You would also need to turn off Mine Access by Rank and TP Access by Rank, then enable access by permissions with the following commands: + +``` +/mines set mineAccessByRank *all* disable +/mines set tpAccessByRank *all* disable + +/mines set accessPermission help +/mines set accessPermission a mines.a +/mines set accessPermission b mines.b +/mines set accessPermission c mines.c +... etc ... +/mines set accessPermission z mines.z +~~~ + + + +
+ + + +## Older notes - Ignore - Maybe deleted + + So to get started with how you would setup a Prison Rank command for Rank B: `/ranks command add B lp user {player} parent settrack [track] b` @@ -206,12 +448,19 @@ And that should be it. -
+
# Setting up LuckPerms Chat Prefixes +To setup a LuckPerms chat prefix, using prison's rank tag, use the following command. This assumes you've followed the directions above with setting up a LP track. + +``` +/lp group default meta setprefix "%prison_rank_tag_prestiges%%prison_rank_tag_default% &r" +``` + + *coming soon...* From 7f4f382e2fc79fbb7ddf475bfc341438f3357f7d Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 19 Jun 2022 13:57:48 -0400 Subject: [PATCH 288/297] Update Docs: LuckPerms groups and tracks... added images and fixes a few minor things too. --- docs/changelog_v3.3.x.md | 4 +- .../prison_docs_030_1_LP_add_a_group.png | Bin 0 -> 36831 bytes .../prison_docs_030_2_LP_create_group_a.png | Bin 0 -> 27391 bytes .../prison_docs_030_3_LP_create_group_b.png | Bin 0 -> 23700 bytes ..._docs_030_4_LP_create_track_mine-ranks.png | Bin 0 -> 40455 bytes ...on_docs_030_5_LP_edit_track-mine-ranks.png | Bin 0 -> 43080 bytes ...prison_docs_030_LuckPerms_Groups_Tracks.md | 67 ++++++++++++++---- 7 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 docs/images/prison_docs_030_1_LP_add_a_group.png create mode 100644 docs/images/prison_docs_030_2_LP_create_group_a.png create mode 100644 docs/images/prison_docs_030_3_LP_create_group_b.png create mode 100644 docs/images/prison_docs_030_4_LP_create_track_mine-ranks.png create mode 100644 docs/images/prison_docs_030_5_LP_edit_track-mine-ranks.png diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 9380ef976..350837fd2 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,9 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11j 2022-06-17 +# 3.3.0-alpha.11j 2022-06-19 +* **Update Docs: LuckPerms groups and tracks... added images and fixes a few minor things too.** + * **Update some of the docs on setting up luckperms and tracks.** diff --git a/docs/images/prison_docs_030_1_LP_add_a_group.png b/docs/images/prison_docs_030_1_LP_add_a_group.png new file mode 100644 index 0000000000000000000000000000000000000000..adab0309f71d0df5096661cdfbf53d2cd7368abb GIT binary patch literal 36831 zcmdSARa9KT76nKIO>hgY!8L>?cyM=jmj*fncRB=jcWB(*9TGG+G~QTnclYVM_kKp! ze9zpEyK2>{?tAvBs#9|I4pml^LPsM;LqI@4mys4%ML>8XfPnBS4COVvMlxmU76Bo; zP)1xt-5qwAiL8w$Me-v#Pisv)EQCSfE&jWouLJ7h7SD&`;L~&& zsPr0FF@)hGiXgtiCXq%iaQaT__Sn{>400SiL?zL4JrhpBjd>I;)cBXw%7O zbtvk_GkEnhHCJGx|M1ll8_B>nw;1>L!*;>D!IJEiWoDDs5v8TNbakB#i^vFHvZ1q9 z5gA}`e3h#debFn!ctJ5GL+?`tMLD^PWZPq_<52M0~2cVm;QRy;+idI_WBzlaUDlLV@#ih-DW5}+!aLFH?Z;p>1FDGQ5QiQZJ9H))- zlM#+QwB)v5f?xR2_K^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8PPltY7n#O6Ah)U>^~m-`xp3S#`MF`b1FL+pF|u&o773|aY z^zH2Ol<#rtzu`K%Q=T}wcJ2W%Wc=kCvLWE-o(YjE|ksE;KYT+QNINzopr0E4wY+W-In literal 0 HcmV?d00001 diff --git a/docs/prison_docs_030_LuckPerms_Groups_Tracks.md b/docs/prison_docs_030_LuckPerms_Groups_Tracks.md index eabfd3b5e..2ed917ae7 100644 --- a/docs/prison_docs_030_LuckPerms_Groups_Tracks.md +++ b/docs/prison_docs_030_LuckPerms_Groups_Tracks.md @@ -128,7 +128,12 @@ For example, where `P1` is the Prestige 1 rank: Although there are many ways to configure any plugin, these suggestions tries to keep things simple by using the same names as the counter parts between Prison and LuckPerms. It may be slightly confusion which is which, as far as Prison or LuckPerms, but it makes it easier by being consistent with the same names for the similar parts. -The best way to setup LuckPerms Groups is to make 1 group for every Prison Rank. Then use the Rank Commands to assign users to that group automatically when they rankup. Then to tie things together within LuckPerms, place these created LuckPerms Groups on a LuckPerms Track. +The best way to setup LuckPerms Groups is to make 1 group for every Prison Rank. Then use the Rank Commands to assign users to that group automatically when they rankup. Then to tie things together within LuckPerms, place these created LuckPerms Groups on a LuckPerms Track. Then when a player ranks up, a Prison Ladder Command will be ran to change the LP track to keep Prison's Ranks in synch with the LuckPerms tracks. + + + +To give you the choice on how to setup the LP groups and tracks, **Step 1** through **Step 3** shows you how to use *either* the LP Web Permissions Editor or how to use the commands through the server's console. Choose one or the other; you should not try to do both. + **Step 1 : Configure Prison's Ranks and Mines** @@ -164,22 +169,34 @@ If you did not run `/ranks autoconfigure`, you can auto link the mines and ranks **Step 2 : Create the LuckPerms Groups using the LP Editor** + Create a new group in LuckPerms for each Rank within Prison. +Please note that the name of the LuckPerms group must match the names you use with the Prison Rank names. This is very important because in **Step 4** below you will need to create a Ladder Command that will run every time a player ranks up, and it will use the next rank's name in the command, which must match the LuckPerms' group name or it won't work. + + We suggest that you should use the LP editor, which makes it easier to perform admin tasks. To open a new editor session, use the command `/lp editor` then click on the hyperlink, or copy and paste it to your browser. Within the LP Web Permissions Editor, to the left of the page is a left-navigation section with expandable topics of: Tracks, Groups, and Users. To the right of the Groups section is a plus sign "+", click on that to add a new group. +Adding a LuckPerms group A + + + To create your first group, give it a name of "a" and a display name of "A". The display name is not intended for using color codes, or anything fancy. Click on "Add Group" to create the group. -(screen print: ) + +Create LuckPerms group A + + Then create group b. But this time, have it list Group A as the parent. -(screen print: ) + +Laying out the new mine Repeat creating all the groups, where group z will be the last one. @@ -228,11 +245,16 @@ Click the plus (+) button to the right of the heading **Tracks** to create a new Name the new track "mine-ranks". It will be shown in all upper case: MINE-RANKS. -(screen print) + +Create LP track mine-ranks + You "must" click on each rank in alphabetical order to add it to the track's list. You can also drag-n-drop. Review the list of ranks and ensure they are in alphabetical order. Notice it shows the groups in order, with arrows identifying the flow of the track. -(screen print) + + +Edit LP track mine-ranks + When finished, click on "Add Track" to keep it. @@ -252,11 +274,13 @@ Create the track, then add the groups in the correct order: ``` /lp createtrack mine-ranks -/op track mine-ranks append a -/op track mine-ranks append b -/op track mine-ranks append c +/lp track mine-ranks append a +/lp track mine-ranks append b +/lp track mine-ranks append c + ... etc ... -/op track mine-ranks append z + +/lp track mine-ranks append z ``` @@ -350,9 +374,11 @@ You would also need to turn off Mine Access by Rank and TP Access by Rank, then /mines set accessPermission a mines.a /mines set accessPermission b mines.b /mines set accessPermission c mines.c + ... etc ... + /mines set accessPermission z mines.z -~~~ +``` @@ -360,7 +386,7 @@ You would also need to turn off Mine Access by Rank and TP Access by Rank, then -## Older notes - Ignore - Maybe deleted +## Older notes - Ignore - May Be deleted So to get started with how you would setup a Prison Rank command for Rank B: @@ -446,6 +472,7 @@ The following is optional, but what it does is to apply all rank commands to all And that should be it. +### end of "may be deleted" section....


@@ -454,14 +481,30 @@ And that should be it. # Setting up LuckPerms Chat Prefixes + To setup a LuckPerms chat prefix, using prison's rank tag, use the following command. This assumes you've followed the directions above with setting up a LP track. + ``` /lp group default meta setprefix "%prison_rank_tag_prestiges%%prison_rank_tag_default% &r" + ``` +You could use just `%prison_rank_tag%`, or it's alias `%prison_rt%`, but that will include the rank tags for all ranks the player has on the server. Normally they will always have a rank on the `default` rank, and optionally on the `prestiges` ladder too. If other ladders are setup, then they will also be included. Generally this is fine, but the drawback is that you cannot control the order in which they are generated. So as listed in the example above, we are controlling the order of the rank tags for both the prestiges and default ladder. The aliases for those two placeholders are `%prison_rt_prestiges%` and `%prison_rt_default%`. + + +Next, you need to install a plugin to enable the LuckPerms Chat Prefixes, which allows LuckPerms to resolve the placeholder through PlaceholderAPI. + + +Download the **LPC** plugin and place it in the server's `/plugins` directory. This plugin also requires the **PlaceholderAPI** plugin. Then restart the server. + + +[https://www.spigotmc.org/resources/lpc-chat-formatter-1-7-10-1-18-2.68965/](https://www.spigotmc.org/resources/lpc-chat-formatter-1-7-10-1-18-2.68965/) + + +There should be no configuration changes needed for the plugin, and it should just work. + -*coming soon...*
\ No newline at end of file From 0a0369f4adef60f5d73bbc31f3de7c45d18021e9 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 19 Jun 2022 15:04:58 -0400 Subject: [PATCH 289/297] Updates to LP docs... --- ...prison_docs_030_LuckPerms_Groups_Tracks.md | 126 +++++------------- 1 file changed, 31 insertions(+), 95 deletions(-) diff --git a/docs/prison_docs_030_LuckPerms_Groups_Tracks.md b/docs/prison_docs_030_LuckPerms_Groups_Tracks.md index 2ed917ae7..455ea7ea4 100644 --- a/docs/prison_docs_030_LuckPerms_Groups_Tracks.md +++ b/docs/prison_docs_030_LuckPerms_Groups_Tracks.md @@ -7,7 +7,7 @@ This document provides an overview to help setup LuckPerms groups and tracks. -*Documented updated: 2022-06-17* +*Documented updated: 2022-06-19*
@@ -21,16 +21,26 @@ Setup LuckPerms as needed. Information on where to download it can be found her [Setting Up LuckPerms](prison_docs_020_setting_up_luckperms.md) +To use the LuckPerms Chat Prefix, you will also need the **PlaceholderAPI** and **LPC** plugins. Information on the LPC plugin is presented near the end of this document. + + Below are detailed steps on how to configure both Prison and LuckPerms. -
+The commands and configurations presented below are for a normal (A-Z) setup, if your ranks and/or mines have different names, use those instead of the A-Z names as shown in this guide + + +
+ # LuckPerms Groups To help simplify the management of permissions for players, LuckPerms uses permission Groups to form a collection of permissions. This helps to simplify assigning permission to players since one group can contain many permissions. For example, if there are 20 permissions in a group, then you would only have to issue one group command instead of 20 permission commands. +
+ + # LuckPerms Tracks @@ -42,7 +52,8 @@ To advance a player within LuckPerms Tracks, you just promote the player to the Since Prison needs to use their own ranks, and is not directly tied to LuckPerms Tracks, Prison Ranks can help manage a player's LuckPerms Track. -
+
+ # Using Prison Rank Commands with Groups and Tracks - An Overview @@ -123,7 +134,7 @@ For example, where `P1` is the Prestige 1 rank:
-# The Suggested Way to Setup LuckPerms Groups and Tracks - An Overview +# Setting Up LuckPerms Groups and Tracks - An Overview Although there are many ways to configure any plugin, these suggestions tries to keep things simple by using the same names as the counter parts between Prison and LuckPerms. It may be slightly confusion which is which, as far as Prison or LuckPerms, but it makes it easier by being consistent with the same names for the similar parts. @@ -176,6 +187,7 @@ Create a new group in LuckPerms for each Rank within Prison. Please note that the name of the LuckPerms group must match the names you use with the Prison Rank names. This is very important because in **Step 4** below you will need to create a Ladder Command that will run every time a player ranks up, and it will use the next rank's name in the command, which must match the LuckPerms' group name or it won't work. + We suggest that you should use the LP editor, which makes it easier to perform admin tasks. To open a new editor session, use the command `/lp editor` then click on the hyperlink, or copy and paste it to your browser. @@ -202,7 +214,7 @@ Then create group b. But this time, have it list Group A as the parent. Repeat creating all the groups, where group z will be the last one. . -Save it. Click the save icon in the upper right hand corner. It will give you a code to apply the changes. Click the code to copy it to your clipboard, then paste it in game, or in the server's console. Close the browser window for that editor (once you apply the changes, never use the same editor session again... create a new one). +Save it. Click the save icon in the upper right hand corner. It will give you a code to apply the changes. Click the code to copy it to your clipboard, then paste it in game, or in the server's console. @@ -243,7 +255,7 @@ Open a new LP Web Permission editor: `/lp editor`. Click the plus (+) button to the right of the heading **Tracks** to create a new LP track. -Name the new track "mine-ranks". It will be shown in all upper case: MINE-RANKS. +Name the new track "mine-ranks". Create LP track mine-ranks @@ -316,33 +328,6 @@ Let's review the parts of that command: * `{targetRank}`- This is a Ladder Command placeholder that will inject the new rank for the player. -**Step 5 - Testing** - -Time to test. - - -Make sure the player you're testing with is not OP'd. - - -You can use `/rankup` to change ranks, but it will cost you. - -Or you can use `/ranks promote help` and `/ranks demote help` to rankup and to rank-down. Check out these commands, since you can force a player to pay for the promote, or even give a refund on a demote. - - - -You can also use `/ranks set rank help` to jump over a number of ranks in either direction. But this could be dangerous if there is a rank command that needs to be set, or removed, at each rank. - - - -To test the teleportation to the mines, you can use `/mines tp`, or the alias `/mtp`. If you did not setup each mine's spawn points yet, then it will teleport you to the top-center of the mine. - - - -To review a player's rank within LP use `/lp user info` and . - - -To review a player's rank within prison use `/ranks player `. - @@ -382,100 +367,51 @@ You would also need to turn off Mine Access by Rank and TP Access by Rank, then -
- - - -## Older notes - Ignore - May Be deleted - - -So to get started with how you would setup a Prison Rank command for Rank B: -`/ranks command add B lp user {player} parent settrack [track] b` +
-When they become rank B, the command `/lp user {player} parent settrack [track] b` will be ran as console/admin. The Prison placeholder `{player}` is the player's name, and `[track]` is the name you're calling your track. +# Testing LuckPerms along with Prison Ranks -To setup all the LuckPerms groups, you can use `/lp editor` to make it easier. And setup the ranks from A through Z. +Here are a few topics to consider when you're testing your setup. Some of these are some general tips that may help with testing and managing your player. -Next you should setup the LuckPerms Tracks, which will take a little more effort up front. You don't have to use Tracks, but it will simplify some things later on by simplifying the synchronization between Prison Ranks and the LuckPerms Groups. +Make sure the player you're testing with is not OP'd. If you're permissions to manage access to mines, mine TP spawn locations, or other commands, then OP will bypass all perms and give that player full access. -For our examples, we will name our track **PrisonRank**. -``` -/luckperms createtrack [track] - -/luckperms createtrack PrisonRanks - -``` +You can use `/rankup` to change ranks, but it will cost you the stand rankup fees. -Now we need to add all of our created groups to this track. It's important to add them **IN ORDER**. Yes, the order is critical. Remember our Prison Ranks are named A through Z, and so are our LuckPerms Groups, so we have to add them all. - - -``` -/luckperms track [track] append - -/luckperms track PrisonRank append A -/luckperms track PrisonRank append B -/luckperms track PrisonRank append C -/luckperms track PrisonRank append D - -... - -/luckperms track PrisonRank append Z - -``` - - -The next step that you need to do, is to setup all the perms for each of your groups. The perms that you need, are based upon the plugins that you have setup on your server, and the perms that they will require. - - -For brevity, we will only show you the commands to use manually. You can use the command `/lp editor` too. Remember that the **group** listed in this command are the LuckPerms groups that you created earlier, that are named A trough Z. The **permission**s that you use in these commands should be entered exactly as they are needed. +Or you can use `/ranks promote help` and `/ranks demote help` to rankup and to rank-down. Check out these commands, since you can force a player to pay for the promote, or even give a refund on a demote. -``` -/lp group permission set -``` +If you're using EssentialsX's economy, also applies to many other economy plugins, the following commands can be helpful to know. `/eco` will show available commands. To give yourself money: `/eco give `. Remove some with `/eco take `. Or to set it to a specific value `/eco set `. -It may take a while to setup all the permissions, and you will have to revisit these as you're adding more plugins. +You can also use `/ranks set rank help` to jump over a number of ranks in either direction. But this could be dangerous if there is a rank command that needs to be set, or removed, at any specific rank that you may skip over. -Next, we need to setup Prison's Rank Commands to allow the rankup process to keep the LuckPerms Track's Groups in synchronization. Luckily, this is pretty simple and is accomplished with just one Rank Command per rank. Please not that for Prison's Rank names they are not case sensitive, but the LuckPerms track names may be, so they are listed here in upper case. -These are based upon the two individual commands; the Prison Ranks Command and the LP command. The **command** reference in the Prison Rank Command is the whole LP command, as you will see following the templates. +To test the teleportation to the mines, especially if you use perms, you can use `/mines tp`, or the alias `/mtp`. If you did not setup each mine's spawn points yet, then it will teleport you to the top-center of the mine. See `/mines set spawn help`. -``` -/ranks command add -/lp user {player} parent settrack [track] -/ranks command add a lp user {player} parent settrack PrisonRank A -/ranks command add b lp user {player} parent settrack PrisonRank B -/ranks command add c lp user {player} parent settrack PrisonRank C -/ranks command add d lp user {player} parent settrack PrisonRank D +Generally your players will be using the GUI for ranks and mines. For mines, the commands for players are just `/mines` but if you're OP'd then you can use `/gui mines` to get to their GUI. Same with player ranks, their command is just `/ranks`, but to access that guil while OP'd use `/gui ranks. Within the Mines GUI, the players can TP to the mines (why its important to test TP'ing). Also they can rankup through the ranks GUI. -... -/ranks command add z lp user {player} parent settrack PrisonRank Z -``` +To review a player's rank within LP use `/lp user info` and `/lp user permission info`. -The following is optional, but what it does is to apply all rank commands to all players at their current ranks. So this will apply everything we just entered above to anyone who is already setup in Prison. -`/ranks set rank *all* *same* default` +To review a player's rank within prison use `/ranks player `. -And that should be it. -### end of "may be deleted" section.... +
-
From ce83c6209f45f951784f618858695c4226b3edd4 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 19 Jun 2022 16:58:33 -0400 Subject: [PATCH 290/297] Fixed an issue where if you try to use a % on a number it's causing String format errors. This now strips off % and $ if they are used. --- docs/changelog_v3.3.x.md | 5 +++++ .../prison/commands/handlers/IntegerArgumentHandler.java | 5 +++++ .../prison/commands/handlers/IntegerClassArgumentandler.java | 2 ++ .../prison/commands/handlers/LongArgumentHandler.java | 5 +++++ .../prison/commands/handlers/LongClassArgumentHandler.java | 3 +++ .../prison/commands/handlers/PlayerArgumentHandler.java | 1 + .../prison/commands/handlers/StringArgumentHandler.java | 5 +++++ 7 files changed, 26 insertions(+) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 350837fd2..8510612ec 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,11 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11j 2022-06-19 + +* **Fixed an issue where if you try to use a % on a number it's causing String format errors.** +This now strips off % and $ if they are used. + + * **Update Docs: LuckPerms groups and tracks... added images and fixes a few minor things too.** diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/IntegerArgumentHandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/IntegerArgumentHandler.java index dc5710bca..4118d2af0 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/IntegerArgumentHandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/IntegerArgumentHandler.java @@ -32,6 +32,11 @@ public IntegerArgumentHandler() { @Override public Integer transform(CommandSender sender, CommandArgument argument, String value) throws TransformError { + + if ( value != null ) { + value = value.replaceAll( "$|%", "" ); + } + try { return Integer.parseInt(value); } catch (NumberFormatException e) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/IntegerClassArgumentandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/IntegerClassArgumentandler.java index f2848b147..f7e31ac49 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/IntegerClassArgumentandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/IntegerClassArgumentandler.java @@ -18,6 +18,8 @@ public IntegerClassArgumentandler() { if ( value != null ) { + value = value.replaceAll( "$|%", "" ); + //value = value.replaceAll("$|%", ""); if ( value.trim().length() > 0 ) { try { diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/LongArgumentHandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/LongArgumentHandler.java index f31b05f95..e10fb6905 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/LongArgumentHandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/LongArgumentHandler.java @@ -14,6 +14,11 @@ public LongArgumentHandler() { @Override public Long transform(CommandSender sender, CommandArgument argument, String value) throws TransformError { + + if ( value != null ) { + value = value.replaceAll( "$|%", "" ); + } + try { return Long.parseLong(value); } catch (NumberFormatException e) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/LongClassArgumentHandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/LongClassArgumentHandler.java index 31469f88d..665e24653 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/LongClassArgumentHandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/LongClassArgumentHandler.java @@ -17,6 +17,9 @@ public Long transform(CommandSender sender, CommandArgument argument, String val Long results = null; if ( value != null ) { + + value = value.replaceAll( "$|%", "" ); + try { results = Long.parseLong(value); } catch (NumberFormatException e) { diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/PlayerArgumentHandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/PlayerArgumentHandler.java index c1de8faa6..7b1976313 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/PlayerArgumentHandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/PlayerArgumentHandler.java @@ -43,6 +43,7 @@ public Player var(CommandSender sender, CommandArgument argument, String varName @Override public Player transform(CommandSender sender, CommandArgument argument, String value) throws TransformError { + return Prison.get().getPlatform().getPlayer(value).orElseThrow(() -> new TransformError( Prison.get().getLocaleManager().getLocalizable("playerNotOnline") .withReplacements(value).localizeFor(sender))); diff --git a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/StringArgumentHandler.java b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/StringArgumentHandler.java index b636a0219..acce7abe3 100644 --- a/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/StringArgumentHandler.java +++ b/prison-core/src/main/java/tech/mcprison/prison/commands/handlers/StringArgumentHandler.java @@ -73,6 +73,11 @@ public void verify(CommandSender sender, CommandArgument argument, String verify @Override public String transform(CommandSender sender, CommandArgument argument, String value) throws TransformError { + + if ( value != null ) { + value = value.replaceAll( "$|%", "" ); + } + return value; } } From a37e2bf2e18005d5e927268763ac5b193d6d518d Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 19 Jun 2022 16:59:46 -0400 Subject: [PATCH 291/297] Update docs.... --- docs/changelog_v3.3.x.md | 2 + docs/knownissues_v3.3.x.md | 214 +++++++++++++++------- docs/prison_docs_115_using_BlockEvents.md | 3 + 3 files changed, 149 insertions(+), 70 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 8510612ec..40ca3e0c7 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,8 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11j 2022-06-19 +* **Update a number of docs...** + * **Fixed an issue where if you try to use a % on a number it's causing String format errors.** This now strips off % and $ if they are used. diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index be5fa7c52..5453074d4 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -5,20 +5,54 @@ -# TODO Items for v3.3.0-alpha.10 +# TODO Items for v3.3.0-alpha.11 -- placeholders are not using the time units as the mine notifications are using. Therefore, they are continuing to use english units. Need to fix the placeholders. One is `prison_mines_timeleft_formatted_Mine`. kstance -- add support for NBTs - mine bombs - ClumbsyIsNotReal - - having problems formatting mine bomb lore with current restrictions since it prevents bombs from working. - +- For v3.3.0 release: + - BlockConverters + - docs + - Sellall - use prison blocks and not XMaterials - Move more code to the sellall module + - Backpacks - create a new player cache for backpacks. Copy the current player cache. + - ranks and ladders + - auto prestiges (unlimited) based upon formulas + - new file formats - json ORM? + - archiving old players + - more work on top-n rankings + - /mines wguard - worldguard hints for mines (generate scripts to run?) - Use patterns that can be edited -- DONE: placeholders - show next rank is skipping p1 when no p is assigned to player. xGeorge26 + +* BlockConverters + + + +* placeholder bar debug is not showing anything useful. + + +- New custom block support: Based upon holding an item or a block. `/mines custom ` + - Way to add custom blocks outside of the CustomItems plugin. Capture NBT values too? Not 100% what can easily be captured, or how to always id a custom block; has to be fast for block break handling. + + + +- Transaction logs - Rankup and player joins would be good to take these messages out of the console. + + +- When placing a mine, it spams resets while it's setting up the liner and the primary mine. May be an issue with zero block resets and having zero block counts remaining. May want to initially set the block counts to something like 1, then after the mine is done being laid out, then reset it. When it's in "tracer" mode, no blocks exist that can be broken, so a value of 1 cannot be decreased.i + + + +- TEST: Add nbt support to gui menus. Issue with rankup not getting the correct ladder name. + - Partially added and is working. Expand to other menu options, which will be time consuming. + + +- Print warnings if auto features configs prevent any drops. Include notice when drops don't occur due to autosell. + - On server startup... not sure how to best check. + + +- auto pickup off, nothing was dropping. LurgenAU -- DONE: Many errors when prison hits a standard potion. - jamo - autofeatures BLOCKEVENTS priority - include backpacks on auto sell - Ryankayz @@ -29,46 +63,17 @@ - SQL support - Six -- DONE: autofeatures BLOCKEVENT priority - check for full inventory and perform sellall - Ryankayz - Mine Resets - Glass block not being removed - harold -- (done ??) Placeholder bar is reversed. As the player earns more money, it shrinks instead of grows. - harold - - prison_rankup_cost_bar_default - - Archive old players - budderman18 - archive all player files to a zip. Remove the originals. If player logs back on, then restore the archives. Prevent startup from adding these players back. - -- DONE: Rankup - Still not working correctly. - - DONE: takes money but does not rank them up? - - DONE: rank changes does not alter the list of players at the ranks - - Placeholders - dynamic content - - custom placeholders based upon other primary placeholders? -- DONE: Top-n: hookup rank-score and penalty. - - Placeholders - hookup placeholders to support top=n players. -- DONE: Top-n balance calculations using essentials - 2 mins 31 secs - Budderman18 - - DONE: move to async thread on startup - high priority -- Top-n - phuong Nguyen -- CustomItems drops - harold -- DONE: Sellall - custom blocks/items and items that have been renamed - harold & RomainD -- DONE: sellall - no sell renamed items - RomainD -- DONE: mine bombs - fortune not using the mine bomb's pick with fortune.. always zero - RomainD - - debug is showing fortune 0 -- DONE: CustomItems - not doing drops, even when drops are set - harold -- DONE: CustomItems - Not block counting custom blocks -- DONE: Upgrade bStats to v3.0.0 -- auto features - normal drops may not be happening. May be using auto pickup code. - - - -* DONE: The function isUnbreakable could return a null for the SpigotBlock/PrisonBlock. Change it so the primary check for that function is location, then block is optional. This is failing because the bukkit block cannot be mapped to a XMaterial which should not be a factor. XMaterial will be null for custom blocks. - - * Add a preformatted sellall multiplier * {prison_player_sellall_mutiplier::nFormat:#,##0.0000} @@ -82,10 +87,6 @@ * Mine bombs: - - DONE: prison reload bombs - - DONE: validate mine bombs when initially loading... - - bomb name cannot have spaces or color formatting - - initial validation added - glowing effect (enchantment) - give madog24 stone{Enchantments:[{}]} - ItemMeta.addFlags(ItemFlag.HIDE_ENCHANTMENTS) @@ -93,18 +94,8 @@ throwableEnable: true, throwVectorVelocity: 1, thrownInstantExplode: true, - - -* DONE: Works for me. HiPriority: Inventory full not producing any messages. alexaille -* DONE: HiPriority: NPCs are generating a lot of errors. Real_Ganster - - Citizens running command `mines` as player -` Prison | VaultEconomyWrapper.getBalance(): Error: Cannot get economy for player vote so returning a value of 0. Failed to get an bukkit offline player.` - - https://pastebin.com/JusySWDs - - -* DONE: HiPriority: Add a event priority of BLOCKEVENTS which only does the block events and counts. * HiPriority: calculated infinite prestiges - Fluffy_ak47 @@ -112,10 +103,6 @@ -- DONE: **Fixed issues with vault economy and withdrawing from a player's balance.** -It now also reports any errors that may be returned. - - - In mines block list, new feature to prevent drops for that item... which then can use blockEvents, but that would bypass auto pickup and autosell. @@ -132,22 +119,6 @@ It now also reports any errors that may be returned. -- Mine Bomb Issues - - DONE: Not dropping blocks - - DONE: give bombs only works with lower case... camel case not working - - DONE: with a stack of 2 oof bombs, setting off one removes both. - - The is happening when the bomb is so large that it breaks the durability on the pseudo tool, which then removes whatever is in the player's hand when it breaks the item. - - DONE: color names for bombs do not work - xGeorge26 - - DONE: Control Y adjustment when setting the bomb. Defaults to -1. - - DONE: armorstand appears in animation when using color coded bomb name? - xGeorge26 - - Update to include more colorful names.. - - Provide a "count down" placeholder function within the armor stand bomb name?? - -- DONE: Need to externalize the time defaults... like Mine x will reset in x seconds from now. 1 seconds. - ShockCharge - -- DONE: Six - air count needs to be asynch'd since it is causing server not to respond for more than 10 seconds upon startup. - - Most mines are greater than 120,000 blocks. - - custom block support: Items Adder - No one is using it currently. @@ -226,6 +197,109 @@ https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main +# Completed tasks + + +- DONE: percent is not being filtered from `/mines blockevent percent` and is causing errors in the formatting of the number. Percent is also not showing the list of events to get the rows... + + +- Mine Bomb Issues + - DONE: Not dropping blocks + - DONE: give bombs only works with lower case... camel case not working + - DONE: with a stack of 2 oof bombs, setting off one removes both. + - The is happening when the bomb is so large that it breaks the durability on the pseudo tool, which then removes whatever is in the player's hand when it breaks the item. + - DONE: color names for bombs do not work - xGeorge26 + - DONE: Control Y adjustment when setting the bomb. Defaults to -1. + - DONE: armorstand appears in animation when using color coded bomb name? - xGeorge26 + - DONE: Update to include more colorful names.. + - DONE: Provide a "count down" placeholder function within the armor stand bomb name?? + +- DONE: Need to externalize the time defaults... like Mine x will reset in x seconds from now. 1 seconds. - ShockCharge + +- DONE: Six - air count needs to be asynch'd since it is causing server not to respond for more than 10 seconds upon startup. + - Most mines are greater than 120,000 blocks. + + + +- DONE reload is doing NPE when blockconverters are not setup and disabled. + +- DONE mine gui - add custom lore to the configs + - DONE: can now use either `{mineName}` or `{mineTag}` and title is now rankTag too. fix using the mine tag and not mine name + +* FIXED: GUI Ladders - Perms are not checked so anyone can run these GUIs. But other than viewing the ladders, they cannot run successfully the /rankup ladder command. + + +- FIXED: autosell not working. McPingvin + + +- FIXED: Sellall signs not working when variant is other than oak. BOmer + +- DONE: placeholders are not using the time units as the mine notifications are using. Therefore, they are continuing to use english units. Need to fix the placeholders. One is `prison_mines_timeleft_formatted_Mine`. kstance + + +- DONE: add support for NBTs - mine bombs - ClumbsyIsNotReal + - having problems formatting mine bomb lore with current restrictions since it prevents bombs from working. + + +- DONE: placeholders - show next rank is skipping p1 when no p is assigned to player. xGeorge26 + + +- DONE: Many errors when prison hits a standard potion. - jamo + + +- DONE: autofeatures BLOCKEVENT priority - check for full inventory and perform sellall - Ryankayz + + +- DONE: Rankup - Still not working correctly. + - DONE: takes money but does not rank them up? + - DONE: rank changes does not alter the list of players at the ranks + + +- DONE: Top-n: hookup rank-score and penalty. + - Placeholders - hookup placeholders to support top=n players. +- DONE: Top-n balance calculations using essentials - 2 mins 31 secs - Budderman18 + - DONE: move to async thread on startup - high priority +- Top-n - phuong Nguyen +- CustomItems drops - harold +- DONE: Sellall - custom blocks/items and items that have been renamed - harold & RomainD +- DONE: sellall - no sell renamed items - RomainD +- DONE: mine bombs - fortune not using the mine bomb's pick with fortune.. always zero - RomainD + - debug is showing fortune 0 +- DONE: CustomItems - not doing drops, even when drops are set - harold +- DONE: CustomItems - Not block counting custom blocks +- DONE: Upgrade bStats to v3.0.0 +- auto features - normal drops may not be happening. May be using auto pickup code. + + + +* DONE: The function isUnbreakable could return a null for the SpigotBlock/PrisonBlock. Change it so the primary check for that function is location, then block is optional. This is failing because the bukkit block cannot be mapped to a XMaterial which should not be a factor. XMaterial will be null for custom blocks. + + +- (done ??) Placeholder bar is reversed. As the player earns more money, it shrinks instead of grows. - harold + - prison_rankup_cost_bar_default + + + +* Mine bombs: + - DONE: prison reload bombs + - DONE: validate mine bombs when initially loading... + - bomb name cannot have spaces or color formatting + - initial validation added + +* DONE: Works for me. HiPriority: Inventory full not producing any messages. alexaille + + +* DONE: HiPriority: NPCs are generating a lot of errors. Real_Ganster + - Citizens running command `mines` as player +` Prison | VaultEconomyWrapper.getBalance(): Error: Cannot get economy for player vote so returning a value of 0. Failed to get an bukkit offline player.` + - https://pastebin.com/JusySWDs + + +* DONE: HiPriority: Add a event priority of BLOCKEVENTS which only does the block events and counts. + +- DONE: **Fixed issues with vault economy and withdrawing from a player's balance.** +It now also reports any errors that may be returned. + - DONE: placeholder for player blocks mined. artic1409 diff --git a/docs/prison_docs_115_using_BlockEvents.md b/docs/prison_docs_115_using_BlockEvents.md index c0f374bf2..0b239dc31 100644 --- a/docs/prison_docs_115_using_BlockEvents.md +++ b/docs/prison_docs_115_using_BlockEvents.md @@ -85,6 +85,9 @@ Prison's BlockEvents also supports more advanced placeholders that can help simp **How the command runs:** +**Note:** Due to overall performance issues when commands are used that cannot support a rapid turn around time, which will contribute to lag, the option to run commands **{inline}** no longer exists. The placeholders are still there, but all blockEvents are preprocessed, then ran together in one blocked-unit in another thread. If the running on any single command takes a while (too long), then the remaining commands will be resubmitted to prevent lag, or at least greatly reduce it. But also submitting the task of running the commands, it will also help Timings better identify it as being related to a command that is being ran. If prison is in debug mode, then high level stats on all of the commands that are ran with the blockEvents will be logged within the console. + + There are four **taskModes** on how BlockEvent commands run. The taskModes can be setup through the command `/mines blockEvent taskMode help`, or they can be specified as placeholders. There are 4 taskModes, and the placeholder versions are listed here: - **{inline}** This is the default taskMode if not specified. **{inline}** runs the commands in the same thread that in which Prison is handling the Block Break Events within Auto Features, and runs them as console (OP). If the command you use with BlockEvents is "slow" to run, then it could cause significant lag on the server. From e927f39c6d2403816452cf8f9cd0c94f55ff91c0 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 19 Jun 2022 17:04:03 -0400 Subject: [PATCH 292/297] minor items changed with the GUIs... no functional changes. --- docs/changelog_v3.3.x.md | 3 +++ .../prison/spigot/gui/mine/SpigotPlayerMinesGUI.java | 5 +++-- .../prison/spigot/gui/rank/SpigotPlayerRanksGUI.java | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 40ca3e0c7..17f07de49 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11j 2022-06-19 +* **minor items changed with the GUIs... no functional changes.** + + * **Update a number of docs...** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java index 3be0b0b33..60bd4f6f1 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java @@ -173,7 +173,8 @@ public void open() { // Get mine Tag, but make sure it is valid and the mine's name is not null: String mineTag = mineName == null ? "-no mine name-" : mineName; - if ( m.getTag() == null && !m.getTag().equalsIgnoreCase("null") && + if ( m.getTag() != null && + !m.getTag().equalsIgnoreCase("null") && !m.getTag().equalsIgnoreCase("none") ) { mineTag = m.getTag(); } @@ -185,7 +186,7 @@ public void open() { double volume = m.getBounds().getArea(); double remaining = volume * m.getPercentRemainingBlockCount() / 100.0; - stringValue = stringValue.replace( "{mineName}", m.getName() ); + stringValue = stringValue.replace( "{mineName}", mineName ); stringValue = stringValue.replace( "{mineTag}", mineTag ); stringValue = stringValue.replace( "{mineSize}", m.getBounds().getDimensions() ); stringValue = stringValue.replace( "{mineVolume}", iFmt.format( volume )); diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java index f436da2de..19a216808 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java @@ -50,7 +50,9 @@ public class SpigotPlayerRanksGUI extends SpigotGUIComponents { private PrisonRanks rankPlugin; private RankPlayer rankPlayer; - private final boolean placeholderAPINotNull = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null || Bukkit.getPluginManager().getPlugin("PlaceholdersAPI") != null; + private final boolean placeholderAPINotNull = + Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null || + Bukkit.getPluginManager().getPlugin("PlaceholdersAPI") != null; // private final List configCustomLore = guiConfig.getStringList("EditableLore.Ranks"); private String ladderName; From 0ad46145795b420622afefcd03e39154c7f626d4 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 19 Jun 2022 17:08:04 -0400 Subject: [PATCH 293/297] Placeholder fix: The PAPI placeholder integrations should not be prefixing raw text with "prison_"; that is the task for PlaceholderIdentifier. --- docs/changelog_v3.3.x.md | 3 +++ .../PlaceHolderAPIIntegrationUppercaseWrapper.java | 6 +++--- .../placeholder/PlaceHolderAPIIntegrationWrapper.java | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 17f07de49..d5d8a8fc1 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,9 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11j 2022-06-19 +* **Placeholder fix: The PAPI placeholder integrations should not be prefixing raw text with "prison_"; that is the task for PlaceholderIdentifier.** + + * **minor items changed with the GUIs... no functional changes.** diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java index 8a8196780..156c4479e 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java @@ -77,9 +77,9 @@ public String getVersion(){ @Override public String onRequest(OfflinePlayer player, String identifier) { - if ( !identifier.toLowerCase().startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } +// if ( !identifier.toLowerCase().startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } UUID playerUuid = player.getUniqueId(); String results = Prison.get().getPlatform().getPlaceholders() diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java index 9ae3b0a1c..897fe35ed 100644 --- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java +++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java @@ -76,9 +76,9 @@ public String getVersion(){ @Override public String onRequest(OfflinePlayer player, String identifier) { - if ( !identifier.toLowerCase().startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) { - identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; - } +// if ( !identifier.toLowerCase().startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) { +// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier; +// } UUID playerUuid = player.getUniqueId(); String results = Prison.get().getPlatform().getPlaceholders() From 2163eb34cb195a35de3868cda48771534b6e401f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 19 Jun 2022 21:05:17 -0400 Subject: [PATCH 294/297] Fix issue: On the creation of a new mine, it would reset the mine a number of times. This fixes the problem by only allowing one reset every 5 seconds at the soonest. --- docs/changelog_v3.3.x.md | 4 ++++ docs/knownissues_v3.3.x.md | 8 +++++--- .../java/tech/mcprison/prison/mines/data/MineData.java | 10 ++++++++++ .../prison/mines/tasks/MinePagedResetAsyncTask.java | 10 ++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d5d8a8fc1..38808e43a 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11j 2022-06-19 +* **Fix issue: On the creation of a new mine, it would reset the mine a number of times. This fixes the problem by only allowing one reset every 5 seconds at the soonest.** + + + * **Placeholder fix: The PAPI placeholder integrations should not be prefixing raw text with "prison_"; that is the task for PlaceholderIdentifier.** diff --git a/docs/knownissues_v3.3.x.md b/docs/knownissues_v3.3.x.md index 5453074d4..13385ef25 100644 --- a/docs/knownissues_v3.3.x.md +++ b/docs/knownissues_v3.3.x.md @@ -38,9 +38,6 @@ - Transaction logs - Rankup and player joins would be good to take these messages out of the console. -- When placing a mine, it spams resets while it's setting up the liner and the primary mine. May be an issue with zero block resets and having zero block counts remaining. May want to initially set the block counts to something like 1, then after the mine is done being laid out, then reset it. When it's in "tracer" mode, no blocks exist that can be broken, so a value of 1 cannot be decreased.i - - - TEST: Add nbt support to gui menus. Issue with rankup not getting the correct ladder name. - Partially added and is working. Expand to other menu options, which will be time consuming. @@ -200,6 +197,11 @@ https://github.com/Auxilor/EcoEnchants/blob/master/eco-core/core-plugin/src/main # Completed tasks + +- DONE: When placing a mine, it spams resets while it's setting up the liner and the primary mine. May be an issue with zero block resets and having zero block counts remaining. May want to initially set the block counts to something like 1, then after the mine is done being laid out, then reset it. When it's in "tracer" mode, no blocks exist that can be broken, so a value of 1 cannot be decreased.i + + + - DONE: percent is not being filtered from `/mines blockevent percent` and is causing errors in the formatting of the number. Percent is also not showing the list of events to get the rows... diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java index 714d29d48..aaf927e13 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineData.java @@ -76,6 +76,8 @@ public abstract class MineData private long targetResetTime; private int resetCount = 0; + private long lastResetTimeLong = 0; + /** * These blocks are obsolete, and are no longer used in prison, but they * are preserved for now. Will be removed in the future. @@ -221,6 +223,7 @@ public MineData() { this.targetResetTime = 0; this.resetCount = 0; + this.lastResetTimeLong = 0; this.totalBlocksMined = 0; this.zeroBlockResetDelaySec = 0; this.resetThresholdPercent = 0; @@ -1057,6 +1060,13 @@ public void setResetTime( int resetTime ) { this.resetTime = resetTime; } + public long getLastResetTimeLong() { + return lastResetTimeLong; + } + public void setLastResetTimeLong(long lastResetTimeLong) { + this.lastResetTimeLong = lastResetTimeLong; + } + public MineNotificationMode getNotificationMode() { return notificationMode; } diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java index dc1374c80..e01772ca7 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java @@ -78,6 +78,16 @@ public void submitTaskAsync() { return; } + // Prevent the task from being submitted if it was already reset less than 5 seconds ago. + if ( mine.getLastResetTimeLong() > 0 && + (System.currentTimeMillis() - mine.getLastResetTimeLong()) <= 5000 ) { + + // cannot reset quicker than every 5 seconds: + return; + } + + mine.setLastResetTimeLong( System.currentTimeMillis() ); + if ( position > 0 && page++ % pagesPerReport == 0 ) { From a91dbdae13c0bf0874a9d6af970684f0b028a8ae Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 20 Jun 2022 01:07:28 -0400 Subject: [PATCH 295/297] Mine resets: Fixed an issue when dealing with zero-block resets on a very small mine, such as a one block mine in that the 5 second delay was preventing from rapid resets. Bypass both 5 second cooldown on resets and blockmatching when 25 blocks or less for the mine size. With running resets in async mode, with rapid resets for a one-block mine, the handling of the block breaks can occur out of order, which will trigger the block mismatch. --- docs/changelog_v3.3.x.md | 7 +++- .../prison/mines/data/MineScheduler.java | 19 +++++---- .../mines/tasks/MinePagedResetAsyncTask.java | 40 +++++++++++++++---- .../spigot/block/OnBlockBreakEventCore.java | 13 +++++- 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 38808e43a..1d03d85eb 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,12 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11j 2022-06-19 +# 3.3.0-alpha.11j 2022-06-20 + + +* **Mine resets: Fixed an issue when dealing with zero-block resets on a very small mine, such as a one block mine in that the 5 second delay was preventing from rapid resets.** +Bypass both 5 second cooldown on resets and blockmatching when 25 blocks or less for the mine size. +With running resets in async mode, with rapid resets for a one-block mine, the handling of the block breaks can occur out of order, which will trigger the block mismatch. * **Fix issue: On the creation of a new mine, it would reset the mine a number of times. This fixes the problem by only allowing one reset every 5 seconds at the soonest.** diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java index 73b16b7f8..693eca1ca 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineScheduler.java @@ -99,6 +99,7 @@ public JobType getJobType() public enum MineResetScheduleType { NORMAL, + ZERO_BLOCK_RESET, FORCED; } @@ -332,8 +333,11 @@ public void run() // appears like it will never load? //checkWorld(); - boolean forced = getCurrentJob() != null && - getCurrentJob().getResetType() == MineResetScheduleType.FORCED; + MineResetScheduleType resetScheduleType = getCurrentJob() == null ? + MineResetScheduleType.NORMAL : + getCurrentJob().getResetType(); + + boolean forced = resetScheduleType == MineResetScheduleType.FORCED; if ( getResetTime() <= 0 && !forced ) { @@ -382,7 +386,8 @@ public void run() List resetActions = getCurrentJob().getResetActions(); MinePagedResetAsyncTask resetTask = - new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal, resetActions ); + new MinePagedResetAsyncTask( (Mine) this, MineResetType.normal, resetActions, resetScheduleType ); + resetTask.submitTaskAsync(); // resetAsynchonously(); @@ -744,7 +749,7 @@ public boolean checkZeroBlockReset() { ) { // submit a manual reset since the mine is empty: - manualReset( MineResetScheduleType.NORMAL, getZeroBlockResetDelaySec() ); + manualReset( MineResetScheduleType.ZERO_BLOCK_RESET, getZeroBlockResetDelaySec() ); reset = true; } @@ -758,9 +763,9 @@ public boolean checkZeroBlockReset() { * triggered by a player. * */ - public void manualReset() { - manualReset( MineResetScheduleType.FORCED ); - } +// public void manualReset() { +// manualReset( MineResetScheduleType.FORCED ); +// } public void manualReset( MineResetScheduleType resetType ) { if ( !isVirtual() ) { diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java index e01772ca7..25e7ed617 100644 --- a/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java +++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/tasks/MinePagedResetAsyncTask.java @@ -10,6 +10,7 @@ import tech.mcprison.prison.mines.PrisonMines; import tech.mcprison.prison.mines.data.Mine; import tech.mcprison.prison.mines.data.MineScheduler.MineResetActions; +import tech.mcprison.prison.mines.data.MineScheduler.MineResetScheduleType; import tech.mcprison.prison.output.Output; import tech.mcprison.prison.tasks.PrisonRunnable; import tech.mcprison.prison.tasks.PrisonTaskSubmitter; @@ -19,6 +20,7 @@ public class MinePagedResetAsyncTask { private Mine mine; private final MineResetType resetType; + private final MineResetScheduleType resetScheduleType; private int position = 0; @@ -44,11 +46,14 @@ public class MinePagedResetAsyncTask - public MinePagedResetAsyncTask( Mine mine, MineResetType resetType, List resetActions ) { + public MinePagedResetAsyncTask( Mine mine, MineResetType resetType, + List resetActions, + MineResetScheduleType resetScheduleType ) { super(); this.mine = mine; this.resetType = resetType; + this.resetScheduleType = resetScheduleType; this.timeStart = System.currentTimeMillis(); @@ -64,13 +69,13 @@ public MinePagedResetAsyncTask( Mine mine, MineResetType resetType, List 0 && - (System.currentTimeMillis() - mine.getLastResetTimeLong()) <= 5000 ) { + (System.currentTimeMillis() - mine.getLastResetTimeLong()) <= 5000 && + ( resetScheduleType != MineResetScheduleType.ZERO_BLOCK_RESET || + resetScheduleType == MineResetScheduleType.ZERO_BLOCK_RESET && + mine.getBounds().getTotalBlockCount() > 25 + ) ) { + + if ( !mine.getMineStateMutex().isMinable() ) { + + // Canceling reset, so cancel mutex if it was blocking mining. + mine.getMineStateMutex().setMineStateResetFinishedForced(); + } + // cannot reset quicker than every 5 seconds: return; @@ -89,6 +105,11 @@ public void submitTaskAsync() { mine.setLastResetTimeLong( System.currentTimeMillis() ); + submitTaskAsyncInternalNextPage(); + } + + private void submitTaskAsyncInternalNextPage() { + if ( position > 0 && page++ % pagesPerReport == 0 ) { if ( PrisonMines.getInstance().getMineManager().isMineStats() ) { @@ -188,7 +209,7 @@ public void run() { // Keep resubmitting this task until it is completed: if ( position < targetBlocks.size() ) { - submitTaskSync(); + submitTaskAsyncInternalNextPage(); } else { @@ -235,6 +256,11 @@ private boolean runSetupCancelAutoResets() { mine.asynchronouslyResetSetup(); } + else if ( !mine.getMineStateMutex().isMinable() ) { + + // Canceling reset, so cancel mutex if it was blocking mining. + mine.getMineStateMutex().setMineStateResetFinishedForced(); + } return cancel; } 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 0e31159bc..029a3a130 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 @@ -317,6 +317,11 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuild MineTargetPrisonBlock targetBlock = mine.getTargetPrisonBlock( sBlockHit ); pmEvent.setTargetBlock( targetBlock ); + boolean bypassMatchedBlocks = pmEvent.getMine().getBounds().getTotalBlockCount() <= 25; + if ( bypassMatchedBlocks ) { + debugInfo.append( "(TargetBlock match requirement is disabled [blocks<=25]) " ); + } + boolean matchedBlocks = isBlockAMatch( targetBlock, sBlockHit ); // If ignore all block events has been set on this target block, then shutdown. @@ -349,7 +354,9 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent, StringBuild PrisonBlockStatusData pbTargetBlock = targetBlock.getPrisonBlock(); PrisonBlock pbBlockHit = sBlockHit == null ? null : sBlockHit.getPrisonBlock(); - if ( pbBlockHit != null && matchedBlocks ) { + if ( pbBlockHit != null && + (matchedBlocks || + !matchedBlocks && bypassMatchedBlocks )) { // Confirmed the block is correct... so get the drops... collectBukkitDrops( pmEvent.getBukkitDrops(), targetBlock, pmEvent.getItemInHand(), sBlockHit, pmEvent.getSpigotPlayer() ); @@ -498,7 +505,9 @@ else if ( targetExplodedBlock.isMined() ) { PrisonBlockStatusData pbTargetExploded = targetExplodedBlock.getPrisonBlock(); - if ( pBlockMined!= null && matchedExplodedBlocks ) { + if ( pBlockMined!= null && + ( matchedExplodedBlocks || + !matchedExplodedBlocks && bypassMatchedBlocks ) ) { // Confirmed the block is correct... so get the drops... collectBukkitDrops( pmEvent.getBukkitDrops(), targetExplodedBlock, pmEvent.getItemInHand(), sBlockMined, pmEvent.getSpigotPlayer() ); From 2878e56a52e181474d846077c4a6e4019abbaf52 Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Mon, 20 Jun 2022 14:30:28 -0400 Subject: [PATCH 296/297] v3.3.0-alpha.11k 2022-06-20 --- docs/changelog_v3.3.x.md | 4 + ...prison_docs_030_LuckPerms_Groups_Tracks.md | 85 ++++++++++++------- gradle.properties | 2 +- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 1d03d85eb..d889b76df 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -14,6 +14,10 @@ These build logs represent the work that has been going on within prison. # 3.3.0-alpha.11j 2022-06-20 +* **v3.3.0-alpha.11k 2022-06-20** +Plus luckperms doc update. + + * **Mine resets: Fixed an issue when dealing with zero-block resets on a very small mine, such as a one block mine in that the 5 second delay was preventing from rapid resets.** Bypass both 5 second cooldown on resets and blockmatching when 25 blocks or less for the mine size. With running resets in async mode, with rapid resets for a one-block mine, the handling of the block breaks can occur out of order, which will trigger the block mismatch. diff --git a/docs/prison_docs_030_LuckPerms_Groups_Tracks.md b/docs/prison_docs_030_LuckPerms_Groups_Tracks.md index 455ea7ea4..2e8448b25 100644 --- a/docs/prison_docs_030_LuckPerms_Groups_Tracks.md +++ b/docs/prison_docs_030_LuckPerms_Groups_Tracks.md @@ -334,13 +334,66 @@ Let's review the parts of that command:
-# Special Variation: Players can only Access the Mine tied to their Rank by using Permissions + + +# Setting up LuckPerms Chat Prefixes + + +To setup a LuckPerms chat prefix, using prison's rank tag, use the following command. This assumes you've followed the directions above with setting up a LP track. + + + +The following commands are examples of setting up a default prefix for your groups. You only need to use one command when setting up a default. + + +The first examples are pretty much identical. The second one is exactly the same as the first, except for it's using the placeholder's aliases. The third one is using the non-ladder variant which includes all rank tags for all ladders on which a player has a rank, which could be more than two. The drawback to the third one is that you don't have control over which one is displayed first. + +``` +/lp group default meta setprefix "%prison_rank_tag_prestiges%%prison_rank_tag_default% &r" +/lp group default meta setprefix "%prison_rt_prestiges% %prison_rt_default% &r" +/lp group default meta setprefix "%prison_rt% &r" + +``` + +This one is rather interesting since it provides the player's current Earnings per Minute. When auto pickup is enabled, and autosell is enable for each block break, then this will show the dynamic earnings as players chat. Providing such information may encourage players to see who can get the highest value. The full placeholder is shown for understandability, but the alias is probably ideal to use due to the shorter length: `%prison_pb_epmf%`. + +``` +/lp group default meta setprefix "%prison_rank_tag_prestiges%%prison_rank_tag_default% &4[&7%prison_player_balance_earnings_per_minute_formatted%&4] &r" +``` + + +Some other variations may include the player's health levels, the total number of blocks mined, or even which mine they are currently in. There are a lot of possibilities. + + + +You could use just `%prison_rank_tag%`, or it's alias `%prison_rt%`, but that will include the rank tags for all ranks the player has on the server. Normally they will always have a rank on the `default` rank, and optionally on the `prestiges` ladder too. If other ladders are setup, then they will also be included. Generally this is fine, but the drawback is that you cannot control the order in which they are generated. So as listed in the example above, we are controlling the order of the rank tags for both the prestiges and default ladder. The aliases for those two placeholders are `%prison_rt_prestiges%` and `%prison_rt_default%`. + + +Next, you need to install a plugin to enable the LuckPerms Chat Prefixes, which allows LuckPerms to resolve the placeholder through PlaceholderAPI. + + +Download the **LPC** plugin and place it in the server's `/plugins` directory. This plugin also requires the **PlaceholderAPI** plugin. Then restart the server. + + +[https://www.spigotmc.org/resources/lpc-chat-formatter-1-7-10-1-18-2.68965/](https://www.spigotmc.org/resources/lpc-chat-formatter-1-7-10-1-18-2.68965/) + + +There should be no configuration changes needed for the plugin, and it should just work. + + + + +
+ + +# Special Variation: Accessing Only One Mine at a Time by using Permissions One special variation in configuring your server, would be if players can "only" access mines that are tied to their current rank. For example, if a player is at Rank C, then they cannot access the prior mines A nor B. This is a very restrictive configuration, which requires managing the permissions. If you are using permissions for access, then the two you need to know about are: `mines.` and `mine..tp`. Such that mine A would require: `mines.a` and `mines.a.tp`. + Add these two perms to all LuckPerm groups. You can use the LP editor, or manually with the following commands. Repeat for all groups. ``` @@ -414,33 +467,3 @@ To review a player's rank within prison use `/ranks player `. - -# Setting up LuckPerms Chat Prefixes - - -To setup a LuckPerms chat prefix, using prison's rank tag, use the following command. This assumes you've followed the directions above with setting up a LP track. - - -``` -/lp group default meta setprefix "%prison_rank_tag_prestiges%%prison_rank_tag_default% &r" - -``` - -You could use just `%prison_rank_tag%`, or it's alias `%prison_rt%`, but that will include the rank tags for all ranks the player has on the server. Normally they will always have a rank on the `default` rank, and optionally on the `prestiges` ladder too. If other ladders are setup, then they will also be included. Generally this is fine, but the drawback is that you cannot control the order in which they are generated. So as listed in the example above, we are controlling the order of the rank tags for both the prestiges and default ladder. The aliases for those two placeholders are `%prison_rt_prestiges%` and `%prison_rt_default%`. - - -Next, you need to install a plugin to enable the LuckPerms Chat Prefixes, which allows LuckPerms to resolve the placeholder through PlaceholderAPI. - - -Download the **LPC** plugin and place it in the server's `/plugins` directory. This plugin also requires the **PlaceholderAPI** plugin. Then restart the server. - - -[https://www.spigotmc.org/resources/lpc-chat-formatter-1-7-10-1-18-2.68965/](https://www.spigotmc.org/resources/lpc-chat-formatter-1-7-10-1-18-2.68965/) - - -There should be no configuration changes needed for the plugin, and it should just work. - - - - -
\ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 9af9cc69d..2a8c888dd 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.11j +version=3.3.0-alpha.11k From bce7459e9fc9c5d553a91e40bb3ca6e790b73f5f Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sat, 25 Jun 2022 11:17:26 -0400 Subject: [PATCH 297/297] v3.3.0-alpha.12 --- docs/changelog_v3.3.x.md | 6 +- gradle.properties | 2 +- .../placeholder/SpigotPlaceholders.java | 77 ++++++++++--------- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index d889b76df..3702a8db8 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -11,7 +11,11 @@ These build logs represent the work that has been going on within prison. -# 3.3.0-alpha.11j 2022-06-20 +# 3.3.0-alpha.12 2022-06-25 + + +* **v3.3.0-alpha.12 2022-06-25** + * **v3.3.0-alpha.11k 2022-06-20** diff --git a/gradle.properties b/gradle.properties index 2a8c888dd..f5658bab9 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.11k +version=3.3.0-alpha.12 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 c8cce41f1..ac7a3c4ea 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 @@ -302,43 +302,46 @@ private String processPlaceholderHavePlaceholderKey( PlaceholderIdentifier ident PlaceHolderKey placeHolderKey = identifier.getPlaceholderKey(); - if ( mm != null && - (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) - )) { - - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { - - mm.getTranslateMinesPlaceholder(identifier); - } - - } - else if ( pm != null && - (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ) - )) { - - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { - - pm.getTranslatePlayerPlaceHolder( identifier ); - } - - } - else if ( rm != null && - (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || - placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) - )) { - - if ( identifier.checkPlaceholderKey(placeHolderKey) ) { - - rm.getTranslateRanksPlaceHolder( identifier ); - } - - } + if ( placeHolderKey != null && placeHolderKey.getPlaceholder() != null ) { + + if ( mm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSMINES ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) + )) { + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + mm.getTranslateMinesPlaceholder(identifier); + } + + } + else if ( pm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYER ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.LADDERS ) + )) { + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + pm.getTranslatePlayerPlaceHolder( identifier ); + } + + } + else if ( rm != null && + (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.RANKPLAYERS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSRANKS ) || + placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.STATSPLAYERS ) + )) { + + if ( identifier.checkPlaceholderKey(placeHolderKey) ) { + + rm.getTranslateRanksPlaceHolder( identifier ); + } + + } + } return identifier.getText();