private void handleBlockChange(Player player, Block block, short entityID, String mobName) { if (!player.hasPermission("silkspawners.changetype." + mobName)) { su.sendMessage( player, ChatColor.translateAlternateColorCodes( '\u0026', plugin.localization.getString("noPermissionChangingSpawner"))); return; } // Call the event and maybe change things! SilkSpawnersSpawnerChangeEvent changeEvent = new SilkSpawnersSpawnerChangeEvent( player, block, entityID, su.getSpawnerEntityID(block), 1); plugin.getServer().getPluginManager().callEvent(changeEvent); // See if we need to stop if (changeEvent.isCancelled()) { return; } // Get the new ID (might be changed) short newEntityID = changeEvent.getEntityID(); String newMob = su.getCreatureName(entityID); if (su.setSpawnerType( block, newEntityID, player, ChatColor.translateAlternateColorCodes( '\u0026', plugin.localization.getString("changingDeniedWorldGuard")))) { su.sendMessage( player, ChatColor.translateAlternateColorCodes( '\u0026', plugin.localization.getString("changedSpawner")) .replace("%creature%", newMob)); } }
private void handleChangeEgg( Player player, short entityID, String mobName, ItemStack itemInHand) { if (!player.hasPermission("silkspawners.changetypewithegg." + mobName)) { su.sendMessage( player, ChatColor.translateAlternateColorCodes( '\u0026', plugin.localization.getString("noPermissionChangingEgg"))); return; } // Call the event and maybe change things! SilkSpawnersSpawnerChangeEvent changeEvent = new SilkSpawnersSpawnerChangeEvent( player, null, entityID, su.getStoredSpawnerItemEntityID(itemInHand), itemInHand.getAmount()); plugin.getServer().getPluginManager().callEvent(changeEvent); // See if we need to stop if (changeEvent.isCancelled()) { return; } // Get the new ID (might be changed) short newEntityID = changeEvent.getEntityID(); String newMob = su.getCreatureName(entityID); ItemStack newItem = su.setSpawnerType(itemInHand, newEntityID, plugin.localization.getString("spawnerName")); su.nmsProvider.setSpawnerItemInHand(player, newItem); su.sendMessage( player, ChatColor.translateAlternateColorCodes( '\u0026', plugin.localization.getString("changedEgg")) .replace("%creature%", newMob)); }