Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- erreur 1 en console quand je lance le serveur :
- [14:50:34 INFO]: [Callisto] Enabling Callisto v1.0
- [14:50:34 WARN]: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Commun
- ications link failure
- The last packet sent successfully to the server was 0 milliseconds ago. The driv
- er has not received any packets from the server.
- [14:50:34 WARN]: at sun.reflect.NativeConstructorAccessorImpl.newInstance
- 0(Native Method)
- [14:50:34 WARN]: at sun.reflect.NativeConstructorAccessorImpl.newInstance
- (Unknown Source)
- [14:50:34 WARN]: at sun.reflect.DelegatingConstructorAccessorImpl.newInst
- ance(Unknown Source)
- [14:50:34 WARN]: at java.lang.reflect.Constructor.newInstance(Unknown Sou
- rce)
- [14:50:34 WARN]: at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
- [14:50:34 WARN]: at com.mysql.jdbc.SQLError.createCommunicationsException
- (SQLError.java:990)
- [14:50:34 WARN]: at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
- [14:50:34 WARN]: at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionI
- mpl.java:2186)
- [14:50:34 WARN]: at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(Conne
- ctionImpl.java:2219)
- [14:50:34 WARN]: at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionI
- mpl.java:2014)
- [14:50:34 WARN]: at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.j
- ava:776)
- [14:50:34 WARN]: at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection
- .java:47)
- [14:50:34 WARN]: at sun.reflect.NativeConstructorAccessorImpl.newInstance
- 0(Native Method)
- [14:50:34 WARN]: at sun.reflect.NativeConstructorAccessorImpl.newInstance
- (Unknown Source)
- [14:50:34 WARN]: at sun.reflect.DelegatingConstructorAccessorImpl.newInst
- ance(Unknown Source)
- [14:50:34 WARN]: at java.lang.reflect.Constructor.newInstance(Unknown Sou
- rce)
- [14:50:34 WARN]: at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
- [14:50:34 WARN]: at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionI
- mpl.java:386)
- [14:50:34 WARN]: at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegist
- eringDriver.java:330)
- [14:50:34 WARN]: at java.sql.DriverManager.getConnection(Unknown Source)
- [14:50:34 WARN]: at java.sql.DriverManager.getConnection(Unknown Source)
- [14:50:34 WARN]: at Main.BanSystem.MySQL.connect(MySQL.java:14)
- [14:50:34 WARN]: at Main.Main.onEnable(Main.java:19)
- [14:50:34 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlug
- in.java:264)
- [14:50:34 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(
- JavaPluginLoader.java:337)
- [14:50:34 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(Si
- mplePluginManager.java:403)
- [14:50:34 WARN]: at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlu
- gin(CraftServer.java:381)
- [14:50:34 WARN]: at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlu
- gins(CraftServer.java:330)
- [14:50:34 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.t(Minec
- raftServer.java:422)
- [14:50:34 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.l(Minec
- raftServer.java:383)
- [14:50:34 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.a(Minec
- raftServer.java:338)
- [14:50:34 WARN]: at net.minecraft.server.v1_12_R1.DedicatedServer.init(De
- dicatedServer.java:272)
- [14:50:34 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.run(Min
- ecraftServer.java:545)
- [14:50:34 WARN]: at java.lang.Thread.run(Unknown Source)
- [14:50:34 WARN]: Caused by: java.net.UnknownHostException: localhost
- [14:50:34 WARN]: at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Me
- thod)
- [14:50:34 WARN]: at java.net.InetAddress$2.lookupAllHostAddr(Unknown Sour
- ce)
- [14:50:34 WARN]: at java.net.InetAddress.getAddressesFromNameService(Unkn
- own Source)
- [14:50:34 WARN]: at java.net.InetAddress.getAllByName0(Unknown Source)
- [14:50:34 WARN]: at java.net.InetAddress.getAllByName(Unknown Source)
- [14:50:34 WARN]: at java.net.InetAddress.getAllByName(Unknown Source)
- [14:50:34 WARN]: at com.mysql.jdbc.StandardSocketFactory.connect(Standard
- SocketFactory.java:188)
- [14:50:34 WARN]: at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
- [14:50:34 WARN]: ... 27 more
- [14:50:34 INFO]: Pompei ON
- [14:50:34 INFO]: Server permissions file permissions.yml is empty, ignoring it
- [14:50:34 INFO]: Done (2,213s)! For help, type "help" or "?"
- [14:51:27 INFO]: UUID of player _LP_ is 50527029-1908-4e1a-b43f-fde071b672e3
- [14:51:28 ERROR]: Could not pass event PlayerJoinEvent to Callisto v1.0
- org.bukkit.event.EventException: null
- at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
- va:306) ~[spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
- a:62) ~[spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
- ava:500) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
- ava:485) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.PlayerList.onPlayerJoin(PlayerList.java
- :346) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:166) [spig
- ot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:159)
- [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:57)
- [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:23
- 3) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.jav
- a:140) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:
- 845) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:
- 406) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:
- 679) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.jav
- a:577) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
- Caused by: java.lang.NullPointerException
- at Main.BanSystem.PlayerInfos.update(PlayerInfos.java:23) ~[?:?]
- at BanSystem.Listeners.PlayerJoin.onJoin(PlayerJoin.java:18) ~[?:?]
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0
- _131]
- at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0
- _131]
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
- .8.0_131]
- at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
- at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
- va:302) ~[spigot.jar:git-Spigot-2cf50f0-2b93d83]
- ... 14 more
- [14:51:28 INFO]: _LP_[/127.0.0.1:49789] logged in with entity id 56 at ([world]2
- Erreur 2 quand je me connect au serveur
- [15:02:54 INFO]: UUID of player _LP_ is 50527029-1908-4e1a-b43f-fde071b672e3
- [15:02:54 ERROR]: Could not pass event PlayerJoinEvent to Callisto v1.0
- org.bukkit.event.EventException: null
- at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
- va:306) ~[spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
- a:62) ~[spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
- ava:500) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
- ava:485) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.PlayerList.onPlayerJoin(PlayerList.java
- :346) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:166) [spig
- ot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:159)
- [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:57)
- [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:23
- 3) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.jav
- a:140) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:
- 845) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:
- 406) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:
- 679) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.jav
- a:577) [spigot.jar:git-Spigot-2cf50f0-2b93d83]
- at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
- Caused by: java.lang.NullPointerException
- at Main.BanSystem.PlayerInfos.update(PlayerInfos.java:23) ~[?:?]
- at BanSystem.Listeners.PlayerJoin.onJoin(PlayerJoin.java:18) ~[?:?]
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0
- _131]
- at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0
- _131]
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
- .8.0_131]
- at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
- at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
- va:302) ~[spigot.jar:git-Spigot-2cf50f0-2b93d83]
- ... 14 more
- [15:02:54 INFO]: _LP_[/127.0.0.1:49883] logged in with entity id 7821 at ([world
- ]270.73017764386225, 34.0, 594.6756096101622)
- classe MAIN :
- package Main;
- import org.bukkit.Bukkit;
- import org.bukkit.plugin.java.JavaPlugin;
- import BanSystem.Listeners.PlayerJoin;
- import Main.BanSystem.MySQL;
- public class Main extends JavaPlugin {
- private static Main instance;
- public MySQL mysql = new MySQL();
- @Override
- public void onEnable(){
- instance = this;
- mysql.connect("localhost ", 3306, "Callisto", "root", "");
- System.out.println("Pompei ON");
- Bukkit.getPluginManager().registerEvents(new PlayerJoin(), this);
- }
- @Override
- public void onDisable() {
- System.out.println("Pompei OFF");
- mysql.disconnect();
- }
- /**
- * Récupérer cette class dans les autres
- * @return Main
- */
- public static Main getInstance(){
- return instance;
- }
- }
- classe MySQL :
- package Main.BanSystem;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class MySQL {
- private Connection conn;
- public void connect(String host, int port, String database, String user, String password){
- if(!isConnected()){
- try {
- conn = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, user, password);
- System.out.println("[BanSystem] Connexion etablie avec la bdd");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public void disconnect(){
- if(isConnected()){
- try {
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public boolean isConnected(){
- try {
- if((conn == null) || (conn.isClosed()) || conn.isValid(5)){
- return false;
- }
- return true;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return false;
- }
- /**
- * Récupérer la connection
- * @return Connection
- */
- public Connection getConnection() {
- return conn;
- }
- }
- Classe PlayerJoin :
- package BanSystem.Listeners;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerJoinEvent;
- import Main.BanSystem.PlayerInfos;
- public class PlayerJoin implements Listener{
- @EventHandler
- public void onJoin(PlayerJoinEvent e){
- Player player = e.getPlayer();
- PlayerInfos playerinfos = new PlayerInfos();
- playerinfos.update(player);
- }
- }
- Classe PlayerInfos :
- package Main.BanSystem;
- import org.bukkit.entity.Player;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.UUID;
- import Main.Main;
- public class PlayerInfos {
- private Main main = Main.getInstance();
- /**
- * Actualiser/créer les informations du joueur
- * @param player
- */
- public void update(Player player){
- try {
- PreparedStatement sts = main.mysql.getConnection().prepareStatement("SELECT player_name FROM player_infos WHERE player_uuid=?" );
- sts.setString(1, player.getUniqueId().toString());
- ResultSet rs = sts.executeQuery();
- if(rs.next()){
- PreparedStatement update = main.mysql.getConnection().prepareStatement("UPDATE player_infos SET player_name=? WHERE player_uuid=?");
- update.setString(1, player.getName());
- update.setString(2, player.getUniqueId().toString());
- update.executeUpdate();
- update.close();
- System.out.println("Update : " + player.getName() + " , " + player.getUniqueId().toString()); //
- } else {
- PreparedStatement insert = main.mysql.getConnection().prepareStatement("INSERT INTO player_infos (player_uuid, player_name) VALUES (?, ?)");
- insert.setString(1, player.getUniqueId().toString());
- insert.setString(2, player.getName());
- insert.executeUpdate();
- insert.close();
- System.out.println("Insertion : " + player.getName() + " , " + player.getUniqueId().toString()); //
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- /**
- * Vérifie si le joueur a des informations dans la table
- * @param playerName
- * @return true/false
- */
- public boolean exist(String playerName){
- try {
- PreparedStatement sts = main.mysql.getConnection().prepareStatement("SELECT * FROM players_infos WHERE player_name?");
- sts.setString(1, playerName);
- ResultSet rs = sts.executeQuery();
- return rs.next();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return false;
- }
- /**
- * Récupérer l'UUID dun joueur avec son pseudo
- * @param playerName
- * @return UUID
- *
- */
- public UUID getUUID(String playerName){
- try {
- PreparedStatement sts = Main.getInstance().mysql.getConnection().prepareStatement("SELECT player_uuid FROM player_infos WHERE player_name=?");
- sts.setString(1, playerName);
- ResultSet rs = sts.executeQuery();
- if(rs.next()){
- return UUID.fromString(rs.getString("player_uuid"));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- throw new NullPointerException("Le joueur na pas dinformations dans la table");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement