Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Fixes Spigot dependencies and various issues #549

Merged
merged 12 commits into from
Nov 9, 2021
Merged

Fixes Spigot dependencies and various issues #549

merged 12 commits into from
Nov 9, 2021

Conversation

datatags
Copy link
Collaborator

@datatags datatags commented Oct 29, 2021

What is the purpose of this pull request?

Fixing bugs, including:

  1. Changes Spigot dependencies in subprojects
  2. Fixes issue Why do you cancel every InventoryClickEvent? #499
  3. Fixes issue Duplicating items  #528
  4. Fixes issue Console Warning from Paper #544
  5. Fixes issue Does not unequippe morphs #537
  6. Fixes issue Emote head dupe glitch #515
  7. Fixes issues When I use the Paint Gun and the blocks are not placed and I throw the following error or log into the console. #463 and Paintball Gun: LIGHT_GRAY isn't a colour (1.8.8) #482, same issue
  8. Fixes issue Trampoline is just white wool + ladder falls off #506
  9. Fixes issue Particles #550
  10. Fixes issue Corner stairs don't revert back to normal ones after using something that changes blocks. #491 for treasure chests only

How do your changes address the purpose?

  1. Some subprojects depended on full CraftBukkit and Spigot-API, which seemed strange since that's basically just a roundabout dependency on full Spigot, so I've changed it to that. Also, some projects depended on Spigot in a non-standard way, and whatever repo served it before doesn't anymore, so I've changed it to the standard full Spigot dependency which pulls from your local Maven repo.
  2. As was suggested in Why do you cancel every InventoryClickEvent? #499, I created CosmeticsInventoryHolder and changed all Bukkit.createInventory() calls to use it. Then, in PlayerListener, I changed it so it would cancel InventoryClickEvent if the item involved was a chest OR if the inventory is "held" by CosmeticsInventoryHolder.
  3. Rewrote Gadget click listener so it takes into account both items that are swapped in the event.
  4. Rewrote SmartLogger so it uses the plugin's logger instead of System.out.
  5. Modified the UltraPlayer#clear() method so if the player is marked as quitting, morphs will be removed regardless of what world they're in. This was enough to fix it because the player is already marked as quitting when switching worlds.
  6. Modified ItemFactory#createSkull and TexturedSkullFactory#createSkull so they use CraftMetaSkull#setProfile(GameProfile) when available rather than setting the field directly. This fixes it because a change in 1.15 requires a new field, serializedProfile, to be set and checked. Setting the profile field directly doesn't set this serializedProfile field, and it throws an error (see my post in Emote head dupe glitch #515). Using setProfile() sets serializedProfile for us as well as the standard profile field.
  7. DyeColor.LIGHT_GRAY was named DyeColor.SILVER before 1.13, so I just added a check in BlockUtils#getBlockByColor()
  8. In GadgetTrampoline#setToRestore(), there was a line block.getState().setRawData(data) which doesn't do anything since block.getState() always returns a copy of the state, meaning that the next line, block.getState().update() can't ever do anything. This was resolved by using a variable. Also, I changed out the Map with a Set since the value was never used, only the key.
  9. Added a new config option for most particles called "Particle-Multiplier". 1.0 is the default, it's 100%. Setting it to 0 uses the minimum amount of particles, in some cases with interesting results (see SantaHat)
  10. Rewrote TreasureChest.java to use BlockStates instead of Material + data (so it can even restore chest contents that were overwritten) and some other minor optimizations.

Changes

  • Created CosmeticsInventoryHolder
  • Changed Bukkit.createInventory() calls
  • Changed PlayerListener to use CosmeticsInventoryHolder
  • Fixed some dependency weirdness
  • Rewrote Gadget InventoryClickEvent listener to consider keyboard keys correctly
  • Rewrote SmartLogger a bit
  • Slightly adjusted UltraPlayer#clear()
  • Changed createSkull methods in TexturedSkullFactory and ItemFactory
  • Slight change in BlockUtils#getBlockByColor()
  • Adjusted GadgetTrampoline#setToRestore()
  • Added Particle-Multiplier in particle cosmetics
  • Rewrote TreasureChest.java

Thanks!

@datatags datatags marked this pull request as draft October 30, 2021 04:15
@datatags
Copy link
Collaborator Author

I'm actually marking this as WIP to see if I can fix #528 also. Currently it still lets you drop gadgets into chests using number keys.

@datatags
Copy link
Collaborator Author

That was easier than I thought. Opened again.

@datatags datatags marked this pull request as ready for review October 30, 2021 05:18
@datatags datatags changed the title Fixes #499 and fixes Spigot dependencies Fixes #499, #528, and Spigot dependencies Oct 30, 2021
@datatags datatags changed the title Fixes #499, #528, and Spigot dependencies Fixes Spigot dependencies and various issues Nov 1, 2021
@datatags
Copy link
Collaborator Author

datatags commented Nov 1, 2021

In rewriting SmartLogger, the log messages look nicer too IMO. Before:

[02:06:41 INFO]: [UltraCosmetics] Enabling UltraCosmetics v2.5.11
[02:06:42 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: -------------------------------------------------------------------
[02:06:42 WARN]: Nag author(s): '[iSach]' of 'UltraCosmetics' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[02:06:42 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: UltraCosmetics v2.5.11 is loading... (server: 1.17.1)
[02:06:42 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: Thanks for downloading it!
[02:06:42 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: Plugin by iSach.
[02:06:42 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: Link: http:https://bit.ly/UltraCosmetics
[02:06:42 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: Initializing module v1_17_R1
[02:06:42 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: bStats enabled!
[02:06:42 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: Module initialized
[02:06:43 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]:
[02:06:43 INFO]: [PlaceholderAPI] Successfully registered expansion: ultracosmetics
[02:06:43 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: Hooked into PlaceholderAPI
[02:06:43 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]:
[02:06:43 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]:
[02:06:43 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: Hooked into Vault for economy: EssentialsX Economy
[02:06:43 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]:
[02:06:44 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: UltraCosmetics successfully finished loading and is now enabled!
[02:06:44 INFO]: [UltraCosmetics] [STDOUT] 11/01/2021 - UltraCosmetics [INFO]: -------------------------------------------------------------------

After:

[10:41:21 INFO]: [UltraCosmetics] Enabling UltraCosmetics v2.5.11
[10:41:21 INFO]: [UltraCosmetics] -------------------------------------------------------------------
[10:41:21 INFO]: [UltraCosmetics] UltraCosmetics v2.5.11 is loading... (server: 1.17.1)
[10:41:21 INFO]: [UltraCosmetics] Thanks for downloading it!
[10:41:21 INFO]: [UltraCosmetics] Plugin by iSach.
[10:41:21 INFO]: [UltraCosmetics] Link: http:https://bit.ly/UltraCosmetics
[10:41:21 INFO]: [UltraCosmetics] Initializing module v1_17_R1
[10:41:21 INFO]: [UltraCosmetics] bStats enabled!
[10:41:21 INFO]: [UltraCosmetics] Module initialized
[10:41:21 INFO]: [UltraCosmetics]
[10:41:21 INFO]: [PlaceholderAPI] Successfully registered expansion: ultracosmetics
[10:41:21 INFO]: [UltraCosmetics] Hooked into PlaceholderAPI
[10:41:21 INFO]: [UltraCosmetics]
[10:41:21 INFO]: [UltraCosmetics]
[10:41:21 INFO]: [UltraCosmetics] Hooked into Vault for economy: EssentialsX Economy
[10:41:21 INFO]: [UltraCosmetics]
[10:41:22 INFO]: [UltraCosmetics] UltraCosmetics successfully finished loading and is now enabled!
[10:41:22 INFO]: [UltraCosmetics] -------------------------------------------------------------------

@datatags
Copy link
Collaborator Author

datatags commented Nov 6, 2021

In this last commit, I did three major things:

  1. Removed the BlockUtils.forceRestore() method because it looks like no block changes actually occur (only Player#sendBlockChange), so there's nothing that needs to happen on server shutdown. Worst case some ghost blocks remain when using /reload but it's generally agreed you shouldn't do that.
  2. Created a new class, BlockViewUpdater that is a BukkitRunnable that handles the "restoring" of blocks rather than using a map and a function that serializes the info to a string and back.
  3. Rewrote the setToRestore method. It used a huge chain of if not w and x and y and z, so I loaded all the mentioned materials into a Set and had it check through those instead.

@iSach iSach merged commit ac8bc51 into iSach:master Nov 9, 2021
@iSach
Copy link
Owner

iSach commented Nov 9, 2021

Thanks a lot for your huge contributions, these are highly, highly appreciated!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants