Garbage Collector - BoBoBalloon/InnovativeItemsDOCS GitHub Wiki

Intro

When running a server with custom items, it is likely that there will be a balance issue where an item is too strong or too weak. You can change the configuration file to be more fair, but what about all the items currently in circulation? This is where the garbage collection system comes in.

Features

The garbage collection system is capable of identifying custom items in the player's inventory and insuring that the item matches the currently up-to- date item stored in the plugin's cache.

There are also cases where you as a server owner no longer want a custom item you built on your server. The garbage collection can also detect if an item has been removed from your configuration files and delete the item in the player's inventory.

Triggers

The garbage collection system makes sure to do all the heavy lifting asynchronously to ensure that it does not impact your servers performance and cause lag.

The garbage collection system checks on the following events:

  • When the configuration is reloaded
  • When a player joins the game
  • When a player opens a container
  • When a player picks up an item

Because of this, items are not constantly checked, which would eat up valuable server resources, but they are checked enough to ensure the security and integrity of the items circulating in the server economy.

What you can do

This is a powerful system, but because of that, it could also lead to issues. For example, if you as a server owner are testing new updates for items, or balancing by removing an item, but you don't want the garbage collector to remove the item yet since you are unsure this change will be permanent. Because of this the garbage collector has options that you as a server owner can set to fit your needs.

To access these options, please go into the plugin root folder and go into the file named "config.yml", this is the main config file with many general options for the plugin. Once you are there, look for the section named "garbage-collector". Once you have found it, there should be two options: should-update and should-delete.

The should-update option will make sure that if the garbage collector encounters a custom item, it will compare it with the current version of the item and if it does not match, it will update it. If this option is set to false, this check will not occur.

The should-delete option will make sure that if the garbage collector encounters a custom item it cannot recognize, it will delete the item, no questions asked. If this option is set to false, this check will not occur.

#The garbage collector will update items in inventories so they match updates in the configs#
garbage-collector:
  should-update: true #if true, when a custom item does not match the values in the config, will update the item to match config
  should-delete: true #if true, when a custom item is not present in the cache, the garbage collector will delete the item

You can make sure that the garbage collector reads these options by either the innovative items reload command or by restarting the server.

Final Thoughts

This system is powerful and gives you more control as a server owner, but just as Uncle Ben said, "With great power comes great responsibility". This is even more true with this system, because it is so powerful the consequences could be catastrophic if a mistake is made. Because of this, please ensure to use this system to the fullest and make constant backups of your server so on the off chance that a mistake occurs, you are prepared.