Log removals of Clans blacklists
This commit is contained in:
parent
514aced5e0
commit
fce33d3313
@ -18,9 +18,11 @@ public class ClansBan
|
|||||||
private Timestamp _unbanTime;
|
private Timestamp _unbanTime;
|
||||||
private boolean _permanent;
|
private boolean _permanent;
|
||||||
private boolean _removed;
|
private boolean _removed;
|
||||||
|
private String _removeAdmin;
|
||||||
|
private String _removeReason;
|
||||||
private UUID _uuid;
|
private UUID _uuid;
|
||||||
|
|
||||||
public ClansBan(int id, UUID uuid, String admin, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed)
|
public ClansBan(int id, UUID uuid, String admin, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed, String removeAdmin, String removeReason)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
_uuid = uuid;
|
_uuid = uuid;
|
||||||
@ -30,6 +32,8 @@ public class ClansBan
|
|||||||
_unbanTime = unbanTime;
|
_unbanTime = unbanTime;
|
||||||
_permanent = permanent;
|
_permanent = permanent;
|
||||||
_removed = removed;
|
_removed = removed;
|
||||||
|
_removeAdmin = removeAdmin;
|
||||||
|
_removeReason = removeReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId()
|
public int getId()
|
||||||
@ -94,6 +98,16 @@ public class ClansBan
|
|||||||
return _uuid;
|
return _uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRemoveAdmin()
|
||||||
|
{
|
||||||
|
return _removeAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemoveReason()
|
||||||
|
{
|
||||||
|
return _removeReason;
|
||||||
|
}
|
||||||
|
|
||||||
public void remove()
|
public void remove()
|
||||||
{
|
{
|
||||||
_removed = true;
|
_removed = true;
|
||||||
|
@ -137,7 +137,7 @@ public class ClansBanManager extends MiniPlugin
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unban(ClansBanClient target, ClansBan ban, Runnable callback)
|
public void unban(ClansBanClient target, ClansBan ban, String admin, String reason, Runnable callback)
|
||||||
{
|
{
|
||||||
if (!target._uuid.equals(ban.getUUID()))
|
if (!target._uuid.equals(ban.getUUID()))
|
||||||
{
|
{
|
||||||
@ -145,7 +145,7 @@ public class ClansBanManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
ban.remove();
|
ban.remove();
|
||||||
_repository.removeBan(ban);
|
_repository.removeBan(ban, admin, reason);
|
||||||
|
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,12 @@ import mineplex.core.account.CoreClientManager;
|
|||||||
import mineplex.serverdata.database.DBPool;
|
import mineplex.serverdata.database.DBPool;
|
||||||
import mineplex.serverdata.database.RepositoryBase;
|
import mineplex.serverdata.database.RepositoryBase;
|
||||||
import mineplex.serverdata.database.column.ColumnInt;
|
import mineplex.serverdata.database.column.ColumnInt;
|
||||||
|
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||||
|
|
||||||
public class ClansBanRepository extends RepositoryBase
|
public class ClansBanRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);";
|
private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed, removeAdmin, removeReason) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||||
private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;";
|
private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1, removeAdmin = ?, removeReason = ? WHERE id = ?;";
|
||||||
private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE uuid = ?;";
|
private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE uuid = ?;";
|
||||||
|
|
||||||
public ClansBanRepository(JavaPlugin plugin)
|
public ClansBanRepository(JavaPlugin plugin)
|
||||||
@ -47,13 +48,15 @@ public class ClansBanRepository extends RepositoryBase
|
|||||||
stmt.setTimestamp(5, unbanTime);
|
stmt.setTimestamp(5, unbanTime);
|
||||||
stmt.setBoolean(6, time == -1);
|
stmt.setBoolean(6, time == -1);
|
||||||
stmt.setBoolean(7, false);
|
stmt.setBoolean(7, false);
|
||||||
|
stmt.setString(8, null);
|
||||||
|
stmt.setString(9, null);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
|
|
||||||
ResultSet resultSet = stmt.getGeneratedKeys();
|
ResultSet resultSet = stmt.getGeneratedKeys();
|
||||||
if (resultSet.next())
|
if (resultSet.next())
|
||||||
{
|
{
|
||||||
int id = resultSet.getInt(1);
|
int id = resultSet.getInt(1);
|
||||||
return Optional.of(new ClansBan(id, uuid, admin, reason, banTime, unbanTime, time == -1, false));
|
return Optional.of(new ClansBan(id, uuid, admin, reason, banTime, unbanTime, time == -1, false, null, null));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -90,8 +93,10 @@ public class ClansBanRepository extends RepositoryBase
|
|||||||
Timestamp unbanTime = resultSet.getTimestamp(6);
|
Timestamp unbanTime = resultSet.getTimestamp(6);
|
||||||
boolean permanent = resultSet.getBoolean(7);
|
boolean permanent = resultSet.getBoolean(7);
|
||||||
boolean removed = resultSet.getBoolean(8);
|
boolean removed = resultSet.getBoolean(8);
|
||||||
|
String removeAdmin = resultSet.getString(9);
|
||||||
|
String removeReason = resultSet.getString(10);
|
||||||
|
|
||||||
bans.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
|
bans.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed, removeAdmin, removeReason));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ClansBanClient(uuid, bans);
|
return new ClansBanClient(uuid, bans);
|
||||||
@ -123,8 +128,8 @@ public class ClansBanRepository extends RepositoryBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBan(ClansBan ban)
|
public void removeBan(ClansBan ban, String admin, String reason)
|
||||||
{
|
{
|
||||||
executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId()));
|
executeUpdate(REMOVE_BAN, new ColumnVarChar("removeAdmin", admin.length(), admin), new ColumnVarChar("removeReason", reason.length(), reason), new ColumnInt("id", ban.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,14 +26,15 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
|||||||
{
|
{
|
||||||
final String playerName = args[0];
|
final String playerName = args[0];
|
||||||
|
|
||||||
String reason = args[1];
|
StringBuilder reasonBuilder = new StringBuilder(args[1]);
|
||||||
|
|
||||||
for (int i = 2; i < args.length; i++)
|
for (int i = 2; i < args.length; i++)
|
||||||
{
|
{
|
||||||
reason += " " + args[i];
|
reasonBuilder.append(' ');
|
||||||
|
reasonBuilder.append(args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String finalReason = reason;
|
final String finalReason = reasonBuilder.toString();
|
||||||
|
|
||||||
Plugin.loadClient(playerName, client ->
|
Plugin.loadClient(playerName, client ->
|
||||||
{
|
{
|
||||||
|
@ -96,9 +96,11 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
|
|||||||
.addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin())
|
.addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin())
|
||||||
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||||
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
||||||
.addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
.addLore(C.cGray + "Removed: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||||
|
.addLore(ban.getRemoveAdmin() != null ? C.cGray + "Removed By: " + C.cYellow + ban.getRemoveAdmin() : null)
|
||||||
|
.addLore(ban.getRemoveReason() != null ? C.cGray + "Remove Reason: " + C.cYellow + ban.getRemoveReason() : null)
|
||||||
.addLore(ban.isActive() ? " " : null)
|
.addLore(ban.isActive() ? " " : null)
|
||||||
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null)
|
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to Remove Ban" : null)
|
||||||
.setGlow(ban.isActive())
|
.setGlow(ban.isActive())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@ -112,9 +114,11 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
|
|||||||
.addLore(C.cGray + "Time Left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
|
.addLore(C.cGray + "Time Left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
|
||||||
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||||
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
||||||
.addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
.addLore(C.cGray + "Removed: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||||
|
.addLore(ban.getRemoveAdmin() != null ? C.cGray + "Removed By: " + C.cYellow + ban.getRemoveAdmin() : null)
|
||||||
|
.addLore(ban.getRemoveReason() != null ? C.cGray + "Remove Reason: " + C.cYellow + ban.getRemoveReason() : null)
|
||||||
.addLore(ban.isActive() ? " " : null)
|
.addLore(ban.isActive() ? " " : null)
|
||||||
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null)
|
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to Remove Ban" : null)
|
||||||
.setGlow(ban.isActive())
|
.setGlow(ban.isActive())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@ -125,7 +129,7 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
|
|||||||
{
|
{
|
||||||
getPlugin().runAsync(() ->
|
getPlugin().runAsync(() ->
|
||||||
{
|
{
|
||||||
getPlugin().unban(_victimClient, ban, () ->
|
getPlugin().unban(_victimClient, ban, getPlayer().getName(), _reason, () ->
|
||||||
{
|
{
|
||||||
refresh();
|
refresh();
|
||||||
playAcceptSound(player);
|
playAcceptSound(player);
|
||||||
@ -138,6 +142,11 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
|
|||||||
|
|
||||||
private void performBan()
|
private void performBan()
|
||||||
{
|
{
|
||||||
|
if (_time == 0 && !_permanent)
|
||||||
|
{
|
||||||
|
playDenySound(getPlayer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban ->
|
getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban ->
|
||||||
{
|
{
|
||||||
if (ban.isPresent())
|
if (ban.isPresent())
|
||||||
|
Loading…
Reference in New Issue
Block a user