Custom Enchantments

Does anyone have or care to look into making a custom enchantment plugin, iv looked everywhere they existed on api 5 and 6 but i havent seen anything for api 7 or 8

Or does anyone have information as to why there is such a lack of this plugin type and is it possible to code myself…

Its possible. Its just there is a lack of need and want from developers. By all means make one yourself.

Do you have any example snippets of sponge item get inventory get codes iv used spigot but never used sponge api

Do you mean getting a item from a inventory? In that case it depends on what inventory (e.g, a item from a players hotbar, item from a chest, item from a furnace)?

Getting an item from a players inventory not the hotbar itself but the inventory, finding the lore/name and applying the right effects depending on what lore/name is present

I havent done inventory handling for a while but if i remeber, you first get the section of the inventory you want and then query for the Slot you wish to target, after that do slot manipulation for the item.

I dont want to spoon feed you so im going to go off memory for the api.

PlayerInventory inv = player.getInventory();
MainPlayerInventory pInv = inv.getMain(); //this is the section of the players inventory that is above the hotbar
Slot slot = pInv.query(QueryOperationTypes.INVENTORY_PROPERTY.of(SlotPos.of(2, 1))); //gets the slot on the 2nd row and 3rd across (remeber 0 is a value too)
Optional<ItemStack> opItem = slot.peek(); //gets the item in the slot, returns Optional.empty() if no item was found

As for Lore and name. This is how to get the name, same goes for lore just change the key.

ItemStack item;
String itemName = item.get(Keys.DISPLAY_NAME);

And this is how to set an items name, same goes for lore just change the key.

Text name;
ItemStack item;
item.offer(Keys.DISPLAY_NAME, name);

Take a look at the sponge docs for way more info on many aspects of the sponge api. The link i have provided takes you directly to the ItemStack use.

https://docs.spongepowered.org/stable/en/plugin/items/usage.html

You my friend are a god from above <3

1 Like