Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into tridentsxbows

This commit is contained in:
nossr50
2020-07-26 05:08:49 -07:00
259 changed files with 2025 additions and 2270 deletions

View File

@ -28,7 +28,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
/* GENERAL */
if (getAbilityLength() < 1) {
@ -687,9 +687,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
}
public double getMaximumProbability(SubSkillType subSkillType) {
double maximumProbability = config.getDouble(subSkillType.getAdvConfigAddress() + ".ChanceMax", 100.0D);
return maximumProbability;
return config.getDouble(subSkillType.getAdvConfigAddress() + ".ChanceMax", 100.0D);
}
public double getMaximumProbability(AbstractSubSkill abstractSubSkill)
@ -719,6 +718,11 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
return config.getBoolean("Feedback.Events.XP.SendTitles", true);
}
public boolean sendAbilityNotificationToOtherPlayers()
{
return config.getBoolean("Feedback.Events.AbilityActivation.SendNotificationToOtherPlayers", true);
}
/*
* JSON Style Settings
*/

View File

@ -28,10 +28,10 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
boolean needSave = false;
Set<String> oldKeys = new HashSet<String>(configKeys);
Set<String> oldKeys = new HashSet<>(configKeys);
oldKeys.removeAll(internalConfigKeys);
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
Set<String> newKeys = new HashSet<>(internalConfigKeys);
newKeys.removeAll(configKeys);
// Don't need a re-save if we have old keys sticking around?
@ -66,17 +66,17 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
try {
// Read internal
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
LinkedHashMap<String, String> comments = new LinkedHashMap<String, String>();
String temp = "";
LinkedHashMap<String, String> comments = new LinkedHashMap<>();
StringBuilder temp = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("#")) {
temp += line + "\n";
temp.append(line).append("\n");
}
else if (line.contains(":")) {
line = line.substring(0, line.indexOf(":") + 1);
if (!temp.isEmpty()) {
if (temp.length() > 0) {
if(comments.containsKey(line)) {
int index = 0;
while(comments.containsKey(line + index)) {
@ -86,14 +86,14 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
line = line + index;
}
comments.put(line, temp);
temp = "";
comments.put(line, temp.toString());
temp = new StringBuilder();
}
}
}
// Dump to the new one
HashMap<String, Integer> indexed = new HashMap<String, Integer>();
HashMap<String, Integer> indexed = new HashMap<>();
for (String key : comments.keySet()) {
String actualkey = key.substring(0, key.indexOf(":") + 1);

View File

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

View File

@ -10,7 +10,7 @@ import java.util.List;
public abstract class ConfigLoader {
protected static final mcMMO plugin = mcMMO.p;
protected String fileName;
private File configFile;
private final File configFile;
protected FileConfiguration config;
public ConfigLoader(String relativePath, String fileName) {

View File

@ -7,14 +7,11 @@ import java.io.InputStreamReader;
public class HiddenConfig {
private static HiddenConfig instance;
private String fileName;
private final String fileName;
private YamlConfiguration config;
private boolean chunkletsEnabled;
private int conversionRate;
private boolean useEnchantmentBuffs;
private int uuidConvertAmount;
private int mojangRateLimit;
private long mojangLimitPeriod;
public HiddenConfig(String fileName) {
this.fileName = fileName;
@ -36,9 +33,6 @@ public class HiddenConfig {
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
conversionRate = config.getInt("Options.ConversionRate", 1);
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
uuidConvertAmount = config.getInt("Options.UUIDConvertAmount", 5);
mojangRateLimit = config.getInt("Options.MojangRateLimit", 50000);
mojangLimitPeriod = config.getLong("Options.MojangLimitPeriod", 600000);
}
}
@ -53,16 +47,4 @@ public class HiddenConfig {
public boolean useEnchantmentBuffs() {
return useEnchantmentBuffs;
}
public int getUUIDConvertAmount() {
return uuidConvertAmount;
}
public int getMojangRateLimit() {
return mojangRateLimit;
}
public long getMojangLimitPeriod() {
return mojangLimitPeriod;
}
}

View File

@ -13,7 +13,7 @@ public class RankConfig extends AutoUpdateConfigLoader {
{
super("skillranks.yml");
validate();
this.instance = this;
instance = this;
}
@Override
@ -31,7 +31,7 @@ public class RankConfig extends AutoUpdateConfigLoader {
@Override
protected boolean 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

@ -9,7 +9,7 @@ public class SoundConfig extends AutoUpdateConfigLoader {
{
super("sounds.yml");
validate();
this.instance = this;
instance = this;
}
@Override

View File

@ -11,7 +11,7 @@ import java.util.ArrayList;
*/
public class WorldBlacklist {
private static ArrayList<String> blacklist;
private mcMMO plugin;
private final mcMMO plugin;
private final String blackListFileName = "world_blacklist.txt";

View File

@ -38,7 +38,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
@Override
protected boolean validateKeys() {
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
/*
* FORMULA SETTINGS

View File

@ -15,12 +15,12 @@ import java.util.Set;
public class CustomArmorConfig extends ConfigLoader {
private boolean needsUpdate = false;
public List<Material> customBoots = new ArrayList<Material>();
public List<Material> customChestplates = new ArrayList<Material>();
public List<Material> customHelmets = new ArrayList<Material>();
public List<Material> customLeggings = new ArrayList<Material>();
public List<Material> customBoots = new ArrayList<>();
public List<Material> customChestplates = new ArrayList<>();
public List<Material> customHelmets = new ArrayList<>();
public List<Material> customLeggings = new ArrayList<>();
public List<Repairable> repairables = new ArrayList<Repairable>();
public List<Repairable> repairables = new ArrayList<>();
protected CustomArmorConfig(String fileName) {
super("mods", fileName);

View File

@ -9,8 +9,8 @@ import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
public class CustomEntityConfig extends ConfigLoader {
public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<>();
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>();
protected CustomEntityConfig(String fileName) {
super("mods", fileName);

View File

@ -17,16 +17,16 @@ import java.util.Set;
public class CustomToolConfig extends ConfigLoader {
private boolean needsUpdate = false;
public List<Material> customAxes = new ArrayList<Material>();
public List<Material> customBows = new ArrayList<Material>();
public List<Material> customHoes = new ArrayList<Material>();
public List<Material> customPickaxes = new ArrayList<Material>();
public List<Material> customShovels = new ArrayList<Material>();
public List<Material> customSwords = new ArrayList<Material>();
public List<Material> customAxes = new ArrayList<>();
public List<Material> customBows = new ArrayList<>();
public List<Material> customHoes = new ArrayList<>();
public List<Material> customPickaxes = new ArrayList<>();
public List<Material> customShovels = new ArrayList<>();
public List<Material> customSwords = new ArrayList<>();
public HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
public HashMap<Material, CustomTool> customToolMap = new HashMap<>();
public List<Repairable> repairables = new ArrayList<Repairable>();
public List<Repairable> repairables = new ArrayList<>();
protected CustomToolConfig(String fileName) {
super("mods", fileName);

View File

@ -27,7 +27,7 @@ public class ItemWeightConfig extends ConfigLoader {
}
public HashSet<Material> getMiscItems() {
HashSet<Material> miscItems = new HashSet<Material>();
HashSet<Material> miscItems = new HashSet<>();
for (String item : config.getStringList("Party_Shareables.Misc_Items")) {
Material material = Material.getMaterial(item.toUpperCase(Locale.ENGLISH));

View File

@ -18,16 +18,16 @@ import java.util.Map;
public class PotionConfig extends ConfigLoader {
private static PotionConfig instance;
private List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<ItemStack>();
private List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<ItemStack>();
private List<ItemStack> concoctionsIngredientsTierThree = new ArrayList<ItemStack>();
private List<ItemStack> concoctionsIngredientsTierFour = new ArrayList<ItemStack>();
private List<ItemStack> concoctionsIngredientsTierFive = new ArrayList<ItemStack>();
private List<ItemStack> concoctionsIngredientsTierSix = new ArrayList<ItemStack>();
private List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
private List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
private final List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierThree = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierFour = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierFive = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierSix = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<>();
private Map<String, AlchemyPotion> potionMap = new HashMap<String, AlchemyPotion>();
private final Map<String, AlchemyPotion> potionMap = new HashMap<>();
private PotionConfig() {
super("potions.yml");
@ -137,14 +137,14 @@ public class PotionConfig extends ConfigLoader {
material = Material.valueOf(mat);
}
List<String> lore = new ArrayList<String>();
List<String> lore = new ArrayList<>();
if (potion_section.contains("Lore")) {
for (String line : potion_section.getStringList("Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
List<PotionEffect> effects = new ArrayList<PotionEffect>();
List<PotionEffect> effects = new ArrayList<>();
if (potion_section.contains("Effects")) {
for (String effect : potion_section.getStringList("Effects")) {
String[] parts = effect.split(" ");
@ -162,7 +162,7 @@ public class PotionConfig extends ConfigLoader {
}
}
Color color = null;
Color color;
if (potion_section.contains("Color")) {
color = Color.fromRGB(potion_section.getInt("Color"));
}
@ -170,7 +170,7 @@ public class PotionConfig extends ConfigLoader {
color = this.generateColor(effects);
}
Map<ItemStack, String> children = new HashMap<ItemStack, String>();
Map<ItemStack, String> children = new HashMap<>();
if (potion_section.contains("Children")) {
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
ItemStack ingredient = loadIngredient(child);
@ -255,7 +255,7 @@ public class PotionConfig extends ConfigLoader {
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());
@ -280,8 +280,7 @@ public class PotionConfig extends ConfigLoader {
green += color.getGreen();
blue += color.getBlue();
}
Color color = Color.fromRGB(red/colors.size(), green/colors.size(), blue/colors.size());
return color;
return Color.fromRGB(red/colors.size(), green/colors.size(), blue/colors.size());
}
}

View File

@ -15,7 +15,7 @@ import java.util.*;
public class RepairConfig extends ConfigLoader {
private List<Repairable> repairables;
private HashSet<String> notSupported;
private final HashSet<String> notSupported;
public RepairConfig(String fileName) {
super(fileName);
@ -25,7 +25,7 @@ public class RepairConfig extends ConfigLoader {
@Override
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
repairables = new ArrayList<>();
if (!config.isConfigurationSection("Repairables")) {
mcMMO.p.getLogger().severe("Could not find Repairables section in " + fileName);
@ -42,7 +42,7 @@ public class RepairConfig extends ConfigLoader {
}
// Validate all the things!
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
// Item Material
Material itemMaterial = Material.matchMaterial(key);
@ -177,7 +177,7 @@ public class RepairConfig extends ConfigLoader {
}
protected List<Repairable> getLoadedRepairables() {
return repairables == null ? new ArrayList<Repairable>() : repairables;
return repairables == null ? new ArrayList<>() : repairables;
}
private boolean noErrorsInRepairable(List<String> issues) {

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.regex.Pattern;
public class RepairConfigManager {
private final List<Repairable> repairables = new ArrayList<Repairable>();
private final List<Repairable> repairables = new ArrayList<>();
public RepairConfigManager(mcMMO plugin) {
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");

View File

@ -18,7 +18,7 @@ import java.util.*;
public class SalvageConfig extends ConfigLoader {
private List<Salvageable> salvageables;
private HashSet<String> notSupported;
private final HashSet<String> notSupported;
public SalvageConfig(String fileName) {
super(fileName);
@ -28,7 +28,7 @@ public class SalvageConfig extends ConfigLoader {
@Override
protected void loadKeys() {
salvageables = new ArrayList<Salvageable>();
salvageables = new ArrayList<>();
if (!config.isConfigurationSection("Salvageables")) {
mcMMO.p.getLogger().severe("Could not find Salvageables section in " + fileName);
@ -59,7 +59,7 @@ public class SalvageConfig extends ConfigLoader {
for (String key : keys) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
// Item Material
Material itemMaterial = Material.matchMaterial(key);
@ -195,7 +195,7 @@ public class SalvageConfig extends ConfigLoader {
}
protected List<Salvageable> getLoadedSalvageables() {
return salvageables == null ? new ArrayList<Salvageable>() : salvageables;
return salvageables == null ? new ArrayList<>() : salvageables;
}
private boolean noErrorsInSalvageable(List<String> issues) {

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.regex.Pattern;
public class SalvageConfigManager {
private final List<Salvageable> salvageables = new ArrayList<Salvageable>();
private final List<Salvageable> salvageables = new ArrayList<>();
public SalvageConfigManager(mcMMO plugin) {
Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");

View File

@ -24,13 +24,13 @@ public class TreasureConfig extends ConfigLoader {
private static TreasureConfig instance;
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>();
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<>();
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<EntityType, List<ShakeTreasure>>();
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<String, List<HylianTreasure>>();
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<>();
private TreasureConfig() {
super("treasures.yml");
@ -49,7 +49,7 @@ public class TreasureConfig extends ConfigLoader {
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
double totalEnchantDropRate = 0;
double totalItemDropRate = 0;
@ -116,13 +116,13 @@ public class TreasureConfig extends ConfigLoader {
// Initialize fishing HashMap
for (Rarity rarity : Rarity.values()) {
if (!fishingRewards.containsKey(rarity)) {
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
fishingRewards.put(rarity, (new ArrayList<>()));
}
}
for (String treasureName : treasureSection.getKeys(false)) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
List<String> reason = new ArrayList<>();
String[] treasureInfo = treasureName.split("[|]");
String materialName = treasureInfo[0];
@ -135,7 +135,7 @@ public class TreasureConfig extends ConfigLoader {
if (materialName.contains("INVENTORY")) {
// Use magic material BEDROCK to know that we're grabbing something from the inventory and not a normal treasure
if (!shakeMap.containsKey(EntityType.PLAYER))
shakeMap.put(EntityType.PLAYER, new ArrayList<ShakeTreasure>());
shakeMap.put(EntityType.PLAYER, new ArrayList<>());
shakeMap.get(EntityType.PLAYER).add(new ShakeTreasure(new ItemStack(Material.BEDROCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
continue;
} else {
@ -218,7 +218,7 @@ public class TreasureConfig extends ConfigLoader {
}
if (config.contains(type + "." + treasureName + ".Lore")) {
List<String> lore = new ArrayList<String>();
List<String> lore = new ArrayList<>();
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', s));
}
@ -237,7 +237,7 @@ public class TreasureConfig extends ConfigLoader {
if (config.contains(type + "." + treasureName + ".Lore")) {
ItemMeta itemMeta = item.getItemMeta();
List<String> lore = new ArrayList<String>();
List<String> lore = new ArrayList<>();
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', s));
}
@ -254,7 +254,7 @@ public class TreasureConfig extends ConfigLoader {
EntityType entityType = EntityType.valueOf(type.substring(6));
if (!shakeMap.containsKey(entityType))
shakeMap.put(entityType, new ArrayList<ShakeTreasure>());
shakeMap.put(entityType, new ArrayList<>());
shakeMap.get(entityType).add(shakeTreasure);
} else if (isExcavation) {
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
@ -262,7 +262,7 @@ public class TreasureConfig extends ConfigLoader {
for (String blockType : dropList) {
if (!excavationMap.containsKey(blockType))
excavationMap.put(blockType, new ArrayList<ExcavationTreasure>());
excavationMap.put(blockType, new ArrayList<>());
excavationMap.get(blockType).add(excavationTreasure);
}
} else if (isHylian) {
@ -305,7 +305,7 @@ public class TreasureConfig extends ConfigLoader {
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);
}
@ -316,7 +316,7 @@ public class TreasureConfig extends ConfigLoader {
}
if (!fishingEnchantments.containsKey(rarity)) {
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
fishingEnchantments.put(rarity, (new ArrayList<>()));
}
ConfigurationSection enchantmentSection = config.getConfigurationSection("Enchantments_Rarity." + rarity.toString());