/** * This method is for backwards-compatibility of plugins that relied on the LinkedList variant, notably MagicWorlds. */ @Nullable @Deprecated public static <T> T weightedRandom(LinkedList<WeightedPair<T>> weightList) { return weightedRandom((Deque<WeightedPair<T>>) weightList); }
public void onDeath(Mage mage, MaterialAndData birthMaterial) { if (deathSpells != null && deathSpells.size() > 0) { String deathSpell = RandomUtils.weightedRandom(deathSpells); if (deathSpell != null && deathSpell.length() > 0) { castSpell(deathSpell, mage, birthMaterial); } } }
public void onTick(Mage mage, MaterialAndData birthMaterial) { if (tickSpells != null && tickSpells.size() > 0) { String tickSpell = RandomUtils.weightedRandom(tickSpells); if (tickSpell.length() > 0) { castSpell(tickSpell, mage, birthMaterial); } } }
public void cast(Mage mage) { String castSpell = RandomUtils.weightedRandom(spells); if (castSpell.length() > 0) { String[] parameters = null; Spell spell = null; if (!castSpell.equalsIgnoreCase("none")) { if (castSpell.contains(" ")) { parameters = StringUtils.split(castSpell, ' '); castSpell = parameters[0]; parameters = Arrays.copyOfRange(parameters, 1, parameters.length); } spell = mage.getSpell(castSpell); } if (spell != null) { spell.cast(parameters); } } }
@Override public void reset(CastContext context) { super.reset(context); if (actionProbability.size() > 0) { currentAction = RandomUtils.weightedRandom(actionProbability); currentAction.getAction().reset(context); } }
Integer spellCount = RandomUtils.weightedRandom(spellCountProbability); if (spellCount == null || spellCount == 0) { spellCount = 1; String spellKey = RandomUtils.weightedRandom(remainingSpells); boolean added = wand.addSpell(spellKey); if (mage != null) { if (needsMaterials && remainingMaterials.size() > 0) { int currentMaterialCount = wand.getBrushes().size(); Integer materialCount = RandomUtils.weightedRandom(materialCountProbability); String materialKey = RandomUtils.weightedRandom(remainingMaterials); materialKey = materialKey.replace("|", ":"); if (!wand.addBrush(materialKey)) { Integer propertyCount = propertyCountProbability.size() == 0 ? Integer.valueOf(0) : RandomUtils.weightedRandom(propertyCountProbability); ConfigurationSection wandProperties = new MemoryConfiguration(); if (probabilities.size() > 0 && current < maxValue) { addedProperties = true; current = Math.min(maxValue, current + RandomUtils.weightedRandom(probabilities)); wandProperties.set(randomProperty, current); if (manaRegenerationProbability.size() > 0 && manaRegeneration < path.getMaxManaRegeneration()) { addedProperties = true; manaRegeneration = Math.min(path.getMaxManaRegeneration(), manaRegeneration + RandomUtils.weightedRandom(manaRegenerationProbability)); wandProperties.set("mana_regeneration", manaRegeneration);
String key = RandomUtils.weightedRandom(dropTable); if (key != null) { ItemStack item = controller.createItem(key);
int count = RandomUtils.weightedRandom(countProbability); if (hasLimit) { count = Math.min(count, limit - mobCount); String randomType = RandomUtils.weightedRandom(entityTypeProbability); try { EntityData entityData = controller.getMob(randomType);
String spell = RandomUtils.weightedRandom(spells); cast(mage, spell, bowpull);
int slope = slopeProbability == null ? 0 : RandomUtils.weightedRandom(slopeProbability); if (targetBlock.getY() - minHeight <= slope) { return SpellResult.NO_TARGET;
int slope = slopeProbability == null ? 0 : RandomUtils.weightedRandom(slopeProbability); if (maxHeight - targetBlock.getY() <= slope) { return SpellResult.NO_TARGET;
level = RandomUtils.weightedRandom(levelWeights);
if (entityType == null) String randomType = RandomUtils.weightedRandom(entityTypeProbability); try { entityType = EntityType.fromName(randomType);
String randomType = RandomUtils.weightedRandom(entityTypeProbability); try { entityData = controller.getMob(randomType);