use of de.dytanic.cloudnet.lib.serverselectors.sign.SignLayout in project CloudNet by Dytanic.
the class ConfigSignLayout method loadLayout.
public de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig loadLayout() {
Document document = Document.loadDocument(path);
if (!document.getDocument("layout_config").contains("knockbackOnSmallDistance")) {
Document document1 = document.getDocument("layout_config").append("knockbackOnSmallDistance", false);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
if (!document.getDocument("layout_config").contains("distance")) {
Document document1 = document.getDocument("layout_config").append("distance", 1D);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
if (!document.getDocument("layout_config").contains("strength")) {
Document document1 = document.getDocument("layout_config").append("strength", 0.8D);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
SignLayoutConfig signLayoutConfig = document.getObject("layout_config", new TypeToken<de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig>() {
}.getType());
boolean injectable = false;
for (SignGroupLayouts groupLayouts : signLayoutConfig.getGroupLayouts()) {
{
SignLayout signLayout = CollectionWrapper.filter(groupLayouts.getLayouts(), new Acceptable<SignLayout>() {
@Override
public boolean isAccepted(SignLayout signLayout) {
return signLayout.getName().equalsIgnoreCase("empty");
}
});
if (signLayout == null) {
groupLayouts.getLayouts().add(new SignLayout("empty", new String[] { "%server%", "&6%state%", "%online_players%/%max_players%", "%motd%" }, 159, 1));
injectable = true;
}
}
}
if (injectable) {
document.append("layout_config", signLayoutConfig).saveAsConfig(path);
}
return signLayoutConfig;
}
Aggregations