-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5ca81c
commit 3840e64
Showing
17 changed files
with
98 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,52 @@ | ||
package org.sct.lock.file; | ||
|
||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.sct.easylib.util.BasicUtil; | ||
import org.sct.lock.Lock; | ||
import org.sct.lock.enumeration.ConfigType; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author LovesAsuna | ||
* @date 2020/7/1 12:29 | ||
*/ | ||
|
||
public class Config { | ||
private static FileConfiguration getConfig() { | ||
return Lock.getInstance().getConfig(); | ||
} | ||
|
||
private static FileConfiguration config = Lock.getInstance().getConfig(); | ||
public static String getString(String path) { | ||
reload(); | ||
String string = getConfig().getString(path); | ||
return string == null ? "Empty String" : string; | ||
} | ||
|
||
public static void loadConfig() { | ||
public static void reload() { | ||
Lock.getInstance().reloadConfig(); | ||
config = Lock.getInstance().getConfig(); | ||
} | ||
|
||
public static String getString(ConfigType configType) { | ||
loadConfig(); | ||
return config.getString(configType.getPath()); | ||
public static List<String> getStringList(String path) { | ||
reload(); | ||
return BasicUtil.convert(getConfig().getStringList(path)); | ||
} | ||
|
||
public static int getInteger(ConfigType configType) { | ||
loadConfig(); | ||
return config.getInt(configType.getPath()); | ||
public static double getDouble(String path) { | ||
reload(); | ||
return getConfig().getDouble(path); | ||
} | ||
|
||
public static boolean getBoolean(ConfigType configType) { | ||
loadConfig(); | ||
return config.getBoolean(configType.getPath()); | ||
public static int getInt(String path) { | ||
reload(); | ||
return (int) getDouble(path); | ||
} | ||
|
||
public static List<String> getStringList(ConfigType configType) { | ||
loadConfig(); | ||
return config.getStringList(configType.getPath()); | ||
public static float getFloat(String path) { | ||
reload(); | ||
return (float) getDouble(path); | ||
} | ||
|
||
public static boolean setStringList(ConfigType configType, List list) { | ||
loadConfig(); | ||
config.set(configType.getPath(), list); | ||
return true; | ||
public static void setStringList(String path, List<String> list) { | ||
getConfig().set(path, list); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,13 @@ | ||
package org.sct.lock.file; | ||
|
||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.sct.easylib.util.function.file.AbstractFile; | ||
import org.sct.lock.Lock; | ||
import org.sct.lock.enumeration.ConfigType; | ||
import org.sct.lock.enumeration.LangType; | ||
import org.sct.easylib.util.BasicUtil; | ||
import java.io.File; | ||
import java.util.List; | ||
|
||
public class Lang { | ||
|
||
private static File file; | ||
private static YamlConfiguration config; | ||
|
||
public static void loadLang() { | ||
file = new File(Lock.getInstance().getDataFolder() + File.separator + Config.getString(ConfigType.SETTING_LANGUAGE) + ".yml"); | ||
if (!file.exists()) { Lock.getInstance().saveResource(Config.getString(ConfigType.SETTING_LANGUAGE) + ".yml",false); } | ||
config = YamlConfiguration.loadConfiguration(file); | ||
} | ||
|
||
public static String getString(LangType langType) { | ||
loadLang(); | ||
return BasicUtil.convert(config.getString(langType.getPath())); | ||
} | ||
import java.io.File; | ||
|
||
public static List<String> getStringList(LangType langType) { | ||
loadLang(); | ||
return BasicUtil.convert(config.getStringList(langType.getPath())); | ||
public class Lang extends AbstractFile { | ||
static { | ||
load(new File(Config.getString(ConfigType.SETTING_LANGUAGE.getPath()) + ".yml"), Lock.getInstance()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.