Plugin  Résolu Problème SQL

Discussion dans 'Support serveur et plugins' créé par IceOrange92, 27 Octobre 2018.

  1. ShE3py

    ShE3py Développeur en autodidacte

    Inscrit:
    26 Septembre 2015
    Messages:
    978
    J'aime reçus:
    163
    Tu appelles bien sql.connection() ? Car le NPE n'a pas lieu d'être.
     
  2. IceOrange92

    IceOrange92 Mineur de diamant

    Inscrit:
    7 Décembre 2017
    Messages:
    24
    J'aime reçus:
    2
    Re-bonjour,

    Oui, je l'appelle dans la classe principal.

    Code:
    package eu.heroria.iceorange92;
    
    import java.util.HashMap;
    import java.util.Map;
    import java.util.UUID;
    
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerKickEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.permissions.PermissionAttachment;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import eu.heroria.iceorange92.Npc.NpcListener;
    import eu.heroria.iceorange92.data.Rank;
    import eu.heroria.iceorange92.data.PlayerData;
    import eu.heroria.iceorange92.data.PlayerDataManager;
    import eu.heroria.iceorange92.data.PlayerXpManager;
    import eu.heroria.iceorange92.data.SqlConnection;
    
    public class Main extends JavaPlugin implements Listener {
        public SqlConnection sql;
        public PlayerDataManager dataManager = new PlayerDataManager(this);
        public Map<Player, PlayerData> dataPlayers = new HashMap<>();
        public Map<UUID, PermissionAttachment> playerPermission = new HashMap<>();
        
        
        public void onEnable() {
            sql = new SqlConnection(this, "jdbc:mysql://", "localhost", "heroria", "root", "");
            sql.connection();
            getServer().getPluginManager().registerEvents(new PlayerXpManager(this), this);
            getServer().getPluginManager().registerEvents(new NpcListener(this), this);
            getServer().getPluginManager().registerEvents(this, this);
        }
        
        public void onDisable() {
            for (Player all : Bukkit.getServer().getOnlinePlayers()){
                all.kickPlayer(Bukkit.getShutdownMessage());
            }
            sql.disconnect();
        }
        
        @EventHandler
        public void onJoin(PlayerJoinEvent event) {
            Player player = (Player)event.getPlayer();
            sql.createAccount(player);
            dataManager.loadPlayerData(player);
        }
        
        @EventHandler
        public void onQuit(PlayerQuitEvent event) {
            Player player = (Player)event.getPlayer();
            dataManager.savePlayerData(player);
        }
        
        @EventHandler
        public void onKick(PlayerKickEvent event) {
            Player player = (Player)event.getPlayer();
            dataManager.savePlayerData(player);
        }
        
        public void setupPermissions(Player player) {
            PermissionAttachment attachment = player.addAttachment(this);
            this.playerPermission.put(player.getUniqueId(), attachment);
            permissionSetter(player, player.getUniqueId());
        }
    
        private void permissionSetter(Player player, UUID uuid) {
            PermissionAttachment attachment = this.playerPermission.get(uuid);
            Rank rank = sql.getRank(player);
            switch(rank) {
                case VIP:
                    attachment.setPermission("minecraft.command.me", true);
                    break;
                case MODO:
                    attachment.setPermission("minecraft.command.kill", true);
                    break;
                
                case CM:
                    attachment.setPermission("minecraft.command.*", true);
                    attachment.setPermission("worldedit.selection.pos", true);
                    attachment.setPermission("worldedit.*", true);
                    break;
                    
                case DEV:
                    attachment.setPermission("worldedit.*", true);
                    attachment.setPermission("minecraft.command.*", true);
                    attachment.setPermission("worldguard.*", true);
                    attachment.setPermission("bukkit.command.restart", true);
                    break;
                    
                case ADMIN:
                    attachment.setPermission("*", true);
                    break;
                    
                default:
                    attachment.setPermission("admintools.player", true);
                    break;
            
            }
        }
    }
    
    
     
  3. Detobel36

    Detobel36 Créateur de plugins (PhoenixRebirth)
    Support

    Inscrit:
    17 Août 2012
    Messages:
    9 165
    J'aime reçus:
    1 938
    Salut,

    Si tu n'as pas touché à la class SqlConnection et que l'erreur est toujours la même. A savoir que l'erreur se trouve à la ligne 83, alors cela veut dire que le soucis est ici:
    PHP:
                PreparedStatement q connection.prepareStatement("SELECT uuid FROM players WHERE uuid = ?");
                
    q.setString(1player.getUniqueId().toString());
                
    ResultSet resultat q.executeQuery();
                
    boolean hasAccount resultat.next();
                
    q.close();
                return 
    hasAccount;
    L'erreur serait donc au "q.close()". Ce qui n'a pas beaucoup de sens vu que tu as utilisé avant déjà la variable "q". Je t'invite à vérifier si l'erreur n'a pas changée et/ou si tu as modifié ta class. Si tel est le cas, il faut nous reposter les deux pour que nous puissions correctement t'aider.


    Cordialement,
    Detobel36
     
    ShE3py et DiscowZombie aiment ça.
  4. IceOrange92

    IceOrange92 Mineur de diamant

    Inscrit:
    7 Décembre 2017
    Messages:
    24
    J'aime reçus:
    2
    Bonjour,

    Je vous reposte le code de SQLConnection.java et Main.java ainsi que mes derniers logs.

    Main.java
    Code:
    package eu.heroria.iceorange92;
    
    import java.util.HashMap;
    import java.util.Map;
    import java.util.UUID;
    
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerKickEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.permissions.PermissionAttachment;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import eu.heroria.iceorange92.Npc.NpcListener;
    import eu.heroria.iceorange92.data.Rank;
    import eu.heroria.iceorange92.data.PlayerData;
    import eu.heroria.iceorange92.data.PlayerDataManager;
    import eu.heroria.iceorange92.data.PlayerXpManager;
    import eu.heroria.iceorange92.data.SqlConnection;
    
    public class Main extends JavaPlugin implements Listener {
        public SqlConnection sql;
        public PlayerDataManager dataManager = new PlayerDataManager(this);
        public Map<Player, PlayerData> dataPlayers = new HashMap<>();
        public Map<UUID, PermissionAttachment> playerPermission = new HashMap<>();
       
       
        public void onEnable() {
            sql = new SqlConnection(this, "jdbc:mysql://", "localhost", "heroria", "root", "");
            sql.connection();
            getServer().getPluginManager().registerEvents(new PlayerXpManager(this), this);
            getServer().getPluginManager().registerEvents(new NpcListener(this), this);
            getServer().getPluginManager().registerEvents(this, this);
        }
       
        public void onDisable() {
            for (Player all : Bukkit.getServer().getOnlinePlayers()){
                all.kickPlayer(Bukkit.getShutdownMessage());
            }
            sql.disconnect();
        }
       
        @EventHandler
        public void onJoin(PlayerJoinEvent event) {
            Player player = (Player)event.getPlayer();
            sql.createAccount(player);
            dataManager.loadPlayerData(player);
        }
       
        @EventHandler
        public void onQuit(PlayerQuitEvent event) {
            Player player = (Player)event.getPlayer();
            dataManager.savePlayerData(player);
        }
       
        @EventHandler
        public void onKick(PlayerKickEvent event) {
            Player player = (Player)event.getPlayer();
            dataManager.savePlayerData(player);
        }
       
        public void setupPermissions(Player player) {
            PermissionAttachment attachment = player.addAttachment(this);
            this.playerPermission.put(player.getUniqueId(), attachment);
            permissionSetter(player, player.getUniqueId());
        }
    
        private void permissionSetter(Player player, UUID uuid) {
            PermissionAttachment attachment = this.playerPermission.get(uuid);
            Rank rank = sql.getRank(player);
            switch(rank) {
                case VIP:
                    attachment.setPermission("minecraft.command.me", true);
                    break;
                case MODO:
                    attachment.setPermission("minecraft.command.kill", true);
                    break;
               
                case CM:
                    attachment.setPermission("minecraft.command.*", true);
                    attachment.setPermission("worldedit.selection.pos", true);
                    attachment.setPermission("worldedit.*", true);
                    break;
                   
                case DEV:
                    attachment.setPermission("worldedit.*", true);
                    attachment.setPermission("minecraft.command.*", true);
                    attachment.setPermission("worldguard.*", true);
                    attachment.setPermission("bukkit.command.restart", true);
                    break;
                   
                case ADMIN:
                    attachment.setPermission("*", true);
                    break;
                   
                default:
                    attachment.setPermission("admintools.player", true);
                    break;
           
            }
        }
    }
    
    
    SQLConnection.java
    Code:
    package eu.heroria.iceorange92.data;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import org.bukkit.entity.Player;
    
    import eu.heroria.iceorange92.Main;
    import eu.heroria.iceorange92.data.PlayerData;
    import eu.heroria.iceorange92.data.Rank;
    
    public class SqlConnection {
        private Connection connection;
        private String urlbase, host, database, user, pass;
        private Main pl;
       
       
        public SqlConnection(Main pl, String urlbase, String host, String database, String user, String pass) {
            this.pl = pl;
            this.urlbase = urlbase;
            this.host = host;
            this.database = database;
            this.user = user;
            this.pass = pass;
        }
       
        public void connection() {
            if(!isConnected()) {
                try {
                    connection = DriverManager.getConnection(urlbase + host + "/" + database, user, pass);
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
       
        public void disconnect() {
            if(isConnected()) {
                try {
                    connection.close();
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
       
        public boolean isConnected() {
            return connection != null;
        }
       
        public void createAccount(Player player) {
            if(!hasAccount(player)) {
                //INSERT
                try {
                    PreparedStatement q = connection.prepareStatement("INSERT INTO players(uuid,balance,rank,faction,xp,reputation) VALUES (?,?,?,?,?,?)");
                    q.setString(1, player.getUniqueId().toString());
                    q.setInt(2, 100);
                    q.setInt(3, Rank.JOUEUR.getPower());
                    q.setInt(4, 0);
                    q.setInt(5, 1);
                    q.setInt(6, 100);
                    q.execute();
                    q.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
       
         public boolean hasAccount(Player player) {
                try {
                    PreparedStatement q = connection.prepareStatement("SELECT uuid FROM players WHERE uuid = ?");
                    q.setString(1, player.getUniqueId().toString());
                    ResultSet resultat = q.executeQuery();
                    boolean hasAccount = resultat.next();
                    q.close();
                    return hasAccount;
                } catch (SQLException e) {
                    System.out.println("SQLException");
                    e.printStackTrace();
                    return false;
                }
         }
       
        public int getBalance(Player player) {
            //SELECT
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                return playerData.getBalance();
            }
            return 0;
        }
       
        public int getFaction(Player player) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                return playerData.getFaction();
            }
            return 0;
        }
       
        public void setFaction(Player player, int faction) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                playerData.setFaction(faction);
                pl.dataPlayers.remove(player);
                pl.dataPlayers.put(player, playerData);
            }
        }
       
        public int getXp(Player player) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                return playerData.getXp();
            }
            return 0;
        }
       
        public void setXp(Player player, int xp) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                playerData.setFaction(xp);
                pl.dataPlayers.remove(player);
                pl.dataPlayers.put(player, playerData);
            }
        }
       
        public int getReputation(Player player) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                return playerData.getReputation();
            }
            return 0;
        }
       
        public void setReputation(Player player, int reputation) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                playerData.setFaction(reputation);
                pl.dataPlayers.remove(player);
                pl.dataPlayers.put(player, playerData);
            }
        }
       
        public void setMoney(Player player, int amount) {
            if(pl.dataPlayers.containsKey(player));{
                PlayerData playerData = pl.dataPlayers.get(player);
                playerData.setBalance(amount);
                pl.dataPlayers.remove(player);
                pl.dataPlayers.put(player, playerData);
            }
        }
       
        public void addMoney(Player player, int amount) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                int balance = playerData.getBalance();
                int newBalance = balance + amount;
                playerData.setBalance(newBalance);
                pl.dataPlayers.remove(player);
                pl.dataPlayers.put(player, playerData);
            }
        }
       
        public boolean removeMoney(Player player, int amount) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                int balance = playerData.getBalance();
                if(balance < amount) {
                    player.sendMessage("§4[Heroria]Désolé, vous n'avez pas assez d'argent pour effectuer cette transaction. On se fait un calin ?");
                    return true;
                }
                int newBalance = balance - amount;
                playerData.setBalance(newBalance);
                pl.dataPlayers.remove(player);
                pl.dataPlayers.put(player, playerData);
            }
            return false;
        }
       
        public void setRank(Player player, Rank rank) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                playerData.setRank(rank);
                pl.dataPlayers.remove(player);
                pl.dataPlayers.put(player, playerData);
            }
        }
       
        public Rank getRank(Player player) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                return playerData.getRank();
            }
            return Rank.JOUEUR;
        }
       
        public PlayerData createPlayerData(Player player) {
            if(!pl.dataPlayers.containsKey(player)) {
                try {
                    PreparedStatement rs = connection.prepareStatement("SELECT balance, rank, faction, reputation FROM players WHERE uuid = ?");
                    rs.setString(1, player.getUniqueId().toString());
                    ResultSet resultats = rs.executeQuery();
                    int balance = 0;
                    int faction = 0;
                    int xp = 1;
                    int reputation = 100;
                    Rank rank = Rank.JOUEUR;
                    while(resultats.next()) {
                        faction = resultats.getInt("faction");
                        balance = resultats.getInt("balance");
                        xp = resultats.getInt("xp");
                        reputation = resultats.getInt("reputation");
                        rank = Rank.powerToRank(resultats.getInt("rank"));
                    }
                    PlayerData playerData = new PlayerData();
                    playerData.setBalance(balance);
                    playerData.setRank(rank);
                    playerData.setFaction(faction);
                    playerData.setReputation(reputation);
                    playerData.setXp(xp);
                    rs.close();
                    return playerData;
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    return new PlayerData();
                }
            }
            return null;
        }
       
        public void updatePlayerData(Player player) {
            if(pl.dataPlayers.containsKey(player)) {
                PlayerData playerData = pl.dataPlayers.get(player);
                int balance = playerData.getBalance();
                Rank rank = playerData.getRank();
                int power = rank.getPower();
                int faction = playerData.getFaction();
                int xp = playerData.getXp();
                int reputation = playerData.getReputation();
                PreparedStatement q;
                try {
                    q = connection.prepareStatement("UPDATE players SET rank = ?, balance = ?, faction = ?, xp = ?, reputation = ? WHERE uuid = ?");
                    q.setInt(1, power);
                    q.setInt(2, balance);
                    q.setInt(3, faction);
                    q.setInt(4, xp);
                    q.setInt(5, reputation);
                    q.setString(6, player.getUniqueId().toString());
                    q.executeUpdate();
                    q.close();
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
       
        public Connection getConnection() {
            return connection;
        }
    }
    
    lasted.log
    Code:
    [11:42:43] [Server thread/INFO]: Loading properties
    [11:42:43] [Server thread/INFO]: Default game type: SURVIVAL
    [11:42:43] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-4bd94dc-bdcc7c7 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)
    [11:42:44] [Server thread/INFO]: Debug logging is disabled
    [11:42:44] [Server thread/INFO]: Server Ping Player Sample Count: 12
    [11:42:44] [Server thread/INFO]: Using 4 threads for Netty based IO
    [11:42:44] [Server thread/INFO]: Generating keypair
    [11:42:44] [Server thread/INFO]: Starting Minecraft server on *:25565
    [11:42:44] [Server thread/INFO]: Using default channel type
    [11:42:44] [Server thread/INFO]: Set PluginClassLoader as parallel capable
    [11:42:44] [Server thread/INFO]: [HeroriaCore] Loading HeroriaCore v1.0
    [11:42:44] [Server thread/WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
    [11:42:44] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
    [11:42:44] [Server thread/WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
    [11:42:44] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
    [11:42:44] [Server thread/INFO]: **** Beginning UUID conversion, this may take A LONG time ****
    [11:42:44] [Server thread/INFO]: Preparing level "world"
    [11:42:44] [Server thread/INFO]: -------- World Settings For [world] --------
    [11:42:44] [Server thread/INFO]: Mob Spawn Range: 4
    [11:42:44] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [11:42:44] [Server thread/INFO]: Random Lighting Updates: false
    [11:42:44] [Server thread/INFO]: Structure Info Saving: true
    [11:42:44] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Cane Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Melon Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Vine Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [11:42:44] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [11:42:44] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [11:42:44] [Server thread/INFO]: Max TNT Explosions: 100
    [11:42:44] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [11:42:44] [Server thread/INFO]: Item Despawn Rate: 6000
    [11:42:44] [Server thread/INFO]: Item Merge Radius: 2.5
    [11:42:44] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [11:42:44] [Server thread/INFO]: View Distance: 10
    [11:42:44] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [11:42:44] [Server thread/INFO]: Experience Merge Radius: 3.0
    [11:42:44] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [11:42:44] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [11:42:44] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [11:42:45] [Server thread/INFO]: -------- World Settings For [world_nether] --------
    [11:42:45] [Server thread/INFO]: Mob Spawn Range: 4
    [11:42:45] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [11:42:45] [Server thread/INFO]: Random Lighting Updates: false
    [11:42:45] [Server thread/INFO]: Structure Info Saving: true
    [11:42:45] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Cane Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Melon Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Vine Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [11:42:45] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [11:42:45] [Server thread/INFO]: Max TNT Explosions: 100
    [11:42:45] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [11:42:45] [Server thread/INFO]: Item Despawn Rate: 6000
    [11:42:45] [Server thread/INFO]: Item Merge Radius: 2.5
    [11:42:45] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [11:42:45] [Server thread/INFO]: View Distance: 10
    [11:42:45] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [11:42:45] [Server thread/INFO]: Experience Merge Radius: 3.0
    [11:42:45] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [11:42:45] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [11:42:45] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [11:42:45] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
    [11:42:45] [Server thread/INFO]: Mob Spawn Range: 4
    [11:42:45] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [11:42:45] [Server thread/INFO]: Random Lighting Updates: false
    [11:42:45] [Server thread/INFO]: Structure Info Saving: true
    [11:42:45] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Cane Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Melon Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Vine Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [11:42:45] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [11:42:45] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [11:42:45] [Server thread/INFO]: Max TNT Explosions: 100
    [11:42:45] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [11:42:45] [Server thread/INFO]: Item Despawn Rate: 6000
    [11:42:45] [Server thread/INFO]: Item Merge Radius: 2.5
    [11:42:45] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [11:42:45] [Server thread/INFO]: View Distance: 10
    [11:42:45] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [11:42:45] [Server thread/INFO]: Experience Merge Radius: 3.0
    [11:42:45] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [11:42:45] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [11:42:45] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [11:42:45] [Server thread/INFO]: Preparing start region for level 0 (Seed: 8091180134227560537)
    [11:42:46] [Server thread/INFO]: Preparing spawn area: 12%
    [11:42:47] [Server thread/INFO]: Preparing spawn area: 89%
    [11:42:48] [Server thread/INFO]: Preparing start region for level 1 (Seed: 8091180134227560537)
    [11:42:49] [Server thread/INFO]: Preparing start region for level 2 (Seed: -5039012617705349796)
    [11:42:49] [Server thread/INFO]: [HeroriaCore] Enabling HeroriaCore v1.0
    [11:42:49] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [11:42:49] [Server thread/INFO]: Done (4,586s)! For help, type "help" or "?"
    [11:43:55] [User Authenticator #1/INFO]: UUID of player IceOrange92 is 564aa009-2a91-3bc0-a77e-a95bf878a102
    [11:43:55] [Server thread/INFO]: ln81SqlConnection
    [11:43:55] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to HeroriaCore v1.0
    org.bukkit.event.EventException: null
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.PlayerList.onPlayerJoin(PlayerList.java:346) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:166) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:159) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:57) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:233) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.java:140) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:845) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]
    Caused by: java.lang.NullPointerException
        at eu.heroria.iceorange92.data.SqlConnection.hasAccount(SqlConnection.java:83) ~[?:?]
        at eu.heroria.iceorange92.data.SqlConnection.createAccount(SqlConnection.java:59) ~[?:?]
        at eu.heroria.iceorange92.Main.onJoin(Main.java:49) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_191]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_191]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_191]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
        ... 14 more
    [11:43:55] [Server thread/INFO]: IceOrange92[/127.0.0.1:52541] logged in with entity id 333 at ([world]-12.084527453903307, 26.0, -6.4200437694109835)
    [11:44:19] [Server thread/INFO]: IceOrange92 was shot by Skeleton
    [11:46:32] [Server thread/INFO]: IceOrange92 lost connection: Disconnected
    [11:46:32] [Server thread/INFO]: IceOrange92 left the game
    
     
  5. ShE3py

    ShE3py Développeur en autodidacte

    Inscrit:
    26 Septembre 2015
    Messages:
    978
    J'aime reçus:
    163
    Essaye de charger le driver avant la connexion, avec un truc du style :
    Code:
    static {
       Class.forName("com.mysql.jdbc.Driver");
    }
     
  6. IceOrange92

    IceOrange92 Mineur de diamant

    Inscrit:
    7 Décembre 2017
    Messages:
    24
    J'aime reçus:
    2
    Bonjour,

    Je crois avoir résolu le problème grâce à une autre méthode. Pour je ne sais quelle raison, les fichiers java n'était pas recompilé, même quand je cliquais sur build. Dans les logs, j'avais remarqué que la ligne System.out.println("ln81SQLConnection"); que j'avais supprimé s'exécuter. Le problème devait bien venir de la ligne sql.connection(); dans la classe principal. Je vérifie si tout marche et je mets le sujet en résolu si tout marche bien.

    Merci à tous pour votre aide.

    Edit: j'avais oublié de mettre xp dans la requete SQL CreatePlayerData ligne 206
     

Partager cette page