use of org.bukkit.entity.EntityType in project Denizen-For-Bukkit by DenizenScript.
the class BiomeNMS_v1_11_R1 method getSpawnableEntities.
private List<EntityType> getSpawnableEntities(EnumCreatureType creatureType) {
List<EntityType> entityTypes = new ArrayList<EntityType>();
for (BiomeBase.BiomeMeta meta : biomeBase.getMobs(creatureType)) {
// TODO: verifyme!
String n = EntityTypes.getName(meta.b).a();
EntityType et = EntityType.fromName(n);
if (et == null) {
et = EntityType.valueOf(n.toUpperCase(Locale.ENGLISH));
}
entityTypes.add(et);
}
return entityTypes;
}
use of org.bukkit.entity.EntityType in project Denizen-For-Bukkit by DenizenScript.
the class StatisticCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Element action = scriptEntry.getElement("action");
dList players = scriptEntry.getdObject("players");
Element statistic = scriptEntry.getElement("statistic");
Element amount = scriptEntry.getElement("amount");
dMaterial material = scriptEntry.getdObject("material");
dEntity entity = scriptEntry.getdObject("entity");
dB.report(scriptEntry, getName(), action.debug() + statistic.debug() + amount.debug() + players.debug() + (material != null ? material.debug() : entity != null ? entity.debug() : ""));
Action act = Action.valueOf(action.asString().toUpperCase());
Statistic stat = Statistic.valueOf(statistic.asString().toUpperCase());
int amt = amount.asInt();
switch(stat.getType()) {
case BLOCK:
case ITEM:
Material mat = material.getMaterial();
switch(act) {
case ADD:
for (dPlayer player : players.filter(dPlayer.class)) {
player.incrementStatistic(stat, mat, amt);
}
break;
case TAKE:
for (dPlayer player : players.filter(dPlayer.class)) {
player.decrementStatistic(stat, mat, amt);
}
break;
case SET:
for (dPlayer player : players.filter(dPlayer.class)) {
player.setStatistic(stat, mat, amt);
}
break;
}
break;
case ENTITY:
EntityType ent = entity.getBukkitEntityType();
switch(act) {
case ADD:
for (dPlayer player : players.filter(dPlayer.class)) {
player.incrementStatistic(stat, ent, amt);
}
break;
case TAKE:
for (dPlayer player : players.filter(dPlayer.class)) {
player.decrementStatistic(stat, ent, amt);
}
break;
case SET:
for (dPlayer player : players.filter(dPlayer.class)) {
player.setStatistic(stat, ent, amt);
}
break;
}
break;
}
}
use of org.bukkit.entity.EntityType in project Glowstone by GlowstoneMC.
the class ItemSpawn method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock against, BlockFace face, ItemStack holding, Vector clickedLoc) {
Location location = against.getLocation().add(face.getModX(), face.getModY(), face.getModZ());
// TODO: change mob spawner when clicked by monster egg
if (holding.hasItemMeta() && holding.getItemMeta() instanceof GlowMetaSpawn) {
GlowMetaSpawn meta = (GlowMetaSpawn) holding.getItemMeta();
EntityType type = meta.getSpawnedType();
CompoundTag tag = meta.getEntityTag();
if (type != null) {
GlowEntity entity = against.getWorld().spawn(location.add(0.5, 0, 0.5), EntityRegistry.getEntity(type), SpawnReason.SPAWNER_EGG);
if (tag != null) {
EntityStorage.load(entity, tag);
}
}
}
}
use of org.bukkit.entity.EntityType in project Essentials by drtshock.
the class SpawnEggProvider method tryProvider.
@Override
public boolean tryProvider() {
try {
EntityType type = EntityType.CREEPER;
ItemStack is = createEggItem(type);
EntityType readType = getSpawnedType(is);
return type == readType;
} catch (Throwable t) {
return false;
}
}
use of org.bukkit.entity.EntityType in project BKCommonLib by bergerhealer.
the class CommonEventFactory method handleCreaturePreSpawn.
/**
* Handles the spawning of creatures on the server
*
* @param world
* @param x
* @param y
* @param z
* @param inputTypes to process and fire events for
* @return a list of mobs to spawn
*/
public List<BiomeMetaHandle> handleCreaturePreSpawn(World world, int x, int y, int z, List<BiomeMetaHandle> inputTypes) {
// Shortcuts
if (LogicUtil.nullOrEmpty(inputTypes) || !CommonUtil.hasHandlers(CreaturePreSpawnEvent.getHandlerList())) {
return inputTypes;
}
// Start processing the elements
creaturePreSpawnMobs.clear();
for (BiomeMetaHandle inputMeta : inputTypes) {
final EntityType oldEntityType = CommonEntityType.byNMSEntityClass(inputMeta.getEntityClass()).entityType;
// Set up the event
creaturePreSpawnEvent.cancelled = false;
creaturePreSpawnEvent.spawnLocation.setWorld(world);
creaturePreSpawnEvent.spawnLocation.setX(x);
creaturePreSpawnEvent.spawnLocation.setY(y);
creaturePreSpawnEvent.spawnLocation.setZ(z);
creaturePreSpawnEvent.spawnLocation.setYaw(0.0f);
creaturePreSpawnEvent.spawnLocation.setPitch(0.0f);
creaturePreSpawnEvent.entityType = oldEntityType;
creaturePreSpawnEvent.minSpawnCount = inputMeta.getMinSpawnCount();
creaturePreSpawnEvent.maxSpawnCount = inputMeta.getMaxSpawnCount();
// Raise it and handle spawn cancel
if (CommonUtil.callEvent(creaturePreSpawnEvent).isCancelled() || (creaturePreSpawnEvent.minSpawnCount == 0 && creaturePreSpawnEvent.maxSpawnCount == 0)) {
continue;
}
// Handle a possibly changed entity type
final Class<?> entityClass;
if (oldEntityType == creaturePreSpawnEvent.entityType) {
entityClass = inputMeta.getEntityClass();
} else {
entityClass = CommonEntityType.byEntityType(creaturePreSpawnEvent.entityType).nmsType.getType();
}
// Unknown or unsupported Entity Type - ignore spawning
if (entityClass == null) {
continue;
}
// Add element to buffer
final BiomeMetaHandle outputMeta = creaturePreSpawnMobs.add();
outputMeta.setEntityClass(entityClass);
outputMeta.setMinSpawnCount(creaturePreSpawnEvent.minSpawnCount);
outputMeta.setMaxSpawnCount(creaturePreSpawnEvent.maxSpawnCount);
outputMeta.setChance(inputMeta.getChance());
}
return creaturePreSpawnMobs;
}
Aggregations