diff --git a/src/main/java/me/totalfreedom/plex/banning/Ban.java b/src/main/java/me/totalfreedom/plex/banning/Ban.java index 24152dc..79aa882 100644 --- a/src/main/java/me/totalfreedom/plex/banning/Ban.java +++ b/src/main/java/me/totalfreedom/plex/banning/Ban.java @@ -44,11 +44,12 @@ public class Ban this.active = true; } - public Ban(String id, UUID uuid, UUID banner, String reason, Date endDate) + public Ban(String id, UUID uuid, UUID banner, String ip, String reason, Date endDate) { this.uuid = uuid; this.id = id; this.banner = banner; + this.ip = ip; this.reason = reason; this.endDate = endDate; this.active = true; diff --git a/src/main/java/me/totalfreedom/plex/banning/BanManager.java b/src/main/java/me/totalfreedom/plex/banning/BanManager.java index 602906c..b381ee1 100644 --- a/src/main/java/me/totalfreedom/plex/banning/BanManager.java +++ b/src/main/java/me/totalfreedom/plex/banning/BanManager.java @@ -20,7 +20,7 @@ import java.util.UUID; public class BanManager { private final String SELECT = "SELECT * FROM `bans` WHERE uuid=?"; - private final String INSERT = "INSERT INTO `bans` (`banID`, `uuid`, `banner`, `reason`, `enddate`, `active`) VALUES (?, ?, ?, ?, ?, ?);"; + private final String INSERT = "INSERT INTO `bans` (`banID`, `uuid`, `banner`, `ip`, ``reason`, `enddate`, `active`) VALUES (?, ?, ?, ?, ?, ?, ?);"; public void executeBan(Ban ban) { @@ -35,9 +35,10 @@ public class BanManager statement.setString(1, ban.getId()); statement.setString(2, ban.getUuid().toString()); statement.setString(3, ban.getBanner() == null ? "" : ban.getBanner().toString()); - statement.setString(4, ban.getReason().isEmpty() ? "" : ban.getReason()); - statement.setLong(5, ban.getEndDate().toInstant().toEpochMilli()); - statement.setBoolean(6, ban.isActive()); + statement.setString(4, ban.getIp()); + statement.setString(5, ban.getReason()); + statement.setLong(6, ban.getEndDate().toInstant().toEpochMilli()); + statement.setBoolean(7, ban.isActive()); statement.execute(); } catch (SQLException throwables) { @@ -58,9 +59,6 @@ public class BanManager PreparedStatement statement = con.prepareStatement(SELECT); statement.setString(1, uuid.toString()); ResultSet set = statement.executeQuery(); - PlexLog.log("-----------"); - PlexLog.log("Next: " + set.next()); - PlexLog.log("Active: " + set.getBoolean("active")); if (!set.next()) return false; while (set.next()) { @@ -140,9 +138,10 @@ public class BanManager String id = set.getString("banID"); UUID uuid = UUID.fromString(set.getString("uuid")); UUID banner = set.getString("banner").isEmpty() ? null : UUID.fromString(set.getString("banner")); + String ip = set.getString("ip"); String reason = set.getString("reason"); Date endDate = set.getLong("enddate") != 0 ? new Date(set.getLong("enddate")) : null; - Ban ban = new Ban(id, uuid, banner, reason, endDate); + Ban ban = new Ban(id, uuid, banner, ip, reason, endDate); bans.add(ban); } } diff --git a/src/main/java/me/totalfreedom/plex/command/impl/BanCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/BanCMD.java index 0725d8d..f9ce667 100644 --- a/src/main/java/me/totalfreedom/plex/command/impl/BanCMD.java +++ b/src/main/java/me/totalfreedom/plex/command/impl/BanCMD.java @@ -75,7 +75,7 @@ public class BanCMD extends PlexCommand punishment.setCustomTime(false); plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment); Bukkit.broadcastMessage(sender.getName() + " - Banning " + plexPlayer.getName()); - if (Bukkit.getOfflinePlayer(targetUUID).isOnline()) + if (Bukkit.getPlayer(targetUUID) != null) { Bukkit.getPlayer(targetUUID).kickPlayer("§cYou've been banned."); } diff --git a/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java b/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java index ee66555..68d4ce0 100644 --- a/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java +++ b/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java @@ -56,6 +56,7 @@ public class SQLConnection extends PlexBase "\t`banID` VARCHAR,\n" + "\t`uuid` VARCHAR(46) NOT NULL,\n" + "\t`banner` VARCHAR(46),\n" + + "\t`ip` VARCHAR,\n" + "\t`reason` VARCHAR,\n" + "\t`enddate` BIGINT,\n" + "\t`active` BOOLEAN,\n" +