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:
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 will have one parameter, namely a string named msg
. After creating this second method, your class will look like the following code:
public class MyFirstBukkitPlugin extends JavaPlugin { @Override public void onEnable() { } private void broadcastToServer(String msg) { } }