mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
-> Add IP Data to Bans
This commit is contained in:
parent
2790d406ed
commit
b072027458
@ -44,11 +44,12 @@ public class Ban
|
|||||||
this.active = true;
|
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.uuid = uuid;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.banner = banner;
|
this.banner = banner;
|
||||||
|
this.ip = ip;
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
this.endDate = endDate;
|
this.endDate = endDate;
|
||||||
this.active = true;
|
this.active = true;
|
||||||
|
@ -20,7 +20,7 @@ import java.util.UUID;
|
|||||||
public class BanManager
|
public class BanManager
|
||||||
{
|
{
|
||||||
private final String SELECT = "SELECT * FROM `bans` WHERE uuid=?";
|
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)
|
public void executeBan(Ban ban)
|
||||||
{
|
{
|
||||||
@ -35,9 +35,10 @@ public class BanManager
|
|||||||
statement.setString(1, ban.getId());
|
statement.setString(1, ban.getId());
|
||||||
statement.setString(2, ban.getUuid().toString());
|
statement.setString(2, ban.getUuid().toString());
|
||||||
statement.setString(3, ban.getBanner() == null ? "" : ban.getBanner().toString());
|
statement.setString(3, ban.getBanner() == null ? "" : ban.getBanner().toString());
|
||||||
statement.setString(4, ban.getReason().isEmpty() ? "" : ban.getReason());
|
statement.setString(4, ban.getIp());
|
||||||
statement.setLong(5, ban.getEndDate().toInstant().toEpochMilli());
|
statement.setString(5, ban.getReason());
|
||||||
statement.setBoolean(6, ban.isActive());
|
statement.setLong(6, ban.getEndDate().toInstant().toEpochMilli());
|
||||||
|
statement.setBoolean(7, ban.isActive());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
|
||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
@ -58,9 +59,6 @@ public class BanManager
|
|||||||
PreparedStatement statement = con.prepareStatement(SELECT);
|
PreparedStatement statement = con.prepareStatement(SELECT);
|
||||||
statement.setString(1, uuid.toString());
|
statement.setString(1, uuid.toString());
|
||||||
ResultSet set = statement.executeQuery();
|
ResultSet set = statement.executeQuery();
|
||||||
PlexLog.log("-----------");
|
|
||||||
PlexLog.log("Next: " + set.next());
|
|
||||||
PlexLog.log("Active: " + set.getBoolean("active"));
|
|
||||||
if (!set.next()) return false;
|
if (!set.next()) return false;
|
||||||
while (set.next())
|
while (set.next())
|
||||||
{
|
{
|
||||||
@ -140,9 +138,10 @@ public class BanManager
|
|||||||
String id = set.getString("banID");
|
String id = set.getString("banID");
|
||||||
UUID uuid = UUID.fromString(set.getString("uuid"));
|
UUID uuid = UUID.fromString(set.getString("uuid"));
|
||||||
UUID banner = set.getString("banner").isEmpty() ? null : UUID.fromString(set.getString("banner"));
|
UUID banner = set.getString("banner").isEmpty() ? null : UUID.fromString(set.getString("banner"));
|
||||||
|
String ip = set.getString("ip");
|
||||||
String reason = set.getString("reason");
|
String reason = set.getString("reason");
|
||||||
Date endDate = set.getLong("enddate") != 0 ? new Date(set.getLong("enddate")) : null;
|
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);
|
bans.add(ban);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class BanCMD extends PlexCommand
|
|||||||
punishment.setCustomTime(false);
|
punishment.setCustomTime(false);
|
||||||
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
||||||
Bukkit.broadcastMessage(sender.getName() + " - Banning " + plexPlayer.getName());
|
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.");
|
Bukkit.getPlayer(targetUUID).kickPlayer("§cYou've been banned.");
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ public class SQLConnection extends PlexBase
|
|||||||
"\t`banID` VARCHAR,\n" +
|
"\t`banID` VARCHAR,\n" +
|
||||||
"\t`uuid` VARCHAR(46) NOT NULL,\n" +
|
"\t`uuid` VARCHAR(46) NOT NULL,\n" +
|
||||||
"\t`banner` VARCHAR(46),\n" +
|
"\t`banner` VARCHAR(46),\n" +
|
||||||
|
"\t`ip` VARCHAR,\n" +
|
||||||
"\t`reason` VARCHAR,\n" +
|
"\t`reason` VARCHAR,\n" +
|
||||||
"\t`enddate` BIGINT,\n" +
|
"\t`enddate` BIGINT,\n" +
|
||||||
"\t`active` BOOLEAN,\n" +
|
"\t`active` BOOLEAN,\n" +
|
||||||
|
Loading…
Reference in New Issue
Block a user