Solved Essentials API | ess.getUser(player) makes an error!

Discussion in 'Plugin Development' started by Mikha Mikhin, Dec 23, 2015.

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

    Mikha Mikhin

    Hello, I am trying to use Essentials API in my plugin:
    private Essentials ess;
    But when I use
    Player player = (Player) Sender;
    User user = ess.getUser(player);
    Makes an error "An internal error occured while attempting to perform this command".
    Bukkit version: 1.7.10.
  2. Is ess null? It looks like it is. Does Essentials#getUser(); take a player as a parameter? (It does) Is the sender actually a player or did you blind cast? You need to show more of your code so we can find out which one of these errors is yours.
  3. Offline

    Mikha Mikhin

    Sender is a player, but ess.getUser(player); makes an error.
  4. Is the error a NullPointerException? Can you show us the rest of your class (Or atleast the constructor/constructors), I'm thinking you never set the ess field.

    If this is correct then your problem quite a basic Java problem.
  5. Offline

    Mikha Mikhin

    Yes! Error is "NullPointer Exception". How can I fix it?

    Attached Files:

  6. Dont start your variables with an upper-case letter,

    And as @Xerox262 said, (can I just say your minecraft name is the same name as my printer :3 (except the 262 bit)) you need to post more of your code if you want us to help you, it's like saying to someone "Line 252 of my code doesnt work can you help me" and expecting them to give you a detailed description of your error and how to fix it
  7. Offline


    Post full stacktrace and full code of the class that is creating this error. Plus did you import the right import (essentials one) for User?
  8. His variable name doesn't start with an uppercase letter "ess" is the name :p And my friend likes to make it obvious every time I walk past a Xerox printer that I'm passing my sibling xD.
    Last edited: Dec 23, 2015
  9. Offline

    Mikha Mikhin

    Code.png Error.png
    I am useing Cauldron, but all bukkit plugins works on Cauldron.
  10. You never set the ess field, in your onEnable do something like
    ess = (Essentails) Bukkit.getPluginManager().getPlugin("Essentials");
  11. Offline

    Mikha Mikhin

    Wow! Thank you! It is working now!
  12. ^

    1. Dont call your main class "MainClass" call it the name of your Plugin
    2. Why're you implementing Listener when you don't have a listener?
    3. You dont need to print in the console your plugin is Enabled, Bukkit already does that for you.
  13. Offline

    Mikha Mikhin

    1. Why?
    2. getServer().getPluginManager().registerEvents(this,this);
    3. And what?

    The problem solved. How can I close this thread?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Dec 23, 2015
    1. It's what a good coder does, calls their class something that can be read and understood as to where it stands (If you try to use it in a different plugin you wont be able to as easy)
    2. You don't have any event listeners, I assume you're going to add some he was just asking why you had all that if you weren't going to use it
    3. Don't do getLogger().info("Plugin have been enabled!"); <-- Bukkit automatically does that for you, it makes two messages appear in console and makes it look weird/if you give people the plugin they will get annoyed by it.
    Oh and set the thread as solved so people will know you're all good :)
Thread Status:
Not open for further replies.

Share This Page