Java Code Examples for org.bukkit.entity.EntityType#values()

The following examples show how to use org.bukkit.entity.EntityType#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatchEntityState.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
protected MatchEntityState(Match match, Class<? extends Entity> entityClass, UUID uuid, EntityLocation location, @Nullable String customName) {
    this.uuid = checkNotNull(uuid);
    this.match = checkNotNull(match);
    this.entityClass = checkNotNull(entityClass);
    this.location = checkNotNull(location);
    this.customName = customName;

    EntityType type = null;
    for(EntityType t : EntityType.values()) {
        if(t.getEntityClass().isAssignableFrom(entityClass)) {
            type = t;
            break;
        }
    }
    checkArgument(type != null, "Unknown entity class " + entityClass);
    this.entityType = type;
}
 
Example 2
Source File: ImportManager.java    From Statz with GNU General Public License v3.0 6 votes vote down vote up
private void importMobsKilled(PlayerInfo playerInfo, String worldName) {
    Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName);

    if (!object.isPresent()) {
        return;
    }

    Optional<JSONObject> killedSection = getKilledSection(playerInfo.getUUID(), worldName);

    if (!killedSection.isPresent()) return;

    for (EntityType entityType : EntityType.values()) {

        if (entityType.isSpawnable()) {
            long killed = (Long) getStatistic(killedSection.get(), entityType.getKey().toString()).orElse(0L);

            if (killed <= 0) continue;

            playerInfo.addRow(PlayerStat.KILLS_MOBS,
                    StatzUtil.makeQuery(playerInfo.getUUID(), "value", killed, "world",
                            worldName, "weapon", "HAND", "mob", entityType.toString()));
        }
    }
}
 
Example 3
Source File: CommandCloudServer.java    From CloudNet with Apache License 2.0 5 votes vote down vote up
private boolean mobList(CommandSender commandSender) {
    if (checkMobSelectorActive(commandSender)) {
        return true;
    }

    for (EntityType entityType : EntityType.values()) {
        if (entityType.isAlive() && entityType.isSpawnable()) {
            commandSender.sendMessage("- " + entityType.name());
        }
    }
    return false;
}
 
Example 4
Source File: TypesSubCommand.java    From MineableSpawners with MIT License 5 votes vote down vote up
public void execute(MineableSpawners plugin, CommandSender sender) {
    StringBuilder msg = new StringBuilder(plugin.getConfigurationHandler().getMessage("types", "title"));
    for (EntityType entityType : EntityType.values()) {
        msg.append(plugin.getConfigurationHandler().getMessage("types", "entries").replace("%mob%", entityType.name().toLowerCase()));
    }
    sender.sendMessage(msg.toString());
}
 
Example 5
Source File: MineableSpawners.java    From MineableSpawners with MIT License 5 votes vote down vote up
@Override
public void onEnable() {
    getConfig().options().copyDefaults(true);
    saveDefaultConfig();

    configurationHandler = new ConfigurationHandler(this);

    checkServerVersion();

    if (!setupEconomy()) {
        System.out.println("[MineableSpawners] vault not found, economy features disabled.");
    }

    getCommand("mineablespawners").setExecutor(new MineableSpawnersCommand(this));

    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new SpawnerMineListener(this), this);
    pm.registerEvents(new SpawnerPlaceListener(this), this);
    pm.registerEvents(new EggChangeListener(this), this);
    pm.registerEvents(new AnvilRenameListener(this), this);
    pm.registerEvents(new SpawnerExplodeListener(this), this);

    StringBuilder str = new StringBuilder("[MineableSpawners] Available mob types: \n");
    for (EntityType type : EntityType.values()) {
        str.append("- ");
        str.append(type.name());
        str.append("\n");
    }
    System.out.println(str.toString());

    api = new API(this);
    int pluginId = 7354;
    Metrics metrics = new Metrics(this, pluginId);
}
 
Example 6
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets spawners to their type
 * @param e - event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onSpawnerBlockPlace(final BlockPlaceEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: block place");
    if (inWorld(e.getPlayer()) && Util.playerIsHolding(e.getPlayer(), Material.MOB_SPAWNER)) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: in world");
        // Get item in hand
        for (ItemStack item : Util.getPlayerInHandItems(e.getPlayer())) {
            if (item.getType().equals(Material.MOB_SPAWNER) && item.hasItemMeta() && item.getItemMeta().hasLore()) {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: spawner in hand with lore");
                List<String> lore = item.getItemMeta().getLore();
                if (!lore.isEmpty()) {
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: lore is not empty");
                    for (EntityType type : EntityType.values()) {
                        if (lore.get(0).equals(Util.prettifyText(type.name()))) {
                            // Found the spawner type
                            if (DEBUG)
                                plugin.getLogger().info("DEBUG: found type");
                            e.getBlock().setType(Material.MOB_SPAWNER);
                            CreatureSpawner cs = (CreatureSpawner)e.getBlock().getState();
                            cs.setSpawnedType(type);
                        }
                    }
                    // Spawner type not found - do anything : it may be another plugin's spawner
                }
            }
        }
    }
}
 
Example 7
Source File: NetherSpawning.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
public NetherSpawning(ASkyBlock plugin) {
    this.plugin = plugin;
    for (EntityType type: EntityType.values()) {
        if (type.toString().equals("WITHER_SKELETON")) {
            this.hasWitherSkeleton = true;
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Wither Skeleton exists");
            break;
        }    
    }
}
 
Example 8
Source File: SpawnEggMeta.java    From ShopChest with MIT License 4 votes vote down vote up
/**	
 * @param plugin An instance of the {@link ShopChest} plugin
 * @param stack {@link ItemStack} (Spawn Egg) of which the Entity should be gotten	
 * @return The {@link EntityType} the Spawn Egg will spawn or <b>null</b> if <i>nbtEntityID</i> is null	
 */	
public static EntityType getEntityTypeFromItemStack(ShopChest plugin, ItemStack stack) {	
    if (Utils.getMajorVersion() == 8) {	
        EntityType type = null;	
	
        for (EntityType entityType : EntityType.values()) {	
            if (entityType.getTypeId() == stack.getDurability()) {	
                type = entityType;	
                break;	
            }	
        }	
	
        return type;	
    }	
	
    String nbtEntityID = getNBTEntityID(plugin, stack);	
	
    if (nbtEntityID == null) return null;	
	
    if (Utils.getMajorVersion() >= 11) {	
        if (nbtEntityID.contains(":")) nbtEntityID = nbtEntityID.split(":")[1];	
        return EntityType.fromName(nbtEntityID);	
    }	
	
    switch (nbtEntityID) {	
        case "PigZombie":	
            return EntityType.valueOf("PIG_ZOMBIE");	
        case "CaveSpider":	
            return EntityType.CAVE_SPIDER;	
        case "LavaSlime":	
            return EntityType.MAGMA_CUBE;	
        case "MushroomCow":	
            return EntityType.MUSHROOM_COW;	
        case "EntityHorse":	
            return EntityType.HORSE;	
        case "PolarBear":	
            return EntityType.POLAR_BEAR;	
        case "Ozelot":	
            return EntityType.OCELOT;	
        default:	
            return EntityType.valueOf(nbtEntityID.toUpperCase());	
	
    }	
}