📖 EnchantmentLeveler 1.0 [API 4.0.3]

EnchantmentLeveler

EnchantmentLeveler is a Sponge clone of the ancient af Bukkit plugin AutoEnchanter.

Features:

  • Use an item enough and it levels up!
  • When an item levels up, an enchantment is added to it (or its enchantment level increases).
  • Any enchantment you want, on any item you want, at any level you want.
  • You can increase level requirements per level.
  • You can also curve this exponentially.

Config

If you used the Bukkit plugin, then you already know how to configure this plugin. Just think HOCONwards.
Except for the unsafe tag. I removed it because it was pointless (you are already specifying a max level).
Example config (look familiar?):

"minecraft:diamond_pickaxe" { break { "minecraft:gold_ore" { enchant="minecraft:fortune" levelFactor=1 } enchant="minecraft:efficiency" rate=1.0 maxLevel=5 permission="enchantmentleveler.level" } } "minecraft:diamond_sword" { damage { enchant="minecraft:sharpness" rate=1.0 maxLevel=2 } }
Here are all the tags and what they do:
maxLevel: The maximum enchantment level that this enchantment can attain. This can be larger than is possible normally. Optional, defaults to the normal max level of that enchantment.
rate: How much XP is gained for this enchantment. Optional, defaults to 0.1.
levelFactor: The rate that the XP required to level up increases per-level. Optional, defaults to 1.0.
levelCurveFactor: The exponent that will be applied to the enchantment level before multiplying by levelFactor. Optional, defaults to 1.0.
permission: The permission node required to gain XP from this action. Optional, no permission will be checked if absent.
enchant: The enchantment that will be added to or leveled up on the item. Nothing will happen if this is not specified.
levelRequirement: The amount of XP required to level up this enchantment. Optional, defaults to 10.0.

These tags are used within the two action nodes, which are break and damage, referring to breaking blocks and damaging entities respectively. Action nodes go under the base item node, which is the item type that you will be checking. Inside an action node, you can also put a block node, which is the name of a block the item can break. You can then use block-specific options. Unspecified tags will be inherited from the action node.
For example, if I were checking for when a stone shovel breaks a snow block, my node would be here:

"minecraft:stone_shovel" { break { "minecraft:snow" {
Note: Also inside the config folder is a file called levels.bin. Don’t touch this or you’ll reset everyone’s XP progress.

Commands

The only command that I would fathom that you’d need is /enchantmentleveler reload, or /el reload for short. The permission to do so is enchleveler.reload.

Download

EnchantmentLeveler.jar

Changelog

1.0: Released! Yay!

3 Likes

Nice work, did you consider using custom DataAPI to keep track of item levels?

No. Should I have? I just convert my HashMap<​UUID, HashMap<​ItemType, HashMap<​Enchantment, Double>>> to a HashMap<​UUID, HashMap<​String, HashMap<​String, Double>>> and then ObjectOutputStream it.
Edit: Damn you, HTML parsing. But you are no match for my zero-width spaces!

It would allow you to store the level information of the item directly on the item stack without having to worry about saving it manually when the world saves, it can be a little tricky to get the interface right without an example though.

Additionally when people serialize itemstacks to configs / databases it would also save the level of the item with it, so you could potentially have a shop plugin that could sell these pre-levelled, without having to provide explicit support for it.

Hm. I’ll look into that. However, I think that it’s better to save the XP to the player rather than the item.

Yeah I might not understand 100% of the mechanics of your plugin, it may be that it’s better to do it as you are saving it now if the levels are player and item specific.

Just noticed this! Thanks so much!

Update:

Works great! I think it would be a good idea to add a configurable message for when the level up occurs, would even be cool to have different messages depending on the item and enchant.

I notice you are hosting your file with google drive, which can be a bit of a nuisance for wget or curl. I’d for sure be willing to host the jars for you, perhaps on a jenkins or something… if you’re interested. To show my appreciation for your work.

Could you make this plugin to add damage of weapons and protection to armors as well?

Ordinarily, I’d say that it’s a year old and I don’t really support it anymore. But today is your lucky day - I can instead tell you that I’m pretty sure those things aren’t present in the API.

Ok… Thanks for your reply.

Is there a version for API 5/6 or the source so that i can compile a version by myself?

What do you mean by this?

What’s missing pie? has an issue been filed?

The things he said - weapons’ attack damage and armor pieces’ protection. And no, I didn’t.

Are there any plans to continue development on this to Sponge API 7.0.0?

I have this in my console after the server is finished loading.