mirror of
https://github.com/plexusorg/Plex.git
synced 2024-10-31 17:17:12 +00:00
add plugin messaging to proxies for kicking players
This commit is contained in:
parent
7d709319c6
commit
9284ec3409
@ -23,10 +23,7 @@ import dev.plex.storage.player.MongoPlayerData;
|
||||
import dev.plex.storage.player.SQLPlayerData;
|
||||
import dev.plex.storage.punishment.SQLNotes;
|
||||
import dev.plex.storage.punishment.SQLPunishment;
|
||||
import dev.plex.util.BuildInfo;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.UpdateChecker;
|
||||
import dev.plex.util.*;
|
||||
import dev.plex.world.CustomWorld;
|
||||
import java.io.File;
|
||||
import lombok.Getter;
|
||||
@ -103,6 +100,7 @@ public class Plex extends PlexPlugin
|
||||
moduleManager.loadModules();
|
||||
|
||||
this.setChatHandler(new ChatListener.ChatHandlerImpl());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,6 +188,15 @@ public class Plex extends PlexPlugin
|
||||
PlexLog.log("Started " + serviceManager.serviceCount() + " services.");
|
||||
|
||||
reloadPlayers();
|
||||
PlexLog.debug("Registered Bukkit -> BungeeCord Plugin Messaging Channel");
|
||||
PlexLog.debug("Velocity Support? " + BungeeUtil.isVelocity());
|
||||
PlexLog.debug("BungeeCord Support? " + BungeeUtil.isBungeeCord());
|
||||
if (BungeeUtil.isBungeeCord() && BungeeUtil.isVelocity())
|
||||
{
|
||||
PlexLog.warn("It seems you have both velocity and bungeecord configuration options enabled! When running Velocity, you do NOT need to enable bungeecord.");
|
||||
}
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
|
||||
moduleManager.enableModules();
|
||||
}
|
||||
|
||||
@ -220,6 +227,8 @@ public class Plex extends PlexPlugin
|
||||
redisConnection.getJedis().close();
|
||||
}
|
||||
|
||||
this.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
|
||||
|
||||
moduleManager.disableModules();
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,8 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import dev.plex.util.WebUtils;
|
||||
import dev.plex.util.*;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
@ -100,7 +98,12 @@ public class BanCMD extends PlexCommand
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.kick(Punishment.generateBanMessage(punishment));
|
||||
if (BungeeUtil.isBungeeCord() || BungeeUtil.isVelocity())
|
||||
{
|
||||
BungeeUtil.kickPlayer(player, Punishment.generateBanMessage(punishment));
|
||||
} else {
|
||||
player.kick(Punishment.generateBanMessage(punishment));
|
||||
}
|
||||
}
|
||||
});
|
||||
PlexLog.debug("(From /ban command) PunishedPlayer UUID: " + plexPlayer.getUuid());
|
||||
|
@ -10,12 +10,10 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import dev.plex.util.WebUtils;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -24,6 +22,10 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandParameters(name = "kick", description = "Kicks a player", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.kick", source = RequiredCommandSource.ANY)
|
||||
public class KickCMD extends PlexCommand
|
||||
@ -65,7 +67,13 @@ 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()));
|
||||
player.kick(componentFromString(reason));
|
||||
if (BungeeUtil.isBungeeCord() || BungeeUtil.isVelocity())
|
||||
{
|
||||
BungeeUtil.kickPlayer(player, Punishment.generateBanMessage(punishment));
|
||||
} else
|
||||
{
|
||||
player.kick(Punishment.generateBanMessage(punishment));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -11,11 +11,10 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import dev.plex.util.WebUtils;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -24,6 +23,9 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason]", description = "Temporarily ban a player")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.tempban", source = RequiredCommandSource.ANY)
|
||||
|
||||
@ -71,8 +73,7 @@ public class TempbanCMD extends PlexCommand
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 2, args.length);
|
||||
punishment.setReason(reason);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
punishment.setReason("No reason provided.");
|
||||
}
|
||||
@ -88,7 +89,13 @@ public class TempbanCMD extends PlexCommand
|
||||
PlexUtils.broadcast(messageComponent("banningPlayer", sender.getName(), plexPlayer.getName()));
|
||||
if (player != null)
|
||||
{
|
||||
player.kick(Punishment.generateBanMessage(punishment));
|
||||
if (BungeeUtil.isBungeeCord() || BungeeUtil.isVelocity())
|
||||
{
|
||||
BungeeUtil.kickPlayer(player, Punishment.generateBanMessage(punishment));
|
||||
} else
|
||||
{
|
||||
player.kick(Punishment.generateBanMessage(punishment));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
32
server/src/main/java/dev/plex/util/BungeeUtil.java
Normal file
32
server/src/main/java/dev/plex/util/BungeeUtil.java
Normal file
@ -0,0 +1,32 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import dev.plex.Plex;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BungeeUtil
|
||||
{
|
||||
public static boolean isBungeeCord()
|
||||
{
|
||||
return Bukkit.spigot().getSpigotConfig().getBoolean("settings.bungeecord");
|
||||
}
|
||||
|
||||
public static boolean isVelocity()
|
||||
{
|
||||
return Bukkit.spigot().getPaperConfig().getBoolean("settings.velocity-support.enabled") && !Bukkit.spigot().getPaperConfig().getString("settings.velocity-support.secret", "").isEmpty();
|
||||
}
|
||||
|
||||
public static void kickPlayer(Player player, Component message)
|
||||
{
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("KickPlayer");
|
||||
out.writeUTF(player.getName());
|
||||
out.writeUTF(LegacyComponentSerializer.legacySection().serialize(message));
|
||||
player.sendPluginMessage(Plex.get(), "BungeeCord", out.toByteArray());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user