@SubscribeEvent public void onScoreboardEvent(PacketEvent.Incoming.Pre event) { if(event.getPacket() instanceof SPacketPlayerListItem && getWorld() != null && System.currentTimeMillis() > waitTime) { final SPacketPlayerListItem packet = (SPacketPlayerListItem) event.getPacket(); packet.getEntries().stream() .filter(Objects::nonNull) .filter(data -> data.getProfile() != null) .filter(data -> !Strings.isNullOrEmpty(data.getProfile().getName())) .forEach(data -> { final String name = data.getProfile().getName(); PlayerInfoHelper.invokeEfficiently(name, new FutureCallback<PlayerInfo>() { @Override public void onSuccess(@Nullable PlayerInfo result) { if(result != null) fireEvents(packet.getAction(), result, data.getProfile()); } @Override public void onFailure(Throwable t) { } }); }); } }
@Nullable @Override public Map.Entry<? extends PoolClassDef, Integer> getClassEntryByType(@Nullable CharSequence name) { if (name == null) { return null; } final PoolClassDef classDef = internedItems.get(name.toString()); if (classDef == null) { return null; } return new Entry<PoolClassDef, Integer>() { @Override public PoolClassDef getKey() { return classDef; } @Override public Integer getValue() { return classDef.classDefIndex; } @Override public Integer setValue(Integer value) { return classDef.classDefIndex = value; } }; }
/** {@inheritDoc} */ @Override @Nullable public SubjectType apply(@Nullable final ProfileRequestContext input) { SubjectType type = null; OIDCMetadataContext ctx = oidcMetadataContextLookupStrategy.apply(input); if (ctx != null && ctx.getClientInformation() != null && ctx.getClientInformation().getOIDCMetadata() != null) { type = ctx.getClientInformation().getOIDCMetadata().getSubjectType(); } if (type == null) { boolean pairwise = false; final RelyingPartyContext rpc = relyingPartyContextLookupStrategy.apply(input); if (rpc != null) { final ProfileConfiguration pc = rpc.getProfileConfig(); if (pc != null && pc instanceof OIDCCoreProtocolConfiguration) { pairwise = ((OIDCCoreProtocolConfiguration) pc).getPairwiseSubject().apply(input); } } type = pairwise ? SubjectType.PAIRWISE : SubjectType.PUBLIC; } return type; }
@CanIgnoreReturnValue @Override public int remove(@Nullable Object element, int occurrences) { if (occurrences == 0) { return count(element); } checkArgument(occurrences > 0, "occurrences cannot be negative: %s", occurrences); Count frequency = backingMap.get(element); if (frequency == null) { return 0; } int oldCount = frequency.get(); int numberRemoved; if (oldCount > occurrences) { numberRemoved = occurrences; } else { numberRemoved = oldCount; backingMap.remove(element); } frequency.add(-numberRemoved); size -= numberRemoved; return oldCount; }
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback) { String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>() { public boolean apply(@Nullable String p_apply_1_) { return !StringUtils.isNullOrEmpty(p_apply_1_); } }), String.class); if (server.isServerInOnlineMode()) { server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback); } else { for (String s : astring) { UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s)); GameProfile gameprofile = new GameProfile(uuid, s); callback.onProfileLookupSucceeded(gameprofile); } } }
private static @Nullable Typeface createTypeface( String fontFamilyName, int style, AssetManager assetManager) { String extension = EXTENSIONS[style]; for (String fileExtension : FILE_EXTENSIONS) { String fileName = new StringBuilder() .append(FONTS_ASSET_PATH) .append(fontFamilyName) .append(extension) .append(fileExtension) .toString(); try { return Typeface.createFromAsset(assetManager, fileName); } catch (RuntimeException e) { // unfortunately Typeface.createFromAsset throws an exception instead of returning null // if the typeface doesn't exist } } return Typeface.create(fontFamilyName, style); }
/** Creates a new entry with the usage count of 0. */ @VisibleForTesting static <K, V> Entry<K, V> of( final K key, final CloseableReference<V> valueRef, final @Nullable EntryStateObserver<K> observer) { return new Entry<>(key, valueRef, observer); }
@CheckForNull public static AwsCredentials getCredentials(@Nullable String credentialsId) { if (StringUtils.isBlank(credentialsId)) { return null; } return CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials(AwsCredentials.class, (Item) null, ACL.SYSTEM, null, null), CredentialsMatchers.withId(credentialsId) ); }
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) { if (false && !worldIn.isRemote && stack != null && stack.getItem() == Items.SHEARS) //Forge: Noop this { player.addStat(StatList.getBlockStats(this)); spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4)); } else { super.harvestBlock(worldIn, player, pos, state, te, stack); } }
public @Nullable String request(String url) throws IOException { try (ResponseBody responseBody = response(url).body()) { if (responseBody != null) return responseBody.string(); return null; } }
/** * Returns the latest value of {@code watchFile()} result. * * @param defaultValue the default value which is returned when the value is not available yet */ @Nullable default T latestValue(@Nullable T defaultValue) { final CompletableFuture<Latest<T>> initialValueFuture = initialValueFuture(); if (initialValueFuture.isDone() && !initialValueFuture.isCompletedExceptionally()) { return latest().value(); } else { return defaultValue; } }
public CustomStyleSpan( int fontStyle, int fontWeight, @Nullable String fontFamily, AssetManager assetManager) { mStyle = fontStyle; mWeight = fontWeight; mFontFamily = fontFamily; mAssetManager = assetManager; }
private static Invokable<?, ?> invokable(@Nullable Object instance, Method method) { if (instance == null) { return Invokable.from(method); } else { return TypeToken.of(instance.getClass()).method(method); } }
@Nullable String commentAt(int line) { List<Comment> comments = commentListPreLineMap.get(line); if (comments != null && !comments.isEmpty()) { return line(line).substring(comments.get(0).column - 1); } return null; }
@Nullable @Override public Boolean apply(@Nullable WebDriver webDriver) { errorElements = new ArrayList<>(); boolean isCorrect = true; for (TeasyElement el : elements) { if (el.getAttribute(attributeName) != null) { isCorrect = false; errorElements.add(el); } } return isCorrect; }
private LinkedHashSet<String> deserialize(@Nullable String serialized) { if (serialized == null) return new LinkedHashSet<>(); String[] list = serialized.split(";"); LinkedHashSet<String> result = new LinkedHashSet<>(list.length); Collections.addAll(result, list); return result; }
@Nullable @Override public Gui getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case GuiID.DRINK_MACHINE: return new GuiContainerDrinkMachine(player.inventory, world.getTileEntity(new BlockPos(x, y, z))); case GuiID.PRESSURE_COOKER: return new GuiContainerPressureCooker(player.inventory, world.getTileEntity(new BlockPos(x, y, z))); case GuiID.SMELTING_PRESSURE_COOKER: return new GuiContainerSmeltingDrinkMachine(player.inventory, world.getTileEntity(new BlockPos(x, y, z))); } return null; }
@Override public boolean equals(@Nullable Object obj) { if (obj instanceof InstanceOfPredicate) { InstanceOfPredicate that = (InstanceOfPredicate) obj; return clazz == that.clazz; } return false; }
/** * Pair a private key integer with a public EC point * * BouncyCastle will be used as the Java Security Provider */ public ECKey(@Nullable BigInteger priv, ECPoint pub) { this( SpongyCastleProvider.getInstance(), privateKeyFromBigInteger(priv), pub ); }
boolean ranged(RangedInfo rangedInfo, @Nullable Location distanceReference) { double distance = rangedInfo.distanceFrom(distanceReference); if(!Double.isNaN(distance) && option("distance")) { setDistance(distance); if(distance >= SNIPE_DISTANCE) { option("snipe"); } return true; } return false; }
public static DevSupportManager create( Context applicationContext, ReactInstanceDevCommandsHandler reactInstanceCommandsHandler, @Nullable String packagerPathForJSBundleName, boolean enableOnCreate) { return create( applicationContext, reactInstanceCommandsHandler, packagerPathForJSBundleName, enableOnCreate, null); }
/** * Not-equal-to comparison. * * @param fieldName the field to compare. * @param value the value to compare with. * @return the query object. * @throws java.lang.IllegalArgumentException if one or more arguments do not match class or field type. */ public RealmQuery<E> notEqualTo(String fieldName, @Nullable byte[] value) { realm.checkIfValid(); FieldDescriptor fd = schema.getColumnIndices(fieldName, RealmFieldType.BINARY); if (value == null) { this.query.isNotNull(fd.getColumnIndices(), fd.getNativeTablePointers()); } else { this.query.notEqualTo(fd.getColumnIndices(), fd.getNativeTablePointers(), value); } return this; }
@Override protected Object handleInvocation( Object proxy, Method method, Object[] args) { Invokable<?, ?> invokable = interfaceType.method(method); ImmutableList<Parameter> params = invokable.getParameters(); for (int i = 0; i < args.length; i++) { Parameter param = params.get(i); if (!param.isAnnotationPresent(Nullable.class)) { checkNotNull(args[i]); } } return dummyReturnValue(interfaceType.resolveType(method.getGenericReturnType())); }
@Nullable /** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { this.setEquipmentBasedOnDifficulty(difficulty); this.setEnchantmentBasedOnDifficulty(difficulty); return super.onInitialSpawn(difficulty, livingdata); }
private RelShuttle getTimestampBasedMaterializationShuttle(final Layout layout) { final RelShuttle shuttle = new FileMaterializationShuttle(Long.MIN_VALUE); return materializationStore.get().get(layout.getId()) .transform(new Function<MaterializedLayout, RelShuttle>() { @Nullable @Override public RelShuttle apply(@Nullable final MaterializedLayout input) { if (AccelerationUtils.selfOrEmpty(input.getMaterializationList()).isEmpty()) { return shuttle; } final Long updateId = FluentIterable.from(input.getMaterializationList()) .toSortedList(new Comparator<Materialization>() { @Override public int compare(Materialization o1, Materialization o2) { // sorting in reverse order return o2.getUpdateId().compareTo(o1.getUpdateId()); } }).get(0).getUpdateId(); if (updateId == null) { return shuttle; } return new FileMaterializationShuttle(updateId); } }) .or(shuttle); }
/** * Deletes and returns the next value from the iterator, or returns * {@code null} if there is no such value. */ @Nullable static <T> T pollNext(Iterator<T> iterator) { if (iterator.hasNext()) { T result = iterator.next(); iterator.remove(); return result; } else { return null; } }
/** * @param functions function resolver * @param granularity the maximum row granularity the normalizer should try to normalize * @param referenceResolver reference resolver which is used to resolve paths * @param fieldResolver optional field resolver to resolve fields * @param inPlace defines if symbols like functions can be changed inplace instead of being copied when changed */ public EvaluatingNormalizer( Functions functions, RowGranularity granularity, ReferenceResolver<? extends Input<?>> referenceResolver, @Nullable FieldResolver fieldResolver, boolean inPlace) { this.functions = functions; this.granularity = granularity; this.referenceResolver = referenceResolver; this.fieldResolver = fieldResolver; if (inPlace) { this.visitor = new InPlaceVisitor(); } else { this.visitor = new CopyingVisitor(); } }
@Nullable ItemStack createIcon(Player viewer) { if(!connector.isVisible()) return null; final RenderedItemBuilder<?> icon = itemBuilders.create(viewer, this.icon.clone()) .flags(ItemFlag.values()); final Object mapped = connector.mappedTo(); if(Navigator.DEFAULT_MAPPING.equals(mapped)) { renderDefault(viewer, icon); } else if(mapped instanceof Server) { renderServer(viewer, icon, (Server) mapped); } else if(mapped instanceof Arena) { renderArena(viewer, icon, (Arena) mapped); } return icon.get(); }
@JsProperty protected native void setOnCompositionUpdate( @Nullable final CompositionEventHandler onCompositionUpdate );
@Override public OffsetRange<CharOffset> apply(@Nullable final Response response) { return checkNotNull(response).canonicalArgument().charOffsetSpan().asCharOffsetRange(); }
abstract void replayModifyTransactionRequest(ModifyTransactionRequest request, @Nullable Consumer<Response<?, ?>> callback, long enqueuedTicks);
/** * @return The team this player is supposed to be on */ public @Nullable Team getTeam(Player player) { return getTeam(userStore.getUser(player)); }
@JsProperty protected native void setOnMouseDown( @Nullable final MouseEventHandler onMouseDown );
@Nullable @Override public LocalDateTime unmarshal(String v) { return isEmpty(v) ? null : LocalDateTime.parse(v); }
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { return args.length == 1 ? getListOfStringsMatchingLastWord(args, server.getPlayerList().getBannedIPs().getKeys()) : Collections.<String>emptyList(); }
@Override public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { Map<C, V> row = Maps.safeGet(rowMap(), rowKey); return row != null && Maps.safeContainsKey(row, columnKey); }
public SimpleI18NString(@Nullable String text, @Nullable String defaultText) { this.text = text; this.defaultText = defaultText; }
@Nullable protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_SNOWMAN_AMBIENT; }
@JsProperty protected native void setOnTouchCancel( @Nullable final TouchEventHandler onTouchCancel );
@JsOverlay public final FormProps onDragLeave( @Nullable final DragEventHandler handler ) { setOnDragLeave( handler ); return self(); }