Making and calling new methods

Let's create a new method that will broadcast a message to the server. The following diagram labels the various parts of a method in case you are not familiar with them:

Making and calling new methods

Create a new method named broadcastToServer. We will place it in the MyFirstBukkitPlugin class under the onEnable method. We only want to call this method from inside the MyFirstBukkitPlugin class so that the access modifier will be private. If you want to call this method from other classes in the plugin, you can remove the modifier or change it to public. The method will not return anything and thus will have a return type of void. Finally, the method ...

Get Building Minecraft Server Modifications - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.