Spell hotbar
ImNotASpy opened this issue · 5 comments
Hello!
I have a plugin called talismans and another one called angelchests. These plugins both have the ability to use items in the inventory at all times. For example, there is a talisman that, when sitting in the inventory, it gives the user night vision. From the angelchest plugin, a totem of undying can be used from the inventory when a player dies.
I am having issues with being able to use these features due to the wand controls being used from Magic. The default Wand controls that replace the user's inventory and hotbar with skills, replaces the objects such as the talisman or totem of undying. These features do not work when the spell hotbar is visible.
A player would be fighting a Mob, swap to spell hotbar and then the totem of undying will not work since it's in the inventory. When a user has spell hotbar active, they no longer receive a talisman effect like night vision.
I am wondering if there is a way to somehow make this feature work without having to change the spell controls.
Thanks for your awesome plugin!
Depending on how your plugin works, you may be able to do this pretty easily!
How do you check for the items? Is it something like when an event triggers you're scanning the player's inventory?
If so then I think you could hook into Magic's API, see if the player has the spell inventory open, then get their survival inventory from Magic, and search through that instead.
Would that work?
Is there a public maven repository for the dependency? I don‘t really wanna have to rely on mvn installing it manually as I use Jenkins in docker to build
Thanks, i didnt find the dependency information in the repo but granted, i only looked at the repo from my phone lol. I‘ll check it out tomorrow @NathanWolf
Woops wrong ping - wanted to ping @ImNotASpy
The API is available in Maven Central.
The one there is pretty outdated, but should have the methods you need to check player's inventory.
Instructions are in the readme here:
https://github.com/elBukkit/MagicPlugin/tree/master/MagicAPI
Once you have the dependencies working and have a MagicAPI reference, you want to get the MageController via getController, then you can get a Mage for a player via getMage.
The Mage class will have the methods you need, namely hasStoredInventory
and getInventory
(which will return the stored inventory if hasStoredInventory()
returns true)