s this me being stupid ? https://hastebin.com/kizesadevo.sql

Discussion in 'Spigot Plugin Development' started by Domboing, Aug 1, 2018.

  1. DavidDevelops


    Yes, Because you gave us no detail, no code, didn't explain shit, and haven't told us what you tried,

    (It's funny when you get more ratings by doing this than helping >.>)
    #2 DavidDevelops, Aug 1, 2018
    Last edited: Aug 1, 2018
    • Agree Agree x 6
  2. NPE in class Credential line 19
  3. give us the code.

    as far as i can tell you will need to add a != null check for whatever is on line 19 in the Credentials class
  4. Code (Text):
    package gg.pots.hcf.database;

    import gg.pots.hcf.HCF;

    import lombok.Getter;

    public class Credential {

        private final String username, host, password, database;
        private final int port;
        private HCF plugin;
        public Credential(HCF plugin) {
            this.plugin = plugin;
            this.host = plugin.getConfig().getString("DATABASE.AUTH.HOST");
            this.port = plugin.getConfig().getInt("DATABASE.AUTH.PORT");
            this.username = plugin.getConfig().getString("DATABASE.AUTH.USERNAME");
            this.password = plugin.getConfig().getString("DATABASE.AUTH.PASSWORD");
            this.database = plugin.getConfig().getString("DATABASE.AUTH.DATABASE");
  5. MiniDigger


    you pass null in the constructor or you call that constructor too early and there is no config created yet. never access anything from bukkit before onLoad
  6. hmm would it be anything to do with this ?

    Code (Text):
        public void onEnable() {

            HCF.plugin = this;

            this.aether = new Aether(this, new KitMapScoreboardProvider(this));
            new TablistManager(this, new KitMapTabListProvider(), 500L);


            Plugin wep = getServer().getPluginManager().getPlugin("WorldEdit");
            this.worldEdit = wep instanceof WorldEditPlugin && wep.isEnabled() ? (WorldEditPlugin) wep : null;



            this.effectRestorer = new EffectRestorer(this);


            try {
                this.mongo = new MongoConnection(CREDENTIALS);
            } catch (MongoSecurityException exception) {
  7. MiniDigger


    where do you initialize CREDENTIALS? you can't do it in a field because that would lead to getConfig being called before the plugin is loaded properly
  8. upload_2018-8-1_16-49-44.png
  9. MiniDigger


    yeah, you can't do it like that. static initializers are called before your class is even constructed, so you didn't assing a value to 'plugin' yet, causing the NPE
  10. HMMM i dont understand
  11. If anyone could spoon feed me i can pay
    • Funny Funny x 1
  12. There is no need to spoon feed cause this is so easy to see:
    in your code private static final Credential CREDENTAILS = new Credential(plugin); is called BEFORE public void onEnable() which leads to the problem that plugin is null at the time.

    A solution would be to initialize CREDENTIALS in your onEnable method (after HCF.plugin = this)