Help! My plugin isn't working.

Discussion in 'Plugin Development' started by Xp10d3, Dec 3, 2019.

  1. Offline

    Xp10d3

    Hello everyone. I'm having a lot of trouble with my economy plugin.
    Here's my code:
    https://hastebin.com/dagadicefu.cs

    Every time I try to right click a gold nugget or do anything related to the plugin, I get spammed with the message:
    "You don't have enough gold to do this action! Please get more."
    Even though I set my gold to 400 or like 10 or something, yet every time I try to do something in the GUI or do anything related to my plugin I get spammed. I am also having trouble with my depositing feature. I can't seem to deposit anything, and my config just gets messed up. When I set it to something it immediately goes to 0.0006658237 or something weird like that AND messes up two other player's values to 0.343947 and 9.93473 or whatever. I have NO CLUE how to fix this. I have deduced that it's from these two methods:

    Code:
        @EventHandler
        public void onGoldenAppleClick(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            player.closeInventory();
            if ((event.getCurrentItem().getType() == Material.GOLDEN_APPLE) && event.getRawSlot() < event.getInventory().getSize()) {
                player.openInventory(shopGUI(player));
            } else if ((event.getCurrentItem().getType() == null)) {
                return;
            } else {
                player.sendMessage(ChatColor.RED + "You don't have enough gold to do this action! Please get more.");
                player.closeInventory();
            }
        }
    
    That's the shop method. It doesn't work either (nothing seems to work for some reason) but whenever I click the gold ore in the GUI, it immediately spams me about three times then goes to the shop screen where I can't do anything.

    It could also be from here:

    Code:
        @EventHandler
        public void deposit(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
           
            ItemStack goldItem = new ItemStack(Material.GOLD_INGOT);
           
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
            if ((event.getCurrentItem().getType() == Material.GOLD_ORE) && event.getRawSlot() < event.getInventory().getSize()) {
                if (player.getInventory().contains(goldItem, 1)) {
                    player.getInventory().remove(goldItem);
                    this.getConfig().set("path.to.gold" + player.getUniqueId().toString(), gold + 1);
                    saveConfig();
                } else if ((event.getCurrentItem().getType() == null)){
                    return;
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have any gold!");
                }
            } else if ((event.getCurrentItem().getType() == null)) {
                return;
            }
        }
    
    That's the deposit method where it just spams me and is linked to the shop method for whatever reason. I really need help; it's bugging me a lot.
    Thanks.
    -Xp10d3
     
  2. Offline

    yPedx

    @Xp10d3
    It's unsafe to open another inventory on InventoryClickEvent, open it a tick later using a runnable. In the same event (in the first code snippet) you're also closing the inventory twice.
     
  3. Offline

    Xp10d3

    Ohhhhhh I see. Thanks I didn't notice that :) By using a runnable are you referring to:

    Code:
        private JavaPlugin parent;
       
        @EventHandler
        public void onGoldenAppleClick(InventoryClickEvent event) {
           
            Player player = (Player) event.getWhoClicked();
            player.closeInventory();
            if ((event.getCurrentItem().getType() == Material.GOLDEN_APPLE) && event.getRawSlot() < event.getInventory().getSize()) {
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        player.openInventory(shopGUI(player));
                    }
                }.runTaskLater(parent, 1);
            } else if ((event.getCurrentItem().getType() == null)) {
                return;
            }
        }
    
    Should I put it in my onEnable()?
     
    Last edited: Dec 4, 2019 at 9:35 AM
  4. Offline

    caderapee

    @Xp10d3 The type of an item cannot be null, it's AIR or something.

    You should rethink about how to perform your event. You got like 10 methods from inventoryClickEvent, 10 calls. With 0 gold, u will have 10x the message in one click.

    Be sure of the path in the config file.
     
  5. Offline

    Xp10d3

    Still isn't working... I've made all those changes (except for cleaning up my code which I will do after it starts working again hopefully) and it just resets all my gold to what it was BEFORE the restart even though I manually changed it in the config file. I am super frustrated cause I don't know how to fix it. All my config paths and anything related to the config is exactly the same except for changing the value of -1 to 1 or -1 to 0.5 etc.

    Updated Code:

    Hastebin: https://hastebin.com/etonuruzuc.cs
    Sourceb.in: https://sourceb.in/40c757f575

    Pasted Code:

    Code:
    package xp10d3.corelia.main;
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.Sound;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.InvalidConfigurationException;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;
    import net.md_5.bungee.api.ChatColor;
    /*
     Helpful stuff:
     https://www.spigotmc.org/wiki/connecting-to-databases-mysql/#getting-data
     https://dev.mysql.com/downloads/connector/j/
     https://www.spigotmc.org/threads/saving-player-data-to-a-config-file.232790/
     https://bukkit.org/threads/storing-player-data.168636/
     https://www.spigotmc.org/threads/config-adddefault.357226/
     https://www.spigotmc.org/wiki/config-files/
     https://www.spigotmc.org/threads/creating-config-file.246894/
     https://www.spigotmc.org/wiki/creating-a-config-file/
     https://www.spigotmc.org/threads/create-a-database.357617/
     https://www.spigotmc.org/threads/storing-data.226211/#post-2307586
    */
    public class Core extends JavaPlugin implements Listener {
       
        private static Core instance;
       
        FileConfiguration config = getConfig();
       
        private File customConfigFile;
        private FileConfiguration customConfig;
       
        @Override
        public void onEnable() {
            createCustomConfig();
            Commands cmd = new Commands();
            getCommand("gold").setExecutor(cmd);
            getServer().getPluginManager().registerEvents(this, this);   
        }
       
        @Override
        public void onDisable() {
            saveConfig();
        }
       
        public static Core getInstance() {
            return instance;
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args) {
            if (cmd.getName().equalsIgnoreCase("nugget")) {
                if (sender instanceof Player) {
                    Player player = (Player) sender;
                    final ItemStack nugget = new ItemStack(Material.GOLD_NUGGET);
                    final ItemMeta nuggetMeta = nugget.getItemMeta();
                    ArrayList<String> nuggetLore = new ArrayList<>();
                    nuggetLore.add("Right Click to display your balance.");
                    nuggetLore.add("You get more money for every kill you get.");
                    nuggetMeta.setLore(nuggetLore);
                   
                    nuggetMeta.setDisplayName(ChatColor.GOLD + "Balance");
                    nugget.setItemMeta(nuggetMeta);
                   
                    player.getInventory().addItem(new ItemStack(Material.GOLD_NUGGET));
                }
            }
            return false;
        }
       
        public FileConfiguration getCustomConfig() {
            return this.customConfig;
        }
       
        private void createCustomConfig() {
            customConfigFile = new File(getDataFolder(), "kills.yml");
            if (!customConfigFile.exists()) {
                customConfigFile.getParentFile().mkdirs();
                saveResource("kills.yml", false);
                getConfig().options().copyDefaults(true);
                saveDefaultConfig();
             }
            customConfig = new YamlConfiguration();
            try {
                customConfig.load(customConfigFile);
            } catch (IOException | InvalidConfigurationException e) {
                e.printStackTrace();
            }
        }
       
        @EventHandler
        public void onDeath(PlayerDeathEvent e) {
            Player p = e.getEntity();
            Player k = p.getKiller();
            int amount = customConfig.getInt("path.to.kills" + k.getUniqueId().toString());
            customConfig.set("path.to.kills" + k.getUniqueId().toString(), amount + 1);
            saveConfig();
            double gold = config.getDouble("path.to.gold" + k.getUniqueId().toString());
            this.getConfig().set("path.to.gold" + k.getUniqueId().toString(), gold + 0.5);
            saveConfig();
           
            final ItemStack nugget = new ItemStack(Material.GOLD_NUGGET);
            final ItemMeta nuggetMeta = nugget.getItemMeta();
            ArrayList<String> nuggetLore = new ArrayList<>();
            nuggetLore.add("Right Click to display your balance.");
            nuggetLore.add("You get more money for every kill you get.");
            nuggetMeta.setLore(nuggetLore);
           
            nuggetMeta.setDisplayName(ChatColor.GOLD + "Balance");
            nugget.setItemMeta(nuggetMeta);
           
            p.getInventory().addItem(new ItemStack(Material.GOLD_NUGGET));
           
            k.sendMessage("You have gotten one gold for killing " + p + ".");
        }
       
        public Inventory goldGUI(Player player) {
           
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
           
            final Inventory inventory = Bukkit.createInventory(null, 9, ChatColor.GOLD + "Balance");
            final ItemStack balance = new ItemStack(Material.GOLD_BLOCK);
            final ItemMeta balanceMeta = balance.getItemMeta();
            final ItemStack close = new ItemStack(Material.RED_STAINED_GLASS_PANE);
            final ItemMeta closeMeta = close.getItemMeta();
            final ItemStack withdraw = new ItemStack(Material.GOLDEN_SHOVEL);
            final ItemMeta withdrawMeta = withdraw.getItemMeta();
            final ItemStack deposit = new ItemStack(Material.GOLD_ORE);
            final ItemMeta depositMeta = deposit.getItemMeta();
            final ItemStack shop = new ItemStack(Material.GOLDEN_APPLE);
            final ItemMeta shopMeta = shop.getItemMeta();
           
            ArrayList<String> balanceLore = new ArrayList<>();
            balanceLore.add(ChatColor.LIGHT_PURPLE + "Your balance is: " + gold + " gold.");
            balanceMeta.setLore(balanceLore);
            ArrayList<String> withdrawLore = new ArrayList<>();
            withdrawLore.add(ChatColor.LIGHT_PURPLE + "Click to withdraw gold from your balance.");
            withdrawMeta.setLore(withdrawLore);
            ArrayList<String> depositLore = new ArrayList<>();
            depositLore.add(ChatColor.LIGHT_PURPLE + "Click to deposit gold.");
            depositMeta.setLore(depositLore);
            ArrayList<String> shopLore = new ArrayList<>();
            shopLore.add(ChatColor.LIGHT_PURPLE + "Click to shop for other items!");
            shopMeta.setLore(shopLore);
           
            balanceMeta.setDisplayName(ChatColor.WHITE + player.getName() + "'s Balance");
            balance.setItemMeta(balanceMeta);
            closeMeta.setDisplayName(ChatColor.DARK_RED + "Close");
            close.setItemMeta(closeMeta);
            withdrawMeta.setDisplayName(ChatColor.RED + "Withdraw");
            withdraw.setItemMeta(withdrawMeta);
            depositMeta.setDisplayName(ChatColor.GREEN + "Deposit");
            deposit.setItemMeta(depositMeta);
            shopMeta.setDisplayName(ChatColor.GOLD + "Shop");
           
            inventory.setItem(4, balance);
            inventory.setItem(8, close);
            inventory.setItem(0, withdraw);
            inventory.setItem(7, deposit);
            inventory.setItem(1, shop);
           
            return inventory;
           
        }
       
        @EventHandler
        public void onRightClickGoldNugget(PlayerInteractEvent event) {
            Player player = event.getPlayer();
           
            /*
            ItemMeta meta = (new ItemStack(Material.GOLD_NUGGET)).getItemMeta();
           
            if (meta.getDisplayName() == ChatColor.GOLD + "Balance" && event.getItem() != null && event.getItem().getType() == Material.GOLD_NUGGET && (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.RIGHT_CLICK_AIR))) {
                player.openInventory(goldGUI(player));
            } else if (meta == null || meta.getDisplayName() == null){
                return;
            }
            else {
                player.sendMessage(ChatColor.RED + "Please use the correct gold nugget.");
            }
            */
            if (event.getItem() != null && event.getItem().getType() == Material.GOLD_NUGGET && (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.RIGHT_CLICK_AIR))) {
                player.openInventory(goldGUI(player));
            }
        }
       
        @EventHandler
        public void click(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            if ((event.getCurrentItem().getType() == Material.RED_STAINED_GLASS_PANE) && event.getRawSlot() < event.getInventory().getSize()) {
                player.closeInventory();
            }
        }
        @EventHandler
        public void onJoinBefore(PlayerJoinEvent player) {
            Player p = player.getPlayer();
           
            boolean hasPlayed = p.hasPlayedBefore();
           
            if (!hasPlayed) {
                final ItemStack nugget = new ItemStack(Material.GOLD_NUGGET);
                final ItemMeta nuggetMeta = nugget.getItemMeta();
                ArrayList<String> nuggetLore = new ArrayList<>();
                nuggetLore.add(ChatColor.LIGHT_PURPLE + "Right Click to display your balance.");
                nuggetLore.add(ChatColor.LIGHT_PURPLE + "You get more money for every kill you get.");
                nuggetMeta.setLore(nuggetLore);
               
                nuggetMeta.setDisplayName(ChatColor.GOLD + "Balance");
                nugget.setItemMeta(nuggetMeta);
               
                p.getInventory().addItem(new ItemStack(Material.GOLD_NUGGET));
            }
        }
       
        @EventHandler
        public void onBlockBreak(BlockBreakEvent event) {
            Player player = (Player) event.getPlayer();
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
            this.getConfig().set("path.to.gold" + player.getUniqueId().toString(), gold + 0.05);
            saveConfig();
        }
       
        @EventHandler
        public void onItemPickupGoldBlock(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            if ((event.getCurrentItem().getType() == Material.GOLD_BLOCK) && event.getRawSlot() < event.getInventory().getSize()) {
                event.setCancelled(true);
                player.sendMessage(ChatColor.RED + "Hey! You can't steal that Gold Block. Stop trying!");
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
       
        @EventHandler
        public void onItemPickupGoldShovel(InventoryClickEvent event) {
            if ((event.getCurrentItem().getType() == Material.GOLDEN_SHOVEL) && event.getRawSlot() < event.getInventory().getSize()) {
                event.setCancelled(true);
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
        @EventHandler
        public void onItemPickupGoldenApple(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            World w = player.getWorld();
            if ((event.getCurrentItem().getType() == Material.GOLDEN_APPLE) && event.getRawSlot() < event.getInventory().getSize()) {
                event.setCancelled(true);
                w.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH, 10, 1);
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
       
        @EventHandler
        public void deposit(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
           
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
            if ((event.getCurrentItem().getType() == Material.GOLDEN_APPLE) && event.getRawSlot() < event.getInventory().getSize()) {
                this.getConfig().set("path.to.gold" + player.getUniqueId().toString(), gold - 1);
                saveConfig();
                player.getInventory().removeItem(new ItemStack(Material.GOLD_INGOT));
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
           
        }
       
        @EventHandler
        public void onShovelClick(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
            if (gold >= 1) {
                if ((event.getCurrentItem().getType() == Material.GOLDEN_SHOVEL) && event.getRawSlot() < event.getInventory().getSize()) {
                    this.getConfig().set("path.to.gold" + player.getUniqueId().toString(), gold - 1);
                    saveConfig();
                    player.getInventory().addItem(new ItemStack(Material.GOLD_INGOT));
                } else if ((event.getCurrentItem().getType() == null)) {
                    return;
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have enough gold! Required gold: 1");
                }
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
       
        private JavaPlugin parent;
       
        @EventHandler
        public void onGoldenAppleClick(InventoryClickEvent event) {
           
            Player player = (Player) event.getWhoClicked();
            player.closeInventory();
            if ((event.getCurrentItem().getType() == Material.GOLDEN_APPLE) && event.getRawSlot() < event.getInventory().getSize()) {
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        player.openInventory(shopGUI(player));
                    }
                }.runTaskLater(parent, 1);
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
       
        public Inventory shopGUI(Player player) {
           
            final Inventory inventory = Bukkit.createInventory(null, 9, ChatColor.GOLD + "Shop");
            final ItemStack woodPick = new ItemStack(Material.WOODEN_PICKAXE);
            final ItemMeta woodPickMeta = woodPick.getItemMeta();
            final ItemStack stonePick = new ItemStack(Material.STONE_PICKAXE);
            final ItemMeta stonePickMeta = stonePick.getItemMeta();
            final ItemStack ironPick = new ItemStack(Material.IRON_PICKAXE);
            final ItemMeta ironPickMeta = ironPick.getItemMeta();
            final ItemStack diamondPick = new ItemStack(Material.DIAMOND_PICKAXE);
            final ItemMeta diamondPickMeta = diamondPick.getItemMeta();
           
            ArrayList<String> woodPickLore = new ArrayList<>();
            woodPickLore.add(ChatColor.LIGHT_PURPLE + "This costs 1 gold.");
            woodPickMeta.setLore(woodPickLore);
           
            ArrayList<String> stonePickLore = new ArrayList<>();
            stonePickLore.add(ChatColor.LIGHT_PURPLE + "This costs 5 gold.");
            stonePickMeta.setLore(stonePickLore);
           
            ArrayList<String> ironPickLore = new ArrayList<>();
            ironPickLore.add(ChatColor.LIGHT_PURPLE + "This costs 25 gold.");
            ironPickMeta.setLore(ironPickLore);
           
            ArrayList<String> diamondPickLore = new ArrayList<>();
            diamondPickLore.add(ChatColor.LIGHT_PURPLE + "This costs 50 gold.");
            diamondPickMeta.setLore(diamondPickLore);
           
            woodPick.setItemMeta(woodPickMeta);
            stonePick.setItemMeta(stonePickMeta);
            ironPick.setItemMeta(ironPickMeta);
            diamondPick.setItemMeta(diamondPickMeta);
           
            inventory.setItem(0, woodPick);
            inventory.setItem(1, stonePick);
            inventory.setItem(2, ironPick);
            inventory.setItem(3, diamondPick);
           
            return inventory;
           
        }
       
        @EventHandler
        public void onWoodPickClick(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
            if (gold >= 1) {
                if ((event.getCurrentItem().getType() == Material.WOODEN_PICKAXE) && event.getRawSlot() < event.getInventory().getSize()) {
                    this.getConfig().set("path.to.gold" + player.getUniqueId().toString(), gold - 1);
                    saveConfig();
                    player.getInventory().addItem(new ItemStack(Material.WOODEN_PICKAXE));
                    player.closeInventory();
                } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                    return;
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have enough gold! Required gold: 1");
                }
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
       
        @EventHandler
        public void onStonePickClick(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
            if (gold >= 5) {
                if ((event.getCurrentItem().getType() == Material.STONE_PICKAXE) && event.getRawSlot() < event.getInventory().getSize()) {
                    this.getConfig().set("path.to.gold" + player.getUniqueId().toString(), gold - 5);
                    saveConfig();
                    player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE));
                    player.closeInventory();
                } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                    return;
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have enough gold! Required gold: 5");
                }
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
       
        @EventHandler
        public void onIronPickClick(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
            if (gold >= 25) {
                if ((event.getCurrentItem().getType() == Material.IRON_PICKAXE) && event.getRawSlot() < event.getInventory().getSize()) {
                    this.getConfig().set("path.to.gold" + player.getUniqueId().toString(), gold - 25);
                    saveConfig();
                    player.getInventory().addItem(new ItemStack(Material.IRON_PICKAXE));
                    player.closeInventory();
                } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                    return;
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have enough gold! Required gold: 25");
                }
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
       
        @EventHandler
        public void onDiamondPickClick(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            double gold = config.getDouble("path.to.gold" + player.getUniqueId().toString());
            if (gold >= 50) {
                if ((event.getCurrentItem().getType() == Material.DIAMOND_PICKAXE) && event.getRawSlot() < event.getInventory().getSize()) {
                    this.getConfig().set("path.to.gold" + player.getUniqueId().toString(), gold - 50);
                    saveConfig();
                    player.getInventory().addItem(new ItemStack(Material.DIAMOND_PICKAXE));
                    player.closeInventory();
                } else if ((event.getCurrentItem().getType() == null)) {
                    return;
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have enough gold! Required gold: 50");
                }
            } else if ((event.getCurrentItem().getType() == Material.AIR)) {
                return;
            }
        }
    }
    
    Here is my error if this helps:

    Code:
    > [21:51:08] [Server thread/ERROR]: Could not pass event InventoryClickEvent to EconomyGold v0.1
    org.bukkit.event.EventException: null
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:529) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:514) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.PlayerConnection.a(PlayerConnection.java:2133) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:33) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.TickTask.run(SourceFile:18) [server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.MinecraftServer.aX(MinecraftServer.java:910) [server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.MinecraftServer.executeNext(MinecraftServer.java:903) [server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127) [server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.MinecraftServer.sleepForTick(MinecraftServer.java:887) [server.jar:git-Spigot-9de398a-9c887d4]
    at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:820) [server.jar:git-Spigot-9de398a-9c887d4]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
    Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
    at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.validate(CraftScheduler.java:443) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:176) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:167) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.runTaskLater(CraftScheduler.java:131) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at org.bukkit.scheduler.BukkitRunnable.runTaskLater(BukkitRunnable.java:79) ~[server.jar:git-Spigot-9de398a-9c887d4]
    at xp10d3.corelia.main.Core.onGoldenAppleClick(Core.java:325) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[server.jar:git-Spigot-9de398a-9c887d4]
    ... 17 more
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 4, 2019 at 9:46 PM
  6. Offline

    yPedx

    Yep, and it seems you've done it right. Also, your config will mess up, because when you're setting/getting the gold amount, you are forgetting the last . in front of the player's unique id.
    Your path: path.to.gold
    Fixed path: path to gold.

    TIP: Make some local variables that hold objects you use very often.
     
  7. Offline

    Xp10d3

    Okay! So instead of
    Code:
     config.getDouble("path.to.gold" + player.getUniqueId().toString());
    its
    Code:
    config.getDouble("path.to.gold." + player.getUniqueId().toString());
    ?
     
  8. Offline

    yPedx

    Yep. That is if your config looks similar to this;
    Code:
    path:
      to:
        gold:
            {someRandomUUIDhere}: 42
            {someRandomUUIDhere}: 23
     
  9. Offline

    Xp10d3

    Thank you! I think I figured it all out. Glad I finally got my plugin to work :) Thanks again!
     
  10. Offline

    Strahan

    Glad to hear you got it working, but I hope you don't really have your config setup like that. It won't hurt anything, but it's janky. The hierarchical nature of YAML is for division of data by proper classification, so having an English sentence hierarchy is a little weird heh.
     

Share This Page