Error MySQL on 1.9+

Discussion in 'Plugin Development' started by OmniShadox, Jul 14, 2016.

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

    OmniShadox

    Hi, I'm currently developing a plugin where I use MySql, and the problem is that when I updated the server to 1.9 and 1.10, all worked perfectly except MySQL. It is supposed to send player's a message when they join that tells them how many money they have, but it doesn't send it.

    The error in console:
    Code:
    UUID of player OmniShadox is 0021415e-472d-40ef-871a-9754360d3868
    [15:06:52] [Server thread/WARN]: java.lang.NullPointerException
    [15:06:52] [Server thread/WARN]:     at server.infinitykingdom.sql.SQL.containsPlayer(SQL.java:38)
    [15:06:52] [Server thread/WARN]:     at server.infinitykingdom.lobby.PlayerJoin.onPlayerJoin(PlayerJoin.java:40)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [15:06:52] [Server thread/WARN]:     at java.lang.reflect.Method.invoke(Method.java:498)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.PlayerList.onPlayerJoin(PlayerList.java:333)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.PlayerList.a(PlayerList.java:159)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.LoginListener.b(LoginListener.java:144)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.LoginListener.E_(LoginListener.java:54)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.NetworkManager.a(NetworkManager.java:233)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.ServerConnection.c(ServerConnection.java:140)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:832)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:399)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:673)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:572)
    [15:06:52] [Server thread/WARN]:     at java.lang.Thread.run(Thread.java:745)
    [15:06:52] [Server thread/WARN]: java.lang.NullPointerException
    [15:06:52] [Server thread/WARN]:     at server.infinitykingdom.sql.SQL.containsPlayer(SQL.java:38)
    [15:06:52] [Server thread/WARN]:     at server.infinitykingdom.sql.SQL.createAccount(SQL.java:53)
    [15:06:52] [Server thread/WARN]:     at server.infinitykingdom.lobby.PlayerJoin.onPlayerJoin(PlayerJoin.java:42)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [15:06:52] [Server thread/WARN]:     at java.lang.reflect.Method.invoke(Method.java:498)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.PlayerList.onPlayerJoin(PlayerList.java:333)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.PlayerList.a(PlayerList.java:159)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.LoginListener.b(LoginListener.java:144)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.LoginListener.E_(LoginListener.java:54)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.NetworkManager.a(NetworkManager.java:233)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.ServerConnection.c(ServerConnection.java:140)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:832)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:399)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:673)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:572)
    [15:06:52] [Server thread/WARN]:     at java.lang.Thread.run(Thread.java:745)
    [15:06:52] [Server thread/WARN]: java.lang.NullPointerException
    [15:06:52] [Server thread/WARN]:     at server.infinitykingdom.sql.SQL.createAccount(SQL.java:54)
    [15:06:52] [Server thread/WARN]:     at server.infinitykingdom.lobby.PlayerJoin.onPlayerJoin(PlayerJoin.java:42)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [15:06:52] [Server thread/WARN]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [15:06:52] [Server thread/WARN]:     at java.lang.reflect.Method.invoke(Method.java:498)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
    [15:06:52] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.PlayerList.onPlayerJoin(PlayerList.java:333)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.PlayerList.a(PlayerList.java:159)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.LoginListener.b(LoginListener.java:144)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.LoginListener.E_(LoginListener.java:54)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.NetworkManager.a(NetworkManager.java:233)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.ServerConnection.c(ServerConnection.java:140)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:832)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:399)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:673)
    [15:06:52] [Server thread/WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:572)
    [15:06:52] [Server thread/WARN]:     at java.lang.Thread.run(Thread.java:745)
    [15:06:52] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to InfinityKingdom vDevBuild_2016--07-07-01
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.PlayerList.onPlayerJoin(PlayerList.java:333) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.PlayerList.a(PlayerList.java:159) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.LoginListener.b(LoginListener.java:144) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.LoginListener.E_(LoginListener.java:54) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.NetworkManager.a(NetworkManager.java:233) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.ServerConnection.c(ServerConnection.java:140) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:832) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:673) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:572) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_92]
    Caused by: java.lang.NullPointerException
        at server.infinitykingdom.sql.SQL.setMoney(SQL.java:120) ~[?:?]
        at server.infinitykingdom.lobby.PlayerJoin.onPlayerJoin(PlayerJoin.java:46) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_92]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_92]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_92]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_92]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        ... 14 more
    [15:06:52] [Server thread/INFO]: OmniShadox[/95.63.117.115:63188] logged in with entity id 536743 at ([lobby]1.0, 5.0, 0.0)
    [15:07:01] [Server thread/INFO]: OmniShadox issued server command: /gamemode 1
    [15:07:01] [Server thread/INFO]: [OmniShadox: Set own game mode to Creative Mode]
    [15:07:04] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to InfinityKingdom vDevBuild_2016--07-07-01
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at org.bukkit.craftbukkit.v1_10_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:231) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.PlayerInteractManager.a(PlayerInteractManager.java:492) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:890) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.PacketPlayInUseItem.a(SourceFile:55) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.PacketPlayInUseItem.a(SourceFile:11) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_92]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_92]
        at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:737) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:673) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:572) [spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_92]
    Caused by: java.lang.NullPointerException
        at server.infinitykingdom.lobby.ItemListener.onPlayerInteract(ItemListener.java:28) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_92]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_92]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-latest.jar:git-Spigot-a9631d2-67b2424]
        ... 17 more
    SQL.java:
    Code:
    public class SQL {
    
        private static Connection con;
    
        public static void closeConnection() {
            try {
                if (con != null && !con.isClosed()) {
                    con.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
        public static synchronized void openConnection() {
            try {
                con = DriverManager.getConnection("jdbc:mysql://" + SQLD.host + ":" + SQLD.port + "/"
                        + SQLD.db + "?user=" + SQLD.user + "&password=" + SQLD.pw
                        + "&autoReconnect=true");
                con.createStatement().execute("CREATE TABLE IF NOT EXISTS Users (UUID TEXT, Money INT, Level INT, Rank TEXT)");
                System.out.println("Successfully connected to MySQL Database!");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public static synchronized boolean containsPlayer(Player p) {
            try {
                PreparedStatement sql = con.prepareStatement("SELECT * FROM Users WHERE UUID=?;");
                sql.setString(1, p.getUniqueId().toString());
                ResultSet rs = sql.executeQuery();
                boolean contains = rs.next();
                sql.close();
                rs.close();
                return contains;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }
    
        public static void createAccount(Player p) {
            try {
                if (!containsPlayer(p)) {
                    PreparedStatement newPlayer = con.prepareStatement("INSERT INTO Users VALUES (?, '0', '0', ?);");
                    newPlayer.setString(1, p.getUniqueId().toString());
    
                    if(p.hasPermission("admin.rank")) {
                        newPlayer.setString(2, "Admin");
                    } else {
                        newPlayer.setString(2, "Recruit");
                    }
    
                    newPlayer.execute();
                    newPlayer.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public static Integer getMoney(Player p) {
            if (containsPlayer(p) == true) {
                Integer coins = 0;
                try {
                    PreparedStatement sql = con.prepareStatement("SELECT Money FROM Users WHERE UUID=?;");
                    sql.setString(1, p.getUniqueId().toString());
                    ResultSet result = sql.executeQuery();
                    result.next();
                    coins = result.getInt("Money");
                    sql.close();
                    result.close();
                    return coins;
                } catch (SQLException e) {
                    e.printStackTrace();
                    return 0;
                }
            }
            return null;
        }
    
        public static void addMoney(Player p, Integer amount) {
            try {
                Integer x = getMoney(p);
                PreparedStatement coinsUpdate = con.prepareStatement("UPDATE Users SET Money=? WHERE UUID=?;");
                coinsUpdate.setInt(1, x + amount);
                coinsUpdate.setString(2, p.getUniqueId().toString());
                coinsUpdate.executeUpdate();
                coinsUpdate.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
        public static void removeMoney(Player p, Integer amount) {
            try {
                Integer x = getMoney(p);
                PreparedStatement coinsUpdate = con.prepareStatement("UPDATE Users SET Money=? WHERE UUID=?;");
                coinsUpdate.setInt(1, x - amount);
                coinsUpdate.setString(2, p.getUniqueId().toString());
                coinsUpdate.executeUpdate();
                coinsUpdate.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
        public static void setMoney(Player p, Integer value) {
    
            try {
                PreparedStatement coinsUpdate = con.prepareStatement("UPDATE Users SET Money=? WHERE UUID=?;");
                coinsUpdate.setInt(1, value);
                coinsUpdate.setString(2, p.getUniqueId().toString());
                coinsUpdate.executeUpdate();
                coinsUpdate.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
        public static String getRank(Player p) {
            if (containsPlayer(p) == true) {
                String rank = "Recruit";
                try {
                    PreparedStatement sql = con.prepareStatement("SELECT Rank FROM Users WHERE UUID=?;");
                    sql.setString(1, p.getUniqueId().toString());
                    ResultSet result = sql.executeQuery();
                    result.next();
                    rank = result.getString("Rank");
                    sql.close();
                    result.close();
                    return rank;
                } catch (SQLException e) {
                    e.printStackTrace();
                    return "Recruit";
                }
            }
            return null;
        }
    
        public static void setRank(Player p, String rank) {
            try {
                PreparedStatement coinsUpdate = con.prepareStatement("UPDATE Users SET Rank=? WHERE UUID=?;");
                coinsUpdate.setString(1, rank);
                coinsUpdate.setString(2, p.getUniqueId().toString());
                coinsUpdate.executeUpdate();
                coinsUpdate.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
        public static Integer getLevel(Player p) {
            if (containsPlayer(p) == true) {
                Integer level = 0;
                try {
                    PreparedStatement sql = con.prepareStatement("SELECT Level FROM Users WHERE UUID=?;");
                    sql.setString(1, p.getUniqueId().toString());
                    ResultSet result = sql.executeQuery();
                    result.next();
                    level = result.getInt("Level");
                    sql.close();
                    result.close();
                    return level;
                } catch (SQLException e) {
                    e.printStackTrace();
                    return 0;
                }
            }
            return null;
        }
    
        public static void setLevel(Player p, Integer value) {
            try {
                PreparedStatement coinsUpdate = con.prepareStatement("UPDATE Users SET Level=? WHERE UUID=?;");
                coinsUpdate.setInt(1, value);
                coinsUpdate.setString(2, p.getUniqueId().toString());
                coinsUpdate.executeUpdate();
                coinsUpdate.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    
    PlayerJoin.java:
    Code:
    public class PlayerJoin implements Listener {
    
        public PlayerJoin(Core core) {
    
        }
    
        @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerJoin(PlayerJoinEvent e) {
    
            e.setJoinMessage(ChatColor.WHITE + e.getPlayer().getName() + ChatColor.GOLD + " has joined the server!");
            e.getPlayer().getInventory().clear();
            LobbyItems.loadLobbyItems(e.getPlayer());
    
            if(e.getPlayer().hasPermission("admin.name")) {
    
                e.getPlayer().setDisplayName(ChatColor.MAGIC + "1" + ChatColor.GOLD + e.getPlayer().getName() + ChatColor.WHITE +
                        ChatColor.MAGIC.toString() +  "1");
                e.getPlayer().setPlayerListName(ChatColor.MAGIC + "1" + ChatColor.GOLD + e.getPlayer().getName() + ChatColor.WHITE +
                        ChatColor.MAGIC.toString() +  "1");
            }
    
            e.getPlayer().teleport(Bukkit.getWorld("lobby").getSpawnLocation());
    
            if(SQL.containsPlayer(e.getPlayer()) == false) {
    
                SQL.createAccount(e.getPlayer());
    
                if(e.getPlayer().hasPermission("admin.money")) {
    
                    SQL.setMoney(e.getPlayer(), 100000);
                    e.getPlayer().sendMessage("You have got currently " + ChatColor.GREEN + ChatColor.BOLD + "∞$" + ChatColor.WHITE + " on your account!");
    
                }
    
            } else {
    
                if(e.getPlayer().hasPermission("admin.money")) {
    
                    SQL.setMoney(e.getPlayer(), 100000);
                    e.getPlayer().sendMessage("You have got currently " + ChatColor.GREEN + "∞$" + ChatColor.WHITE + " on your account!");
    
                } else {
    
                    e.getPlayer().sendMessage("You have got currently " + ChatColor.GREEN + SQL.getMoney(e.getPlayer()) + "$" +
                            ChatColor.WHITE + " on your account!");
    
                }
    
            }
    
        }
    
    }
    And Core.java:
    Code:
    public class Core extends JavaPlugin {
    
        private static Core instance;
        File homeLocationsFile;
        public static FileConfiguration homeLocations;
        public static HomeManager hm;
        File inventoriesFile;
        public static FileConfiguration inventories;
        public static InventoryManager im;
        File friendsFile;
        public static FileConfiguration friends;
        public static FriendManager fm;
    
        @Override
        public void onEnable() {
            getLogger().info("Infinity Kingdom v" + getDescription().getVersion() + " has been enabled!");
            listeners();
    
            homeLocationsFile = new File(getDataFolder(), "homeLocations.yml");
            homeLocations = YamlConfiguration.loadConfiguration(homeLocationsFile);
            hm = new HomeManager(homeLocations);
    
            inventoriesFile = new File(getDataFolder(), "inventories.yml");
            inventories = YamlConfiguration.loadConfiguration(inventoriesFile);
            im = new InventoryManager(inventories);
    
            friendsFile = new File(getDataFolder(), "friends.yml");
            friends = YamlConfiguration.loadConfiguration(friendsFile);
            fm = new FriendManager(friends);
    
            if(Bukkit.getWorld("lobby") == null) {
                WorldCreator wc = new WorldCreator("lobby");
                wc.type(WorldType.FLAT);
                wc.createWorld();
            }
    
            if(Bukkit.getWorld("survival") == null) {
                WorldCreator wc = new WorldCreator("survival");
                wc.environment(World.Environment.NORMAL);
                wc.createWorld();
            }
    
            getCommand("lobby").setExecutor(new LobbyCommand());
            getCommand("burbank").setExecutor(new BurbankCommand());
            getCommand("home").setExecutor(new HomeCommand());
            getCommand("survival").setExecutor(new SurvivalCommand());
            getCommand("friends").setExecutor(new FriendCommand());
    
            SQL.openConnection();
            saveLocationsConfig();
            saveInventoriesConfig();
            saveFriendsConfig();
            hm.loadLocations();
            im.loadInventories();
            fm.loadFriends();
    
            CooldownManager.cooldowns = new HashMap<UUID, Integer>();
    
            instance = this;
    
        }
    
        @Override
        public void onDisable() {
    
            getLogger().info("Infinity Kingdom v" + getDescription().getVersion() + " has been disabled!");
            instance = null;
            hm.saveLocations();
            im.saveInventories();
            fm.saveFriends();
            saveLocationsConfig();
            saveInventoriesConfig();
            saveFriendsConfig();
    
            SQL.closeConnection();
        }
    
        private void listeners() {
            getServer().getPluginManager().registerEvents(new PlayerJoin(this), this);
            getServer().getPluginManager().registerEvents(new PlayerLeave(this), this);
            getServer().getPluginManager().registerEvents(new ItemListener(this), this);
            getServer().getPluginManager().registerEvents(new MenuListener(this), this);
            getServer().getPluginManager().registerEvents(new PlayerChat(this), this);
        }
    
        public void saveLocationsConfig(){
    
            try {
                homeLocations.save(homeLocationsFile);
            } catch(Exception e) {
    
            }
    
        }
    
        public void saveInventoriesConfig(){
    
            try {
                inventories.save(inventoriesFile);
            } catch(Exception e) {
    
            }
    
        }
    
        public void saveFriendsConfig(){
    
            try {
                friends.save(friendsFile);
            } catch(Exception e) {
    
            }
    
        }
    
        public static Core getInstance() {
            return instance;
        }
    
        public static Player getPlayerById(String UUID) {
            for(Player p : Bukkit.getOnlinePlayers()) {
                if(p.getUniqueId().toString() == UUID.toString()) {
                    return p;
                }
            }
            return null;
        }
    
    }
     
  2. Something in the method containsPlayer(..) is null on line 38. I don't know where exactly because you didn't show the whole class from the start
     
  3. Offline

    hexaan

    @OmniShadox

    Do you ever call openConnection() before calling containsPlayer()? If you are I'm guessing something is going wrong in your openConnection() method.

    Btw you are abusing static way too much. I think this will increase your chance of getting more null pointers or other errors later on.
     
  4. Offline

    OmniShadox

    @hexaan

    Ok, so I fixed all the static methods. For the openConnection method, I have a problem. I start it in onEnable beacouse I have to, and I can't seem to find where's the problem in the method.
     
    Last edited: Jul 16, 2016
  5. Offline

    OmniShadox

Thread Status:
Not open for further replies.

Share This Page