Solved [VAULT] Register new chat plugin

Discussion in 'Plugin Development' started by Bammerbom, May 20, 2014.

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

    Bammerbom

    I couldn't find any information about how to register a new Chat plugin for Vault.
    How to do this?
     
  2. Offline

    caseif

    Jhtzb likes this.
  3. Offline

    Bammerbom

    ShadyPotato I knew that. I mean register my OWN chat plugin to vault...

    I found this:
    Code:java
    1. plugin.getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, ?, plugin, ServicePriority.Normal);

    But what I have to say by the "?"
    It says "T"

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  4. Offline

    caseif

    Sorry, misread the section. I'm pretty sure there's a tutorial out there somewhere, but since I can't find it, I'll explain myself:

    First you'll need to create a class called VaultConnector (the name is actually arbitrary) that implements Chat, and fill in the methods inherited from the interface. Most of them are self-explanatory, but you may feel the need to Google some just to be sure you're using them correctly. Finally, add this code to your onEnable():
    Code:java
    1. if (getServer().getPluginManager().getPlugin("Vault") != null){
    2. final ServicesManager sm = getServer().getServicesManager();
    3. sm.register(Chat.class, new VaultConnector(), this, ServicePriority.Highest);
    4. getLogger().info("Registered Vault interface.");
    5. }


    Edit:
    "?" is a wildcard type in Java. In this case, it could be any instance of any class.
     
    Jhtzb likes this.
  5. Offline

    Bammerbom

    ShadyPotato I cannot import chat:
    The type Chat cannot be a superinterface of VaultConnector; a superinterface must be an interface
     
  6. Offline

    caseif

    You're importing Chat from Vault, right? Also, have you verified that VaultConnector implements Chat (again from Vault)?

    Edit: Try using extends Chat instead. Implementation may only work for the Economy class.
     
    Jhtzb likes this.
  7. Offline

    Bammerbom

    ShadyPotato I am importing the Chat of vault. But when I am trying to implement it it underlines it red saying The type Chat cannot be a superinterface of VaultConnector; a superinterface must be an interface
     
  8. Offline

    caseif

    See my edit. :)
     
    Jhtzb likes this.
  9. Offline

    Bammerbom

  10. Offline

    caseif

    Glad to hear it. :D
     
    Jhtzb likes this.
Thread Status:
Not open for further replies.

Share This Page