From 8061c4b267123ec97b0fea8e787fb837ffa571c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Moreno?= Date: Thu, 29 Dec 2022 17:07:34 +0100 Subject: [PATCH] Minor refactorization - Renamed FakeImage.enableAnimation() to FakeImage.configure() - Updated YamipaPlugin class --- .../josemmo/bukkit/plugin/YamipaPlugin.java | 25 +++++-------------- .../bukkit/plugin/renderer/FakeImage.java | 7 +++--- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java b/src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java index 135572b..0788a7c 100644 --- a/src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java +++ b/src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java @@ -60,17 +60,6 @@ public class YamipaPlugin extends JavaPlugin { return scheduler; } - /** - * Get configuration value - * @param path Configuration key path - * @param defaultValue Default value - * @return Configuration value - */ - private @NotNull String getConfigValue(@NotNull String path, @NotNull String defaultValue) { - String value = getConfig().getString(path); - return (value == null) ? defaultValue : value; - } - @Override public void onLoad() { instance = this; @@ -79,7 +68,7 @@ public void onLoad() { @Override public void onEnable() { // Initialize logger - verbose = getConfig().getBoolean("verbose"); + verbose = getConfig().getBoolean("verbose", false); if (verbose) { info("Running on VERBOSE mode"); } @@ -89,9 +78,9 @@ public void onEnable() { // Read plugin configuration paths Path basePath = getDataFolder().toPath(); - String imagesPath = getConfigValue("images-path", "images"); - String cachePath = getConfigValue("cache-path", "cache"); - String dataPath = getConfigValue("data-path", "images.dat"); + String imagesPath = getConfig().getString("images-path", "images"); + String cachePath = getConfig().getString("cache-path", "cache"); + String dataPath = getConfig().getString("data-path", "images.dat"); // Create image storage storage = new ImageStorage( @@ -106,10 +95,8 @@ public void onEnable() { // Create image renderer boolean animateImages = getConfig().getBoolean("animate-images", true); - if (animateImages) { - FakeImage.enableAnimation(); - info("Enabled image animation support"); - } + FakeImage.configure(animateImages); + info(animateImages ? "Enabled image animation support" : "Image animation support is disabled"); renderer = new ImageRenderer(basePath.resolve(dataPath).toString()); renderer.start(); diff --git a/src/main/java/io/josemmo/bukkit/plugin/renderer/FakeImage.java b/src/main/java/io/josemmo/bukkit/plugin/renderer/FakeImage.java index fd4458e..ec84f62 100644 --- a/src/main/java/io/josemmo/bukkit/plugin/renderer/FakeImage.java +++ b/src/main/java/io/josemmo/bukkit/plugin/renderer/FakeImage.java @@ -57,10 +57,11 @@ public class FakeImage extends FakeEntity { private int currentStep = -1; // Current animation step /** - * Enable plugin-wide image animation support + * Configure class + * @param animImages Animate images */ - public static void enableAnimation() { - animateImages = true; + public static void configure(boolean animImages) { + animateImages = animImages; } /**