Refactoring the oopsies

This commit is contained in:
nossr50 2019-02-16 16:11:55 -08:00
parent 9731b9cffb
commit acf2bf362f
17 changed files with 47 additions and 47 deletions

View File

@ -56,19 +56,19 @@ public class FishingCommand extends SkillCommand {
lootTier = fishingManager.getLootTier(); lootTier = fishingManager.getLootTier();
// Item drop rates // Item drop rates
commonTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0); commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
uncommonTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0); uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
rareTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0); rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
epicTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0); epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
legendaryTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0); legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
recordTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0); recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0);
// Magic hunter drop rates // Magic hunter drop rates
double totalEnchantChance = 0; double totalEnchantChance = 0;
for (Rarity rarity : Rarity.values()) { for (Rarity rarity : Rarity.values()) {
if (rarity != Rarity.RECORD) { if (rarity != Rarity.RECORD) {
totalEnchantChance += TreasureMainConfig.getInstance().getEnchantmentDropRate(lootTier, rarity); totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
} }
} }

View File

@ -122,7 +122,7 @@ public class AlchemyPotion {
if (!children.isEmpty()) { if (!children.isEmpty()) {
for (Entry<ItemStack, String> child : children.entrySet()) { for (Entry<ItemStack, String> child : children.entrySet()) {
if (ingredient.isSimilar(child.getKey())) { if (ingredient.isSimilar(child.getKey())) {
return PotionMainConfig.getInstance().getPotion(child.getValue()); return PotionConfig.getInstance().getPotion(child.getValue());
} }
} }
} }

View File

@ -611,7 +611,7 @@ public class BlockListener implements Listener {
} }
public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) { public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) {
if (HiddenMainConfig.getInstance().useEnchantmentBuffs()) { if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) { if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
SkillUtils.removeAbilityBuff(heldItem); SkillUtils.removeAbilityBuff(heldItem);
} }

View File

@ -420,12 +420,12 @@ public class mcMMO extends JavaPlugin {
// Force the loading of config files // Force the loading of config files
TreasureMainConfig.getInstance(); TreasureConfig.getInstance();
HiddenMainConfig.getInstance(); HiddenConfig.getInstance();
AdvancedConfig.getInstance(); AdvancedConfig.getInstance();
PotionMainConfig.getInstance(); PotionConfig.getInstance();
CoreSkillsMainConfig.getInstance(); CoreSkillsMainConfig.getInstance();
SoundMainConfig.getInstance(); SoundConfig.getInstance();
RankConfig.getInstance(); RankConfig.getInstance();
new ChildConfig(); new ChildConfig();

View File

@ -15,9 +15,9 @@ import java.util.logging.Level;
public class UUIDUpdateAsyncTask extends BukkitRunnable { public class UUIDUpdateAsyncTask extends BukkitRunnable {
private mcMMO plugin; private mcMMO plugin;
private static final int MAX_LOOKUP = Math.max(HiddenMainConfig.getInstance().getUUIDConvertAmount(), 100); private static final int MAX_LOOKUP = Math.max(HiddenConfig.getInstance().getUUIDConvertAmount(), 100);
private static final int RATE_LIMIT = HiddenMainConfig.getInstance().getMojangRateLimit(); private static final int RATE_LIMIT = HiddenConfig.getInstance().getMojangRateLimit();
private static final long LIMIT_PERIOD = HiddenMainConfig.getInstance().getMojangLimitPeriod(); private static final long LIMIT_PERIOD = HiddenConfig.getInstance().getMojangLimitPeriod();
private static final int BATCH_SIZE = MAX_LOOKUP * 3; private static final int BATCH_SIZE = MAX_LOOKUP * 3;
private List<String> userNames; private List<String> userNames;

View File

@ -25,7 +25,7 @@ public class AlchemyManager extends SkillManager {
} }
public List<ItemStack> getIngredients() { public List<ItemStack> getIngredients() {
return PotionMainConfig.getInstance().getIngredients(getTier()); return PotionConfig.getInstance().getIngredients(getTier());
} }
public String getIngredientList() { public String getIngredientList() {

View File

@ -34,7 +34,7 @@ public final class AlchemyPotionBrewer {
continue; continue;
} }
if (getChildPotion(PotionMainConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) { if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) {
return true; return true;
} }
} }
@ -92,7 +92,7 @@ public final class AlchemyPotionBrewer {
} }
private static List<ItemStack> getValidIngredients(Player player) { private static List<ItemStack> getValidIngredients(Player player) {
return PotionMainConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); return PotionConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier());
} }
public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) { public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
@ -112,11 +112,11 @@ public final class AlchemyPotionBrewer {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
ItemStack item = inventory.getItem(i); ItemStack item = inventory.getItem(i);
if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionMainConfig.getInstance().isValidPotion(item)) { if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionConfig.getInstance().isValidPotion(item)) {
continue; continue;
} }
AlchemyPotion input = PotionMainConfig.getInstance().getPotion(item); AlchemyPotion input = PotionConfig.getInstance().getPotion(item);
AlchemyPotion output = input.getChild(ingredient); AlchemyPotion output = input.getChild(ingredient);
inputList.add(input); inputList.add(input);

View File

@ -18,8 +18,8 @@ public class Excavation {
*/ */
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) { protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
if (TreasureMainConfig.getInstance().excavationMap.containsKey(friendly)) if (TreasureConfig.getInstance().excavationMap.containsKey(friendly))
return TreasureMainConfig.getInstance().excavationMap.get(friendly); return TreasureConfig.getInstance().excavationMap.get(friendly);
return new ArrayList<ExcavationTreasure>(); return new ArrayList<ExcavationTreasure>();
} }

View File

@ -30,8 +30,8 @@ public final class Fishing {
* @return possibleDrops List of ItemStack that can be dropped * @return possibleDrops List of ItemStack that can be dropped
*/ */
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) { protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
if (TreasureMainConfig.getInstance().shakeMap.containsKey(target.getType())) if (TreasureConfig.getInstance().shakeMap.containsKey(target.getType()))
return TreasureMainConfig.getInstance().shakeMap.get(target.getType()); return TreasureConfig.getInstance().shakeMap.get(target.getType());
return null; return null;
} }

View File

@ -367,7 +367,7 @@ public class FishingManager extends SkillManager {
break; break;
case BEDROCK: case BEDROCK:
if (TreasureMainConfig.getInstance().getInventoryStealEnabled()) { if (TreasureConfig.getInstance().getInventoryStealEnabled()) {
PlayerInventory inventory = targetPlayer.getInventory(); PlayerInventory inventory = targetPlayer.getInventory();
int length = inventory.getContents().length; int length = inventory.getContents().length;
int slot = Misc.getRandom().nextInt(length); int slot = Misc.getRandom().nextInt(length);
@ -377,7 +377,7 @@ public class FishingManager extends SkillManager {
break; break;
} }
if (TreasureMainConfig.getInstance().getInventoryStealStacks()) { if (TreasureConfig.getInstance().getInventoryStealStacks()) {
inventory.setItem(slot, null); inventory.setItem(slot, null);
} }
else { else {
@ -445,7 +445,7 @@ public class FishingManager extends SkillManager {
FishingTreasure treasure = null; FishingTreasure treasure = null;
for (Rarity rarity : Rarity.values()) { for (Rarity rarity : Rarity.values()) {
double dropRate = TreasureMainConfig.getInstance().getItemDropRate(getLootTier(), rarity); double dropRate = TreasureConfig.getInstance().getItemDropRate(getLootTier(), rarity);
if (diceRoll <= dropRate) { if (diceRoll <= dropRate) {
/*if (rarity == Rarity.TRAP) { /*if (rarity == Rarity.TRAP) {
@ -453,7 +453,7 @@ public class FishingManager extends SkillManager {
break; break;
}*/ }*/
List<FishingTreasure> fishingTreasures = TreasureMainConfig.getInstance().fishingRewards.get(rarity); List<FishingTreasure> fishingTreasures = TreasureConfig.getInstance().fishingRewards.get(rarity);
if (fishingTreasures.isEmpty()) { if (fishingTreasures.isEmpty()) {
return null; return null;
@ -504,7 +504,7 @@ public class FishingManager extends SkillManager {
continue; continue;
} }
double dropRate = TreasureMainConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity); double dropRate = TreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity);
if (diceRoll <= dropRate) { if (diceRoll <= dropRate) {
// Make sure enchanted books always get some kind of enchantment. --hoorigan // Make sure enchanted books always get some kind of enchantment. --hoorigan
@ -512,7 +512,7 @@ public class FishingManager extends SkillManager {
diceRoll = dropRate + 1; diceRoll = dropRate + 1;
continue; continue;
} }
fishingEnchantments = TreasureMainConfig.getInstance().fishingEnchantments.get(rarity); fishingEnchantments = TreasureConfig.getInstance().fishingEnchantments.get(rarity);
break; break;
} }

View File

@ -212,9 +212,9 @@ public class HerbalismManager extends SkillManager {
} }
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
if (!TreasureMainConfig.getInstance().hylianMap.containsKey(friendly)) if (!TreasureConfig.getInstance().hylianMap.containsKey(friendly))
return false; return false;
List<HylianTreasure> treasures = TreasureMainConfig.getInstance().hylianMap.get(friendly); List<HylianTreasure> treasures = TreasureConfig.getInstance().hylianMap.get(friendly);
Player player = getPlayer(); Player player = getPlayer();

View File

@ -4,7 +4,7 @@ import com.gmail.nossr50.config.HiddenConfig;
public class ChunkletManagerFactory { public class ChunkletManagerFactory {
public static ChunkletManager getChunkletManager() { public static ChunkletManager getChunkletManager() {
HiddenConfig hConfig = HiddenMainConfig.getInstance(); HiddenConfig hConfig = HiddenConfig.getInstance();
if (hConfig.getChunkletsEnabled()) { if (hConfig.getChunkletsEnabled()) {
return new HashChunkletManager(); return new HashChunkletManager();

View File

@ -4,7 +4,7 @@ import com.gmail.nossr50.config.HiddenConfig;
public class ChunkManagerFactory { public class ChunkManagerFactory {
public static ChunkManager getChunkManager() { public static ChunkManager getChunkManager() {
HiddenConfig hConfig = HiddenMainConfig.getInstance(); HiddenConfig hConfig = HiddenConfig.getInstance();
if (hConfig.getChunkletsEnabled()) { if (hConfig.getChunkletsEnabled()) {
return new HashChunkManager(); return new HashChunkManager();

View File

@ -18,7 +18,7 @@ public class BlockStoreConversionMain implements Runnable {
this.world = world; this.world = world;
this.scheduler = mcMMO.p.getServer().getScheduler(); this.scheduler = mcMMO.p.getServer().getScheduler();
this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data"); this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data");
this.converters = new BlockStoreConversionXDirectory[HiddenMainConfig.getInstance().getConversionRate()]; this.converters = new BlockStoreConversionXDirectory[HiddenConfig.getInstance().getConversionRate()];
} }
public void start() { public void start() {
@ -51,7 +51,7 @@ public class BlockStoreConversionMain implements Runnable {
this.xDirs = this.dataDir.listFiles(); this.xDirs = this.dataDir.listFiles();
for (this.i = 0; (this.i < HiddenMainConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) { for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) {
if (this.converters[this.i] == null) { if (this.converters[this.i] == null) {
this.converters[this.i] = new BlockStoreConversionXDirectory(); this.converters[this.i] = new BlockStoreConversionXDirectory();
} }

View File

@ -20,7 +20,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
public void start(org.bukkit.World world, File dataDir) { public void start(org.bukkit.World world, File dataDir) {
this.world = world; this.world = world;
this.scheduler = mcMMO.p.getServer().getScheduler(); this.scheduler = mcMMO.p.getServer().getScheduler();
this.converters = new BlockStoreConversionZDirectory[HiddenMainConfig.getInstance().getConversionRate()]; this.converters = new BlockStoreConversionZDirectory[HiddenConfig.getInstance().getConversionRate()];
this.dataDir = dataDir; this.dataDir = dataDir;
if (this.taskID >= 0) { if (this.taskID >= 0) {
@ -52,7 +52,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
this.zDirs = this.dataDir.listFiles(); this.zDirs = this.dataDir.listFiles();
for (this.i = 0; (this.i < HiddenMainConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) { for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) {
if (this.converters[this.i] == null) { if (this.converters[this.i] == null) {
this.converters[this.i] = new BlockStoreConversionZDirectory(); this.converters[this.i] = new BlockStoreConversionZDirectory();
} }

View File

@ -129,7 +129,7 @@ public class SkillUtils {
} }
public static void handleAbilitySpeedIncrease(Player player) { public static void handleAbilitySpeedIncrease(Player player) {
if (HiddenMainConfig.getInstance().useEnchantmentBuffs()) { if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
if (heldItem == null || heldItem.getType() == Material.AIR) { if (heldItem == null || heldItem.getType() == Material.AIR) {
@ -187,7 +187,7 @@ public class SkillUtils {
} }
public static void handleAbilitySpeedDecrease(Player player) { public static void handleAbilitySpeedDecrease(Player player) {
if (!HiddenMainConfig.getInstance().useEnchantmentBuffs()) { if (!HiddenConfig.getInstance().useEnchantmentBuffs()) {
return; return;
} }

View File

@ -14,13 +14,13 @@ public class SoundManager {
*/ */
public static void sendSound(Player player, Location location, SoundType soundType) public static void sendSound(Player player, Location location, SoundType soundType)
{ {
if(SoundMainConfig.getInstance().getIsEnabled(soundType)) if(SoundConfig.getInstance().getIsEnabled(soundType))
player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType)); player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
} }
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory)
{ {
if(SoundMainConfig.getInstance().getIsEnabled(soundType)) if(SoundConfig.getInstance().getIsEnabled(soundType))
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType)); player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
} }
@ -28,13 +28,13 @@ public class SoundManager {
{ {
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier)); float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
if(SoundMainConfig.getInstance().getIsEnabled(soundType)) if(SoundConfig.getInstance().getIsEnabled(soundType))
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch); player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
} }
public static void worldSendSound(World world, Location location, SoundType soundType) public static void worldSendSound(World world, Location location, SoundType soundType)
{ {
if(SoundMainConfig.getInstance().getIsEnabled(soundType)) if(SoundConfig.getInstance().getIsEnabled(soundType))
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType)); world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
} }
@ -45,7 +45,7 @@ public class SoundManager {
*/ */
private static float getVolume(SoundType soundType) private static float getVolume(SoundType soundType)
{ {
return SoundMainConfig.getInstance().getVolume(soundType) * SoundMainConfig.getInstance().getMasterVolume(); return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance().getMasterVolume();
} }
private static float getPitch(SoundType soundType) private static float getPitch(SoundType soundType)
@ -55,7 +55,7 @@ public class SoundManager {
else if (soundType == SoundType.POP) else if (soundType == SoundType.POP)
return getPopPitch(); return getPopPitch();
else else
return SoundMainConfig.getInstance().getPitch(soundType); return SoundConfig.getInstance().getPitch(soundType);
} }
private static Sound getSound(SoundType soundType) private static Sound getSound(SoundType soundType)