use of com.bergerkiller.mountiplex.conversion.util.ConvertingList in project BKCommonLib by bergerhealer.
the class PlayerUtil method getNearbyPlayers.
/**
* Gets a (referenced) list of all players nearby another Player
*
* @param player to get the nearby players of
* @param radius to look around the player for other playrs
* @return list of nearby players
*/
public static List<Player> getNearbyPlayers(Player player, double radius) {
EntityPlayerHandle handle = CommonNMS.getHandle(player);
List<?> nearbyPlayerHandles = handle.getWorld().getRawEntitiesOfType(EntityPlayerHandle.T.getType(), handle.getBoundingBox().grow(radius, radius, radius));
return new ConvertingList<Player>(nearbyPlayerHandles, DuplexConversion.player);
}
use of com.bergerkiller.mountiplex.conversion.util.ConvertingList in project BKCommonLib by bergerhealer.
the class ChunkProviderServerHook method getMobsFor.
@HookMethod("public List<BiomeBase.BiomeMeta> getBiomeSpawnInfo:???(EnumCreatureType enumcreaturetype, BlockPosition blockposition)")
public List<?> getMobsFor(Object enumcreaturetype, Object blockposition) {
List<?> mobs = base.getMobsFor(enumcreaturetype, blockposition);
if (CommonPlugin.hasInstance()) {
// There is no use wasting CPU time when no one handles the event!
if (LogicUtil.nullOrEmpty(mobs) || !CommonUtil.hasHandlers(CreaturePreSpawnEvent.getHandlerList())) {
return mobs;
}
// Wrap the parameters and send the event along
BlockPositionHandle pos = BlockPositionHandle.createHandle(blockposition);
org.bukkit.World world = getWorld();
List<BiomeMetaHandle> mobsHandles = new ConvertingList<BiomeMetaHandle>(mobs, BiomeMetaHandle.T.getHandleConverter());
mobsHandles = CommonPlugin.getInstance().getEventFactory().handleCreaturePreSpawn(world, pos.getX(), pos.getY(), pos.getZ(), mobsHandles);
return new ConvertingList<Object>(mobsHandles, BiomeMetaHandle.T.getHandleConverter().reverse());
} else {
return mobs;
}
}
Aggregations