mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-05 07:57:59 +01:00
Fix empty paths with Configurate (#4214)
This commit is contained in:
parent
2018149395
commit
8e712bc827
@ -126,7 +126,7 @@ public class Warps implements IConf, net.ess3.api.IWarps {
|
|||||||
final EssentialsConfiguration conf = new EssentialsConfiguration(listOfFile);
|
final EssentialsConfiguration conf = new EssentialsConfiguration(listOfFile);
|
||||||
conf.load();
|
conf.load();
|
||||||
final String name = conf.getString("name", null);
|
final String name = conf.getString("name", null);
|
||||||
if (name != null) {
|
if (name != null && conf.hasProperty("world")) {
|
||||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
|
@ -105,7 +105,6 @@ public class EssentialsConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setProperty(String path, final Location location) {
|
public void setProperty(String path, final Location location) {
|
||||||
path = path == null ? "" : path;
|
|
||||||
setInternal(path, LazyLocation.fromLocation(location));
|
setInternal(path, LazyLocation.fromLocation(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +264,7 @@ public class EssentialsConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CommentedConfigurationNode getSection(final String path) {
|
public CommentedConfigurationNode getSection(final String path) {
|
||||||
final CommentedConfigurationNode node = configurationNode.node(toSplitRoot(path));
|
final CommentedConfigurationNode node = toSplitRoot(path, configurationNode);
|
||||||
if (node.virtual()) {
|
if (node.virtual()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -297,14 +296,14 @@ public class EssentialsConfiguration {
|
|||||||
|
|
||||||
private void setInternal(final String path, final Object value) {
|
private void setInternal(final String path, final Object value) {
|
||||||
try {
|
try {
|
||||||
configurationNode.node(toSplitRoot(path)).set(value);
|
toSplitRoot(path, configurationNode).set(value);
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
LOGGER.log(Level.SEVERE, e.getMessage(), e);
|
LOGGER.log(Level.SEVERE, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommentedConfigurationNode getInternal(final String path) {
|
private CommentedConfigurationNode getInternal(final String path) {
|
||||||
final CommentedConfigurationNode node = configurationNode.node(toSplitRoot(path));
|
final CommentedConfigurationNode node = toSplitRoot(path, configurationNode);
|
||||||
if (node.virtual()) {
|
if (node.virtual()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -312,12 +311,15 @@ public class EssentialsConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasProperty(final String path) {
|
public boolean hasProperty(final String path) {
|
||||||
return !configurationNode.node(toSplitRoot(path)).isNull();
|
return !toSplitRoot(path, configurationNode).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] toSplitRoot(String node) {
|
public CommentedConfigurationNode toSplitRoot(String path, final CommentedConfigurationNode node) {
|
||||||
node = node.startsWith(".") ? node.substring(1) : node;
|
if (path == null) {
|
||||||
return node.contains(".") ? node.split("\\.") : new Object[]{node};
|
return node;
|
||||||
|
}
|
||||||
|
path = path.startsWith(".") ? path.substring(1) : path;
|
||||||
|
return node.node(path.contains(".") ? path.split("\\.") : new Object[]{path});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void load() {
|
public synchronized void load() {
|
||||||
|
Loading…
Reference in New Issue
Block a user