Skip to content

Commit

Permalink
Minor refactorization
Browse files Browse the repository at this point in the history
- Renamed FakeImage.enableAnimation() to FakeImage.configure()
- Updated YamipaPlugin class
  • Loading branch information
josemmo committed Dec 29, 2022
1 parent bb59fbc commit 8061c4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
25 changes: 6 additions & 19 deletions src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
Expand All @@ -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(
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 8061c4b

Please sign in to comment.