当前位置: 首页>>代码示例>>Java>>正文


Java EntityType.valueOf方法代码示例

本文整理汇总了Java中org.bukkit.entity.EntityType.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java EntityType.valueOf方法的具体用法?Java EntityType.valueOf怎么用?Java EntityType.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.EntityType的用法示例。


在下文中一共展示了EntityType.valueOf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildFromJson

import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
@Override
public Map<String, Object> buildFromJson(Map<String, JsonElement> configuration) throws Exception
{
    if (configuration.containsKey("drops"))
    {
        JsonArray dropsJson = configuration.get("drops").getAsJsonArray();

        for (int i = 0; i < dropsJson.size(); i++)
        {
            JsonObject dropJson = dropsJson.get(i).getAsJsonObject();

            EntityType entityType = EntityType.valueOf(dropJson.get("entity").getAsString().toUpperCase());
            JsonArray stacksJson = dropJson.get("stacks").getAsJsonArray();
            ItemStack[] stacks = new ItemStack[stacksJson.size()];

            for (int j = 0; j < stacksJson.size(); j++)
                stacks[j] = ItemUtils.strToStack(stacksJson.get(i).getAsString());

            this.addCustomDrops(entityType, stacks);
        }
    }

    return this.build();
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:25,代码来源:EntityDropModule.java

示例2: getSpawnEgg

import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
// This is kind of a dumb way to do this.. But I'm too lazy to fix my reflection
public org.bukkit.inventory.ItemStack getSpawnEgg(org.bukkit.inventory.ItemStack i, String entityTag){
	EntityType type = null;
	try{
		type = EntityType.valueOf(entityTag.toUpperCase());
	}catch(Exception ex){
		switch (entityTag){
			case "mooshroom":
				type = EntityType.MUSHROOM_COW;
				break;
			case "zombie_pigman":
				type = EntityType.PIG_ZOMBIE;
				break;
			default:
				type = EntityType.BAT;
				System.out.println("Bad tag: " + entityTag);
				break;
		}
	}
	return new ItemStack(i.getType(), i.getAmount(), type.getTypeId());
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:24,代码来源:SpawnUtil.java

示例3: setSpawnerType

import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
/**
 * Sets the spawner type if this block is a spawner
 * @param tileData
 */
public void setSpawnerType(Map<String, Tag> tileData) {
    //Bukkit.getLogger().info("DEBUG: " + tileData.toString());
    String creatureType = "";
    if (tileData.containsKey("EntityId")) {
        creatureType = ((StringTag) tileData.get("EntityId")).getValue().toUpperCase();
    } else if (tileData.containsKey("SpawnData")) {
        // 1.9 format
        Map<String,Tag> spawnData = ((CompoundTag) tileData.get("SpawnData")).getValue();
        //Bukkit.getLogger().info("DEBUG: " + spawnData.toString());
        if (spawnData.containsKey("id")) {
            creatureType = ((StringTag) spawnData.get("id")).getValue().toUpperCase();
        }
    }
    //Bukkit.getLogger().info("DEBUG: creature type = " + creatureType);
    // The mob type might be prefixed with "Minecraft:"
    if (creatureType.startsWith("MINECRAFT:")) {
        creatureType = creatureType.substring(10);
    }
    if (WEtoME.containsKey(creatureType)) {
        spawnerBlockType = WEtoME.get(creatureType);
    } else {
        try {
            spawnerBlockType = EntityType.valueOf(creatureType);
        } catch (Exception e) {
            Bukkit.getLogger().warning("Spawner setting of " + creatureType + " is unknown for this server. Skipping.");
        }
    }
    //Bukkit.getLogger().info("DEBUG: spawnerblock type = " + spawnerBlockType);
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:34,代码来源:IslandBlock.java

示例4: EntitySpawnTask

import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
/**Constructor, passes arguments to super class and loads special values from config.
 * @param parent	The Room this Task belongs to
 * @param conf		Given config file of this room has entries on tasks.
 * @param taskNr	Task number is needed to load keys correctly.
 */
public EntitySpawnTask(Room parent, FileConfiguration conf, int taskNr) {
	super(parent, conf, taskNr);
	this.type = TaskType.ENTITYSPAWN;
	
	// loading values for this Task type:
	String path = "tasks.task" + this.taskNr + ".";
	grp = new EntityGroup();
	grp.type = EntityType.valueOf(conf.getString( path + "entityType"));
	grp.count = 				  conf.getInt(    path + "count");
	//TODO: maxCount noch einbauen -> bei jedem Spawning z�hlen, bei Tod runterz�hlen
	grp.maxCount =				  conf.getInt(    path + "maxCount");
	grp.isTarget = 				  conf.getBoolean(path + "isTarget");
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:19,代码来源:EntitySpawnTask.java

示例5: stringToType

import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
private static EntityType stringToType(String type) {
    try {
        return EntityType.valueOf(type.toUpperCase());
    } catch (IllegalArgumentException e) {
        return null;
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:8,代码来源:CommandEntityCount.java

示例6: getPossibleSkin

import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
public EntityType getPossibleSkin(String skin) {
    String possibleSkin = skin;
    if (possibleSkin == null) {
        possibleSkin = defaultSkin;
    } else if (!possibleSkins.contains(skin)) {
        possibleSkin = defaultSkin;
    }

    return EntityType.valueOf(possibleSkin);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:11,代码来源:PetType.java

示例7: spawnEntity

import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
public static void spawnEntity(String player, int challenge, String str, int amount) {
	EntityType entity = EntityType.valueOf(str);
	Location loc1 = plugin.getChallengesFile().getFirstLocation(challenge);
	Location loc2 = plugin.getChallengesFile().getSecondLocation(challenge);
	Location spawnLoc = loc1;
	for(int i = 0; i < amount; i++) {
		spawnLoc.setX(getRandom(loc1.getBlockX(), loc2.getBlockX()));
		spawnLoc.setY(getRandom(loc1.getBlockY(), loc2.getBlockY()));
		spawnLoc.setZ(getRandom(loc1.getBlockZ(), loc2.getBlockZ()));
		Entity e = loc1.getWorld().spawnEntity(spawnLoc, entity);
		e.setMetadata("challenge", new FixedMetadataValue(plugin, String.valueOf(challenge) + ", " + player));
	}
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:14,代码来源:Convert.java

示例8: get

import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
public EntityType get() {
    try {
        return EntityType.valueOf(this.entityTypeName);
    } catch (Exception exception) {
        return null;
    }
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:8,代码来源:WrappedEntityType.java


注:本文中的org.bukkit.entity.EntityType.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。