Because we don't need that many Random objects.

This commit is contained in:
gmcferrin
2013-01-09 23:46:35 -05:00
parent e036b7ac70
commit c1463c3257
24 changed files with 52 additions and 118 deletions

View File

@ -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;
}
}

View File

@ -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));
}
}

View File

@ -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;
}
}

View File

@ -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();
}
}