From 9ec2dfb95b46d1a9689c95645078227f5ebdc699 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Fri, 26 Dec 2014 00:24:32 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20de=20l'ORM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data_model/PandacraftUtils_Player.java | 29 +++++++++++++++++-- .../java/util/mysql/DBConnection.java | 4 ++- 2 files changed, 29 insertions(+), 4 deletions(-) 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; }