Change to fit Rpg configs

- Changed configtype to not be an enum
- Removed an unused import
- Edited configmanager to match ConfigType
This commit is contained in:
Benford 2016-02-29 15:36:19 -05:00
parent 47ba35b760
commit e332875e1b
3 changed files with 973 additions and 954 deletions

View file

@ -12,7 +12,6 @@ import com.projectkorra.projectkorra.waterbending.WaterArms;
import com.projectkorra.projectkorra.waterbending.WaterSpout; import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.rpg.RPGMethods; import com.projectkorra.rpg.RPGMethods;
import org.bukkit.Bukkit;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;

View file

@ -1,6 +1,5 @@
package com.projectkorra.projectkorra.configuration; package com.projectkorra.projectkorra.configuration;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import java.io.File; import java.io.File;
@ -23,8 +22,7 @@ public class ConfigManager {
public static void configCheck(ConfigType type) { public static void configCheck(ConfigType type) {
FileConfiguration config; FileConfiguration config;
switch (type) { if (type == ConfigType.PRESETS) {
case PRESETS:
config = presetConfig.get(); config = presetConfig.get();
ArrayList<String> abilities = new ArrayList<String>(); ArrayList<String> abilities = new ArrayList<String>();
@ -41,8 +39,7 @@ public class ConfigManager {
config.addDefault("Example", abilities); config.addDefault("Example", abilities);
presetConfig.save(); presetConfig.save();
break; } else if (type == ConfigType.DEATH_MESSAGE) {
case DEATH_MESSAGE:
config = deathMsgConfig.get(); config = deathMsgConfig.get();
config.addDefault("Properties.Enabled", true); config.addDefault("Properties.Enabled", true);
@ -95,8 +92,7 @@ public class ConfigManager {
config.addDefault("HorizontalVelocity.Bloodbending","{victim} experienced kinetic damage by {attacker}'s {ability}"); config.addDefault("HorizontalVelocity.Bloodbending","{victim} experienced kinetic damage by {attacker}'s {ability}");
deathMsgConfig.save(); deathMsgConfig.save();
break; } else if (type == ConfigType.DEFAULT) {
case DEFAULT:
config = defaultConfig.get(); config = defaultConfig.get();
ArrayList<String> earthBlocks = new ArrayList<String>(); ArrayList<String> earthBlocks = new ArrayList<String>();
@ -955,7 +951,6 @@ public class ConfigManager {
config.addDefault("debug", false); config.addDefault("debug", false);
defaultConfig.save(); defaultConfig.save();
break;
} }
} }

View file

@ -1,22 +1,47 @@
package com.projectkorra.projectkorra.configuration; package com.projectkorra.projectkorra.configuration;
/** import java.util.ArrayList;
* Enum representing different types of Configurations. import java.util.Arrays;
* import java.util.HashMap;
* @author Jacklin213 import java.util.List;
*
*/ public class ConfigType {
public enum ConfigType {
/** public static final ConfigType DEFAULT = new ConfigType("Default");
* Default Configuration represented by config.yml public static final ConfigType PRESETS = new ConfigType("Presets");
*/ public static final ConfigType DEATH_MESSAGE = new ConfigType("DeathMessage");
DEFAULT, public static final ConfigType[] CORE_TYPES = {DEFAULT, PRESETS, DEATH_MESSAGE};
/**
* Death Message configuration represented by deathmessages.yml private static HashMap<String, ConfigType> allTypes = new HashMap<>();
*/ private static List<ConfigType> addonTypes = new ArrayList<>();
DEATH_MESSAGE,
/** private String string;
* Preset configuration represented by presets.yml
*/ public ConfigType(String string) {
PRESETS; this.string = string;
allTypes.put(string, this);
if (!Arrays.asList(CORE_TYPES).contains(this)) {
addonTypes.add(this);
}
}
public static List<ConfigType> addonValues() {
return addonTypes;
}
public static ConfigType[] coreValues() {
return CORE_TYPES;
}
public String toString() {
return string;
}
public static List<ConfigType> values() {
List<ConfigType> values = new ArrayList<>();
for (String key : allTypes.keySet()) {
values.add(allTypes.get(key));
}
return values;
}
} }