Use slightly different YAML loading, try fix an issue on a Chinese user's server
This commit is contained in:
parent
a309b24004
commit
00507a1194
@ -70,7 +70,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
saveResource("disguises.yml", false);
|
saveResource("disguises.yml", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
YamlConfiguration pluginYml = ReflectionManager.getPluginYaml(getClassLoader());
|
YamlConfiguration pluginYml = ReflectionManager.getPluginYAML(getClassLoader());
|
||||||
buildNumber = StringUtils.stripToNull(pluginYml.getString("build-number"));
|
buildNumber = StringUtils.stripToNull(pluginYml.getString("build-number"));
|
||||||
|
|
||||||
getLogger().info("Discovered nms version: " + ReflectionManager.getBukkitVersion());
|
getLogger().info("Discovered nms version: " + ReflectionManager.getBukkitVersion());
|
||||||
|
@ -128,7 +128,7 @@ public class LibsPremium {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the plugin.yml from the jar file
|
// Fetch the plugin.yml from the jar file
|
||||||
YamlConfiguration config = ReflectionManager.getPluginYaml(cl);
|
YamlConfiguration config = ReflectionManager.getPluginYAML(cl);
|
||||||
// No checks for null config as the correct error will be thrown on access
|
// No checks for null config as the correct error will be thrown on access
|
||||||
|
|
||||||
Boolean premium;
|
Boolean premium;
|
||||||
|
@ -30,6 +30,8 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -157,16 +159,28 @@ public class ReflectionManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YamlConfiguration getPluginYaml(ClassLoader loader) {
|
public static YamlConfiguration getPluginYAML(ClassLoader loader) {
|
||||||
try (InputStream stream = loader.getResourceAsStream("plugin.yml")) {
|
try {
|
||||||
|
URL url = loader.getResource("plugin.yml");
|
||||||
|
|
||||||
|
if (url == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
URLConnection connection = url.openConnection();
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
|
||||||
|
try (InputStream stream = connection.getInputStream()) {
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
|
|
||||||
config.loadFromString(new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)).lines()
|
config.loadFromString(new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)).lines()
|
||||||
.collect(Collectors.joining("\n")));
|
.collect(Collectors.joining("\n")));
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
catch (IOException | InvalidConfigurationException e) {
|
}
|
||||||
e.printStackTrace();
|
}
|
||||||
|
catch (IOException | InvalidConfigurationException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -7,7 +7,7 @@ build-number: ${build.number}
|
|||||||
author: libraryaddict
|
author: libraryaddict
|
||||||
authors: [Byteflux, Navid K.]
|
authors: [Byteflux, Navid K.]
|
||||||
depend: [ProtocolLib]
|
depend: [ProtocolLib]
|
||||||
api-version: 1.13
|
api-version: '1.13'
|
||||||
commands:
|
commands:
|
||||||
libsdisguises:
|
libsdisguises:
|
||||||
aliases: [libsdisg, ld]
|
aliases: [libsdisg, ld]
|
||||||
|
Loading…
Reference in New Issue
Block a user