Comply with checkstyle again

This commit is contained in:
Frank van der Heijden 2020-07-05 16:59:07 +02:00
parent e67b20dee0
commit af4c7ba214
No known key found for this signature in database
GPG key ID: 26DA56488D314D11
36 changed files with 329 additions and 74 deletions

View file

@ -1,14 +1,26 @@
package net.frankheijden.serverutils.common.config;
/**
* The general common config class.
*/
public class Config extends YamlResource {
private static Config instance;
/**
* Constructs a new Config with the config file name and the resource name from the jar.
* @param fileName The file name in the data folder.
* @param resource The resource name in the jar file.
*/
public Config(String fileName, String resource) {
super(fileName, resource);
instance = this;
}
/**
* Retrieves the current instance of the Config.
* @return The current instance.
*/
public static Config getInstance() {
return instance;
}

View file

@ -5,16 +5,28 @@ import net.frankheijden.serverutils.common.entities.ServerCommandSender;
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
import net.frankheijden.serverutils.common.utils.StringUtils;
/**
* The general common messenger class.
*/
public class Messenger extends YamlResource {
private static Messenger instance;
private static final ServerUtilsPlugin plugin = ServerUtilsApp.getPlugin();
/**
* Constructs a new Messenger with the messages file name and the resource name from the jar.
* @param fileName The file name in the data folder.
* @param resource The resource name in the jar file.
*/
public Messenger(String fileName, String resource) {
super(fileName, resource);
instance = this;
}
/**
* Retrieves the current instance of the Messenger.
* @return The current instance.
*/
public static Messenger getInstance() {
return instance;
}
@ -61,6 +73,11 @@ public class Messenger extends YamlResource {
}
}
/**
* Colorizes the given string.
* @param str The string to color.
* @return The colored string.
*/
public static String color(String str) {
return Messenger.plugin.getChatProvider().color(str);
}

View file

@ -3,20 +3,56 @@ package net.frankheijden.serverutils.common.config;
import java.io.IOException;
import java.util.Collection;
/**
* A wrap for a Yaml Configuration file.
*/
public interface YamlConfig {
/**
* Retrieves the value at a given path.
* @param path The path.
* @return The object.
*/
Object get(String path);
/**
* Sets a value to a path.
* @param path The path.
* @param value The object to set the path's value to.
*/
void set(String path, Object value);
/**
* Retrieves a string from a path.
* @param path The path.
* @return The string at given path.
*/
String getString(String path);
/**
* Retrieves a boolean from a path.
* @param path The path.
* @return The boolean at given path.
*/
boolean getBoolean(String path);
/**
* Retrieves the key nodes at the current level.
* @return The keys.
*/
Collection<? extends String> getKeys();
/**
* Saves the YamlConfig to disk.
* @throws IOException Iff an I/O error occurred.
*/
void save() throws IOException;
/**
* Adds defaults if keys don't exist to the configuration specified.
* @param def The defaults to copy values over from.
* @param conf The configuration to copy the defaults to.
*/
static void addDefaults(YamlConfig def, YamlConfig conf) {
addDefaults(def, conf, "");
}

View file

@ -7,6 +7,9 @@ import net.frankheijden.serverutils.common.ServerUtilsApp;
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
import net.frankheijden.serverutils.common.providers.ResourceProvider;
/**
* A class which provides functionality for loading and setting defaults of Yaml Configurations.
*/
public class YamlResource {
private static final ServerUtilsPlugin plugin = ServerUtilsApp.getPlugin();
@ -26,6 +29,10 @@ public class YamlResource {
config = YamlConfig.init(provider.load(is), provider.load(file));
}
/**
* Retrieves the YamlConfig of this resource.
* @return The YamlConfig.
*/
public YamlConfig getConfig() {
return config;
}