O'Reilly logo

Building Minecraft Server Modifications by Cody M. Sommer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing variables from another class

Our MobEnhancer class is growing in size. There is no need to place all of our code within a single class. Our one class is extending the JavaPlugin class as well as implementing both the Listener and CommandExecutor interfaces. Our program may be easier to understand if we split these into three unique classes.

Create two new classes named MobSpawnListener and MobEnhancerReloadCommand. MobEnhancer will still be your main class, so it will still extend JavaPlugin. However, the two new classes will implement Listener and CommandExecutor, respectively. Move the appropriate methods to their new classes. That is, onMobSpawn is an event handler, so it belongs within the Listener class and onCommand belongs within ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required