This is an extremely simple plugin with no commands or permissions that uses bytecode manipulation through
ByteBuddy to modify the Minecraft Server source code to unnerf the infinity and mending enchantments!
I was developing this for my own server as part of another plugin with more various features, however I thought people may find this useful, so I quickly threw together a standalone plugin only containing this feature.
I have tested this plugin on 1.11 to 1.18, and it has worked on all versions. If something changes in the future, I will update this plugin to support that, however I doubt it will break anytime soon. Enjoy!
IMPORTANT: JAVA 10 AND BELOW IS UNSUPPORTED. Please use Java 11 or newer. While JDK 8 (not JRE 8), Java 9 and up should work, Java 11 or newer is ideal and should be used where possible.
NOTE: Because of the nature of this plugin, the server MUST fully restart in order for it to be removed. Using other plugins like PlugMan to remove this plugin may break things.
The way this plugin works, is it uses reflection to find the NMS class "net.minecraft.server.VERSION.EnchantmentInfiniteArrows", then uses ByteBuddy, an ASM wrapper, to do some bytecode manipulation and replace the method "a" (in 1.14.3) that takes Enchantment as an argument, and it replaces it with a call to the superclass (Enchantment)'s method.
This method is designed as a test for compatibility of two enchantments when Minecraft is determining if an enchantment is valid. For example, when putting an item in an anvil, Minecraft will iterate through the list of enchantments on one item, and check them against the enchantments on the other item by using this method. In most cases, the method simply returns true if the two enchantments are different, and false if they are the same. However, for infinity, it will also return false if the second enchantment is mending, in order to keep the two exclusive.
By removing this unique method and simply calling the superclass, infinity and mending are no longer exclusive and the enchantments can be mixed as if nothing had ever changed!
Data Collection: This plugin utilizes bStats for plugin metrics. bStats does not collect any personal data. Most of the collected data is information about the plugin's server like player count, online mode, Minecraft version, Java version, and more. All data gets sent and stored completely anonymously. Server IPs are only stored for ratelimiting and not linked to the data. All data that is collected is publicly visible. If you are interested in what data is collected for your Minecraft server, take a look at the pages for the plugins on your server. Please note that plugin authors can also send data that is customized for their plugin.
If you don't want bStats to collect data from your server, you can disable it in the bStats config file. This file can be found in the /plugins/bStats/ folder.
More information is available
here
If you found my plugin useful, please consider
donating to help me out, as I am a student, and with great education, comes great student loans!