FancyHolograms icon indicating copy to clipboard operation
FancyHolograms copied to clipboard

[Bug] Calling `isEnabled` before enabled causes plugin to not start correctly

Open Matt-MX opened this issue 1 year ago • 2 comments

When using the API, calling FancyHologramsPlugin.isEnabled() will cause the plugin to not correctly enable.

Steps to reproduce

  1. Create a plugin soft depending on FancyHolograms 2.4.0
  2. Call FancyHologramsPlugin.isEnabled() on startup
  3. Try and use the plugin in game
  4. Observe a Plugin Not Enabled stacktrace in console.

Fixes

FancyHologramsPlugin.java

        public static Boolean isFancyHologramsEnabled() {
            if (enabled == null) {
                enabled = Bukkit.getPluginManager().isPluginEnabled("FancyHolograms");
                if (enabled) {
                    try {
                        plugin = (FancyHologramsPlugin)Bukkit.getPluginManager().getPlugin("FancyHolograms");
                    } catch (ClassCastException var1) {
                        throw new IllegalStateException("API failed to access plugin, if using the FancyHolograms API make sure to set the dependency to compile only.");
                    }
                }
            }

            return enabled;
        }

The enabled var is only set once. Calling the method before the plugin is initialized results in unintended behaviour.

Matt-MX avatar Nov 11 '24 16:11 Matt-MX

Should be fixed in 31598f86787ca7eee5d7a7a40473629169a8816d and dev build #118

OliverSchlueter avatar Nov 14 '24 07:11 OliverSchlueter

Never realized i didnt add a title 😭

Matt-MX avatar Nov 14 '24 11:11 Matt-MX