Registering Extended Interfaces?

Discussion in 'Plugin Development' started by Malikk, May 27, 2012.

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

    Malikk

    Hey everybody,

    This is kind of a very specific problem, but I need to register an interface which extends two other interfaces.

    I need to do this because I want devs using my api to have everything in one place, but I also need to keep the methods separate. Right now, I've got one interface which has a handful of classes using it, and another which has a different handful of classes using it, but they cannot be combined into a single interface, hence a third interface which does nothing but extend the first two. However, I cannot come up with a way to actually register this third interface, as it isn't actually the Service for either of the first two.

    Not sure this is even possible. If it's not, I'm open to alternatives.

    Thanks in advance.

    EDIT:
    I could actually get away with getting rid of one of the interfaces. But I would still need the main API to have methods in the interface and some not in it.

    Is it possible to have methods outlined in an interface that aren't necessary to be implemented by all the providers, without having to make all my classes abstract?

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  2. 1 class can extends 2 interfaces, whats your problem?
     
  3. Offline

    Malikk

    I understand how to make it extend, I don't understand how to register it.

    In order to use an interface, which is the service, you have to register its providers. Like this,

    Code:
     
    ShieldPluginInterface pluginInt = new ShieldPluginManager(this);
    Bukkit.getServicesManager().register(ShieldPluginInterface.class, pluginInt, this, ServicePriority.Normal);
     
    
    Then, someone using my API has to be able to get that registered service, like so,

    Code:
    RegisteredServiceProvider<ShieldAPI> provider = plugin.getServer().getServicesManager().getRegistration(us.twoguys.shield.ShieldAPI.class);
            if (provider != null) {
                api = provider.getProvider();
            }
    
    But since an extended interface is not directly the service, I cannot figure out a way to register it. Casting appears to do nothing.
     
  4. register it at the shieldApi class?
     
  5. Offline

    Malikk

    Register it using the bukkit services manager.
     
Thread Status:
Not open for further replies.

Share This Page