Allow access to clans blacklisting from core, make GWEN issue 90-day clans blacklists for instabans and banwaves

This commit is contained in:
AlexTheCoder 2017-07-14 06:36:28 -04:00
parent c2a46c14ed
commit 7354c4dc1c
22 changed files with 381 additions and 238 deletions

View File

@ -158,7 +158,7 @@ public class AntiHack extends MiniPlugin
require(GuardianManager.class); require(GuardianManager.class);
_banWaveManager = require(BanWaveManager.class); _banWaveManager = require(BanWaveManager.class);
Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), this._plugin, ServicePriority.Normal); Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), _plugin, ServicePriority.Normal);
ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation -> ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation ->
{ {
@ -167,9 +167,13 @@ public class AntiHack extends MiniPlugin
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
if (_detailedMessages.contains(player.getName())) if (_detailedMessages.contains(player.getName()))
{
player.spigot().sendMessage(detailed); player.spigot().sendMessage(detailed);
}
else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS))) else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS)))
{
player.spigot().sendMessage(minimal); player.spigot().sendMessage(minimal);
}
} }
}); });
@ -222,12 +226,19 @@ public class AntiHack extends MiniPlugin
{ {
Consumer<Consumer<PunishmentResponse>> doPunish = after -> Consumer<Consumer<PunishmentResponse>> doPunish = after ->
{ {
runAsync(() -> runAsync(() ->
{ {
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish();
}); });
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after); _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after);
if (UtilServer.getGroup().equals("Clans"))
{
_punish.getClansPunish().loadClient(coreClient.getUniqueId(), client ->
{
_punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, finalMessage, null, ban -> {});
});
}
}; };
if (coreClient.GetRank().has(Rank.TWITCH)) if (coreClient.GetRank().has(Rank.TWITCH))
@ -266,14 +277,21 @@ public class AntiHack extends MiniPlugin
Consumer<Consumer<PunishmentResponse>> doPunish = after -> Consumer<Consumer<PunishmentResponse>> doPunish = after ->
{ {
_punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, getHoursBanned(player), true, after); final int hoursBanned = getHoursBanned(player);
_punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, hoursBanned, true, after);
String[] serverSplit = info.getServer().split("-");
if (serverSplit.length > 0 && serverSplit[0].equals("Clans"))
{
_punish.getClansPunish().loadClient(coreClient.getUniqueId(), client ->
{
_punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, info.getMessage(), null, ban -> {});
});
}
}; };
if (coreClient.GetRank().has(Rank.TWITCH)) if (coreClient.GetRank().has(Rank.TWITCH))
{ {
doPunish.accept(response -> doPunish.accept(response -> {});
{
});
} }
else else
{ {
@ -332,14 +350,18 @@ public class AntiHack extends MiniPlugin
public void on(EntityDamageEvent event) public void on(EntityDamageEvent event)
{ {
if (_pendingBan.contains(event.getEntity())) if (_pendingBan.contains(event.getEntity()))
{
event.setCancelled(true); event.setCancelled(true);
}
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void on(EntityDamageByEntityEvent event) public void on(EntityDamageByEntityEvent event)
{ {
if (_pendingBan.contains(event.getDamager())) if (_pendingBan.contains(event.getDamager()))
{
event.setCancelled(true); event.setCancelled(true);
}
} }
public int getPunishments(Player player) public int getPunishments(Player player)
@ -414,7 +436,9 @@ public class AntiHack extends MiniPlugin
} }
if (_ignoredChecks.contains(event.getCheckClass())) if (_ignoredChecks.contains(event.getCheckClass()))
{
return; return;
}
ACTIONS.getOrDefault(event.getCheckClass(), NOOP_ACTION).handle(event); ACTIONS.getOrDefault(event.getCheckClass(), NOOP_ACTION).handle(event);
@ -434,7 +458,7 @@ public class AntiHack extends MiniPlugin
MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage()); MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage());
ServerCommandManager.getInstance().publishCommand(command); ServerCommandManager.getInstance().publishCommand(command);
this._cooldown.put(key, event.getViolations()); _cooldown.put(key, event.getViolations());
} }
} }
@ -525,6 +549,6 @@ public class AntiHack extends MiniPlugin
public void setStrict(boolean strict) public void setStrict(boolean strict)
{ {
this._strict = strict; _strict = strict;
} }
} }

View File

@ -116,4 +116,4 @@ public class BanWaveInfo
{ {
return Objects.hash(_accountId, _timeToBan, _hackType, _message, _vl, _server); return Objects.hash(_accountId, _timeToBan, _hackType, _message, _vl, _server);
} }
} }

View File

@ -62,7 +62,7 @@ public class BanWaveManager extends MiniPlugin
CoreClient client = _clientManager.Get(player); CoreClient client = _clientManager.Get(player);
if (this._repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server)) if (_repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server))
{ {
runAsync(() -> runAsync(() ->
{ {
@ -81,4 +81,4 @@ public class BanWaveManager extends MiniPlugin
{ {
_repository.flagDone(client.getAccountId()); _repository.flagDone(client.getAccountId());
} }
} }

View File

@ -4,7 +4,6 @@ import java.util.HashMap;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.logging.Level; import java.util.logging.Level;
import mineplex.core.account.CoreClient;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,6 +20,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.common.Constants; import mineplex.core.common.Constants;
@ -36,6 +36,7 @@ import mineplex.core.punish.Command.PunishCommand;
import mineplex.core.punish.Command.RulesCommand; import mineplex.core.punish.Command.RulesCommand;
import mineplex.core.punish.Tokens.PunishClientToken; import mineplex.core.punish.Tokens.PunishClientToken;
import mineplex.core.punish.Tokens.PunishmentToken; import mineplex.core.punish.Tokens.PunishmentToken;
import mineplex.core.punish.clans.ClansBanManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.commands.AddPunishCommand; import mineplex.serverdata.commands.AddPunishCommand;
@ -47,18 +48,30 @@ public class Punish extends MiniPlugin
private HashMap<String, PunishClient> _punishClients; private HashMap<String, PunishClient> _punishClients;
private PunishRepository _repository; private PunishRepository _repository;
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private ClansBanManager _clansPunish;
public Punish(JavaPlugin plugin, CoreClientManager clientManager) public Punish(JavaPlugin plugin, CoreClientManager clientManager)
{
this(plugin, clientManager, false);
}
public Punish(JavaPlugin plugin, CoreClientManager clientManager, boolean clansServer)
{ {
super("Punish", plugin); super("Punish", plugin);
_punishClients = new HashMap<String, PunishClient>(); _punishClients = new HashMap<String, PunishClient>();
_clientManager = clientManager; _clientManager = clientManager;
_repository = new PunishRepository(); _repository = new PunishRepository();
_clansPunish = new ClansBanManager(plugin, clientManager, clansServer);
ServerCommandManager.getInstance().registerCommandType("PunishCommand", mineplex.serverdata.commands.PunishCommand.class, new PunishmentHandler(this)); ServerCommandManager.getInstance().registerCommandType("PunishCommand", mineplex.serverdata.commands.PunishCommand.class, new PunishmentHandler(this));
} }
public ClansBanManager getClansPunish()
{
return _clansPunish;
}
public PunishRepository GetRepository() public PunishRepository GetRepository()
{ {
return _repository; return _repository;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.ban; package mineplex.core.punish.clans;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.UUID; import java.util.UUID;
@ -7,7 +7,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
/** /**
* Stores the information about a ban in Clans. * Stores the information about a blacklist in Clans.
*/ */
public class ClansBan public class ClansBan
{ {
@ -98,4 +98,4 @@ public class ClansBan
{ {
_removed = true; _removed = true;
} }
} }

View File

@ -1,14 +1,13 @@
package mineplex.game.clans.clans.ban; package mineplex.core.punish.clans;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
/** /**
* Signifies a player on clans, and a Set of their current clan bans. * A client representing a player and a List of their Clans blacklists
*/ */
public class ClansBanClient public class ClansBanClient
{ {

View File

@ -0,0 +1,161 @@
package mineplex.core.punish.clans;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.punish.clans.command.ClansBanCommand;
import mineplex.core.punish.clans.redis.ClansBanNotification;
import mineplex.serverdata.commands.ServerCommandManager;
public class ClansBanManager extends MiniPlugin
{
private final CoreClientManager _clientManager;
private final ClansBanRepository _repository;
private final boolean _fullOperation;
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, boolean fullOperation)
{
super("Clans Blacklist", plugin);
_clientManager = clientManager;
_repository = new ClansBanRepository(plugin);
_fullOperation = fullOperation;
if (_fullOperation)
{
ServerCommandManager.getInstance().registerCommandType(ClansBanNotification.class, notification ->
{
runSync(() ->
{
if (Bukkit.getPlayer(notification.getTarget()) != null)
{
Bukkit.getPlayer(notification.getTarget()).kickPlayer(C.cRedB + "You have been banned from Clans " + notification.getBanTimeFormatted() + ".");
}
});
});
}
}
@Override
public void addCommands()
{
addCommand(new ClansBanCommand(this));
}
public CoreClientManager getClientManager()
{
return _clientManager;
}
public ClansBanRepository getRepository()
{
return _repository;
}
public void loadClient(String name, Consumer<Optional<ClansBanClient>> callback)
{
_repository.loadClient(name).thenAccept(client -> runSync(() -> callback.accept(client)));
}
public void loadClient(UUID uuid, Consumer<ClansBanClient> callback)
{
_repository.loadClient(uuid).thenAccept(client -> runSync(() -> callback.accept(client)));
}
public void ban(ClansBanClient target, String targetName, String admin, long duration, String reason, Player caller, Consumer<Optional<ClansBan>> callback)
{
_repository.ban(target._uuid, admin, duration, reason).thenAccept(ban -> runSync(() ->
{
if (ban.isPresent())
{
target._bans.add(ban.get());
String banTimeFormatted = target.getBanTimeFormatted();
if (targetName != null)
{
for (Player notify : Bukkit.getOnlinePlayers())
{
if (_clientManager.Get(notify).GetRank().has(notify, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false))
{
UtilPlayer.message(notify, F.main(getName(), F.elem(targetName) + " is now banned " + banTimeFormatted + "."));
}
}
}
if (_fullOperation && Bukkit.getPlayer(target._uuid) != null)
{
Bukkit.getPlayer(target._uuid).kickPlayer(C.cRedB + "You have been banned from Clans " + banTimeFormatted + ".");
}
new ClansBanNotification(target._uuid, banTimeFormatted).publish();
}
else
{
if (caller != null && targetName != null)
{
UtilPlayer.message(caller, F.main(getName(), C.cRed + "An issue occurred when trying to ban " + F.elem(targetName)));
}
}
callback.accept(ban);
}));
}
public void unban(ClansBanClient target, ClansBan ban, Runnable callback)
{
if (!target._uuid.equals(ban.getUUID()))
{
return;
}
ban.remove();
_repository.removeBan(ban);
callback.run();
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onLogin(AsyncPlayerPreLoginEvent event)
{
if (!_fullOperation)
{
return;
}
try
{
ClansBanClient client = _repository.loadClient(event.getUniqueId()).get();
if (client.isBanned())
{
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
if (client.getLongestBan().isPermanent())
{
time = "Permanent";
}
String reason = C.cRedB + "You are banned from Clans for " + time +
"\n" + C.cWhite + client.getLongestBan().getReason();
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, reason);
}
}
catch (Exception ignored) {}
}
}

View File

@ -1,20 +1,24 @@
package mineplex.game.clans.clans.ban; package mineplex.core.punish.clans;
import mineplex.core.Managers; import java.sql.Connection;
import mineplex.core.account.CoreClientManager; import java.sql.PreparedStatement;
import mineplex.core.database.MinecraftRepository; import java.sql.ResultSet;
import mineplex.serverdata.database.DBPool; import java.sql.Statement;
import mineplex.serverdata.database.RepositoryBase; import java.sql.Timestamp;
import mineplex.serverdata.database.column.ColumnInt;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnInt;
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) VALUES (?, ?, ?, ?, ?, ?, ?);";
@ -50,18 +54,22 @@ public class ClansBanRepository extends RepositoryBase
{ {
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));
} else }
else
{ {
return Optional.empty(); return Optional.empty();
} }
} catch (Exception e) { }
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
return Optional.empty(); return Optional.empty();
} }
}); });
} }
public CompletableFuture<ClansBanClient> loadClient(UUID uuid) { public CompletableFuture<ClansBanClient> loadClient(UUID uuid)
{
return CompletableFuture.supplyAsync(() -> return CompletableFuture.supplyAsync(() ->
{ {
try (Connection conn = DBPool.getAccount().getConnection()) try (Connection conn = DBPool.getAccount().getConnection())
@ -87,7 +95,9 @@ public class ClansBanRepository extends RepositoryBase
} }
return new ClansBanClient(uuid, bans); return new ClansBanClient(uuid, bans);
} catch (Exception e) { }
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
return new ClansBanClient(uuid, new ArrayList<>()); return new ClansBanClient(uuid, new ArrayList<>());
} }
@ -106,7 +116,9 @@ public class ClansBanRepository extends RepositoryBase
CompletableFuture<Optional<ClansBanClient>> future = new CompletableFuture<>(); CompletableFuture<Optional<ClansBanClient>> future = new CompletableFuture<>();
future.complete(Optional.empty()); future.complete(Optional.empty());
return future; return future;
} else { }
else
{
return loadClient(uuid).thenApply(Optional::of); return loadClient(uuid).thenApply(Optional::of);
} }
}); });
@ -116,4 +128,4 @@ public class ClansBanRepository extends RepositoryBase
{ {
executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId())); executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId()));
} }
} }

View File

@ -1,13 +1,13 @@
package mineplex.game.clans.clans.ban.commands; package mineplex.core.punish.clans.command;
import mineplex.game.clans.clans.ban.ui.ClansBanShop;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.core.punish.clans.ClansBanManager;
import mineplex.core.punish.clans.ui.ClansBanShop;
public class ClansBanCommand extends CommandBase<ClansBanManager> public class ClansBanCommand extends CommandBase<ClansBanManager>
{ {
@ -35,23 +35,22 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
} }
final String finalReason = reason; final String finalReason = reason;
Plugin.getRepository().loadClient(playerName) Plugin.loadClient(playerName, client ->
.thenAccept(maybeClient -> {
Plugin.runSync(() -> if (client.isPresent())
{ {
if (!maybeClient.isPresent()) new ClansBanShop(Plugin, playerName, client.get(), finalReason).attemptShopOpen(caller);
{ }
UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName); else
} else {
{ UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName);
new ClansBanShop(Plugin, playerName, maybeClient.get(), finalReason).attemptShopOpen(caller); }
} });
}));
} }
else else
{ {
UtilPlayer.message(caller, C.cBlue + "/cb <username> <reason>" + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans."); UtilPlayer.message(caller, C.cBlue + "/cb <username> <reason>" + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans.");
} }
} }
} }

View File

@ -0,0 +1,27 @@
package mineplex.core.punish.clans.redis;
import java.util.UUID;
import mineplex.serverdata.commands.ServerCommand;
public class ClansBanNotification extends ServerCommand
{
private final UUID _target;
private final String _banTimeFormatted;
public ClansBanNotification(UUID target, String banTimeFormatted)
{
_target = target;
_banTimeFormatted = banTimeFormatted;
}
public UUID getTarget()
{
return _target;
}
public String getBanTimeFormatted()
{
return _banTimeFormatted;
}
}

View File

@ -1,21 +1,21 @@
package mineplex.game.clans.clans.ban.ui; package mineplex.core.punish.clans.ui;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ban.ClansBan;
import mineplex.game.clans.clans.ban.ClansBanClient;
import mineplex.game.clans.clans.ban.ClansBanManager;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.punish.clans.ClansBan;
import mineplex.core.punish.clans.ClansBanClient;
import mineplex.core.punish.clans.ClansBanManager;
import mineplex.core.shop.page.ShopPageBase;
public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop> public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
{ {
private long _time; private long _time;
@ -28,7 +28,7 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final String name, final Player player, String victimName, ClansBanClient client, String reason) public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final String name, final Player player, String victimName, ClansBanClient client, String reason)
{ {
super(banManager, shop, banManager.getClientManager(), banManager.getDonationManager(), name, player); super(banManager, shop, banManager.getClientManager(), Managers.get(DonationManager.class), name, player);
_reason = reason; _reason = reason;
@ -71,7 +71,8 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
C.cRed + C.Italics + "Left-Click to BAN PLAYER", C.cRed + C.Italics + "Left-Click to BAN PLAYER",
C.cGray + C.Italics + "Right-Click to toggle permanent ban setting" C.cGray + C.Italics + "Right-Click to toggle permanent ban setting"
).build(), ).build(),
(player, click) -> { (player, click) ->
{
if (click == ClickType.RIGHT) if (click == ClickType.RIGHT)
{ {
_permanent = !_permanent; _permanent = !_permanent;
@ -99,13 +100,16 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
.setGlow(ban.isActive()) .setGlow(ban.isActive())
.build(); .build();
addButton(slot++, item, (player, click) -> { addButton(slot++, item, (player, click) ->
{
if (ban.isActive()) if (ban.isActive())
{ {
getPlugin().runAsync(() -> { getPlugin().runAsync(() ->
getPlugin().unban(_victimClient, ban, client -> { {
getPlugin().unban(_victimClient, ban, () ->
{
refresh(); refresh();
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f); playAcceptSound(player);
}); });
}); });
} }
@ -115,32 +119,27 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
private void performBan() private void performBan()
{ {
getPlugin().getRepository().ban(_victimClient._uuid, getPlayer().getName(), _permanent ? -1 : _time, _reason) getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban ->
.thenAccept(maybeBan -> getPlugin().runSync(() -> {
{ if (ban.isPresent())
if (maybeBan.isPresent()) {
{ playAcceptSound(getPlayer());
_victimClient._bans.add(maybeBan.get()); refresh();
}
String banTimeFormatted = _victimClient.getBanTimeFormatted(); else
UtilPlayer.message(getPlayer(), F.main("Clans", F.elem(_victimName) + " is now banned " + banTimeFormatted + ".")); {
playDenySound(getPlayer());
Player target = Bukkit.getPlayer(_victimClient._uuid); }
target.kickPlayer(C.cRedB + "You have been banned from Clans " + banTimeFormatted + "."); });
refresh();
} else
{
F.main("Clans", C.cRed + "An issue occurred when trying to ban " + F.elem(_victimName));
}
}));
} }
private void addTimeAdjuster(int index, long time) private void addTimeAdjuster(int index, long time)
{ {
addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(), addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(),
(player, click) -> { (player, click) ->
{
_time += time; _time += time;
refresh(); refresh();
}); });
} }
} }

View File

@ -1,11 +1,13 @@
package mineplex.game.clans.clans.ban.ui; package mineplex.core.punish.clans.ui;
import mineplex.game.clans.clans.ban.ClansBanClient;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.Managers;
import mineplex.core.donation.DonationManager;
import mineplex.core.punish.clans.ClansBanClient;
import mineplex.core.punish.clans.ClansBanManager;
import mineplex.core.shop.ShopBase; import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase; import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ban.ClansBanManager;
public class ClansBanShop extends ShopBase<ClansBanManager> public class ClansBanShop extends ShopBase<ClansBanManager>
{ {
@ -15,7 +17,7 @@ public class ClansBanShop extends ShopBase<ClansBanManager>
public ClansBanShop(final ClansBanManager plugin, String victimName, ClansBanClient client, String reason) public ClansBanShop(final ClansBanManager plugin, String victimName, ClansBanClient client, String reason)
{ {
super(plugin, plugin.getClientManager(), plugin.getDonationManager(), "Clans Punish"); super(plugin, plugin.getClientManager(), Managers.get(DonationManager.class), "Clans Punish");
_clientName = victimName; _clientName = victimName;
_client = client; _client = client;
_reason = reason; _reason = reason;
@ -25,6 +27,5 @@ public class ClansBanShop extends ShopBase<ClansBanManager>
protected ShopPageBase<ClansBanManager, ? extends ShopBase<ClansBanManager>> buildPagesFor(final Player player) protected ShopPageBase<ClansBanManager, ? extends ShopBase<ClansBanManager>> buildPagesFor(final Player player)
{ {
return new ClansBanPage(getPlugin(), this, "Clans Punish", player, _clientName, _client, _reason); return new ClansBanPage(getPlugin(), this, "Clans Punish", player, _clientName, _client, _reason);
} }
} }

View File

@ -66,7 +66,7 @@ import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater; import mineplex.core.updater.Updater;
import mineplex.core.visibility.VisibilityManager; import mineplex.core.visibility.VisibilityManager;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.freeze.ClansFreezeManager;
import mineplex.game.clans.items.GearManager; import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.shop.building.BuildingShop; import mineplex.game.clans.shop.building.BuildingShop;
import mineplex.game.clans.shop.farming.FarmingShop; import mineplex.game.clans.shop.farming.FarmingShop;
@ -143,9 +143,9 @@ public class Clans extends JavaPlugin
Portal portal = new Portal(); Portal portal = new Portal();
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion(), GenericServer.CLANS_HUB); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion(), GenericServer.CLANS_HUB);
ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); ClansFreezeManager clansFreeze = new ClansFreezeManager(this, _clientManager);
Punish punish = new Punish(this, _clientManager); Punish punish = new Punish(this, _clientManager, true);
DisguiseManager disguiseManager = require(DisguiseManager.class); DisguiseManager disguiseManager = require(DisguiseManager.class);
Creature creature = new Creature(this); Creature creature = new Creature(this);
@ -187,7 +187,7 @@ public class Clans extends JavaPlugin
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
HologramManager hologram = new HologramManager(this, packetHandler); HologramManager hologram = new HologramManager(this, packetHandler);
_clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory); _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory);
new Recipes(this); new Recipes(this);
new Farming(this); new Farming(this);
new BuildingShop(_clansManager, _clientManager, _donationManager); new BuildingShop(_clansManager, _clientManager, _donationManager);
@ -243,4 +243,4 @@ public class Clans extends JavaPlugin
{ {
return MAP; return MAP;
} }
} }

View File

@ -90,7 +90,6 @@ import mineplex.game.clans.Clans;
import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.amplifiers.AmplifierManager; import mineplex.game.clans.clans.amplifiers.AmplifierManager;
import mineplex.game.clans.clans.ban.ClansBanManager;
import mineplex.game.clans.clans.banners.BannerManager; import mineplex.game.clans.clans.banners.BannerManager;
import mineplex.game.clans.clans.boxes.BoxManager; import mineplex.game.clans.clans.boxes.BoxManager;
import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClanManagementCommand;
@ -98,7 +97,6 @@ import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand;
import mineplex.game.clans.clans.commands.ClansCommand; import mineplex.game.clans.clans.commands.ClansCommand;
import mineplex.game.clans.clans.commands.KillCommand; import mineplex.game.clans.clans.commands.KillCommand;
import mineplex.game.clans.clans.commands.MapCommand;
import mineplex.game.clans.clans.commands.RegionsCommand; import mineplex.game.clans.clans.commands.RegionsCommand;
import mineplex.game.clans.clans.commands.SpeedCommand; import mineplex.game.clans.clans.commands.SpeedCommand;
import mineplex.game.clans.clans.data.PlayerClan; import mineplex.game.clans.clans.data.PlayerClan;
@ -106,7 +104,6 @@ import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.gui.ClanShop;
import mineplex.game.clans.clans.invsee.InvseeManager; import mineplex.game.clans.clans.invsee.InvseeManager;
import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.map.ItemMapManager;
import mineplex.game.clans.clans.mounts.MountManager; import mineplex.game.clans.clans.mounts.MountManager;
import mineplex.game.clans.clans.nameblacklist.ClansBlacklist; import mineplex.game.clans.clans.nameblacklist.ClansBlacklist;
import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.nether.NetherManager;
@ -115,7 +112,6 @@ import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.potato.PotatoManager;
import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
import mineplex.game.clans.core.ClaimLocation;
import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.regions.ClansRegions;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
@ -124,6 +120,7 @@ import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.clans.warpoints.WarPointEvasion; import mineplex.game.clans.clans.warpoints.WarPointEvasion;
import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.core.ClaimLocation;
import mineplex.game.clans.core.ClanDeleteCommand; import mineplex.game.clans.core.ClanDeleteCommand;
import mineplex.game.clans.core.ClanLoadCommand; import mineplex.game.clans.core.ClanLoadCommand;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
@ -257,7 +254,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// Spawn area // Spawn area
public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager) public ClansManager(JavaPlugin plugin, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager)
{ {
super("Clans Manager", plugin); super("Clans Manager", plugin);
@ -288,7 +285,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_npcManager = new NpcManager(plugin, Managers.get(Creature.class)); _npcManager = new NpcManager(plugin, Managers.get(Creature.class));
_condition = new SkillConditionManager(plugin); _condition = new SkillConditionManager(plugin);
_damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition); _damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition);
_damageManager.addCommand(new KillCommand(_damageManager));
_condition.setDamageManager(_damageManager); _condition.setDamageManager(_damageManager);
_worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null); _worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null);
@ -494,6 +490,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
addCommand(new ClanManagementCommand(this)); addCommand(new ClanManagementCommand(this));
// addCommand(new MapCommand(this)); // addCommand(new MapCommand(this));
addCommand(new SpeedCommand(this)); addCommand(new SpeedCommand(this));
addCommand(new KillCommand(this));
} }
public void loadClan(ClanToken clanToken, boolean loadBanner) public void loadClan(ClanToken clanToken, boolean loadBanner)
@ -515,7 +512,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
} }
if (loadBanner) if (loadBanner)
{
_bannerManager.loadBanner(clan); _bannerManager.loadBanner(clan);
}
} }
public void loadClan(ClanToken clanToken) public void loadClan(ClanToken clanToken)

View File

@ -1,26 +0,0 @@
package mineplex.game.clans.clans.ban;
/**
* Stores the data provided through the /cban (Clans ban) command for use further in the plugin.
*/
public class ClansBanCache
{
private String _victim;
private String _reason;
public ClansBanCache(String victim, String reason)
{
_victim = victim;
_reason = reason;
}
public String getVictim()
{
return _victim;
}
public String getReason()
{
return _reason;
}
}

View File

@ -1,17 +1,19 @@
package mineplex.game.clans.clans.commands; package mineplex.game.clans.clans.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.game.clans.spawn.Spawn;
import org.bukkit.entity.Player; public class KillCommand extends CommandBase<ClansManager>
public class KillCommand extends CommandBase<DamageManager>
{ {
public KillCommand(DamageManager plugin) public KillCommand(ClansManager plugin)
{ {
super(plugin, Rank.ALL, "suicide", "kill"); super(plugin, Rank.ALL, "suicide", "kill");
} }
@ -19,26 +21,26 @@ public class KillCommand extends CommandBase<DamageManager>
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if ((System.currentTimeMillis() - Plugin.GetCombatManager().Get(caller).GetLastCombat()) <= 20000) if (!UtilTime.elapsed(Plugin.getCombatManager().Get(caller).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION))
{ {
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat.")); UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat."));
return; return;
} }
if(ClansManager.getInstance().getTutorial().inTutorial(caller)) if (Plugin.getTutorial().inTutorial(caller))
{ {
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial.")); UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial."));
return; return;
} }
if (mineplex.core.recharge.Recharge.Instance.use(caller, "Suicide", 5000, false, false)) if (Plugin.getClanUtility().isSafe(caller.getLocation()) || (Plugin.getClanUtility().getClaim(caller.getLocation()) != null && Plugin.getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn")))
{
UtilPlayer.message(caller, F.main("Clans", "Please wait a bit before suiciding"));
return;
}
if (ClansManager.getInstance().getClanUtility().isSafe(caller.getLocation()) || (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn")))
{ {
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in a safezone!")); UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in a safezone!"));
return; return;
} }
if (Recharge.Instance.use(caller, "Suicide", 5000, false, false))
{
UtilPlayer.message(caller, F.main("Clans", "Run the command again to confirm."));
return;
}
UtilPlayer.message(caller, F.main("Clans", "You have imploded.")); UtilPlayer.message(caller, F.main("Clans", "You have imploded."));

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.clans.ban; package mineplex.game.clans.clans.freeze;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -12,7 +12,6 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -23,89 +22,38 @@ import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
import mineplex.game.clans.clans.ban.commands.FreezeCommand;
import mineplex.game.clans.clans.ban.commands.UnfreezeCommand;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.clans.freeze.commands.FreezeCommand;
import mineplex.game.clans.clans.freeze.commands.UnfreezeCommand;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class ClansBanManager extends MiniPlugin public class ClansFreezeManager extends MiniPlugin
{ {
private static final long FREEZE_MESSAGE_INTERVAL = 10000; private static final long FREEZE_MESSAGE_INTERVAL = 10000;
private final CoreClientManager _clientManager; private final CoreClientManager _clientManager;
private final DonationManager _donationManager;
private final ClansBanRepository _repository;
private final Map<UUID, Float> _frozen = new HashMap<>(); private final Map<UUID, Float> _frozen = new HashMap<>();
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) public ClansFreezeManager(JavaPlugin plugin, CoreClientManager clientManager)
{ {
super("Blacklist", plugin); super("Freeze", plugin);
_clientManager = clientManager; _clientManager = clientManager;
_repository = new ClansBanRepository(plugin);
_donationManager = donationManager;
} }
@Override @Override
public void addCommands() public void addCommands()
{ {
addCommand(new ClansBanCommand(this));
addCommand(new FreezeCommand(this)); addCommand(new FreezeCommand(this));
addCommand(new UnfreezeCommand(this)); addCommand(new UnfreezeCommand(this));
} }
public CoreClientManager getClientManager()
{
return _clientManager;
}
public DonationManager getDonationManager()
{
return _donationManager;
}
public ClansBanRepository getRepository()
{
return _repository;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onLogin(AsyncPlayerPreLoginEvent event)
{
try
{
ClansBanClient client = _repository.loadClient(event.getUniqueId()).get();
if (client.isBanned())
{
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
if (client.getLongestBan().isPermanent())
{
time = "Permanent";
}
String reason = C.cRedB + "You are banned from Clans for " + time +
"\n" + C.cWhite + client.getLongestBan().getReason();
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, reason);
}
} catch (Exception ignored) {}
}
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onQuit(PlayerQuitEvent event) public void onQuit(PlayerQuitEvent event)
@ -299,17 +247,4 @@ public class ClansBanManager extends MiniPlugin
} }
} }
} }
}
public void unban(ClansBanClient target, ClansBan ban, Callback<ClansBanClient> callback)
{
if (!target._uuid.equals(ban.getUUID()))
{
return;
}
ban.remove();
_repository.removeBan(ban);
callback.run(target);
}
}

View File

@ -1,20 +1,20 @@
package mineplex.game.clans.clans.ban.commands; package mineplex.game.clans.clans.freeze.commands;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.freeze.ClansFreezeManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
* Command to freeze players * Command to freeze players
*/ */
public class FreezeCommand extends CommandBase<ClansBanManager> public class FreezeCommand extends CommandBase<ClansFreezeManager>
{ {
public FreezeCommand(ClansBanManager plugin) public FreezeCommand(ClansFreezeManager plugin)
{ {
super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "freeze"); super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "freeze");
} }

View File

@ -1,20 +1,20 @@
package mineplex.game.clans.clans.ban.commands; package mineplex.game.clans.clans.freeze.commands;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.freeze.ClansFreezeManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
* Command to unfreeze players * Command to unfreeze players
*/ */
public class UnfreezeCommand extends CommandBase<ClansBanManager> public class UnfreezeCommand extends CommandBase<ClansFreezeManager>
{ {
public UnfreezeCommand(ClansBanManager plugin) public UnfreezeCommand(ClansFreezeManager plugin)
{ {
super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "unfreeze"); super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "unfreeze");
} }

View File

@ -756,4 +756,4 @@ public class Gameplay extends MiniPlugin
{ {
UtilPlayer.message(player, F.main("Clans", message)); UtilPlayer.message(player, F.main("Clans", message));
} }
} }

View File

@ -23,8 +23,8 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.freeze.ClansFreezeManager;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ban.ClansBanManager;
import mineplex.game.clans.clans.worldevent.raid.RaidManager; import mineplex.game.clans.clans.worldevent.raid.RaidManager;
import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
import mineplex.game.clans.restart.RestartManager; import mineplex.game.clans.restart.RestartManager;
@ -66,7 +66,7 @@ public class SafeLog extends MiniPlugin
return; return;
} }
if (Managers.get(ClansBanManager.class).isFrozen(player)) if (Managers.get(ClansFreezeManager.class).isFrozen(player))
{ {
isSafeLog = true; isSafeLog = true;
} }

View File

@ -236,7 +236,5 @@ public class CombatLog
public void SetKillerColor(String color) public void SetKillerColor(String color)
{ {
_killerColor = color; _killerColor = color;
} }
}
}