Aight, So I have made a TownyFly plugin that allows players to fly within their town, I've been ironing out all the problems with it but there is one I am confused on. When a player opens their inventory while in mid air their fly mode gets disabled and they drop to the ground and die. Is there a EventHandler that listens for inventories opening and closing or am I overthinking this bug? How would I fix this? Cheers, Panda !
Problem might be that there is no event, for players opening their own inventory. AFAIK the only way knowing is the achievement, but that would need faking not having it + resetting. So for opening their own inventory i assume that something like the InventoryClickEvent could be helpful to at least do something then. (If you made a count down from 5 or so, for players who stand still in-air while flying, you'd still have them opening their inventory when flying at some speed, so they actually don't stand still. In addition cheats or inventory managers would rather be quick, so one penalizes legitimate players rather than cheaters.)
Both of these don't allow me to check if the player if flying, or if their fly mode is set? Which is annoying, would their be another alternative to the problem? Or is this the most effective way to fix it?
Yaa sorry, just noticed what I put and recoiled in horror, brainfart moment xD. Still failing to resolve the bug, here is my code if you're able to point out something I have missed: https://github.com/StuddedExpandable/TownyFly/blob/master/src/thevoxstudios/vtownyfly/TownyFly.java Guess I'll try it out, nothing to lose xD.
Ohh alright, So InventoryOpenEvent & InventoryCloseEvent are useless in my case? Any other way I can resolve this easily?
Yeah since you wouldn't be able to listen for them with an event. But you can however have a repeating loop that checks to see if the player's opened inventory is theirs. I'm not 100% if that's how it works though.
that really helps when you read the spigot javadoc Code (Java): // when player opens a inventory InventoryOpenEvent for(Player p : e.getViewers()) { if(p.isFlying()) { // do something } }