Fix deserialization problems
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'sh.okx'
|
group 'sh.okx'
|
||||||
version '3.13'
|
version '3.13.1'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ public class RanksGui {
|
|||||||
ConfigurationSection basePath = plugin.getMessages().getConfigurationSection("rankup.ranksgui");
|
ConfigurationSection basePath = plugin.getMessages().getConfigurationSection("rankup.ranksgui");
|
||||||
|
|
||||||
String title = get(ConfigurationSection::getString, "title", playerPath, basePath, "Ranks");
|
String title = get(ConfigurationSection::getString, "title", playerPath, basePath, "Ranks");
|
||||||
int rows = get(ConfigurationSection::getInt, "rows", playerPath, basePath, 3);
|
int rows = get(this::getInt, "rows", playerPath, basePath, 3);
|
||||||
int offset = get(ConfigurationSection::getInt, "offset", playerPath, basePath, 10);
|
int offset = get(this::getInt, "offset", playerPath, basePath, 10);
|
||||||
int width = get(ConfigurationSection::getInt, "width", playerPath, basePath, 7);
|
int width = get(this::getInt, "width", playerPath, basePath, 7);
|
||||||
|
|
||||||
inventory = Bukkit.createInventory(null, rows * 9, Colour.translate(title));
|
inventory = Bukkit.createInventory(null, rows * 9, Colour.translate(title));
|
||||||
|
|
||||||
@@ -87,6 +87,19 @@ public class RanksGui {
|
|||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Integer getInt(ConfigurationSection section, String key) {
|
||||||
|
String string = section.getString(key);
|
||||||
|
if (string == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(string);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private <T> T get(BiFunction<ConfigurationSection, String, T> fun, String path, ConfigurationSection primary, ConfigurationSection secondary, T def) {
|
private <T> T get(BiFunction<ConfigurationSection, String, T> fun, String path, ConfigurationSection primary, ConfigurationSection secondary, T def) {
|
||||||
T get = null;
|
T get = null;
|
||||||
if (primary != null) {
|
if (primary != null) {
|
||||||
|
|||||||
@@ -57,10 +57,12 @@ public class ShadowDeserializer {
|
|||||||
private static void updateMap(Map<String, String> map, UnmodifiableConfig config, String prefix) {
|
private static void updateMap(Map<String, String> map, UnmodifiableConfig config, String prefix) {
|
||||||
for (Entry message : config.entrySet()) {
|
for (Entry message : config.entrySet()) {
|
||||||
Object value = message.getValue();
|
Object value = message.getValue();
|
||||||
if (value instanceof String) {
|
if (value != null) {
|
||||||
map.put(prefix + message.getKey(), (String) value);
|
if (value instanceof UnmodifiableConfig) {
|
||||||
} else if (value instanceof UnmodifiableConfig) {
|
|
||||||
updateMap(map, (UnmodifiableConfig) value, prefix + message.getKey() + ".");
|
updateMap(map, (UnmodifiableConfig) value, prefix + message.getKey() + ".");
|
||||||
|
} else {
|
||||||
|
map.put(prefix + message.getKey(), String.valueOf(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,10 @@ public class YamlDeserializer {
|
|||||||
Set<String> rankup = rankupSection.getKeys(true);
|
Set<String> rankup = rankupSection.getKeys(true);
|
||||||
messages = new HashMap<>(rankup.size());
|
messages = new HashMap<>(rankup.size());
|
||||||
for (String key : rankup) {
|
for (String key : rankup) {
|
||||||
|
if (!rankupSection.isConfigurationSection(key)) {
|
||||||
messages.put(MemorySection.createPath(rankupSection, key, section), rankupSection.getString(key));
|
messages.put(MemorySection.createPath(rankupSection, key, section), rankupSection.getString(key));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
messages = Collections.emptyMap();
|
messages = Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user