本文整理汇总了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();
}
示例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());
}
示例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);
}
示例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");
}
示例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;
}
}
示例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);
}
示例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));
}
}
示例8: get
import org.bukkit.entity.EntityType; //导入方法依赖的package包/类
public EntityType get() {
try {
return EntityType.valueOf(this.entityTypeName);
} catch (Exception exception) {
return null;
}
}