本文整理匯總了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;
}
}