ZeppelinII Posted February 5, 2016 Share Posted February 5, 2016 Does anyone know if it is possible to stop a method from from firing? Events.OnPlayerUpdate.Add(checkPlayer) i tried this, but i got an error - Events.OnPlayerUpdate.Remove(checkPlayer) So if anyone knows how to accomplish this functionality then please let me know or if you know that it isn't possible that would be great also. I just feel like this would be the optimal solution for toggling a feature on/off as opposed to checking a condition once inside the method. Thank you for your responses. Link to comment Share on other sites More sharing options...
RoboMat Posted February 6, 2016 Share Posted February 6, 2016 You could use a flag: if updatePlayer then -- doStuffend When you don't want to fire the event simply set updatePlayer to false. It's a bit hacky but it should work. EnigmaGrey 1 Link to comment Share on other sites More sharing options...
ZeppelinII Posted February 6, 2016 Author Share Posted February 6, 2016 Thank you, but I know that is an option. I was hoping that i could just remove the call to that function all together as to not have useless/unnecessary calls to a method I no longer want to invoke. If there is no other way, I will just do it this way. Thought it would be nice to save the user some cpu time (however minimal). Link to comment Share on other sites More sharing options...
RoboMat Posted February 6, 2016 Share Posted February 6, 2016 I don't think removing event hooks is possible ... you could spelunk in the java source and check the EventManager if you want to be sure (it's been quite some time since I've actively written mods so it might have changed in the meantime). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now