1.16.x Instantiating a Namespacekey breaks my plugin

Discussion in 'Spigot Plugin Development' started by DapperCode, Oct 18, 2020 at 12:48 AM.

  1. All i did was literally just
    Code (Text):
        NamespacedKey bouncevalues = new NamespacedKey(Main.instance(), "bounce");
    and then that class doesnt work. if i remove it, that class works again. strangest part is that i can put that code in other classes and it works fine but this one SPECIFIC class i have hates that i make Namespacedkeys in it. what do i do?
     
  2. Are you getting any errors? If so please post them here.
     
  3. I'm not getting any errors at compile time it just straight up doesn't work in game. it doesn't even say "An internal server error occurred". it is in a BukkitRunnable class but its not in the run() method so it should be an issue there.
    EDIT: Apparently instantiating a namespacekey literally anywhere just breaks everything. My version is 1.16 if that means anything
     
    #3 DapperCode, Oct 18, 2020 at 1:57 AM
    Last edited: Oct 18, 2020 at 2:07 AM
  4. A couple things could be wrong, I can't be sure because I don't have much to go off.

    Here's some guesses:
    1) You're trying to register more than one key with the name "bounce". I'm pretty sure this cannot be done
    2) Main.instance() might not be returning what you think it is. I just use the static method provided by JavaPlugin:
    Code (Text):

    MainClass.getPlugin(MainClass.class);
     
    3) I don't have enough information about this "broken class," but if it's just in that class, do testing to make sure Main.instance() is returning what it should be. Other than that, there might just be something "unrelated" going on in the class preventing the code from being run, it's hard to say.
     
  5. Are you using eclipse IDE? Its been flaky about stuff since the last upgrade(maybe before? I waited awhile to upgrade), make sure your main is inherited.
     
  6. Dependency injection should be more relevant here.
     
    • Winner Winner x 1