diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/data_model/PandacraftUtils_Player.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/data_model/PandacraftUtils_Player.java index d373e8c..825551b 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/data_model/PandacraftUtils_Player.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/data_model/PandacraftUtils_Player.java @@ -1,4 +1,10 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.data_model; + +import java.sql.Date; +import java.util.UUID; + +import org.bukkit.entity.Player; + /** * Représente les données persistante correspondant à un joueur donné sur le serveur * @@ -13,22 +19,39 @@ public class PandacraftUtils_Player extends Table { // TODO Créer la table dans la base de donnée // TODO Ajouter les champs + public UUID uuid; // NOT NULL + public String name; // NOT NULL + public boolean vanish = false; // NOT NULL + public Date mute = null; + public PandacraftUtils_Player(Player p) { + name = p.getName(); + uuid = p.getUniqueId(); + } + @Override public String[] getValues() { - // TODO Auto-generated method stub - return null; + + return new String[]{ + uuid.toString(), + name, + (vanish)?"true":"false", + String.valueOf(mute)}; } @Override public String[] getFieldsName() { // TODO Auto-generated method stub - return null; + return new String[]{ + "uuid", + "name", + "vanish", + "mute"}; } } diff --git a/src/net/mc_pandacraft/java/util/mysql/DBConnection.java b/src/net/mc_pandacraft/java/util/mysql/DBConnection.java index 266301a..54b2dc4 100644 --- a/src/net/mc_pandacraft/java/util/mysql/DBConnection.java +++ b/src/net/mc_pandacraft/java/util/mysql/DBConnection.java @@ -36,8 +36,10 @@ public class DBConnection { } } - public Connection getConnection() + public Connection getConnection() throws SQLException { + if (!conn.isValid(1)) + reconnectIfNecessary(); return conn; }