Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by iMedia, Aug 10, 2018.
I was wondering how would I add a toggleable command that disables/enables an event?
Add a command, make it change a variable, make the event check that variable every time it's fired.
How would I check the variable/change it?
Let's take for example a boolean variable. Each time the command runs check the boolean value, if the value is true set (for example) weather to rainy else if the value is false set (for example) weather to sunny. After each change you need to change the boolean value to the opposite of it.
boolean toggle = true;
// AFTER THE TOGGLE
toggle = !toggle;
I still don't get how to check it and how do I cancel a event if it is a ! im so cofused xd
Use getters and setters. https://stackoverflow.com/questions/2036970/how-do-getters-and-setters-work
var toCancel = false
toCancel = !toCancel
if (toCancel) return@listen
Something along those lines but in Java.