mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 08:39:49 +01:00
Because we don't need that many Random objects.
This commit is contained in:
parent
e036b7ac70
commit
c1463c3257
@ -1,12 +1,9 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
|
||||
public class Acrobatics {
|
||||
private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private static Random random = new Random();
|
||||
|
||||
public static final int DODGE_MAX_CHANCE = advancedConfig.getDodgeChanceMax();
|
||||
public static final int DODGE_MAX_BONUS_LEVEL = advancedConfig.getDodgeMaxBonusLevel();
|
||||
@ -19,8 +16,4 @@ public class Acrobatics {
|
||||
|
||||
public static final int ROLL_XP_MODIFIER = advancedConfig.getRollXPModifier();
|
||||
public static final int FALL_XP_MODIFIER = advancedConfig.getFallXPModifier();
|
||||
|
||||
protected static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class AcrobaticsManager {
|
||||
chance = ((float) Acrobatics.ROLL_MAX_CHANCE / Acrobatics.ROLL_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
||||
}
|
||||
|
||||
if (chance > Acrobatics.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER);
|
||||
@ -82,7 +82,7 @@ public class AcrobaticsManager {
|
||||
|
||||
float chance = ((float) Acrobatics.DODGE_MAX_CHANCE / Acrobatics.DODGE_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Acrobatics.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
|
||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.archery;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -14,7 +13,6 @@ import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class Archery {
|
||||
private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private static Random random = new Random();
|
||||
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
|
||||
|
||||
public static final int ARROW_TRACKING_MAX_BONUS_LEVEL = advancedConfig.getRetrieveMaxBonusLevel();
|
||||
@ -66,8 +64,4 @@ public class Archery {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class ArcheryManager {
|
||||
|
||||
float chance = ((float) Archery.ARROW_TRACKING_MAX_BONUS / Archery.ARROW_TRACKING_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Archery.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
eventHandler.addToTracker();
|
||||
}
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class ArcheryManager {
|
||||
|
||||
float chance = ((float) Archery.DAZE_MAX_BONUS / Archery.DAZE_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Archery.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
eventHandler.handleDazeEffect();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class DazeEventHandler {
|
||||
protected void handleDazeEffect() {
|
||||
Location location = defender.getLocation();
|
||||
|
||||
if (Archery.getRandom().nextInt(100) > DAZE_CHANCE) {
|
||||
if (Misc.getRandom().nextInt(100) > DAZE_CHANCE) {
|
||||
location.setPitch(90);
|
||||
}
|
||||
else {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -24,8 +22,6 @@ import com.gmail.nossr50.util.Users;
|
||||
public class Axes {
|
||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Apply bonus to damage done by axes.
|
||||
*
|
||||
@ -95,7 +91,7 @@ public class Axes {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (chance > random.nextInt(randomChance) && !entity.isDead()) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && !entity.isDead()) {
|
||||
int damage = event.getDamage();
|
||||
|
||||
if (entity instanceof Player) {
|
||||
@ -145,7 +141,7 @@ public class Axes {
|
||||
for (int i = 0; i <= durabilityDamage; i ++) {
|
||||
if (armor.containsEnchantment(Enchantment.DURABILITY)) {
|
||||
int level = armor.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||
if (random.nextInt(level + 1) > 0) {
|
||||
if (Misc.getRandom().nextInt(level + 1) > 0) {
|
||||
lowerdamage++;
|
||||
}
|
||||
}
|
||||
@ -189,7 +185,7 @@ public class Axes {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextInt(randomChance) <= GREATER_IMPACT_CHANCE) {
|
||||
if (Misc.getRandom().nextInt(randomChance) <= GREATER_IMPACT_CHANCE) {
|
||||
event.setDamage(event.getDamage() + GREATER_IMPACT_DAMAGE);
|
||||
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
|
||||
attacker.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
|
||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -29,8 +28,6 @@ import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Excavation {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Check to see if treasures were found.
|
||||
*
|
||||
@ -103,7 +100,7 @@ public class Excavation {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
|
||||
if (Misc.getRandom().nextDouble() * randomChance <= treasure.getDropChance()) {
|
||||
xp += treasure.getXp();
|
||||
is.add(treasure.getDrop());
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.gathering;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
@ -38,8 +37,6 @@ import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Fishing {
|
||||
|
||||
private static Random random = new Random();
|
||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
|
||||
/**
|
||||
@ -112,7 +109,7 @@ public class Fishing {
|
||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0
|
||||
&& Permissions.fishingTreasures(player)) {
|
||||
FishingTreasure treasure;
|
||||
treasure = rewards.get(random.nextInt(rewards.size()));
|
||||
treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
@ -120,7 +117,7 @@ public class Fishing {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
|
||||
if (Misc.getRandom().nextDouble() * randomChance <= treasure.getDropChance()) {
|
||||
Users.getPlayer(player).addXP(SkillType.FISHING,treasure.getXp());
|
||||
theCatch.setItemStack(treasure.getDrop());
|
||||
}
|
||||
@ -131,7 +128,7 @@ public class Fishing {
|
||||
short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
|
||||
|
||||
if (maxDurability > 0) {
|
||||
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); // Change durability to random value
|
||||
theCatch.getItemStack().setDurability((short) (Misc.getRandom().nextInt(maxDurability))); // Change durability to random value
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
||||
@ -167,7 +164,7 @@ public class Fishing {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE
|
||||
if (Misc.getRandom().nextInt(randomChance) <= ENCHANTMENT_CHANCE
|
||||
&& Permissions.fishingMagic(player)) {
|
||||
for (Enchantment newEnchant : Enchantment.values()) {
|
||||
if (newEnchant.canEnchantItem(fishingResults)) {
|
||||
@ -182,9 +179,9 @@ public class Fishing {
|
||||
* Actual chance to have an enchantment is related
|
||||
* to your fishing skill
|
||||
*/
|
||||
if (random.nextInt(15) < Fishing.getFishingLootTier(profile)) {
|
||||
if (Misc.getRandom().nextInt(15) < Fishing.getFishingLootTier(profile)) {
|
||||
enchanted = true;
|
||||
int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
|
||||
int randomEnchantLevel = Misc.getRandom().nextInt(newEnchant.getMaxLevel()) + 1;
|
||||
|
||||
if (randomEnchantLevel < newEnchant.getStartLevel()) {
|
||||
randomEnchantLevel = newEnchant.getStartLevel();
|
||||
@ -230,8 +227,8 @@ public class Fishing {
|
||||
dropChance = (int) (dropChance * 1.25);
|
||||
}
|
||||
|
||||
final int DROP_CHANCE = random.nextInt(100);
|
||||
final int DROP_NUMBER = random.nextInt(randomChance) + 1;
|
||||
final int DROP_CHANCE = Misc.getRandom().nextInt(100);
|
||||
final int DROP_NUMBER = Misc.getRandom().nextInt(randomChance) + 1;
|
||||
|
||||
LivingEntity le = (LivingEntity) event.getCaught();
|
||||
EntityType type = le.getType();
|
||||
@ -341,7 +338,7 @@ public class Fishing {
|
||||
wool.setColor(sheep.getColor());
|
||||
|
||||
final ItemStack theWool = wool.toItemStack();
|
||||
theWool.setAmount(1 + random.nextInt(6));
|
||||
theWool.setAmount(1 + Misc.getRandom().nextInt(6));
|
||||
|
||||
Misc.dropItem(location, theWool);
|
||||
sheep.setSheared(true);
|
||||
@ -404,7 +401,7 @@ public class Fishing {
|
||||
break;
|
||||
|
||||
case WITCH:
|
||||
final int DROP_NUMBER_2 = random.nextInt(randomChance) + 1;
|
||||
final int DROP_NUMBER_2 = Misc.getRandom().nextInt(randomChance) + 1;
|
||||
if (DROP_NUMBER > 95) {
|
||||
if (DROP_NUMBER_2 > 66) {
|
||||
Misc.dropItem(location, new Potion(PotionType.INSTANT_HEAL).toItemStack(1));
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
@ -30,8 +28,6 @@ import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Herbalism {
|
||||
|
||||
private static Random random = new Random();
|
||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
|
||||
/**
|
||||
@ -129,7 +125,7 @@ public class Herbalism {
|
||||
if (b.getType().equals(Material.CACTUS)) {
|
||||
mat = Material.CACTUS;
|
||||
if (!mcMMO.placeStore.isTrue(b)) {
|
||||
if (chance > random.nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
catciDrops++;
|
||||
}
|
||||
xp += Config.getInstance().getHerbalismXPCactus();
|
||||
@ -189,7 +185,7 @@ public class Herbalism {
|
||||
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
||||
mat = Material.SUGAR_CANE;
|
||||
if (!mcMMO.placeStore.isTrue(b)) {
|
||||
if (chance > random.nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
caneDrops++;
|
||||
}
|
||||
xp += Config.getInstance().getHerbalismXPSugarCane();
|
||||
@ -287,7 +283,7 @@ public class Herbalism {
|
||||
}
|
||||
}
|
||||
|
||||
if (chance > random.nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
switch (type) {
|
||||
@ -456,7 +452,7 @@ public class Herbalism {
|
||||
float chance = (float) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * herbLevel);
|
||||
if (chance > MAX_CHANCE) chance = (float) MAX_CHANCE;
|
||||
|
||||
if (hasSeeds && profile.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (chance > random.nextInt(randomChance))) {
|
||||
if (hasSeeds && profile.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (chance > Misc.getRandom().nextInt(randomChance))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
switch(type) {
|
||||
@ -526,7 +522,7 @@ public class Herbalism {
|
||||
float chance = (float) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > MAX_CHANCE) chance = (float) MAX_CHANCE;
|
||||
|
||||
if (chance > random.nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
greenTerraConvert(player, block);
|
||||
}
|
||||
else {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -35,7 +34,6 @@ import com.gmail.nossr50.util.Users;
|
||||
public class WoodCutting {
|
||||
|
||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Handle the Tree Feller ability.
|
||||
@ -82,7 +80,7 @@ public class WoodCutting {
|
||||
int health = player.getHealth();
|
||||
|
||||
if (health >= 2) {
|
||||
Combat.dealDamage(player, random.nextInt(health - 1));
|
||||
Combat.dealDamage(player, Misc.getRandom().nextInt(health - 1));
|
||||
}
|
||||
inHand.setDurability(inHand.getType().getMaxDurability());
|
||||
return;
|
||||
@ -94,7 +92,7 @@ public class WoodCutting {
|
||||
int health = player.getHealth();
|
||||
|
||||
if (health >= 2) {
|
||||
Combat.dealDamage(player, random.nextInt(health - 1));
|
||||
Combat.dealDamage(player, Misc.getRandom().nextInt(health - 1));
|
||||
}
|
||||
inHand.setDurability(inHand.getType().getMaxDurability());
|
||||
return;
|
||||
@ -361,7 +359,7 @@ public class WoodCutting {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (chance > random.nextInt(randomChance) && Permissions.woodcuttingDoubleDrops(player)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && Permissions.woodcuttingDoubleDrops(player)) {
|
||||
Config configInstance = Config.getInstance();
|
||||
ItemStack item;
|
||||
Location location;
|
||||
@ -503,7 +501,7 @@ public class WoodCutting {
|
||||
private static int durabilityLossCalulate(ArrayList<Block> toBeFelled, int level) {
|
||||
int durabilityLoss = 0;
|
||||
for (Block x : toBeFelled) {
|
||||
if (random.nextInt(level + 1) > 0) {}//Don't add durabilityLoss, because Unbreaking enchantment does it's work.
|
||||
if (Misc.getRandom().nextInt(level + 1) > 0) {}//Don't add durabilityLoss, because Unbreaking enchantment does it's work.
|
||||
else if (x.getType().equals(Material.LOG) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(x))) {
|
||||
durabilityLoss = durabilityLoss + Config.getInstance().getAbilityToolDamage();
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
|
||||
public class BlastMining {
|
||||
private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private static Random random = new Random();
|
||||
|
||||
public final static int BLAST_MINING_RANK_1 = advancedConfig.getBlastMiningRank1();
|
||||
public final static int BLAST_MINING_RANK_2 = advancedConfig.getBlastMiningRank2();
|
||||
@ -18,8 +15,4 @@ public class BlastMining {
|
||||
public final static int BLAST_MINING_RANK_8 = advancedConfig.getBlastMiningRank8();
|
||||
|
||||
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
||||
|
||||
protected static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class BlastMiningDropEventHandler {
|
||||
Location location = block.getLocation();
|
||||
Material type = block.getType();
|
||||
|
||||
if (BlastMining.getRandom().nextFloat() < (yield + oreBonus)) {
|
||||
if (Misc.getRandom().nextFloat() < (yield + oreBonus)) {
|
||||
droppedOres.add(block);
|
||||
Mining.miningDrops(block, location, type);
|
||||
|
||||
@ -82,7 +82,7 @@ public class BlastMiningDropEventHandler {
|
||||
Location location = block.getLocation();
|
||||
Material type = block.getType();
|
||||
|
||||
if (BlastMining.getRandom().nextFloat() < debrisYield) {
|
||||
if (Misc.getRandom().nextFloat() < debrisYield) {
|
||||
Misc.dropItem(location, new ItemStack(type));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.CoalType;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
@ -23,7 +21,6 @@ import com.gmail.nossr50.util.Skills;
|
||||
public class Mining {
|
||||
private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private static Config config = Config.getInstance();
|
||||
private static Random random = new Random();
|
||||
|
||||
public static final int DOUBLE_DROPS_MAX_BONUS_LEVEL = advancedConfig.getMiningDoubleDropMaxLevel();
|
||||
public static final int DOUBLE_DROPS_MAX_CHANCE = advancedConfig.getMiningDoubleDropChance();
|
||||
@ -315,8 +312,4 @@ public class Mining {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public class MiningManager {
|
||||
|
||||
float chance = ((float) Mining.DOUBLE_DROPS_MAX_CHANCE / Mining.DOUBLE_DROPS_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Mining.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
eventHandler.processDrops();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -18,13 +17,12 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Repair {
|
||||
|
||||
private static Random random = new Random();
|
||||
private static Config configInstance = Config.getInstance();
|
||||
|
||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
@ -121,11 +119,11 @@ public class Repair {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextInt(randomChance) <= getEnchantChance(rank)) {
|
||||
if (Misc.getRandom().nextInt(randomChance) <= getEnchantChance(rank)) {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (configInstance.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
|
||||
if (random.nextInt(randomChance) < getDowngradeChance(rank)) {
|
||||
if (Misc.getRandom().nextInt(randomChance) < getDowngradeChance(rank)) {
|
||||
is.addEnchantment(enchantment, --enchantLevel);
|
||||
downgraded = true;
|
||||
}
|
||||
@ -249,7 +247,7 @@ public class Repair {
|
||||
|
||||
if (Permissions.luckyRepair(player)) randomChance = (int) (randomChance * 0.75);
|
||||
|
||||
if (chance > random.nextInt(randomChance) && Permissions.repairBonus(player)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance) && Permissions.repairBonus(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.skills.swords;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
|
||||
public class Swords {
|
||||
@ -18,10 +16,4 @@ public class Swords {
|
||||
|
||||
public static final int SERRATED_STRIKES_MODIFIER = advancedConfig.getSerratedStrikesModifier();
|
||||
public static final int SERRATED_STRIKES_BLEED_TICKS = advancedConfig.getSerratedStrikesTicks();
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
protected static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@ -45,7 +46,7 @@ public class SwordsManager {
|
||||
float chance = (float) (((double) Swords.BLEED_CHANCE_MAX / (double) Swords.BLEED_MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > Swords.BLEED_CHANCE_MAX) chance = Swords.BLEED_CHANCE_MAX;
|
||||
|
||||
if (chance > Swords.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
eventHandler.addBleedTicks();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
@ -74,7 +75,7 @@ public class SwordsManager {
|
||||
float chance = (float) (((double) Swords.COUNTER_ATTACK_CHANCE_MAX / (double) Swords.COUNTER_ATTACK_MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > Swords.COUNTER_ATTACK_CHANCE_MAX) chance = Swords.COUNTER_ATTACK_CHANCE_MAX;
|
||||
|
||||
if (chance > Swords.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
eventHandler.dealDamage();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class CallOfTheWildEventHandler {
|
||||
((Tameable) entity).setOwner(player);
|
||||
|
||||
if (type == EntityType.OCELOT) {
|
||||
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Taming.getRandom().nextInt(3)));
|
||||
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3)));
|
||||
}
|
||||
else {
|
||||
entity.setHealth(entity.getMaxHealth());
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
|
||||
public class Taming {
|
||||
@ -25,10 +23,4 @@ public class Taming {
|
||||
|
||||
public static final int THICK_FUR_ACTIVATION_LEVEL = advancedConfig.getThickFurUnlock();
|
||||
public static final int THICK_FUR_MODIFIER = advancedConfig.getThickFurModifier();
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
public static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@ -48,7 +49,7 @@ public class TamingManager {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Taming.getRandom().nextInt(randomChance) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) {
|
||||
if (Misc.getRandom().nextInt(randomChance) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) {
|
||||
FastFoodServiceEventHandler eventHandler = new FastFoodServiceEventHandler(wolf);
|
||||
|
||||
eventHandler.modifyHealth(damage);
|
||||
@ -100,7 +101,7 @@ public class TamingManager {
|
||||
float chance = (float) (((double) Taming.GORE_CHANCE_MAX / (double) Taming.GORE_MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > Taming.GORE_CHANCE_MAX) chance = Taming.GORE_CHANCE_MAX;
|
||||
|
||||
if (chance > Taming.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.applyBleed();
|
||||
eventHandler.sendAbilityMessage();
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.skills.unarmed;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
|
||||
public class Unarmed {
|
||||
@ -17,11 +15,5 @@ public class Unarmed {
|
||||
public static final int DISARM_MAX_BONUS_LEVEL = advancedConfig.getDeflectMaxBonusLevel();
|
||||
|
||||
public static final int IRON_GRIP_MAX_CHANCE = advancedConfig.getIronGripChanceMax();
|
||||
public static final int IRON_GRIP_MAX_BONUS_LEVEL = advancedConfig.getIronGripMaxBonusLevel();
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
protected static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
public static final int IRON_GRIP_MAX_BONUS_LEVEL = advancedConfig.getIronGripMaxBonusLevel();
|
||||
}
|
@ -5,6 +5,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@ -46,7 +47,7 @@ public class UnarmedManager {
|
||||
float chance = (float) (((double) Unarmed.DISARM_MAX_CHANCE / (double) Unarmed.DISARM_MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > Unarmed.DISARM_MAX_CHANCE) chance = Unarmed.DISARM_MAX_CHANCE;
|
||||
|
||||
if (chance > Unarmed.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (!hasIronGrip(defender)) {
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.handleDisarm();
|
||||
@ -80,7 +81,7 @@ public class UnarmedManager {
|
||||
float chance = (float) (((double) Unarmed.DEFLECT_MAX_CHANCE / (double) Unarmed.DEFLECT_MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > Unarmed.DEFLECT_MAX_CHANCE) chance = Unarmed.DEFLECT_MAX_CHANCE;
|
||||
|
||||
if (chance > Unarmed.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
eventHandler.cancelEvent();
|
||||
eventHandler.sendAbilityMessage();
|
||||
}
|
||||
@ -130,7 +131,7 @@ public class UnarmedManager {
|
||||
float chance = (float) (((double) Unarmed.IRON_GRIP_MAX_CHANCE / (double) Unarmed.IRON_GRIP_MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (chance > Unarmed.IRON_GRIP_MAX_CHANCE) chance = Unarmed.IRON_GRIP_MAX_CHANCE;
|
||||
|
||||
if (chance > Unarmed.getRandom().nextInt(randomChance)) {
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
eventHandler.sendAbilityMessages();
|
||||
return true;
|
||||
}
|
||||
|
@ -308,4 +308,8 @@ public class Misc {
|
||||
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -28,8 +26,6 @@ public class Skills {
|
||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
|
||||
private final static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Checks to see if the cooldown for an item or ability is expired.
|
||||
*
|
||||
@ -387,7 +383,7 @@ public class Skills {
|
||||
if (Config.getInstance().getAbilitiesDamageTools()) {
|
||||
if (inHand.containsEnchantment(Enchantment.DURABILITY)) {
|
||||
int level = inHand.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||
if (random.nextInt(level + 1) > 0) {
|
||||
if (Misc.getRandom().nextInt(level + 1) > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user