Solved Vault issues

Discussion in 'Plugin Development' started by beastman3226, Dec 10, 2013.

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

    beastman3226

    Simply put, my RSP is null for some weird reason in setupEconomy().
     
  2. Offline

    fireblast709

    Do you have an economy providing plugin, one that is supported by Vault?
     
  3. Offline

    beastman3226

    BOSEconomy and iConomy 7, neither are working

    I am at a complete loss at what to do.

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

    fireblast709

    did you add
    Code:
    depend: [Vault]
    in plugin.yml?
     
  5. Offline

    beastman3226

  6. Offline

    fireblast709

    beastman3226 are Vault and the economy plugin loaded in /pl?
     
  7. Offline

    beastman3226

    fireblast709
    Yes, they load before my plugin too.

    Got it! Class casting issue.

    Scratch that, still broken.

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

    fireblast709

    debug it to see what is causing this. (Assuming you use the setupEconomy() method found on the Vault git, there are a few steps you take before setting the value)
     
  9. Offline

    Sleaker

    Please post the relevant code sections for your plugin loading, otherwise it's going to be a guessing game for everyone here.
     
  10. Offline

    beastman3226

    fireblast709 Sleaker
    Code:java
    1. private boolean setupEconomy() {
    2. RegisteredServerProvider provider = getServer().getServicesManager().getRegistration(Economy.class);
    3. if(provider != null) {
    4. econ = ((Economy) provider.getProvider());
    5. return econ != null;
    6. } else {
    7. //debug message
    8. return false;
    9. }
    10. }


    RSP is null. I did try RegisteredServiceProvider<Economy>. I did softdepend on the economy plugins I am testing with, nothing is working.

    Any other solutions?

    onEanble
    Code:java
    1. Information.BusinessCore = this;
    2. if (getConfig().getBoolean("firstrun")) {
    3. saveDefaultConfig();
    4. }
    5. Information.config = getConfig();
    6. if (getConfig().getBoolean("debug-messages")) {
    7. Information.debug = true;
    8. } else {
    9. Information.debug = false;
    10. }
    11. if (getConfig().getBoolean("database.enabled")) {
    12. Database.instance();
    13. Information.database = true;
    14. } else {
    15. Information.initFiles(this);
    16. Information.database = false;
    17. }
    18. Information.eco = setupEconomy();
    19. Information.eco = this.eco;
    20. registerListeners();
    21. registerCommands();
    22. Information.log = this.getLogger();
    23. if (getConfig().getBoolean("firstrun")) {
    24. getConfig().set("firstrun", false);
    25. } else {
    26. if (Information.database) {
    27. Connection c = Database.MySQL.getConnection();
    28. try {
    29. Statement s = c.createStatement();
    30. BusinessManager.createBusiness(s.executeQuery("SELECT * FROM " + Table.BUSINESS));
    31. } catch (SQLException ex) {
    32. Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    33. }
    34. } else {
    35. BusinessManager.createBusinesses();
    36. }
    37. }

    The other thing:
    Code:java
    1.  
    2. private Economy setupEconomy() {
    3. RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
    4. if (economyProvider != null) {
    5. Information.eco = ((Economy) economyProvider.getProvider());
    6. } else {
    7. System.out.println("Null");
    8. }
    9. return ((Economy) economyProvider.getProvider());
    10. }


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

    fireblast709

    beastman3226 wait so first you set Information.eco if the rsp is not null, and then you return the Economy regardless if the rsp is null or not? (NullPointerException would be thrown in the case the RSP is null)
     
  12. Offline

    Sleaker

    beastman3226
    Line 19 completely overwrites line 18, I'm not sure why you're writing to the same Information.eco twice, but you're erasing it's value, that's why it's always null.

    Basically, stop writing to your variables all over the place multiple times. You set Information.eco in the setupEconomy portion, then you return the value and set it again, then in the next line you set it to something completely different that's not even shown. Write to that static value once, no more.
     
  13. Offline

    beastman3226

    Sleaker fireblast709
    I know. Fixed the issue with setting the value twice but it doesn't change the fact that the RSP is still null and it never gets set.

    Sleaker fireblast709
    I did a little test to see what is causing the problem:
    Code:java
    1. Plugin p = Bukkit.getServicesManager().getRegistration(Economy.class).getPlugin();

    The null pointer points to:
    Code:java
    1. .getRegistration(Economy.class)


    Sleaker
    Is vault compatible with 1.6.4? I believe it should be but I'm not sure.

    Economy.class is not provided for.

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

    xize

    beastman3226
    hmm ive a little question about your onEnable class what does "Information.eco" because I see you first try to reference it to a method called setupEconomy() and then you reference it to your plugin why are you doing that?:p

    you know that it means that the older reference no longer exists to that variable?

    edit also make sure you have both iconomy and vault added in the library references
     
  15. Offline

    beastman3226

    Information is an inner class that contains thing of a static reference so I don't have to have an instance of the plugin.

    iConomy has no function that I am intentionally trying to hook into, it is just an economy plugin to test my plugin with. Besides if I need a reference to iConomy I would errors all over the place. The issue is not in the setup.
     
  16. Offline

    Sleaker

    You've drastically changed the setupEconomy method, I'm not sure where you got your version, but if you just follow the template it should work without problems.

    Code:
        public static Economy econ = null;
    
        private boolean setupEconomy() {
            if (getServer().getPluginManager().getPlugin("Vault") == null) {
                return false;
            }
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                return false;
            }
            econ = rsp.getProvider();
            return econ != null;
        }
    
     
  17. Offline

    beastman3226

    Sleaker
    I have modified a multitude of times, none are working.
     
  18. Offline

    Sleaker

    Like I said, just use the base example.

    EDIT: if anything returns false out of that method, then you either don't have an economy installed in the plugins directory, or vault is not installed in the plugins directory. To verify which, add System.out.println debugging to the method at each if statement.
     
  19. Offline

    beastman3226

    Sleaker
    I appreciate your help but I have used every version of the setupEconomy() method I could find. I know for a fact that I am using vault and that it is installed. I have tried using iConomy, BOSEconomy, and MinEconomy. All of my tests have resulted in the null pointer (because the economy value never got set). Ill try this method once more,
    if it doesn't work can you give me a contingency plan?
     
  20. Offline

    fireblast709

    If that throws a NullPointerException, post your plugin.yml
     
  21. Offline

    beastman3226

    fireblast709
    Code:
    [COLOR=#000000]name: BusinessCore[/COLOR]
    [COLOR=#000000]version: 0.0.1
    author: beastman3226
    main: me.beastman3226.bc.Main
    depend: [Vault]
    commands:
      b.create:
        description: Creates a business
        permission: business.create
        permission-message: "&4You do not have 'business.create' or the like, please talk to an adminstrator"
        aliases: [business.create, create, b.c]
      b.delete:
        description: Delete your business, or (from console) someone elses
        permission: business.delete
        permission-message: "&4You do not have 'business.delete' or the like, please talk to an adminstrator"
        aliases: [business.delete, delete, b.d]
      b.withdraw:
        description: Withdraws money from your business
        permission: business.withdraw
        permission-message: "&4You do not have 'business.withdraw' or the like, please talk to an adminstrator"
        aliases: [business.withdraw, withdraw, b.w]
      b.deposit:
        description: Deposits money into the bank
        permission: business.deposit
        permission-message: "&4You do not have 'business.deposit' or the like, please talk to an adminstrator"
        aliases: [business.deposit, deposit, b.de]
      b.balance:
        description: Shows you your balance
        permission: business.balance
        permission-message: "&4You do not have 'business.balance' or the like, please talk to an adminstrator"
        aliases: [business.balance, balance, b.b]
      hire:
        description: Hires the specified player
        permission: business.hire
        permission-message: "&4You do not have 'business.hire' or the like, please talk to an adminstrator"
        aliases: [b.h, h]
    permissions:
      business.create: true
      business.delete: true
      business.withdraw: true
      business.deposit: true
      business.balance: true
      business.hire: true
      business.business:
        children:
          business.create: true
          business.delete: true
          business.withdraw: true
          business.deposit: true
          business.balance: true
          business.hire: true
    [/COLOR]

    Tried BOSEconomy and iConomy, can't find the economy class.

    Do the plugins I am testing with not support Vault?

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

    fireblast709

    beastman3226 it would rather be that Vault doesn't support them. You could always check that.
     
  23. Offline

    beastman3226

    fireblast709
    What should I do now? I checked if the implement Vault, they do not. What should I do?
     
  24. Offline

    Sleaker

    At this point if it's still not working you'll need to post more source code, and the log files with what plugins are loading. When you post source, you're not showing enough of it, and the last source you posted had things that I explicitly notated would break. iConomy, BOSe and MineEco are all supported directly in vault. This really appears to be something you're doing in your program logic, but the above would help in resolving it. If you had the code on github that would help even more.
     
  25. Offline

    beastman3226

  26. Offline

    Sleaker

    beastman3226 - and are you currently still having problems with that code? What do startup logs show? etc.
     
  27. Offline

    beastman3226

    Sleaker
    Code:java
    1. [18:12:24 ERROR]: Could not load 'E:\Projects\Minecraft\Plugins\BusinessCore\dist\craftbukkit-1.7.2-R0.1-20131214.232726-37.jar' in folder 'E:\Projects\Minecraft\Plugins\BusinessCore\dist'
    2. org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    3. at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:247) ~[craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    4. at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:132) [craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    5. at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:255) [craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    6. at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:233) [craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    7. at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    8. at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    9. at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    10. at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:424) [craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    11. at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit-1.7.2-R0.1-20131214.232726-37.jar:git-Bukkit-1.6.4-R2.0-50-g402ee87-b2958jnks]
    12. Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
    13. ... 9 more
    14. [18:12:24 INFO]: [Vault] Loading Vault v1.2.27-b349
    15. [18:12:24 INFO]: [iConomy] Loading iConomy v7.0
    16. [18:12:24 INFO]: [BusinessCore] Loading BusinessCore v0.0.1
    17. [18:12:24 INFO]: [Vault] Enabling Vault v1.2.27-b349
    18. [18:12:24 INFO]: [Vault][Permission] SuperPermissions loaded as backup permission system.
    19. [18:12:24 INFO]: [Vault] Enabled Version 1.2.27-b349
    20. [18:12:24 INFO]: Preparing level "world"
    21. [18:12:24 INFO]: Preparing start region for level 0 (Seed: 6348518780849687986)
    22. [18:12:25 INFO]: Preparing start region for level 1 (Seed: 6348518780849687986)
    23. [18:12:25 INFO]: ----- Bukkit Auto Updater -----
    24. [18:12:25 INFO]: It appears that you're running a Development Build, when you've specified in bukkit.yml that you prefer to run Recommended Builds.
    25. [18:12:25 INFO]: If you would like to be kept informed about new Development Build releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to 'dev'.
    26. [18:12:25 INFO]: With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.
    27. [18:12:25 INFO]: If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.
    28. [18:12:25 INFO]: ----- ------------------- -----
    29. [18:12:25 INFO]: Preparing start region for level 2 (Seed: 6348518780849687986)
    30. [18:12:26 INFO]: [iConomy] Enabling iConomy v7.0
    31. [18:12:26 INFO]: [iConomy] Default setup file written: Config.yml
    32. [18:12:26 INFO]: [iConomy] Default setup file written: Template.yml
    33. [18:12:26 INFO]: [iConomy - April Fools] Enabled (22 ms)
    34. [18:12:26 INFO]: [iConomy] Hello, I'm Nijikokun. Yes, this is an April Fools joke, but '/money top' was fixed! Enjoy :) - Rare Version!
    35. [18:12:26 INFO]: [BusinessCore] Enabling BusinessCore v0.0.1
    36. [18:12:26 INFO]: [iConomy - April Fools] Purged accounts with default balance.
    37. [18:12:26 INFO]: Economy plugin not detected
    38. [18:12:26 INFO]: [BusinessCore] false
    39. [18:12:26 INFO]: Server permissions file permissions.yml is empty, ignoring it
    40. [18:12:26 INFO]: Done (1.177s)! For help, type "help" or "?"
    41. pl
    42. [18:12:42 INFO]: Plugins (3): Vault, iConomy, BusinessCore

    You can quite obviously ignore the error because the plugin initializes fine and that didn't happen originally.

    EDIT: Derp, had the CB.jar in the folder :p
     
  28. Offline

    Sleaker

    Whatever version of iConomy you're using is not official, Vault doesn't say it sees it, have you tested with another economy plugin?
     
  29. Offline

    beastman3226

    Sleaker
    7.0? Should I use 6.0? What do most servers use? Should I post results for BOS and Mine?
    Code:
    [18:25:31 INFO]: [MineConomy] Loading MineConomy v1.4
    [18:25:31 INFO]: [Vault] Loading Vault v1.2.27-b349
    [18:25:31 INFO]: [BusinessCore] Loading BusinessCore v0.0.1
    [18:25:31 INFO]: [Vault] Enabling Vault v1.2.27-b349
    [18:25:31 INFO]: [Vault][Permission] SuperPermissions loaded as backup permission system.
    [18:25:31 INFO]: [Vault] Enabled Version 1.2.27-b349
    [18:25:31 INFO]: Preparing level "world"
    [18:25:31 INFO]: Preparing start region for level 0 (Seed: 6348518780849687986)
    [18:25:31 INFO]: ----- Bukkit Auto Updater -----
    [18:25:31 INFO]: It appears that you're running a Development Build, when you've specified in bukkit.yml that you prefer to run Recommended Builds.
    [18:25:31 INFO]: If you would like to be kept informed about new Development Build releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to 'dev'.
    [18:25:31 INFO]: With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.
    [18:25:31 INFO]: If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.
    [18:25:31 INFO]: ----- ------------------- -----
    [18:25:31 INFO]: Preparing start region for level 1 (Seed: 6348518780849687986)
    [18:25:32 INFO]: Preparing start region for level 2 (Seed: 6348518780849687986)
    [18:25:32 INFO]: [MineConomy] Enabling MineConomy v1.4
    [18:25:32 INFO]: [MineConomy] [INFO] Enabling plugin...
    [18:25:32 INFO]: [MineConomy] [INFO] Found CraftBukkit [2958]. It is compatible!
    [18:25:32 INFO]: [MineConomy] [INFO] Loading Config file...
    [18:25:32 INFO]: [MineConomy] [INFO] Config file loaded!
    [18:25:32 INFO]: [MineConomy] [INFO] YML is enabled for Accounts.
    [18:25:32 INFO]: [MineConomy] [INFO] Loading Accounts file...
    [18:25:32 INFO]: [MineConomy] [INFO] Accounts file loaded!
    [18:25:32 INFO]: [MineConomy] [INFO] Loading Banks file...
    [18:25:32 INFO]: [MineConomy] [INFO] Banks file loaded!
    [18:25:32 INFO]: [MineConomy] [INFO] Loading Currency file...
    [18:25:32 INFO]: [MineConomy] [INFO] Currency file loaded!
    [18:25:32 INFO]: [MineConomy] [INFO] Loading Language file...
    [18:25:32 INFO]: [MineConomy] [INFO] Language file loaded!
    [18:25:32 INFO]: [MineConomy] [INFO] Interest Disabled.
    [18:25:32 INFO]: [MineConomy] [INFO] Tax Disabled.
    [18:25:32 INFO]: [MineConomy] [INFO] GUI Disabled.
    [18:25:32 INFO]: [MineConomy] [INFO] Checking for updates...
    [18:25:33 INFO]: [MineConomy] [VERY IMPORTANT] Updates available. Check http://dev.bukkit.org/server-mods/mineconomy/ for the update.
    [18:25:33 INFO]: [MineConomy] [IMPORTANT] Version 1.4 by MjolnirCommando is enabled!
    [18:25:33 INFO]: [BusinessCore] Enabling BusinessCore v0.0.1
    [18:25:33 INFO]: Economy plugin not detected
    [18:25:33 INFO]: [BusinessCore] false
    [18:25:33 INFO]: Server permissions file permissions.yml is empty, ignoring it
    [18:25:33 INFO]: Done (1.840s)! For help, type "help" or "?"
    [18:25:34 INFO]: [MineConomy] [INFO] Auto-Saving files...
    [18:25:34 INFO]: [MineConomy] [INFO] Finished auto-save.
     
  30. Offline

    Sleaker

    beastman3226 that's really odd, I'll look into this for you.
     
Thread Status:
Not open for further replies.

Share This Page