Vault?

Discussion in 'Plugin Development' started by GRANTSWIM4, Dec 26, 2012.

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

    GRANTSWIM4

    How do i hock into vault i read the wki and dev page im stuck
     
  2. Offline

    evilmidget38

    GRANTSWIM4 likes this.
  3. Offline

    GRANTSWIM4

  4. Offline

    evilmidget38

    What exactly are you having issues with? Explain how you're unable to hook into vault.
     
  5. Offline

    GRANTSWIM4

    sorry for the long replay but how do I use it
     
  6. Offline

    stuntguy3000

    What do you want from it? What are you trying to achieve?
     
  7. Offline

    GRANTSWIM4

    Economy part so i can give money on death
     
  8. Offline

    raGan.

  9. Offline

    GRANTSWIM4

  10. Offline

    fireblast709

    Weird the "implementing Vault" part seems pretty clear to me
     
  11. Offline

    raGan.

    I believe that major responsibility for this falls to your "inability to understand" than lacking example. If you are familiar with java, it should definitely make some sense.
     
  12. Offline

    ImDeJay


    Here is what i use to hook into Vault, never had a problem.

    Add this class to your project.

    Code:java
    1. package your.package.here;
    2.  
    3. import net.milkbowl.vault.chat.Chat;
    4. import net.milkbowl.vault.economy.Economy;
    5. import net.milkbowl.vault.permission.Permission;
    6.  
    7. import org.bukkit.Bukkit;
    8. import org.bukkit.Server;
    9. import org.bukkit.plugin.RegisteredServiceProvider;
    10.  
    11. public class VaultAdapter {
    12. private static final String VAULT = "Vault";
    13. //economy
    14. private static Economy ecoVault = null;
    15. private static Permission permVault = null;
    16. private static Chat chatVault = null;
    17. private static boolean vaultLoaded = false;
    18.  
    19. public static Economy getEconomy(){
    20. if(!vaultLoaded){
    21. vaultLoaded = true;
    22. Server theServer = Bukkit.getServer();
    23. if (theServer.getPluginManager().getPlugin(VAULT) != null){
    24. RegisteredServiceProvider<Economy> rsp = theServer.getServicesManager().getRegistration(Economy.class);
    25. if(rsp!=null){
    26. ecoVault = rsp.getProvider();
    27. }
    28. }
    29. }
    30.  
    31. return ecoVault;
    32. }
    33.  
    34.  
    35.  
    36. public static Permission getPermissions(){
    37. if(!vaultLoaded){
    38. vaultLoaded = true;
    39. Server theServer = Bukkit.getServer();
    40. if (theServer.getPluginManager().getPlugin(VAULT) != null){
    41. RegisteredServiceProvider<Permission> rsp = theServer.getServicesManager().getRegistration(Permission.class);
    42. if(rsp!=null){
    43. permVault = rsp.getProvider();
    44. }
    45. }
    46. }
    47.  
    48. return permVault;
    49. }
    50.  
    51.  
    52. public static Chat getChat(){
    53. if(!vaultLoaded){
    54. vaultLoaded = true;
    55. Server theServer = Bukkit.getServer();
    56. if (theServer.getPluginManager().getPlugin(VAULT) != null){
    57. RegisteredServiceProvider<Chat> rsp = theServer.getServicesManager().getRegistration(Chat.class);
    58. if(rsp!=null){
    59. chatVault = rsp.getProvider();
    60. }
    61. }
    62. }
    63.  
    64. return chatVault;
    65. }
    66.  
    67.  
    68.  
    69. }


    Now on your main class or the class that your using to send people money etc. do this

    under where you have "extends javaplugin" do this

    Code:java
    1. public class Main extends JavaPlugin implements Listener{
    2.  
    3. public static Economy econ = null;


    Then on your onCommand or whever your actually sending money, do something like this.

    Code:
    Economy econ = VaultAdapter.getEconomy();
    Then to send a player money do this.

    Code:
    econ.depositPlayer(NAME, AMOUNT);
     
  13. Offline

    Lolmewn

    ImDeJay aww, you ruined the fun :'(
    But yes, that's the way to do it.
    I really don't see how the OP is like 'I dun getz itz gimme codeh'.
     
  14. Offline

    GRANTSWIM4


    Thank ImDeJay and i agree with Lolmewn but i love your help thanks

    I need to know about GIT idk how it work any good tuts out there?

    DURP i put that code in my main class EPIC FAIL

    Plugin working well it a plugin that gives money to the killer and remove it form the person who died

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
Thread Status:
Not open for further replies.

Share This Page