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.
This commit is contained in:
GKasparov 2021-08-30 14:15:26 +10:00 committed by GitHub
parent ca78215100
commit 90fec80bb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}
}
}