mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Major refactoring. This WILL break any mcMMO-related plugin that
does not properly hook into the API classes. This consolidates the skill-related classes into their own individual packages, and moves several misc skill classes into the main Skill package as well. This also moves all Party & Spout related files into their own respective packages as well.
This commit is contained in:
@ -1,94 +0,0 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
|
||||
public class SpoutConfig extends ConfigLoader {
|
||||
private static SpoutConfig instance;
|
||||
public HudType defaultHudType;
|
||||
|
||||
private SpoutConfig() {
|
||||
super("spout.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static SpoutConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new SpoutConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
// Setup default HUD
|
||||
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
||||
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(temp.toString())) {
|
||||
defaultHudType = hudType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultHudType == null) {
|
||||
defaultHudType = HudType.STANDARD;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||
public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); }
|
||||
|
||||
/* XP Bar */
|
||||
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
||||
public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); }
|
||||
public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); }
|
||||
public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }
|
||||
public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); }
|
||||
public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); }
|
||||
|
||||
/* HUD Colors */
|
||||
public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); }
|
||||
public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); }
|
||||
public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); }
|
||||
public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); }
|
||||
public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); }
|
||||
public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); }
|
||||
|
||||
public double getRetroHUDAcrobaticsRed() { return config.getDouble("HUD.Retro.Colors.Acrobatics.RED", 0.3); }
|
||||
public double getRetroHUDAcrobaticsGreen() { return config.getDouble("HUD.Retro.Colors.Acrobatics.GREEN", 0.3); }
|
||||
public double getRetroHUDAcrobaticsBlue() { return config.getDouble("HUD.Retro.Colors.Acrobatics.BLUE", 0.75); }
|
||||
public double getRetroHUDArcheryRed() { return config.getDouble("HUD.Retro.Colors.Archery.RED", 0.3); }
|
||||
public double getRetroHUDArcheryGreen() { return config.getDouble("HUD.Retro.Colors.Archery.GREEN", 0.3); }
|
||||
public double getRetroHUDArcheryBlue() { return config.getDouble("HUD.Retro.Colors.Archery.BLUE", 0.75); }
|
||||
public double getRetroHUDAxesRed() { return config.getDouble("HUD.Retro.Colors.Axes.RED", 0.3); }
|
||||
public double getRetroHUDAxesGreen() { return config.getDouble("HUD.Retro.Colors.Axes.GREEN", 0.3); }
|
||||
public double getRetroHUDAxesBlue() { return config.getDouble("HUD.Retro.Colors.Axes.BLUE", 0.75); }
|
||||
public double getRetroHUDExcavationRed() { return config.getDouble("HUD.Retro.Colors.Excavation.RED", 0.3); }
|
||||
public double getRetroHUDExcavationGreen() { return config.getDouble("HUD.Retro.Colors.Excavation.GREEN", 0.3); }
|
||||
public double getRetroHUDExcavationBlue() { return config.getDouble("HUD.Retro.Colors.Excavation.BLUE", 0.75); }
|
||||
public double getRetroHUDHerbalismRed() { return config.getDouble("HUD.Retro.Colors.Herbalism.RED", 0.3); }
|
||||
public double getRetroHUDHerbalismGreen() { return config.getDouble("HUD.Retro.Colors.Herbalism.GREEN", 0.3); }
|
||||
public double getRetroHUDHerbalismBlue() { return config.getDouble("HUD.Retro.Colors.Herbalism.BLUE", 0.75); }
|
||||
public double getRetroHUDMiningRed() { return config.getDouble("HUD.Retro.Colors.Mining.RED", 0.3); }
|
||||
public double getRetroHUDMiningGreen() { return config.getDouble("HUD.Retro.Colors.Mining.GREEN", 0.3); }
|
||||
public double getRetroHUDMiningBlue() { return config.getDouble("HUD.Retro.Colors.Mining.BLUE", 0.75); }
|
||||
public double getRetroHUDRepairRed() { return config.getDouble("HUD.Retro.Colors.Repair.RED", 0.3); }
|
||||
public double getRetroHUDRepairGreen() { return config.getDouble("HUD.Retro.Colors.Repair.GREEN", 0.3); }
|
||||
public double getRetroHUDRepairBlue() { return config.getDouble("HUD.Retro.Colors.Repair.BLUE", 0.75); }
|
||||
public double getRetroHUDSwordsRed() { return config.getDouble("HUD.Retro.Colors.Swords.RED", 0.3); }
|
||||
public double getRetroHUDSwordsGreen() { return config.getDouble("HUD.Retro.Colors.Swords.GREEN", 0.3); }
|
||||
public double getRetroHUDSwordsBlue() { return config.getDouble("HUD.Retro.Colors.Swords.BLUE", 0.75); }
|
||||
public double getRetroHUDTamingRed() { return config.getDouble("HUD.Retro.Colors.Taming.RED", 0.3); }
|
||||
public double getRetroHUDTamingGreen() { return config.getDouble("HUD.Retro.Colors.Taming.GREEN", 0.3); }
|
||||
public double getRetroHUDTamingBlue() { return config.getDouble("HUD.Retro.Colors.Taming.BLUE", 0.75); }
|
||||
public double getRetroHUDUnarmedRed() { return config.getDouble("HUD.Retro.Colors.Unarmed.RED", 0.3); }
|
||||
public double getRetroHUDUnarmedGreen() { return config.getDouble("HUD.Retro.Colors.Unarmed.GREEN", 0.3); }
|
||||
public double getRetroHUDUnarmedBlue() { return config.getDouble("HUD.Retro.Colors.Unarmed.BLUE", 0.75); }
|
||||
public double getRetroHUDWoodcuttingRed() { return config.getDouble("HUD.Retro.Colors.Woodcutting.RED", 0.3); }
|
||||
public double getRetroHUDWoodcuttingGreen() { return config.getDouble("HUD.Retro.Colors.Woodcutting.GREEN", 0.3); }
|
||||
public double getRetroHUDWoodcuttingBlue() { return config.getDouble("HUD.Retro.Colors.Woodcutting.BLUE", 0.75); }
|
||||
public double getRetroHUDFishingRed() { return config.getDouble("HUD.Retro.Colors.Fishing.RED", 0.3); }
|
||||
public double getRetroHUDFishingGreen() { return config.getDouble("HUD.Retro.Colors.Fishing.GREEN", 0.3); }
|
||||
public double getRetroHUDFishingBlue() { return config.getDouble("HUD.Retro.Colors.Fishing.BLUE", 0.75); }
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
package com.gmail.nossr50.config.repair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfig(String fileName) {
|
||||
super(fileName);
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
ConfigurationSection section = config.getConfigurationSection("Repairables");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
for (String key : keys) {
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
if (!config.contains("Repairables." + key + ".ItemId")) {
|
||||
reason.add(key + " is missing ItemId");
|
||||
}
|
||||
|
||||
if (!config.contains("Repairables." + key + ".RepairMaterialId")) {
|
||||
reason.add(key + " is missing RepairMaterialId");
|
||||
}
|
||||
|
||||
if (!config.contains("Repairables." + key + ".MaximumDurability")) {
|
||||
reason.add(key + " is missing MaximumDurability");
|
||||
}
|
||||
|
||||
int itemId = config.getInt("Repairables." + key + ".ItemId", 0);
|
||||
int repairMaterialId = config.getInt("Repairables." + key + ".RepairMaterialId", 0);
|
||||
int maximumDurability = config.getInt("Repairables." + key + ".MaximumDurability", 0);
|
||||
|
||||
int repairMetadata = config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
|
||||
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel", 0);
|
||||
int minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
|
||||
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
|
||||
|
||||
RepairItemType repairItemType = RepairItemType.OTHER;
|
||||
RepairMaterialType repairMaterialType = RepairMaterialType.OTHER;
|
||||
|
||||
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
|
||||
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
|
||||
|
||||
if (minimumLevel < 0) {
|
||||
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||
}
|
||||
|
||||
if (minimumQuantity < 0) {
|
||||
reason.add(key + " has an invalid MinimumQuantity of " + minimumQuantity);
|
||||
}
|
||||
|
||||
try {
|
||||
repairItemType = RepairItemType.valueOf(repairItemTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||
}
|
||||
|
||||
try {
|
||||
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||
}
|
||||
|
||||
if (noErrorsInRepairable(reason)) {
|
||||
Repairable repairable = RepairableFactory.getRepairable(itemId, repairMaterialId, (byte) repairMetadata, minimumLevel, minimumQuantity, (short) maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||
repairables.add(repairable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
|
||||
private boolean noErrorsInRepairable(List<String> issues) {
|
||||
if (issues.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (String issue : issues) {
|
||||
plugin.getLogger().warning(issue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.gmail.nossr50.config.repair;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
|
||||
public class RepairConfigManager {
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfigManager(mcMMO plugin) {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File vanilla = new File(dataFolder, "repair.vanilla.yml");
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource("repair.vanilla.yml", false);
|
||||
}
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
File file = new File(dataFolder, fileName);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RepairConfig rConfig = new RepairConfig(fileName);
|
||||
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
|
||||
|
||||
if (rConfigRepairables != null) {
|
||||
repairables.addAll(rConfigRepairables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user