diff --git a/bungee/src/main/java/me/affanhaq/keeper/Keeper.java b/bungee/src/main/java/me/affanhaq/keeper/Keeper.java index 9c6a5b0..462e9cc 100644 --- a/bungee/src/main/java/me/affanhaq/keeper/Keeper.java +++ b/bungee/src/main/java/me/affanhaq/keeper/Keeper.java @@ -18,7 +18,7 @@ public class Keeper { /** * @param plugin instance of your plugin */ - public Keeper(Plugin plugin) { + public Keeper(@NotNull Plugin plugin) { this.plugin = plugin; } @@ -52,36 +52,31 @@ public Keeper register(@NotNull Object... objects) { * @return instance of this class so you can build */ public Keeper load() { - OBJECTS.entrySet().forEach(this::load); - return this; - } - - public Keeper load(@NotNull Object object) { - ConfigurationFile file = OBJECTS.get(object); - Arrays.stream(object.getClass().getDeclaredFields()) - .filter(field -> field.isAnnotationPresent(ConfigValue.class)) - .forEach(field -> { - - Object value = file.getConfiguration().get( - field.getAnnotation(ConfigValue.class).value() - ); - - if (value == null) { - return; - } - - if (value instanceof String) { - value = ChatColor.translateAlternateColorCodes('&', value.toString()); - } - - try { - field.setAccessible(true); - field.set(object, value); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - }); + OBJECTS.forEach((object, configFile) -> + Arrays.stream(object.getClass().getDeclaredFields()) + .filter(field -> field.isAnnotationPresent(ConfigValue.class)) + .forEach(field -> { + + Object value = configFile.getConfiguration().get( + field.getAnnotation(ConfigValue.class).value() + ); + + if (value == null) { + return; + } + + if (value instanceof String) { + value = ChatColor.translateAlternateColorCodes('&', value.toString()); + } + + try { + field.setAccessible(true); + field.set(object, value); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + })); return this; } diff --git a/spigot/src/main/java/me/affanhaq/keeper/Keeper.java b/spigot/src/main/java/me/affanhaq/keeper/Keeper.java index 5e706f0..585b3b7 100644 --- a/spigot/src/main/java/me/affanhaq/keeper/Keeper.java +++ b/spigot/src/main/java/me/affanhaq/keeper/Keeper.java @@ -52,36 +52,31 @@ public Keeper register(@NotNull Object... objects) { * @return instance of this class so you can build */ public Keeper load() { - OBJECTS.entrySet().forEach(this::load); - return this; - } - - public Keeper load(@NotNull Object object) { - ConfigurationFile file = OBJECTS.get(object); - Arrays.stream(object.getClass().getDeclaredFields()) - .filter(field -> field.isAnnotationPresent(ConfigValue.class)) - .forEach(field -> { - - Object value = file.getConfiguration().get( - field.getAnnotation(ConfigValue.class).value() - ); - - if (value == null) { - return; - } - - if (value instanceof String) { - value = ChatColor.translateAlternateColorCodes('&', value.toString()); - } - - try { - field.setAccessible(true); - field.set(object, value); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - }); + OBJECTS.forEach((object, configFile) -> + Arrays.stream(object.getClass().getDeclaredFields()) + .filter(field -> field.isAnnotationPresent(ConfigValue.class)) + .forEach(field -> { + + Object value = configFile.getConfiguration().get( + field.getAnnotation(ConfigValue.class).value() + ); + + if (value == null) { + return; + } + + if (value instanceof String) { + value = ChatColor.translateAlternateColorCodes('&', value.toString()); + } + + try { + field.setAccessible(true); + field.set(object, value); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + })); return this; }