Attempting to return kit information from Essentials always throws exception

Discussion in 'Spigot Plugin Development' started by myokan, Jun 5, 2017.

  1. I am trying to write a few methods to return information about a kit from essentials (if it is available, time until available, and number of items), but unfortunately it always throws the exception while trying to run
    k = new Kit(kitName, ess).

    Here is the relevant part of the code I am using: https://hastebin.com/upisepatik.java

    Would anyone here have an idea on why this would be?
     
  2. Can you post the error you're getting?
     
  3. Your creating a new kit tho?
     
  4. Isn't the "new Kit(String kitName, IEssentials ess)" for assigning the Kit under Essentials based on the essentials instance and the name of the kit from the config? This is my first time using Essentials's API and I have no clue.
     
  5. Unsure but usually it seems as if you're creating a new kit object?
     
  6. Yeah, for now I redid the code that returns the cooldown time (formatted), but it returns as:
    upload_2017-6-5_15-26-26.png
    (-2038466s)

    The updated code for it is:
    Code (Text):
        public static String timeUntilKitAvailable(Player p, String kitName) {
            IEssentials ess = (IEssentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
            User u = ess.getUser(p);
            long time = u.getKitTimestamp(kitName);
            int seconds = (int)(time - System.currentTimeMillis()) / 1000;
            return TimeUtil.getTime(seconds);

        }
     
  7. Try

    int seconds = (int)(System.currentTimeMillis() - time) / 1000;
     
  8. That returns

    upload_2017-6-5_15-37-51.png

    while the actual value for the cooldown through essentials itself is upload_2017-6-5_15-38-23.png