Untitled
Tue May 05 2020
ClassDataStorage classDataStorage = SCPCore.getInstance().getClassDataStorage();
List<? extends CommentedConfigurationNode> classes = classDataStorage.getNode().getNode("classes").getChildrenList();
if(classes.isEmpty())
{
SCPCore.getInstance().getLogger().warn("There is no registered classes. {" + classes.toString() + "}");
return;
}
SCPCore.getInstance().getLogger().debug("Loading registered classes...");
for(CommentedConfigurationNode loopedClass : classes)
{
try
{
String name = loopedClass.getNode("name").getString();
String prefix = loopedClass.getNode("prefix").getString();
long discordID = loopedClass.getNode("discordID").getLong();
boolean itemsDisappear = loopedClass.getNode("itemsDisappear").getBoolean();
TextColor textColor = Utils.getTextColor(loopedClass.getNode("textColor").getString());
DyeColor dyeColor = Utils.getDyeColor(loopedClass.getNode("dyeColor").getString());
int x = loopedClass.getNode("spawnLocation", "x").getInt();
int y = loopedClass.getNode("spawnLocation", "y").getInt();
int z = loopedClass.getNode("spawnLocation", "z").getInt();
String worldName = loopedClass.getNode("spawnLocation", "w").getString();
Optional<World> world = Sponge.getServer().getWorld(worldName);
World w = world.get();
List<String> permissions = loopedClass.getNode("permissions").getList(TypeToken.of(String.class));
LambdaClass lambdaClass = new LambdaClass(loopedClass.getString(), name, prefix, discordID, itemsDisappear, textColor, dyeColor, new Location<World>(w, x, y, z), permissions);
SCPCore.getInstance().getLogger().debug("Class loaded: " + lambdaClass.toString());
SCPCore.getInstance().getLambdaClasses().put(loopedClass.getString(), lambdaClass);
}
catch (NullPointerException | ObjectMappingException e)
{
SCPCore.getInstance().getLogger().error("One of class is wrong configurated - " + loopedClass.toString());
}
}
SCPCore.getInstance().getLogger().debug("All classes have been loaded.");