PermissionsEx main class constructor

Discussion in 'Plugin Development' started by brord, Sep 23, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    brord

    Hey i was looking into some trouble my plugin had with PermissionsEx.
    So i took a look at h teh code from pex github (https://github.com/PEXPlugins/PermissionsEx).

    But i noticed the author did something strange.
    There is a a main constructr defined:
    Code:
    public PermissionsEx() {
            super();
            PermissionBackend.registerBackendAlias("sql", SQLBackend.class);
            PermissionBackend.registerBackendAlias("file", FileBackend.class);
            PermissionBackend.registerBackendAlias("memory", MemoryBackend.class);
        }
    Now i was wondering, when exacly do0es this code get run?
    If anyone could clarify this for me, i would be soo happy :D
     
  2. Offline

    Nateb1121

    Just find anywhere you make an instance of PermissionsEx, it should call that constructor. Lots of things are instanced in all sorts of places in this plugin, I'm sure you could find it if you dig.
     
  3. Offline

    brord

    i did, there is nothing with a call like "new PermissionsEx()".
     
  4. Offline

    1Rogue

    I believe PermissionsEx's main instance is static. i.e. PermissionsEx.getInstance (or similar).

    Alternatively you could use:
    Code:java
    1. (PermissionsEx) Bukkit.getPluginManager().getPlugin("PermissionsEx");


    EDIT: Misunderstood the question. However I believe the constructor for the class is called when Bukkit first registers the plugin itself.
     
  5. Offline

    Nateb1121


    I was lookin' in the onEnable and it doesn't instance it, does Bukkit call the constructor by it self when a plugin is registered if a constructor is present? (Technically any class you have will have a no-args constructor weather you make one or not, if I remember correctly.)
     
  6. Offline

    1Rogue



    I believe so, because in calling in a new instance of a class you call its constructor
     
Thread Status:
Not open for further replies.

Share This Page