Ajouts/suppression de librairies (sources) + Ajout support basique 1.10
- Transfert de la librairie com.luckycatlabs.sunrisesunset vers un autre module Pandacube. - Ajout de l'utilitaire OfflineUUID développé précédemment hors projet. - Ajout de Minecraft 1.10 dans l'enum des versions de Minecraft - Ajout d'une libraire d'accès aux anciens pseudos des joueurs - L'historique de login enregistre des informations supplémentaires (pseudo actuel, version de MC) - ORM : retrait des SuppressWarnings("rawtypes") et ajout des <?> pour retirer proprement ces warnings
This commit is contained in:
@@ -8,27 +8,28 @@ public class LoginHistoryElement extends SQLElement {
|
||||
|
||||
private long time;
|
||||
private String playerId;
|
||||
private String ip;
|
||||
private String ip = null;
|
||||
private ActionType actionType;
|
||||
private int nbOnline;
|
||||
private String playerName;
|
||||
private int minecraftVersion = 0;
|
||||
|
||||
|
||||
public LoginHistoryElement(long t, UUID pId, InetAddress IP, ActionType action, int nbO) {
|
||||
public LoginHistoryElement(long t, UUID pId, ActionType action, int nbO) {
|
||||
super("pandacube_login_history");
|
||||
setTime(t);
|
||||
setPlayerId(pId);
|
||||
setIp(IP);
|
||||
setActionType(action);
|
||||
setNbOnline(nbO);
|
||||
}
|
||||
|
||||
LoginHistoryElement(int id, long t, String pId, String IP, ActionType action, int nbO) {
|
||||
LoginHistoryElement(int id, long t, String pId, String ip, ActionType action, int nbO) {
|
||||
super("pandacube_login_history", id);
|
||||
if (IP == null || pId == null)
|
||||
throw new IllegalArgumentException("pId et IP ne peuvent être null");
|
||||
if (pId == null)
|
||||
throw new IllegalArgumentException("pId ne peuvent être null");
|
||||
setTime(t);
|
||||
playerId = pId;
|
||||
ip = IP;
|
||||
this.ip = ip;
|
||||
setActionType(action);
|
||||
setNbOnline(nbO);
|
||||
}
|
||||
@@ -40,7 +41,9 @@ public class LoginHistoryElement extends SQLElement {
|
||||
playerId,
|
||||
ip,
|
||||
actionType.toString(),
|
||||
Integer.toString(nbOnline)
|
||||
Integer.toString(nbOnline),
|
||||
playerName,
|
||||
Integer.toString(minecraftVersion)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,7 +54,9 @@ public class LoginHistoryElement extends SQLElement {
|
||||
"playerId",
|
||||
"ip",
|
||||
"actionType",
|
||||
"nbOnline"
|
||||
"nbOnline",
|
||||
"playerName",
|
||||
"minecraftVersion"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,8 +87,9 @@ public class LoginHistoryElement extends SQLElement {
|
||||
|
||||
public void setIp(InetAddress addr) {
|
||||
if (addr == null)
|
||||
throw new IllegalArgumentException("addr ne peut être null");
|
||||
ip = addr.getHostAddress();
|
||||
ip = null;
|
||||
else
|
||||
ip = addr.getHostAddress();
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +111,31 @@ public class LoginHistoryElement extends SQLElement {
|
||||
public void setNbOnline(int nbOnline) {
|
||||
this.nbOnline = nbOnline;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public void setPlayerName(String pn) {
|
||||
playerName = pn;
|
||||
}
|
||||
|
||||
public int getMinecraftVersion() {
|
||||
return minecraftVersion;
|
||||
}
|
||||
|
||||
public void setMinecraftVersion(int m) {
|
||||
minecraftVersion = m;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public enum ActionType {
|
||||
|
@@ -16,9 +16,11 @@ public class LoginHistoryTable extends SQLTable<LoginHistoryElement> {
|
||||
return "id INT AUTO_INCREMENT PRIMARY KEY,"
|
||||
+ "time BIGINT NOT NULL,"
|
||||
+ "playerId CHAR(36) NOT NULL,"
|
||||
+ "ip VARCHAR(128) NOT NULL,"
|
||||
+ "ip VARCHAR(128) NULL,"
|
||||
+ "actionType ENUM('LOGIN', 'LOGOUT') NOT NULL,"
|
||||
+ "nbOnline INT NOT NULL";
|
||||
+ "nbOnline INT NOT NULL,"
|
||||
+ "playerName VARCHAR(16) NULL,"
|
||||
+ "minecraftVersion INT NOT NULL DEFAULT 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,6 +32,8 @@ public class LoginHistoryTable extends SQLTable<LoginHistoryElement> {
|
||||
sqlResult.getString("ip"),
|
||||
ActionType.valueOf(sqlResult.getString("actionType")),
|
||||
sqlResult.getInt("nbOnline"));
|
||||
el.setPlayerName(sqlResult.getString("playerName"));
|
||||
el.setMinecraftVersion(sqlResult.getInt("minecraftVersion"));
|
||||
return el;
|
||||
}
|
||||
|
||||
|
@@ -22,8 +22,7 @@ import java.util.List;
|
||||
*/
|
||||
public final class ORM {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static List<SQLTable> tables = new ArrayList<SQLTable>();
|
||||
private static List<SQLTable<?>> tables = new ArrayList<SQLTable<?>>();
|
||||
|
||||
/* package */ static DBConnection connection;
|
||||
|
||||
@@ -39,18 +38,21 @@ public final class ORM {
|
||||
tables.add(new LoginHistoryTable());
|
||||
|
||||
tables.add(new ModoHistoryTable());
|
||||
|
||||
tables.add(new StaffTicketTable());
|
||||
|
||||
tables.add(new MPMessageTable());
|
||||
tables.add(new MPGroupTable());
|
||||
tables.add(new MPGroupUserTable());
|
||||
tables.add(new MPMessageTable());
|
||||
|
||||
tables.add(new OnlineShopHistoryTable());
|
||||
|
||||
tables.add(new PlayerTable());
|
||||
|
||||
tables.add(new PlayerIgnoreTable());
|
||||
|
||||
tables.add(new ShopStockTable());
|
||||
|
||||
tables.add(new StaffTicketTable());
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@@ -61,10 +63,9 @@ public final class ORM {
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public synchronized static <T extends SQLTable> T getTable(Class<T> c) {
|
||||
public synchronized static <T extends SQLTable<?>> T getTable(Class<T> c) {
|
||||
if (c == null) return null;
|
||||
for (SQLTable table : tables) {
|
||||
for (SQLTable<?> table : tables) {
|
||||
|
||||
if (c.isAssignableFrom(table.getClass())) {
|
||||
return c.cast(table);
|
||||
@@ -83,4 +84,12 @@ public final class ORM {
|
||||
private ORM() { } // rend la classe non instanciable
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user