org.bukkit.util.Consumer Java Examples
The following examples show how to use
org.bukkit.util.Consumer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftWorld.java From Kettle with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") public <T extends Entity> T addEntity(net.minecraft.entity.Entity entity, SpawnReason reason, Consumer<T> function) throws IllegalArgumentException { Preconditions.checkArgument(entity != null, "Cannot spawn null entity"); if (entity instanceof EntityLiving) { ((EntityLiving) entity).onInitialSpawn(getHandle().getDifficultyForLocation(new BlockPos(entity)), null); } if (function != null) { function.accept((T) entity.getBukkitEntity()); } world.spawnEntity(entity, reason); return (T) entity.getBukkitEntity(); }
Example #2
Source File: AsyncWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function) throws IllegalArgumentException { return TaskManager.IMP.sync(new RunnableVal<T>() { @Override public void run(T value) { this.value = parent.spawn(location, clazz, function); } }); }
Example #3
Source File: CraftWorld.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function) throws IllegalArgumentException { return spawn(location, clazz, function, SpawnReason.CUSTOM); }
Example #4
Source File: CraftWorld.java From Kettle with GNU General Public License v3.0 | 4 votes |
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function, SpawnReason reason) throws IllegalArgumentException { net.minecraft.entity.Entity entity = createEntity(location, clazz); return addEntity(entity, reason, function); }
Example #5
Source File: ItemUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public static void updateMeta(ItemStack item, Consumer<ItemMeta> mutator) { final ItemMeta meta = item.getItemMeta(); mutator.accept(meta); item.setItemMeta(meta); }
Example #6
Source File: ItemUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public static void updateMetaIfPresent(@Nullable ItemStack item, Consumer<ItemMeta> mutator) { if(item != null && item.hasItemMeta()) { updateMeta(item, mutator); } }
Example #7
Source File: WorldImpl.java From Civs with GNU General Public License v3.0 | 4 votes |
@Override public <T extends Entity> T spawn(Location location, Class<T> aClass, Consumer<T> consumer) throws IllegalArgumentException { return null; }
Example #8
Source File: World.java From Kettle with GNU General Public License v3.0 | 3 votes |
/** * Spawn an entity of a specific class at the given {@link Location}, with * the supplied function run before the entity is added to the world. * <br> * Note that when the function is run, the entity will not be actually in * the world. Any operation involving such as teleporting the entity is undefined * until after this function returns. * * @param location the {@link Location} to spawn the entity at * @param clazz the class of the {@link Entity} to spawn * @param function the function to be run before the entity is spawned. * @param <T> the class of the {@link Entity} to spawn * @return an instance of the spawned {@link Entity} * @throws IllegalArgumentException if either parameter is null or the * {@link Entity} requested cannot be spawned */ public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function) throws IllegalArgumentException;