Search in sources :

Example 1 with SignLayout

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;
}
Also used : SignLayout(de.dytanic.cloudnet.lib.serverselectors.sign.SignLayout) SignLayoutConfig(de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig) TypeToken(com.google.gson.reflect.TypeToken) Acceptable(de.dytanic.cloudnet.lib.utility.Acceptable) SignGroupLayouts(de.dytanic.cloudnet.lib.serverselectors.sign.SignGroupLayouts) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Aggregations

TypeToken (com.google.gson.reflect.TypeToken)1 SignGroupLayouts (de.dytanic.cloudnet.lib.serverselectors.sign.SignGroupLayouts)1 SignLayout (de.dytanic.cloudnet.lib.serverselectors.sign.SignLayout)1 SignLayoutConfig (de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig)1 Acceptable (de.dytanic.cloudnet.lib.utility.Acceptable)1 Document (de.dytanic.cloudnet.lib.utility.document.Document)1