Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Matt-MX opened this issue Nov 11, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@Matt-MX
Copy link
Contributor

Matt-MX commented Nov 11, 2024

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.

@OliverSchlueter
Copy link
Member

Should be fixed in 31598f8 and dev build #118

@OliverSchlueter OliverSchlueter added the bug Something isn't working label Nov 14, 2024
@Matt-MX
Copy link
Contributor Author

Matt-MX commented Nov 14, 2024

Never realized i didnt add a title 😭

@Matt-MX Matt-MX changed the title [Bug] [Bug] Calling isEnabled before enabled causes plugin to not start correctly Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants