In this case, the type is PotionEffectType.INVISIBILITY and we want it to last forever,
so we'll make the duration the largest possible value we can: Integer.MAX_VALUE .
There is no integer larger. The magnitude doesn't really matter in this case,
as you can't be any “more invisible,” so we'll just use a 1.
Finally, we add that new potion to the bat, and it's invisible.
Congratulations! You are now the proud owner of flying creepers. Good luck,
and stay low.
For extra credit, you could go back and modify the SquidBomb to generate a ton
of invisible creepers instead of squid. That'd be fun.
We'll see some more examples of modifying and spawning entities in the next
section, once we see how to listen for game events.
Listen for Events
Now we get to the best part. You know how to write code for commands the
user types in and you know how to do things to affect the world. Now it's time
to see how to monitor what's going on in the world so you can respond to
gameplay automatically, without typing in a command or anything.
It works like this: you set up your code such that your functions get called
when some interesting event happens. In your function, you can let the events
happen or you can stop them.
Here's a skeleton of what we need to add to our basic plugin in order to
incorporate a listener. There are four parts to it: