YumCore/src/main/java/pw/yumc/YumCore/config/ext/RemoteConfig.java

61 lines
1.4 KiB
Java
Raw Normal View History

package pw.yumc.YumCore.config.ext;
import pw.yumc.YumCore.bukkit.Log;
import pw.yumc.YumCore.config.FileConfig;
import java.io.IOException;
import java.net.URL;
/**
*
*
* @since 2016222 8:33:51
* @author
*/
public class RemoteConfig extends FileConfig {
public RemoteConfig(String url) throws IOException {
this(new URL(url));
}
public RemoteConfig(URL url) throws IOException {
super(url.openStream());
}
/**
* (null)
*
* @param url
*
* @return {@link FileConfig}
*/
public static FileConfig getConfig(String url) {
try {
return new RemoteConfig(url);
} catch (IOException e) {
Log.d("获取远程配置文件失败!", e);
return null;
}
}
/**
* Yaml
*
* @param url
* XML
* @param tag
*
* @param def
*
* @return
*/
public static String getYamlTag(String url, String tag, String def) {
String result = def;
FileConfig config = getConfig(url);
if (config != null) {
result = config.getString(tag);
}
return result;
}
}