use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class AdminCommands method clearZombies.
public void clearZombies(CommandSender sender) {
if (checkSenderIsConsole(sender))
return;
if (!hasPermission(sender, "villagedefense.admin.clear"))
return;
if (!checkIsInGameInstance((Player) sender))
return;
Arena arena = ArenaRegistry.getArena((Player) sender);
if (arena.getZombies() != null) {
for (Zombie zombie : arena.getZombies()) {
zombie.getWorld().playEffect(zombie.getLocation(), Effect.LAVA_POP, 20);
zombie.remove();
}
arena.getZombies().clear();
} else {
sender.sendMessage(ChatManager.colorMessage("Kits.Cleaner.Nothing-To-Clean"));
return;
}
sendSound((Player) sender, "ENTITY_ZOMBIE_DEATH", "ZOMBIE_DEATH");
for (Player loopPlayer : arena.getPlayers()) {
String message = ChatManager.formatMessage(arena, ChatManager.colorMessage("In-Game.Messages.Admin-Messages.Removed-Zombies"), new Player[] { (loopPlayer) });
loopPlayer.sendMessage(ChatManager.PLUGIN_PREFIX + message);
}
}
use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class AdminCommands method setWave.
public void setWave(CommandSender sender, String number) {
if (checkSenderIsConsole(sender))
return;
if (!checkIsInGameInstance((Player) sender))
return;
if (!hasPermission(sender, "villagedefense.admin.setwave"))
return;
Arena arena = ArenaRegistry.getArena((Player) sender);
if (NumberUtils.isNumber(number)) {
arena.setWave(Integer.parseInt(number) - 1);
arena.endWave();
String message = ChatManager.formatMessage(arena, ChatManager.colorMessage("In-Game.Messages.Admin-Messages.Changed-Wave"), arena.getWave());
for (Player player1 : arena.getPlayers()) {
player1.sendMessage(ChatManager.PLUGIN_PREFIX + message);
}
if (arena.getZombies() != null) {
for (Zombie zombie : arena.getZombies()) {
zombie.getWorld().playEffect(zombie.getLocation(), Effect.LAVA_POP, 20);
zombie.remove();
}
arena.getZombies().clear();
} else {
sender.sendMessage(ChatManager.colorMessage("Kits.Cleaner.Nothing-To-Clean"));
return;
}
sendSound((Player) sender, "ENTITY_ZOMBIE_DEATH", "ZOMBIE_DEATH");
for (Player loopPlayer : arena.getPlayers()) {
String message1 = ChatManager.formatMessage(arena, ChatManager.colorMessage("In-Game.Messages.Admin-Messages.Removed-Zombies"), new Player[] { (loopPlayer) });
loopPlayer.sendMessage(ChatManager.PLUGIN_PREFIX + message1);
}
} else {
sender.sendMessage(ChatColor.RED + "Wave needs to be number! Do /villagedefense set wave <number>");
}
}
use of org.bukkit.entity.Zombie in project EliteMobs by MagmaGuy.
the class ZombieTeamRocket method onHit.
@EventHandler
public void onHit(EntityDamageEvent event) {
if (event.getEntity().hasMetadata(powerMetadata) && event.getEntity() instanceof Zombie && !event.getEntity().hasMetadata(MetadataHandler.TEAM_ROCKET_ACTIVATED) && random.nextDouble() < 0.5) {
Entity entity = event.getEntity();
entity.setMetadata(MetadataHandler.TEAM_ROCKET_ACTIVATED, new FixedMetadataValue(plugin, true));
int assistMobLevel = (int) Math.floor(entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() / 4);
if (assistMobLevel < 1) {
assistMobLevel = 1;
}
LeatherArmorMeta teamRocketChestpieceMeta = (LeatherArmorMeta) TEAM_ROCKET_CHESTPIECE.getItemMeta();
teamRocketChestpieceMeta.setColor(Color.WHITE);
TEAM_ROCKET_CHESTPIECE.setItemMeta(teamRocketChestpieceMeta);
LeatherArmorMeta teamRocketLeggingsMeta = (LeatherArmorMeta) TEAM_ROCKET_CHESTPIECE.getItemMeta();
teamRocketLeggingsMeta.setColor(Color.WHITE);
TEAM_ROCKET_LEGGINGS.setItemMeta(teamRocketLeggingsMeta);
LeatherArmorMeta teamRocketBootsMeta = (LeatherArmorMeta) TEAM_ROCKET_BOOTS.getItemMeta();
teamRocketBootsMeta.setColor(Color.BLACK);
TEAM_ROCKET_BOOTS.setItemMeta(teamRocketBootsMeta);
ItemStack jesseHelmet = TEAM_ROCKET_HELMET.clone();
LeatherArmorMeta jesseHelmetMeta = (LeatherArmorMeta) jesseHelmet.getItemMeta();
jesseHelmetMeta.setColor(Color.PURPLE);
jesseHelmet.setItemMeta(jesseHelmetMeta);
ItemStack jamesHelmet = TEAM_ROCKET_HELMET.clone();
LeatherArmorMeta jamesHelmetMeta = (LeatherArmorMeta) jamesHelmet.getItemMeta();
jamesHelmetMeta.setColor(Color.BLUE);
jamesHelmet.setItemMeta(jamesHelmetMeta);
Zombie jesse = (Zombie) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.ZOMBIE);
jesse.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, assistMobLevel));
jesse.setMetadata(MetadataHandler.CUSTOM_NAME, new FixedMetadataValue(plugin, true));
jesse.setMetadata(MetadataHandler.CUSTOM_ARMOR, new FixedMetadataValue(plugin, true));
jesse.setMetadata(MetadataHandler.FORBIDDEN_MD, new FixedMetadataValue(plugin, true));
jesse.setMetadata(MetadataHandler.CUSTOM_POWERS_MD, new FixedMetadataValue(plugin, true));
jesse.setMetadata(MetadataHandler.TEAM_ROCKET_MEMBER, new FixedMetadataValue(plugin, true));
jesse.setCustomName("Jesse");
jesse.getEquipment().setHelmet(jesseHelmet);
jesse.getEquipment().setChestplate(TEAM_ROCKET_CHESTPIECE);
jesse.getEquipment().setLeggings(TEAM_ROCKET_LEGGINGS);
jesse.getEquipment().setBoots(TEAM_ROCKET_BOOTS);
Zombie james = (Zombie) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.ZOMBIE);
james.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, assistMobLevel));
james.setMetadata(MetadataHandler.CUSTOM_NAME, new FixedMetadataValue(plugin, true));
james.setMetadata(MetadataHandler.CUSTOM_ARMOR, new FixedMetadataValue(plugin, true));
james.setMetadata(MetadataHandler.FORBIDDEN_MD, new FixedMetadataValue(plugin, true));
james.setMetadata(MetadataHandler.CUSTOM_POWERS_MD, new FixedMetadataValue(plugin, true));
james.setMetadata(MetadataHandler.TEAM_ROCKET_MEMBER, new FixedMetadataValue(plugin, true));
james.setCustomName("James");
james.getEquipment().setHelmet(jamesHelmet);
james.getEquipment().setChestplate(TEAM_ROCKET_CHESTPIECE);
james.getEquipment().setLeggings(TEAM_ROCKET_LEGGINGS);
james.getEquipment().setBoots(TEAM_ROCKET_BOOTS);
Ocelot meowth = (Ocelot) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.OCELOT);
meowth.setMetadata(MetadataHandler.TEAM_ROCKET_MEMBER, new FixedMetadataValue(plugin, true));
meowth.setCustomName("Meowth");
((Zombie) entity).getEquipment().setChestplate(TEAM_ROCKET_CHESTPIECE);
((Zombie) entity).getEquipment().setLeggings(TEAM_ROCKET_LEGGINGS);
((Zombie) entity).getEquipment().setBoots(TEAM_ROCKET_BOOTS);
entity.setMetadata(MetadataHandler.CUSTOM_ARMOR, new FixedMetadataValue(plugin, true));
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
int counter = 1;
@Override
public void run() {
switch(counter) {
case 1:
jesse.setCustomNameVisible(true);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(0)));
break;
case 2:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(1)));
james.setCustomNameVisible(true);
break;
case 3:
james.setCustomNameVisible(false);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(2)));
jesse.setCustomNameVisible(true);
break;
case 4:
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(3)));
break;
case 5:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(4)));
james.setCustomNameVisible(true);
break;
case 6:
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(5)));
break;
case 7:
james.setCustomNameVisible(false);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(6)));
jesse.setCustomNameVisible(true);
break;
case 8:
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(7)));
break;
case 9:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(8)));
james.setCustomNameVisible(true);
break;
case 10:
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(9)));
break;
case 11:
james.setCustomNameVisible(false);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(10)));
jesse.setCustomNameVisible(true);
break;
case 12:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(11)));
james.setCustomNameVisible(true);
break;
case 13:
james.setCustomNameVisible(false);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(12)));
jesse.setCustomNameVisible(true);
break;
case 14:
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(13)));
break;
case 15:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(14)));
james.setCustomNameVisible(true);
break;
case 16:
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(15)));
break;
case 17:
james.setCustomNameVisible(false);
meowth.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(16)));
meowth.setCustomNameVisible(true);
break;
default:
jesse.setCustomName(chatColorConverter(configuration.getString("ZombieTeamRocket.Jesse name")));
jesse.setCustomNameVisible(true);
james.setCustomName(chatColorConverter(configuration.getString("ZombieTeamRocket.James name")));
james.setCustomNameVisible(true);
meowth.setCustomName(chatColorConverter(configuration.getString("ZombieTeamRocket.Meowth name")));
Bukkit.getScheduler().cancelTask(processID);
break;
}
counter++;
}
}, 1, 15 * 2);
}
}
use of org.bukkit.entity.Zombie in project EliteMobs by MagmaGuy.
the class PowerHandler method powerHandler.
public static void powerHandler(Entity entity) {
int availableMinorPowers = 0;
int availableMajorPowers = 0;
if (entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && entity.isValid() && ((LivingEntity) entity).getHealth() > 0) {
if (entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() >= 5) {
int EliteMobLevel = entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt();
availableMinorPowers = (EliteMobLevel - 5) / 10 + 1;
availableMajorPowers = EliteMobLevel / 10;
}
}
if (availableMinorPowers >= 1) {
int currentMinorPowerAmount = 0;
if (entity.hasMetadata(MetadataHandler.CUSTOM_POWERS_MD)) {
return;
}
if (minorPowerArray.isEmpty()) {
minorPowerArrayInitializer();
}
if (entity.hasMetadata(MetadataHandler.MINOR_POWER_AMOUNT_MD)) {
currentMinorPowerAmount = entity.getMetadata(MetadataHandler.MINOR_POWER_AMOUNT_MD).get(0).asInt();
//TODO: this is probably not working as intended
Iterator<MinorPowers> minorPowerIterator = minorPowerArray.iterator();
while (minorPowerIterator.hasNext()) {
MinorPowers minorPower = minorPowerIterator.next();
if (minorPower.existingPowers(entity)) {
minorPowerIterator.remove();
}
}
}
int missingMinorPowerAmount = availableMinorPowers - currentMinorPowerAmount;
if (missingMinorPowerAmount > 0 && minorPowerArray.size() > 0) {
for (int i = 0; i < missingMinorPowerAmount; i++) {
if (minorPowerArray.size() > 0) {
int randomizer = random.nextInt(minorPowerArray.size());
MinorPowers selectedMinorPower = minorPowerArray.get(randomizer);
minorPowerArray.remove(minorPowerArray.get(randomizer));
if (entity.hasMetadata(MetadataHandler.MINOR_POWER_AMOUNT_MD)) {
int oldMinorPowerAmount = entity.getMetadata(MetadataHandler.MINOR_POWER_AMOUNT_MD).get(0).asInt();
int newMinorPowerAmount = oldMinorPowerAmount + 1;
entity.setMetadata(MetadataHandler.MINOR_POWER_AMOUNT_MD, new FixedMetadataValue(plugin, newMinorPowerAmount));
} else {
entity.setMetadata(MetadataHandler.MINOR_POWER_AMOUNT_MD, new FixedMetadataValue(plugin, 1));
}
selectedMinorPower.applyPowers(entity);
}
}
}
}
if (availableMajorPowers >= 1) {
int currentMajorPowerAmount = 0;
if (entity.hasMetadata(MetadataHandler.CUSTOM_POWERS_MD)) {
return;
}
ArrayList<MajorPowers> majorPowersArrayList = new ArrayList();
if (majorPowersArrayList.isEmpty()) {
if (entity instanceof Zombie) {
//These powers can't be intialized like minor powers because the list depends on the mob type
//TODO: Add a mob type sensitive power list
majorPowersArrayList.add(zombieFriends);
majorPowersArrayList.add(zombieNecronomicon);
majorPowersArrayList.add(zombieTeamRocket);
majorPowersArrayList.add(zombieParents);
}
}
if (entity.hasMetadata(MetadataHandler.MAJOR_POWER_AMOUNT_MD)) {
currentMajorPowerAmount = entity.getMetadata(MetadataHandler.MAJOR_POWER_AMOUNT_MD).get(0).asInt();
Iterator<MajorPowers> majorPowerIterator = majorPowersArrayList.iterator();
while (majorPowerIterator.hasNext()) {
MajorPowers majorPowers = majorPowerIterator.next();
if (majorPowers.existingPowers(entity)) {
majorPowerIterator.remove();
}
}
}
//TODO: pretty sure this doesn't check for level 10?
int missingMajorPowerAmount = availableMajorPowers - currentMajorPowerAmount;
if (missingMajorPowerAmount > 0 && majorPowersArrayList.size() > 0) {
for (int i = 0; i < missingMajorPowerAmount; i++) {
if (majorPowersArrayList.size() > 0) {
int randomizer = random.nextInt(majorPowersArrayList.size());
MajorPowers selectedMajorPower = majorPowersArrayList.get(randomizer);
majorPowersArrayList.remove(majorPowersArrayList.get(randomizer));
if (entity.hasMetadata(MetadataHandler.MAJOR_POWER_AMOUNT_MD)) {
int oldMajorPowerAmount = entity.getMetadata(MetadataHandler.MAJOR_POWER_AMOUNT_MD).get(0).asInt();
int newMajorPowerAmount = oldMajorPowerAmount + 1;
entity.setMetadata(MetadataHandler.MAJOR_POWER_AMOUNT_MD, new FixedMetadataValue(plugin, newMajorPowerAmount));
} else {
entity.setMetadata(MetadataHandler.MAJOR_POWER_AMOUNT_MD, new FixedMetadataValue(plugin, 1));
}
selectedMajorPower.applyPowers(entity);
}
}
}
}
}
use of org.bukkit.entity.Zombie in project MagicPlugin by elBukkit.
the class MagicCommandExecutor method onMagicList.
protected boolean onMagicList(CommandSender sender, String subCommand, String[] args) {
String usage = "Usage: magic list <wands|map|automata|tasks|schematics|entities|blocks>";
String listCommand = "";
if (args.length > 1) {
listCommand = args[1];
if (!api.hasPermission(sender, "Magic.commands.magic." + subCommand + "." + listCommand)) {
sendNoPermission(sender);
return false;
}
} else {
sender.sendMessage(ChatColor.GRAY + "For more specific information, add 'tasks', 'wands', 'maps', 'schematics', 'entities', 'blocks' or 'automata' parameter.");
MageController apiController = api.getController();
if (apiController != null && apiController instanceof MagicController) {
MagicController controller = (MagicController) apiController;
long timeout = controller.getPhysicsTimeout();
if (timeout > 0) {
long seconds = (timeout - System.currentTimeMillis()) / 1000;
sender.sendMessage(ChatColor.GREEN + "Physics handler active for another " + ChatColor.DARK_GREEN + seconds + ChatColor.GREEN + " seconds");
} else {
sender.sendMessage(ChatColor.GRAY + "Physics handler inactive");
}
}
Collection<Mage> mages = controller.getMages();
sender.sendMessage(ChatColor.AQUA + "Modified blocks (" + ChatColor.LIGHT_PURPLE + UndoList.getRegistry().getModified().size() + ChatColor.AQUA + ")");
sender.sendMessage(ChatColor.AQUA + "Watching blocks (" + ChatColor.LIGHT_PURPLE + UndoList.getRegistry().getWatching().size() + ChatColor.AQUA + ")");
sender.sendMessage(ChatColor.AQUA + "Registered breaking (" + ChatColor.LIGHT_PURPLE + UndoList.getRegistry().getBreaking().size() + ChatColor.AQUA + ")");
sender.sendMessage(ChatColor.AQUA + "Registered breakable (" + ChatColor.LIGHT_PURPLE + UndoList.getRegistry().getBreakable().size() + ChatColor.AQUA + ")");
sender.sendMessage(ChatColor.AQUA + "Registered reflective (" + ChatColor.LIGHT_PURPLE + UndoList.getRegistry().getReflective().size() + ChatColor.AQUA + ")");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Active mages: " + ChatColor.LIGHT_PURPLE + mages.size());
Collection<com.elmakers.mine.bukkit.api.block.UndoList> pendingUndo = api.getPendingUndo();
sender.sendMessage(ChatColor.AQUA + "Pending undo (" + ChatColor.LIGHT_PURPLE + pendingUndo.size() + ChatColor.AQUA + "): ");
long now = System.currentTimeMillis();
for (com.elmakers.mine.bukkit.api.block.UndoList undo : pendingUndo) {
long remainingTime = (undo.getScheduledTime() - now) / 1000;
sender.sendMessage(ChatColor.AQUA + undo.getName() + ChatColor.GRAY + " will undo in " + ChatColor.WHITE + "" + remainingTime + "" + ChatColor.GRAY + " seconds");
}
Collection<Mage> pending = api.getMagesWithPendingBatches();
sender.sendMessage(ChatColor.AQUA + "Pending casts (" + ChatColor.LIGHT_PURPLE + pending.size() + ChatColor.AQUA + "): ");
for (Mage mage : pending) {
int totalSize = 0;
int totalRemaining = 0;
Collection<Batch> pendingBatches = mage.getPendingBatches();
String names = "";
if (pendingBatches.size() > 0) {
for (Batch batch : pendingBatches) {
names = names + batch.getName() + " ";
totalSize += batch.size();
totalRemaining += batch.remaining();
}
}
sender.sendMessage(ChatColor.AQUA + mage.getName() + ChatColor.GRAY + " has " + ChatColor.WHITE + "" + pendingBatches.size() + "" + ChatColor.GRAY + " pending (" + ChatColor.WHITE + "" + totalRemaining + "/" + totalSize + "" + ChatColor.GRAY + ") (" + names + ")");
}
return true;
}
if (listCommand.equalsIgnoreCase("schematics")) {
List<String> schematics = new ArrayList<>();
try {
Plugin plugin = (Plugin) api;
MagicController controller = (MagicController) api.getController();
// Find built-in schematics
CodeSource src = MagicAPI.class.getProtectionDomain().getCodeSource();
if (src != null) {
URL jar = src.getLocation();
try (InputStream is = jar.openStream();
ZipInputStream zip = new ZipInputStream(is)) {
while (true) {
ZipEntry e = zip.getNextEntry();
if (e == null)
break;
String name = e.getName();
if (name.startsWith("schematics/")) {
schematics.add(name.replace("schematics/", ""));
}
}
}
}
// Check extra path first
File configFolder = plugin.getDataFolder();
File magicSchematicFolder = new File(configFolder, "schematics");
if (magicSchematicFolder.exists()) {
for (File nextFile : magicSchematicFolder.listFiles()) {
schematics.add(nextFile.getName());
}
}
String extraSchematicFilePath = controller.getExtraSchematicFilePath();
if (extraSchematicFilePath != null && extraSchematicFilePath.length() > 0) {
File schematicFolder = new File(configFolder, "../" + extraSchematicFilePath);
if (schematicFolder.exists() && !schematicFolder.equals(magicSchematicFolder)) {
for (File nextFile : schematicFolder.listFiles()) {
schematics.add(nextFile.getName());
}
}
}
} catch (Exception ex) {
sender.sendMessage("Error loading schematics: " + ex.getMessage());
ex.printStackTrace();
;
}
sender.sendMessage(ChatColor.DARK_AQUA + "Found " + ChatColor.LIGHT_PURPLE + schematics.size() + ChatColor.DARK_AQUA + " schematics");
Collections.sort(schematics);
for (String schematic : schematics) {
if (schematic.indexOf(".schematic") > 0) {
sender.sendMessage(ChatColor.AQUA + schematic.replace(".schematic", ""));
}
}
return true;
}
if (listCommand.equalsIgnoreCase("tasks")) {
List<BukkitTask> tasks = Bukkit.getScheduler().getPendingTasks();
HashMap<String, Integer> pluginCounts = new HashMap<>();
HashMap<String, HashMap<String, Integer>> taskCounts = new HashMap<>();
for (BukkitTask task : tasks) {
String pluginName = task.getOwner().getName();
HashMap<String, Integer> pluginTaskCounts = taskCounts.get(pluginName);
if (pluginTaskCounts == null) {
pluginTaskCounts = new HashMap<>();
taskCounts.put(pluginName, pluginTaskCounts);
}
String className = "(Unknown)";
Runnable taskRunnable = CompatibilityUtils.getTaskRunnable(task);
if (taskRunnable != null) {
Class<? extends Runnable> taskClass = taskRunnable.getClass();
className = taskClass.getName();
}
Integer count = pluginTaskCounts.get(className);
if (count == null)
count = 0;
count++;
pluginTaskCounts.put(className, count);
Integer totalCount = pluginCounts.get(pluginName);
if (totalCount == null)
totalCount = 0;
totalCount++;
pluginCounts.put(pluginName, totalCount);
}
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Active tasks: " + tasks.size());
for (Entry<String, HashMap<String, Integer>> pluginEntry : taskCounts.entrySet()) {
String pluginName = pluginEntry.getKey();
sender.sendMessage(" " + ChatColor.DARK_PURPLE + pluginName + ": " + ChatColor.LIGHT_PURPLE + pluginCounts.get(pluginName));
for (Entry<String, Integer> taskEntry : pluginEntry.getValue().entrySet()) {
sender.sendMessage(" " + ChatColor.DARK_PURPLE + taskEntry.getKey() + ": " + ChatColor.LIGHT_PURPLE + taskEntry.getValue());
}
}
return true;
}
if (listCommand.equalsIgnoreCase("wands")) {
String owner = "";
if (args.length > 2) {
owner = args[2];
}
Collection<LostWand> lostWands = api.getLostWands();
int shown = 0;
for (LostWand lostWand : lostWands) {
Location location = lostWand.getLocation();
if (location == null)
continue;
if (owner.length() > 0 && !owner.equalsIgnoreCase(lostWand.getOwner())) {
continue;
}
shown++;
sender.sendMessage(ChatColor.AQUA + lostWand.getName() + ChatColor.WHITE + " (" + lostWand.getOwner() + ") @ " + ChatColor.BLUE + location.getWorld().getName() + " " + location.getBlockX() + " " + location.getBlockY() + " " + location.getBlockZ());
}
sender.sendMessage(shown + " lost wands found" + (owner.length() > 0 ? " for " + owner : ""));
return true;
}
if (listCommand.equalsIgnoreCase("automata")) {
Collection<Mage> automata = api.getAutomata();
for (Mage automaton : automata) {
Location location = automaton.getLocation();
String worldName = location.getWorld().getName();
boolean isOnline = false;
World world = Bukkit.getWorld(worldName);
if (worldName != null) {
isOnline = world.isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4);
}
ChatColor nameColor = isOnline ? ChatColor.AQUA : ChatColor.GRAY;
sender.sendMessage(nameColor + automaton.getName() + ChatColor.WHITE + " @ " + ChatColor.BLUE + worldName + " " + location.getBlockX() + " " + location.getBlockY() + " " + location.getBlockZ());
}
sender.sendMessage(automata.size() + " automata active");
return true;
}
if (listCommand.equalsIgnoreCase("maps")) {
String keyword = "";
for (int i = 2; i < args.length; i++) {
if (i != 2)
keyword = keyword + " ";
keyword = keyword + args[i];
}
onMapList(sender, keyword);
return true;
}
if (listCommand.equalsIgnoreCase("blocks")) {
for (BlockData blockData : UndoList.getRegistry().getModified().values()) {
BlockVector blockLocation = blockData.getLocation();
Block block = blockData.getBlock();
sender.sendMessage(ChatColor.BLUE + "Block at " + ChatColor.GRAY + blockLocation.getBlockX() + ChatColor.DARK_GRAY + "," + ChatColor.GRAY + blockLocation.getBlockY() + ChatColor.DARK_GRAY + "," + ChatColor.GRAY + blockLocation.getBlockZ() + ChatColor.BLUE + " stored as " + ChatColor.AQUA + blockData.getMaterial() + ChatColor.BLUE + " is currently " + ChatColor.AQUA + block.getType() + ChatColor.BLUE + " from " + ChatColor.GOLD + blockData.getUndoList().getName());
}
return true;
}
if (listCommand.equalsIgnoreCase("mages")) {
for (Mage mage : api.getController().getMages()) {
Entity mageEntity = mage.getEntity();
Location location = mage.getLocation();
ChatColor mageColor = ChatColor.YELLOW;
if (mage instanceof com.elmakers.mine.bukkit.magic.Mage && ((com.elmakers.mine.bukkit.magic.Mage) mage).isForget()) {
mageColor = ChatColor.RED;
} else if (mage.isAutomaton()) {
mageColor = ChatColor.GOLD;
}
String mageType = mageEntity == null ? "Non-Entity" : mageEntity.getType().name();
String message = ChatColor.AQUA + "Mage " + mageColor + mage.getId() + ChatColor.GRAY + " (" + mage.getName() + ")" + ChatColor.AQUA + " of type " + ChatColor.DARK_AQUA + mageType + ChatColor.AQUA;
if (location != null) {
String worldName = location.getWorld() != null ? location.getWorld().getName() : "(Unknown world)";
message = message + " is at " + ChatColor.BLUE + worldName + " " + ChatColor.DARK_PURPLE + " " + location.getBlockX() + " " + location.getBlockY() + " " + location.getBlockZ();
}
sender.sendMessage(message);
}
return true;
}
if (listCommand.equalsIgnoreCase("entities")) {
World world = Bukkit.getWorlds().get(0);
NumberFormat formatter = new DecimalFormat("#0.0");
List<EntityType> types = Arrays.asList(EntityType.values());
Collections.sort(types, new Comparator<EntityType>() {
@Override
public int compare(EntityType o1, EntityType o2) {
return o1.name().compareTo(o2.name());
}
});
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
for (Player player : players) {
showEntityInfo(sender, player, EntityType.PLAYER.name() + ChatColor.GRAY + " (" + player.getName() + " [" + (player.isSneaking() ? "sneaking" : "standing") + "])", formatter);
break;
}
final Class<?> worldClass = NMSUtils.getBukkitClass("net.minecraft.server.World");
for (EntityType entityType : types) {
if (entityType.isSpawnable()) {
Entity testEntity = null;
String errorMessage = null;
String entityName = "Entity" + entityType.getEntityClass().getSimpleName();
// Still better than actually adding all of these entities to the world!
if (entityName.equals("EntityGiant")) {
entityName = "EntityGiantZombie";
} else if (entityName.equals("EntityLeashHitch")) {
entityName = "EntityLeash";
} else if (entityName.equals("EntityStorageMinecart")) {
entityName = "EntityMinecartChest";
} else if (entityName.equals("EntitySpawnerMinecart")) {
entityName = "EntityMinecartMobSpawner";
} else if (entityName.equals("EntityCommandMinecart")) {
entityName = "EntityMinecartCommandBlock";
} else if (entityName.equals("EntityPoweredMinecart")) {
entityName = "EntityMinecartFurnace";
} else if (entityName.equals("EntityExplosiveMinecart")) {
entityName = "EntityMinecartTNT";
} else if (entityName.contains("Minecart")) {
entityName = entityType.getEntityClass().getSimpleName();
entityName = entityName.replace("Minecart", "");
entityName = "EntityMinecart" + entityName;
}
try {
Class<?> entityClass = NMSUtils.getBukkitClass("net.minecraft.server." + entityName);
if (entityClass != null) {
Constructor<? extends Object> constructor = entityClass.getConstructor(worldClass);
Object nmsWorld = NMSUtils.getHandle(world);
Object nmsEntity = constructor.newInstance(nmsWorld);
testEntity = NMSUtils.getBukkitEntity(nmsEntity);
if (testEntity == null) {
errorMessage = "Failed to get Bukkit entity for class " + entityName;
}
} else {
errorMessage = "Could not load class " + entityName;
}
} catch (Exception ex) {
testEntity = null;
errorMessage = ex.getClass().getSimpleName() + " [" + entityName + "]";
String message = ex.getMessage();
if (message != null && !message.isEmpty()) {
errorMessage += ": " + message;
}
}
if (testEntity == null) {
sender.sendMessage(ChatColor.BLACK + entityType.name() + ": " + ChatColor.RED + "Spawning error " + ChatColor.DARK_RED + "(" + errorMessage + ")");
continue;
}
String label = entityType.name();
Ageable ageable = (testEntity instanceof Ageable) ? (Ageable) testEntity : null;
Zombie zombie = (testEntity instanceof Zombie) ? (Zombie) testEntity : null;
Skeleton skeleton = (testEntity instanceof Skeleton) ? (Skeleton) testEntity : null;
Slime slime = (testEntity instanceof Slime) ? (Slime) testEntity : null;
if (ageable != null) {
label = label + ChatColor.GRAY + " (Adult)";
ageable.setAdult();
} else if (zombie != null) {
label = label + ChatColor.GRAY + " (Adult)";
zombie.setBaby(false);
} else if (skeleton != null) {
label = label + ChatColor.GRAY + " (NORMAL)";
skeleton.setSkeletonType(Skeleton.SkeletonType.NORMAL);
} else if (slime != null) {
label = label + ChatColor.GRAY + " (Size 1)";
slime.setSize(1);
}
showEntityInfo(sender, testEntity, label, formatter);
if (ageable != null) {
label = entityType.name() + ChatColor.GRAY + " (Baby)";
ageable.setBaby();
showEntityInfo(sender, testEntity, label, formatter);
} else if (zombie != null) {
label = entityType.name() + ChatColor.GRAY + " (Baby)";
zombie.setBaby(true);
showEntityInfo(sender, testEntity, label, formatter);
} else if (skeleton != null) {
label = entityType.name() + ChatColor.GRAY + " (WITHER)";
skeleton.setSkeletonType(Skeleton.SkeletonType.WITHER);
showEntityInfo(sender, testEntity, label, formatter);
} else if (slime != null) {
label = entityType.name() + ChatColor.GRAY + " (Size 2)";
slime.setSize(2);
showEntityInfo(sender, testEntity, label, formatter);
label = entityType.name() + ChatColor.GRAY + " (Size 4)";
slime.setSize(4);
showEntityInfo(sender, testEntity, label, formatter);
label = entityType.name() + ChatColor.GRAY + " (Size 8)";
slime.setSize(8);
showEntityInfo(sender, testEntity, label, formatter);
label = entityType.name() + ChatColor.GRAY + " (Size 16)";
slime.setSize(16);
showEntityInfo(sender, testEntity, label, formatter);
}
}
}
return true;
}
sender.sendMessage(usage);
return true;
}
Aggregations