Using configured settings within your plugin
The current EventHandler method
of the MobEnhancer
plugin sets the health of zombies to 40
, where the number 40 is
hardcoded. This means that the value of 40
is a part of the code itself, and this cannot be changed after the code is compiled. We wish to make this value
softcoded, that is, we want to retrieve the value from an external source, which is config.yml
in our case:
Currently, the onMobSpawn
method is as follows:
@EventHandler public void onMobSpawn(CreatureSpawnEvent event) { if (event.getEntityType() == EntityType.ZOMBIE) { int health = 40; event.getEntity().setMaxHealth(health); event.getEntity().setHealth(health); } }
We will work from this existing code. The if
statement is no longer needed, ...
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.