1.8.8 I have more questions.

Discussion in 'Spigot Plugin Development' started by Wilsoon, Jan 30, 2020.

  1. So, this time I'm tryna make something so that when any player is in range of the sun only, they will die/get withered or something. And when there is any block above the player, they won't die. How would I do this?
     
  2. 1) Add listener for PlayerMoveEvent
    2) Check if it's daytime
    3) Get the block below the player
    4) run Block#getLightFromSky
    5) ?
    6) profit
     
    • Funny Funny x 2
  3. if the light level at the block the player is on is 15, theyre in direct sunlight. this likely includes going through transparent blocks like glass and leaves. youll have to check and see.
     
  4. Thank you, but may I ask, what will player.getLocation() exactly return me?
    Would it return me the block I'm standing on or is it the block my feet is at?
    For example, this is me:
    upload_2020-1-31_16-27-52.png
    If I do player.getLocation(), does it return me the coords of the glass block or quartz block?


    Secondly, I've noticed Player.getBlock().getLightFromSky() is a "byte", may I know what that is?
    Google doesn't give me the definition in English.
     
  5. You could debug this your self by typing:
    Code (Text):
    Bukkit.broadcastMessage(player.getLocation().getBlock().getType().name())
    go ahead try it :)

    It will return the Glass block
     
    #5 Heretere, Jan 31, 2020
    Last edited: Jan 31, 2020
    • Agree Agree x 1
  6. Thanks, I managed to find the block.
    As for now, another roadblock I've hit is to figure out what byte is and what it's value could possibly be for a maximum light level of 15.
    Google seems to say that:
    upload_2020-1-31_17-29-49.png
    Since the maximum value is 127, does light level of 15 mean my code will be
    Code (Java):

    Block b = player.getLocation().clone().subtract(0, 1, 0).getBlock();
    byte LightLevel = b.getLightFromSky();

    if(LightLevel = 127) {
      getLogger().info(player + "is about to die from sunburn!")
    }
     
    If this is the case, what would I put as the value if I want for example a light level of 6?
     
  7. that max value for getLightFromSky() is 15.

    if getLightFromSky() equals 15 then they are in the sun
    if getLightFromSky() is less than 15 then they are not in the sun
     
  8. I'm sure this would make it so even if it's night they still die, as the light level still stays at 15, how can I make it so it only works from morning to sunset?
     
  9. My code didn't work:
    Main:
    Code (Java):


    package com.gmail.calorious.Java;

    import java.io.File;
    import java.io.IOException;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.HandlerList;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin {
        private static Main instance;
        public static Main getInstance() { return instance; }
           @Override
           public void onEnable() {
               try {
                File config = File.createTempFile("config", ".yml");
                boolean exists = config.exists();
                if(exists) {
                    getLogger().info("Saving Config...");
                    saveDefaultConfig();
                    getLogger().info("Config has been saved!");
                } else {
                    getLogger().info("Creating Config...");
                    saveDefaultConfig();
                    getLogger().info("Created!");
                }
            } catch (IOException e) {
                getLogger().warning("An error occurred while loading the config.");
                e.printStackTrace();
            }
               getLogger().info(ChatColor.GREEN + "Registering Listeners...");
               getServer().getPluginManager().registerEvents(new PlayerMoveToSun(), this);
               getLogger().info(ChatColor.GREEN + "Successfully registered listeners!");
               getLogger().info(ChatColor.GREEN + "NoSunlight Plugin has been enabled!");
               getLogger().info(ChatColor.GOLD + "           Made by Java             ");
           }
         
           @Override
           public void onDisable() {
               getLogger().info(ChatColor.RED + "Unregistering listeners...");
               HandlerList.unregisterAll();
               getLogger().info(ChatColor.RED + "Listeners have been unregistered.");
               getLogger().info(ChatColor.DARK_RED + "NoSunlight Plugin has been disabled!");
           }
           @Override
           public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
               if(cmd.getName().equalsIgnoreCase("nosunlight")) {
                   if(args.length == 1 && args[0].equalsIgnoreCase("on")) {
                       if(PlayerMoveToSun.enabled) {
                           sender.sendMessage(ChatColor.RED + "FAIL: Plugin is already enabled!");
                       } else {
                           sender.sendMessage(ChatColor.GREEN + "SUCCESS: Plugin has been enabled!");
                       }
                       return true;
                   }
                   if(args.length == 1 && args[0].equalsIgnoreCase("off")) {
                       if(!(PlayerMoveToSun.enabled)) {
                           sender.sendMessage(ChatColor.RED + "FAIL: Plugin is already disabled!");
                       } else {
                           sender.sendMessage(ChatColor.GREEN + "SUCCESS: Plugin has been enabled!");
                       }
                       return true;
                    }
                   if(args.length == 1 && args[0].equalsIgnoreCase("info")) {
                      sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "]==========" + ChatColor.GOLD + "Info" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "==========[");
                      sender.sendMessage(ChatColor.GREEN + "You are not allowed to be in direct sunlight with this plugin enabled, this means, if your light level is at 15 (Direct Sunlight), you will die.");
                      sender.sendMessage(ChatColor.RED + "  This plugin was made by Java/Calorious.");
                      return true;
                   }
                   if(args.length == 0) {
                       sender.sendMessage(ChatColor.GREEN + "NoSunlight");
                       sender.sendMessage(ChatColor.DARK_GRAY + "==========");
                       sender.sendMessage(ChatColor.GOLD + "/nosunlight on - Enables the plugin");
                       sender.sendMessage(ChatColor.GOLD + "/nosunlight off - Disables the plugin");
                       sender.sendMessage(ChatColor.GOLD + "/nosunlight info - Information on plugin");
                   }
               }
            return true;
           }
    }

     
    Note: I have very useless parts of my code, including file.exists config.yml, pls ignore.

    Event class:
    Code (Java):


    package com.gmail.calorious.Java;

    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    @SuppressWarnings("unused")
    public class PlayerMoveToSun implements Listener {
     
        public static boolean enabled = true;
               public void onPlayerMove(PlayerMoveEvent e) {
                   Player player = e.getPlayer();
                   if(enabled) {
                     
                       Location PlayerLoc = player.getLocation();
                       Block PlayerLocBlock = PlayerLoc.getBlock();
                       Block CheckingBlock = PlayerLoc.clone().subtract(0, 1, 0).getBlock();
                       byte CheckingBlockLight = CheckingBlock.getLightFromSky();
                       if(CheckingBlockLight == 15) {
                           if(Main.getInstance().getConfig().getInt("deathmethod") == 1) {
                               player.setHealth(0);
                           }
                           if(Main.getInstance().getConfig().getInt("deathmethod") == 0) {
                               player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 1200, 10));
                           }
                       }
                   }
               }
    }
     
    Config.yml:
    Code (YAML):


    ##########################################
    # Select Death Method of players who     #
    #           see the sun                  #
    #            0 - Wither                  #
    #            1 - /kill                   #
    #           Default - 1                  #
    ##########################################
    deathmethod
    : 1

     
     
  10. Another question:
    Is it possible to send a "Minecraft" way of command feedback when you do a command?
    Like whenever a player changes gamemode with commandfeedback on, another player would see
    [Player: Set own game mode to Survival mode]
    Is there a way to do it with the plugin? or is it just simple sender.sendMessages?
     
  11. for this, you could use PlayerChangeGameModeEvent (iirc) - then get the player and what gamemode they changed it to. and just broadcast that to the server.
     
  12. Thanks, but what I'm looking for is not a Gamemode, /gamemode was just an example, I want my plugin's output message to have that effect.
     
  13. yes u just send them a message

    /e to make sure its daytime, find the data values for daytime (im sure this is on the minecraft wiki for time) and see what time the world is currently at
     
  14. Strahan

    Benefactor

    https://minecraft.gamepedia.com/Day-night_cycle

    The "24 hour Minecraft day" section will tell you the tick count at each part of the day.

    Looked at your code:
    • Spigot has built in config handling. All that work you are doing with File object in the onEnable is totally unnecessary. Simply call saveDefaultConfig(). It will know if config.yml exists already and will not overwrite. Actually, it looks like all you are using that for anyway is to tell whether to say "Saving" or "Creating". That's even more pointless, since saveDefaultConfig() does nothing if the file already exists.
    • Also, all that messaging in your enable and disable is kinda pointless anyway as Spigot already sends enable/disable messages. Especially "Made by Java". First, that's obvious and second, it's made with Java not "by" Java unless you have that one kid's imaginary AI creating the plugin for you lol
    • Move the args 0 check in your onCommand up to the top, then you won't have to check in every single subcommand if args length is 1. Also you're better off checking if args length > 0 rather than == 1 so if the user for some inexplicable reason puts another arg, it won't just silently fail it will still function.
    • Instead of on/off functions, I find it easier to just do a "toggle" function then you don't have to duplicate code and users won't get "fail" messages it'll just toggle and report back.
    • If you made your plugin instance static, you really don't need a getter you know. Personally, I'd use dependency injection instead.
    • Subtracting Y isn't really necessary, simply checking the block at player's future location will suffice. By future I mean don't use player location, use the getTo location. Remember, events that can be cancelled are called before their action takes place otherwise you wouldn't be able to cancel them.
    • It's a waste of time to declare a Byte object for this, just check .getLightLevel() directly from the block.
    • I'd use a switch on deathmethod so if/when you add more ways to punish players for being in the sun, you won't end up with a mess of if statements.
    • You forgot the EventHandler annotation
    • Also you should filter the move event so it isn't performing all that logic every time the event is called. That event gets called if you so much as twitch your head. You should only be checking if the X or Z has changed.
    • A minute of wither is a death sentence. It would seem to me if a person gets wither in the sun, darting back into the darkness should stop it. That'd make more sense to me.
     
    #14 Strahan, Jan 31, 2020
    Last edited: Jan 31, 2020
    • Winner Winner x 1
  15. 1. Yes I'm an idiot, it sounds cringy now having it being pointed out by someone else lol

    2. Actually my nickname is Java, I just never took it seriously in putting my nickname as Java here. I'll change my name if I choose to donate tho.
    So yea.


    3. Hmm, true, my bad.

    4.Hmm, ok. I'll try to change this.

    5. I have no idea what a dependency injection is, I don't understand why listing my dependencies and repositories in pom.xml is required. It seems to work without it...


    6. It's above, I did it before, it returned the block that was on my feet and not the block I was standing on, so I had to subtract so maybe it would work?


    7. owh, ok.


    I don't know what you meant by a switch, but isn't a switch just something like on/off?

    8. O.O oops.

    9. I don't really know how to do this, and in any way I think twitching my head to die is kinda quite okay for me. If you don't mind you can still do this so that I can learn.



    10. This is kinda another stupid question, but would anyone give me any advice on using another API?
    Full scenario:
    I have an open source code of another plugin's API, I have my own code, I have imported into my code, I have put the jar into my build path, how do I put it into use? I've imported Commandgamemode.java from: https://github.com/EssentialsX/Esse...essentials/commands/Commandgamemode.java#L107 and I wanna use it in my code to set someone's gamemode (without any bukkit#dispatchCommand), how would I do that?
    (I added the numbers at the start in case anyone wants to give comments, it's more orderly than just filling out in any order)
     
  16. Strahan

    Benefactor

    Not an idiot, just inexperienced. We all were at one point ;)

    It has nothing to do with that. Basically if I wanted to inject my plugin to an event handler, I'd do this:
    Code (Text):
    class Main {
      onEnable {
        getServer().getPluginManager().registerEvents(new PlayerMoveToSun(this), this);
      }
    }

    class PlayerMoveToSun {
      private Main plugin;

      public PlayerMoveToSun(Main plugin) {
        this.plugin = plugin;
      }

      function() {
        plugin.getConfig().set("example.of.plugin.call", "easy-peasy");
        plugin.saveConfig();
      }
    }
    ...and that's a problem, why?

    This is why it pays to learn the basics of a programming language before you use it ;) Let's say you have a function where you want to broadcast "someone in the nether" when a person kills a blaze, ghast, witherskelly or pigzombie and broadcast "call peta!" if someone kills a cow, pig, sheep or chicken and broadcast "meh don't care" if it is none of those. You could do a big if/elseif or you could simply do:
    Code (Text):
    switch (entity.getType()) {
    case BLAZE:
    case GHAST:
    case WITHER_SKELETON:
    case PIG_ZOMBIE:
      Bukkit.broadcastMessage("someone in the nether!");
      break;

    case COW:
    case PIG:
    case SHEEP:
    case CHICKEN:
      Bukkit.broadcastMessage("call PETA!");
      break;

    default:
      Bukkit.broadcastMessage("meh don't care");
      break;
    }
    Much easier to read than all that if/else crap IMO.

    I don't mean for simple purposes of your game logic, I mean to reduce the load on the server. There is no point to being so granular as to track the head motion; light level doesn't change when head position changes only when block position changes. To filter, I'd do:
    Code (Text):
    if (e.getFrom().getBlockX() == e.getTo().getBlockX() &&
    e.getFrom().getBlockZ() == e.getTo().getBlockZ()) return;
    as the first thing you do in the PlayerMoveEvent.
     
    • Like Like x 1
  17. Uhh, why is that a problem again... Oh wait it isn't never mind.





    My new codes:
    Main class:
    Code (Java):


    package com.gmail.calorious.Java;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.HandlerList;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin {
        private static Main instance;
        public static Main getInstance() { return instance; }
       
           @Override
           public void onEnable() {
               getLogger().info(ChatColor.GREEN + "Registering Listeners...");
               getServer().getPluginManager().registerEvents(new PlayerMoveToSun(), this);
               getLogger().info(ChatColor.GREEN + "Successfully registered listeners!");
               getLogger().info(ChatColor.GREEN + "NoSunlight Plugin has been enabled!");
               getLogger().info(ChatColor.GOLD + "           Made by Java             ");
           }
           
           @Override
           public void onDisable() {
               getLogger().info(ChatColor.RED + "Deregistering listeners...");
               HandlerList.unregisterAll();
               getLogger().info(ChatColor.RED + "Listeners have been deregistered.");
               getLogger().info(ChatColor.DARK_RED + "NoSunlight Plugin has been disabled!");
           }
           @Override
           public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
               if(cmd.getName().equalsIgnoreCase("nosunlight")) {
                   if(args.length > 0) {
                        if(args[0].equalsIgnoreCase("info")) {
                         sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "]==========" + ChatColor.GOLD + "Info" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "==========[");
                         sender.sendMessage(ChatColor.GREEN + "You are not allowed to be in direct sunlight with this plugin enabled, this means, if your light level is at 15 (Direct Sunlight), you will die.");
                         sender.sendMessage(ChatColor.GREEN + "This includes Glass blocks and other transparent blocks.");
                         sender.sendMessage(ChatColor.RED + "  This plugin was made by Java/Calorious.");
                         return true;
                   }
                        if(args[0].equalsIgnoreCase("toggle")) {
                            if(PlayerMoveToSun.enabled) {
                                PlayerMoveToSun.enabled = false;
                                sender.sendMessage(ChatColor.RED + "NoSunlight plugin has been disabled.");
                            } else {
                                PlayerMoveToSun.enabled = true;
                                sender.sendMessage(ChatColor.GREEN + "NoSunlight plugin has been enabled.");
                            }
                            return true;
                        }
                   }
                   if(args.length == 0) {
                       sender.sendMessage(ChatColor.GREEN + "NoSunlight");
                       sender.sendMessage(ChatColor.DARK_GRAY + "==========");
                       sender.sendMessage(ChatColor.GOLD + "/nosunlight toggle - Enable/Disable the plugin");
                       sender.sendMessage(ChatColor.GOLD + "/nosunlight info - Information on the plugin");
                       return true;
               }
           }
            return true;
    }
    }
     

    My event class:
    Code (Java):


    package com.gmail.calorious.Java;

    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    @SuppressWarnings("unused")
    public class PlayerMoveToSun implements Listener {
          public static boolean enabled = true;
               @EventHandler
               public void onPlayerMove(PlayerMoveEvent e) {
                   Player player = e.getPlayer();
                   if (e.getFrom().getBlockX() == e.getTo().getBlockX() && e.getFrom().getBlockZ() == e.getTo().getBlockZ()) return;
                   if(enabled) {
                       
                       Location PlayerLoc = player.getLocation();
                       Block PlayerLocBlock = PlayerLoc.getBlock();
                       if(PlayerLoc.clone().subtract(0, 1, 0).getBlock().getLightFromSky() == 15) {
                           if(Main.getInstance().getConfig().getInt("deathmethod") == 1) {
                               player.setHealth(0);
                           }
                           if(Main.getInstance().getConfig().getInt("deathmethod") == 0) {
                               player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 1200, 10));
                           }
                       }
                   }
               }
    }

     
    I'm getting an error constantly at the if(Main.getInstance().getConfig().getInt("deathmethod")) places.

    This is the error:
    Code (Text):


    [00:15:30 ERROR]: Could not pass event PlayerMoveEvent to NoSunlight v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:270) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_241]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_241]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
    Caused by: java.lang.NullPointerException
            at com.gmail.calorious.Java.PlayerMoveToSun.onPlayerMove(PlayerMoveToSun.java:24) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_241]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_241]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_241]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            ... 15 more
    [00:15:30 ERROR]: Could not pass event PlayerMoveEvent to NoSunlight v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:270) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_241]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_241]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
    Caused by: java.lang.NullPointerException
            at com.gmail.calorious.Java.PlayerMoveToSun.onPlayerMove(PlayerMoveToSun.java:24) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_241]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_241]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_241]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            ... 15 more
     
     
  18. Strahan

    Benefactor

    You never gave instance a value in the main class, it's null. This couldn't happen with dependency injection :)
     
  19. WoT iS dependency injection
    upload_2020-2-1_1-12-36.png
    This isn't English. I still don't understand after examples :(
     
  20. Strahan

    Benefactor

    See example prior. To fix your current code, just give instance a value; i.e. set it to "this" in onEnable.