當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。