Search in sources :

Example 6 with EntityData

use of com.elmakers.mine.bukkit.api.entity.EntityData in project MagicPlugin by elBukkit.

the class MagicMobCommandExecutor method onListMobs.

protected void onListMobs(CommandSender sender) {
    Map<String, Integer> mobCounts = new HashMap<>();
    Collection<Mage> mages = new ArrayList<>(api.getController().getMobMages());
    for (Mage mage : mages) {
        EntityData entityData = mage.getEntityData();
        if (entityData == null)
            continue;
        Integer mobCount = mobCounts.get(entityData.getKey());
        if (mobCount == null) {
            mobCounts.put(entityData.getKey(), 1);
        } else {
            mobCounts.put(entityData.getKey(), mobCount + 1);
        }
    }
    Set<String> keys = api.getController().getMobKeys();
    for (String key : keys) {
        EntityData mobType = api.getController().getMob(key);
        String message = ChatColor.AQUA + key + ChatColor.WHITE + " : " + ChatColor.DARK_AQUA + mobType.describe();
        Integer mobCount = mobCounts.get(key);
        if (mobCount != null) {
            message = message + ChatColor.GRAY + " (" + ChatColor.GREEN + mobCount + ChatColor.DARK_GREEN + " Active" + ChatColor.GRAY + ")";
        }
        sender.sendMessage(message);
    }
}
Also used : HashMap(java.util.HashMap) Mage(com.elmakers.mine.bukkit.api.magic.Mage) ArrayList(java.util.ArrayList) EntityData(com.elmakers.mine.bukkit.api.entity.EntityData)

Aggregations

EntityData (com.elmakers.mine.bukkit.api.entity.EntityData)6 Entity (org.bukkit.entity.Entity)3 Mage (com.elmakers.mine.bukkit.api.magic.Mage)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Player (org.bukkit.entity.Player)2 MaterialAndData (com.elmakers.mine.bukkit.api.block.MaterialAndData)1 MaterialBrush (com.elmakers.mine.bukkit.api.block.MaterialBrush)1 Mage (com.elmakers.mine.bukkit.magic.Mage)1 HashSet (java.util.HashSet)1 Nullable (javax.annotation.Nullable)1 Art (org.bukkit.Art)1 Location (org.bukkit.Location)1 Material (org.bukkit.Material)1 Rotation (org.bukkit.Rotation)1 World (org.bukkit.World)1 BlockCommandSender (org.bukkit.command.BlockCommandSender)1 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 MemoryConfiguration (org.bukkit.configuration.MemoryConfiguration)1