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.rpg.RPGMethods;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;

View file

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

View file

@ -1,22 +1,47 @@
package com.projectkorra.projectkorra.configuration;
/**
* Enum representing different types of Configurations.
*
* @author Jacklin213
*
*/
public enum ConfigType {
/**
* Default Configuration represented by config.yml
*/
DEFAULT,
/**
* Death Message configuration represented by deathmessages.yml
*/
DEATH_MESSAGE,
/**
* Preset configuration represented by presets.yml
*/
PRESETS;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public class ConfigType {
public static final ConfigType DEFAULT = new ConfigType("Default");
public static final ConfigType PRESETS = new ConfigType("Presets");
public static final ConfigType DEATH_MESSAGE = new ConfigType("DeathMessage");
public static final ConfigType[] CORE_TYPES = {DEFAULT, PRESETS, DEATH_MESSAGE};
private static HashMap<String, ConfigType> allTypes = new HashMap<>();
private static List<ConfigType> addonTypes = new ArrayList<>();
private String string;
public ConfigType(String string) {
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;
}
}