Code Cleanup Pt 2

This commit is contained in:
nossr50
2019-04-03 19:25:14 -07:00
parent 0e39656c88
commit 43037f8c13
118 changed files with 372 additions and 400 deletions

View File

@@ -160,7 +160,7 @@ public class AdvancedConfig extends ConfigValidated {
@Override
public List<String> validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
/* GENERAL */
if (getAbilityLength() < 1) {

View File

@@ -235,7 +235,7 @@ public class MainConfig extends ConfigValidated {
@Override
public List<String> validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
/* General Settings */
/*if (getSaveInterval() <= 0) {

View File

@@ -49,7 +49,7 @@ public class RankConfig extends ConfigValidated {
@Override
public List<String> validateKeys() {
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
/*
* In the future this method will check keys for all skills, but for now it only checks overhauled skills

View File

@@ -77,7 +77,6 @@ public class ExperienceConfig extends ConfigValidated {
public static final String OCELOT = "Ocelot";
public static final String WOLF = "Wolf";
public static final String FEATHER_FALL_MULTIPLIER = "FeatherFall_Multiplier";
private static ExperienceConfig instance;
//TODO: Should merge be false? Seems okay to leave it as true..
public ExperienceConfig() {
@@ -109,12 +108,12 @@ public class ExperienceConfig extends ConfigValidated {
@Override
public void unload() {
instance = null; //TODO: this might be a bit problematic
}
@Override
public List<String> validateKeys() {
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
/*
* FORMULA SETTINGS

View File

@@ -7,32 +7,32 @@ public final class HOCONUtil {
public static String serializeENUMName(String hyphenedString)
{
String[] split = hyphenedString.split("_");
String formattedString = "";
StringBuilder formattedString = new StringBuilder();
for(int x = 0; x < split.length; x++)
{
if(x + 1 >= split.length)
formattedString += StringUtils.getCapitalized(split[x]);
formattedString.append(StringUtils.getCapitalized(split[x]));
else
formattedString+= (StringUtils.getCapitalized(split[x]) + '-');
formattedString.append(StringUtils.getCapitalized(split[x])).append('-');
}
return formattedString;
return formattedString.toString();
}
public static String deserializeENUMName(String serializedName)
{
String[] split = serializedName.split("-");
String formattedString = "";
StringBuilder formattedString = new StringBuilder();
for(int x = 0; x < split.length; x++)
{
if(x + 1 >= split.length)
formattedString += split[x].toUpperCase();
formattedString.append(split[x].toUpperCase());
else
formattedString+= (split[x] + '_');
formattedString.append(split[x]).append('_');
}
return formattedString;
return formattedString.toString();
}
}

View File

@@ -63,7 +63,7 @@ public class PotionConfig extends ConfigCollection {
private List<ItemStack> concoctionsIngredientsTierSeven;
private List<ItemStack> concoctionsIngredientsTierEight;
private Map<String, AlchemyPotion> potionMap = new HashMap<String, AlchemyPotion>();
private Map<String, AlchemyPotion> potionMap = new HashMap<>();
public PotionConfig() {
super("skillranks", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true);
@@ -211,14 +211,14 @@ public class PotionConfig extends ConfigCollection {
material = Material.valueOf(materialTypeString);
}
List<String> lore = new ArrayList<String>();
List<String> lore = new ArrayList<>();
if (potion_section.getNode(LORE) != null) {
for (String line : potion_section.getNode(LORE).getList(TypeToken.of(String.class))) {
lore.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
List<PotionEffect> effects = new ArrayList<PotionEffect>();
List<PotionEffect> effects = new ArrayList<>();
if (potion_section.getNode(EFFECTS) != null) {
for (String effect : potion_section.getNode(EFFECTS).getList(TypeToken.of(String.class))) {
String[] parts = effect.split(" ");
@@ -235,14 +235,14 @@ public class PotionConfig extends ConfigCollection {
}
}
Color color = null;
Color color;
if (potion_section.getNode(COLOR) != null) {
color = Color.fromRGB(potion_section.getNode(COLOR).getInt());
} else {
color = this.generateColor(effects);
}
Map<ItemStack, String> children = new HashMap<ItemStack, String>();
Map<ItemStack, String> children = new HashMap<>();
if (potion_section.getNode(CHILDREN) != null) {
for (String child : potion_section.getNode(CHILDREN).getList(TypeToken.of(String.class))) {
ItemStack ingredient = loadIngredient(child);
@@ -324,7 +324,7 @@ public class PotionConfig extends ConfigCollection {
public Color generateColor(List<PotionEffect> effects) {
if (effects != null && !effects.isEmpty()) {
List<Color> colors = new ArrayList<Color>();
List<Color> colors = new ArrayList<>();
for (PotionEffect effect : effects) {
if (effect.getType().getColor() != null) {
colors.add(effect.getType().getColor());

View File

@@ -23,7 +23,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
public static final String DROP_LEVEL = "Drop_Level";
public static final String CUSTOM_NAME = "Custom_Name";
public static final String LORE = "Lore";
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>();
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<>();
public ExcavationTreasureConfig() {
super("excavation_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
@@ -141,8 +141,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
*/
for(String dropBlock : dropsFrom)
{
if(excavationMap.get(dropBlock) == null)
excavationMap.put(dropBlock, new ArrayList<>());
excavationMap.computeIfAbsent(dropBlock, k -> new ArrayList<>());
excavationMap.get(dropBlock).add(excavationTreasure);
}

View File

@@ -40,9 +40,9 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
public static final String RARITY = "Rarity";
public static final String DROPS_FROM = "Drops_From";
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<EntityType, List<ShakeTreasure>>();
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<>();
/**
* This grabs an instance of this config class from the Config Manager
@@ -81,7 +81,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
// Initialize fishing HashMap
for (Rarity rarity : Rarity.values()) {
if (!fishingRewards.containsKey(rarity)) {
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
fishingRewards.put(rarity, (new ArrayList<>()));
}
}
@@ -276,8 +276,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
/*
* Add to map
*/
if(shakeMap.get(entityType) == null)
shakeMap.put(entityType, new ArrayList<>());
shakeMap.computeIfAbsent(entityType, k -> new ArrayList<>());
shakeMap.get(entityType).add(shakeTreasure);
@@ -297,7 +296,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
}
if (!fishingEnchantments.containsKey(rarity)) {
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
fishingEnchantments.put(rarity, (new ArrayList<>()));
}
ConfigurationNode enchantmentSection = getUserRootNode().getNode(ENCHANTMENTS_RARITY, rarity.toString());
@@ -334,7 +333,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
@Override
public List<String> validateKeys() {
// Validate all the settings!
List<String> errorMessages = new ArrayList<String>();
List<String> errorMessages = new ArrayList<>();
try {
for (String tier : getUserRootNode().getNode(ENCHANTMENT_DROP_RATES).getList(TypeToken.of(String.class))) {
/*double totalEnchantDropRate = 0;

View File

@@ -26,7 +26,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
public static final String CUSTOM_NAME = "Custom_Name";
public static final String LORE = "Lore";
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<String, List<HylianTreasure>>();
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
public HerbalismTreasureConfig() {
super("hylian_luck_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
@@ -206,7 +206,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
private void addHylianTreasure(String dropper, HylianTreasure treasure) {
if (!hylianMap.containsKey(dropper))
hylianMap.put(dropper, new ArrayList<HylianTreasure>());
hylianMap.put(dropper, new ArrayList<>());
hylianMap.get(dropper).add(treasure);
}

View File

@@ -81,7 +81,7 @@ public class TreasureFactory {
if(customLore != null && !customLore.getString().equalsIgnoreCase(CHANGE_ME))
{
ItemMeta itemMeta = treasure.getItemMeta();
List<String> lore = new ArrayList<String>();
List<String> lore = new ArrayList<>();
try {
//TODO: Not sure how this will be handled by Configurate