mirror of
https://github.com/plexusorg/Plex.git
synced 2024-11-13 07:13:32 +00:00
Cache whether the server is on a proxy or not
Fix kick where ban message was displayed instead of kick message
This commit is contained in:
parent
b0240ef46e
commit
f97411ce09
@ -39,14 +39,14 @@ public class BanCMD extends PlexCommand
|
||||
return usage();
|
||||
}
|
||||
|
||||
UUID targetUUID = WebUtils.getFromName(args[0]);
|
||||
final PlexPlayer plexPlayer = DataUtils.getPlayer(args[0]);
|
||||
|
||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||
if (plexPlayer == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||
Player player = Bukkit.getPlayer(targetUUID);
|
||||
|
||||
Player player = Bukkit.getPlayer(plexPlayer.getUuid());
|
||||
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
@ -64,7 +64,7 @@ public class BanCMD extends PlexCommand
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getPunishmentManager().isAsyncBanned(targetUUID).whenComplete((aBoolean, throwable) ->
|
||||
plugin.getPunishmentManager().isAsyncBanned(plexPlayer.getUuid()).whenComplete((aBoolean, throwable) ->
|
||||
{
|
||||
if (aBoolean)
|
||||
{
|
||||
@ -72,7 +72,7 @@ public class BanCMD extends PlexCommand
|
||||
return;
|
||||
}
|
||||
String reason;
|
||||
Punishment punishment = new Punishment(targetUUID, getUUID(sender));
|
||||
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setType(PunishmentType.BAN);
|
||||
if (args.length > 1)
|
||||
{
|
||||
|
@ -38,21 +38,20 @@ public class KickCMD extends PlexCommand
|
||||
return usage();
|
||||
}
|
||||
|
||||
UUID targetUUID = WebUtils.getFromName(args[0]);
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(args[0]);
|
||||
String reason = "No reason provided";
|
||||
|
||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||
if (plexPlayer == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||
Player player = Bukkit.getPlayer(targetUUID);
|
||||
Player player = Bukkit.getPlayer(plexPlayer.getUuid());
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
Punishment punishment = new Punishment(targetUUID, getUUID(sender));
|
||||
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setType(PunishmentType.KICK);
|
||||
if (args.length > 1)
|
||||
{
|
||||
@ -67,7 +66,7 @@ public class KickCMD extends PlexCommand
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||
plugin.getPunishmentManager().punish(plexPlayer, punishment);
|
||||
PlexUtils.broadcast(messageComponent("kickedPlayer", sender.getName(), plexPlayer.getName()));
|
||||
BungeeUtil.kickPlayer(player, Punishment.generateBanMessage(punishment));
|
||||
BungeeUtil.kickPlayer(player, Punishment.generateKickMessage(punishment));
|
||||
return null;
|
||||
}
|
||||
}
|
@ -49,6 +49,11 @@ public class Punishment
|
||||
return PlexUtils.messageComponent("banMessage", banUrl, punishment.getReason(), TimeUtils.useTimezone(punishment.getEndDate()), punishment.getPunisher() == null ? "CONSOLE" : MojangUtils.getInfo(punishment.getPunisher().toString()).getUsername());
|
||||
}
|
||||
|
||||
public static Component generateKickMessage(Punishment punishment)
|
||||
{
|
||||
return PlexUtils.messageComponent("kickMessage", punishment.getReason(), punishment.getPunisher() == null ? "CONSOLE" : MojangUtils.getInfo(punishment.getPunisher().toString()).getUsername());
|
||||
}
|
||||
|
||||
public static Component generateIndefBanMessageWithReason(String type, String reason)
|
||||
{
|
||||
return PlexUtils.messageComponent("indefBanMessageReason", type, banUrl, reason);
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class BungeeUtil
|
||||
{
|
||||
public static final boolean PROXIED_SERVER = isBungeeCord() || isVelocity();
|
||||
public static boolean isBungeeCord()
|
||||
{
|
||||
return Bukkit.spigot().getSpigotConfig().getBoolean("settings.bungeecord");
|
||||
@ -23,7 +24,7 @@ public class BungeeUtil
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public static void kickPlayer(Player player, Component message)
|
||||
{
|
||||
if (isBungeeCord() || isVelocity())
|
||||
if (PROXIED_SERVER)
|
||||
{
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("KickPlayer");
|
||||
|
@ -14,6 +14,9 @@
|
||||
# 2 - Expiry
|
||||
# 3 - Punisher
|
||||
banMessage: "<red>You have been banned! You may appeal at <gold>{0}.\n<red>Reason: <gold>{1}\n<red>End date: <gold>{2}\n<red>Banned by: <gold>{3}"
|
||||
# 0 - Reason
|
||||
# 1 - Punisher
|
||||
kickMessage: "<red>You have been kicked! \n<red>Reason: <gold>{0}\n<red>Kicked by: <gold>{1}"
|
||||
# 0 - The type of indefinite ban
|
||||
# 1 - Appeal URL
|
||||
indefBanMessage: "<red>Your {0} is indefinitely banned! You may appeal at <gold>{1}."
|
||||
|
Loading…
Reference in New Issue
Block a user