From 90fec80bb33bf6ec418622e19e1698284793ec8b Mon Sep 17 00:00:00 2001 From: GKasparov <60962839+GKasparov@users.noreply.github.com> Date: Mon, 30 Aug 2021 14:15:26 +1000 Subject: [PATCH] giveOldEgg function This change is to add a function that will give the player the egg of the old mob of the spawner when they change the mob. It also adds an option in the config.yml to either enable or disable it. --- .../epicspawners/listeners/InteractListeners.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/epicspawners/listeners/InteractListeners.java b/src/main/java/com/songoda/epicspawners/listeners/InteractListeners.java index bdc5bbe..713b3fe 100644 --- a/src/main/java/com/songoda/epicspawners/listeners/InteractListeners.java +++ b/src/main/java/com/songoda/epicspawners/listeners/InteractListeners.java @@ -146,7 +146,14 @@ public class InteractListeners implements Listener { spawner.getCreatureSpawner().setSpawnedType(EntityType.DROPPED_ITEM); } spawner.getCreatureSpawner().update(); - + + if (plugin.getConfig().getBoolean("giveOldEgg")) { + CreatureSpawner creatureSpawner = (CreatureSpawner) block.getState(); + ItemStack oldEgg = new ItemStack(item.getType(), 1); + ((SpawnEggMeta) oldEgg.getItemMeta()).setSpawnedType(creatureSpawner.getSpawnedType()); + player.getInventory().addItem(oldEgg); + } + plugin.processChange(block); ItemUtils.takeActiveItem(player, CompatibleHand.getHand(event), bmulti); } @@ -231,4 +238,4 @@ public class InteractListeners implements Listener { EpicSpawners.getInstance().getDataManager().createSpawner(spawner); return spawner; } -} \ No newline at end of file +}