Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7847

Method JavaPlugin.setEnabled has a logical flaw

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • 1.20.6-R0.1-SNAPSHOT
    • Yes

      at org.bukkit.plugin.java.JavaPlugin.setEnabled(boolean enabled)

      This code has a logical flaw.It should be

      protected final void setEnabled(boolean enabled) {
          if (this.isEnabled != enabled) {
              if (enabled) {
                  this.onEnable();
              } else {
                  this.onDisable();
              }
              this.isEnabled = enabled;
         }
      
      }

      Because when call method "onEnable()" it may throw an exception and not loaded successfully, but call method "isEnabled()" will get a fake status.This also cause some plugin work incorrect, for example, use PlugManX to load a plugin but throw an exception and loaded unsuccessfully, but call method "isEnabled()" will get a value that "true"!!!

      However, I don't consider a condition that call method "onDisable()" but throw an exception!!!!!!!!

            Unassigned Unassigned
            enderlight3336 enderlight3336
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: