From 372c41d652d829fd1964ef967f7445b90a69c584 Mon Sep 17 00:00:00 2001 From: mohammed jasem alaajel Date: Tue, 14 May 2024 21:45:59 +0400 Subject: [PATCH] add bungeecord specific kick api --- .../bungeecord-api/build.gradle.kts | 1 + .../minecraft/redisbungee/RedisBungeeAPI.java | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/proxies/bungeecord/bungeecord-api/build.gradle.kts b/proxies/bungeecord/bungeecord-api/build.gradle.kts index 8fd4840..8b006f7 100644 --- a/proxies/bungeecord/bungeecord-api/build.gradle.kts +++ b/proxies/bungeecord/bungeecord-api/build.gradle.kts @@ -10,6 +10,7 @@ dependencies { exclude("com.google.code.gson", "gson") exclude("net.kyori","adventure-api") } + compileOnly(libs.adventure.platforms.bungeecord) } description = "RedisBungee Bungeecord API" diff --git a/proxies/bungeecord/bungeecord-api/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java b/proxies/bungeecord/bungeecord-api/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java index 7681063..6fe8456 100644 --- a/proxies/bungeecord/bungeecord-api/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java +++ b/proxies/bungeecord/bungeecord-api/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java @@ -13,7 +13,8 @@ package com.imaginarycode.minecraft.redisbungee; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner; -import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; +import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.plugin.Plugin; import org.checkerframework.checker.nullness.qual.NonNull; @@ -56,6 +57,30 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI { return ((Plugin) this.plugin).getProxy().getServerInfo(serverName); } + /** + * Kicks a player from the network but with bungeecord chat Component system + * calls {@link #getUuidFromName(String)} to get uuid + * + * @param playerName player name + * @param message kick message that player will see on kick + * @since 0.13.0 + */ + public void kickPlayer(String playerName, BaseComponent[] message) { + kickPlayer(getUuidFromName(playerName), message); + } + + /** + * Kicks a player from the network but with bungeecord chat Component system + * + * @param playerUUID player name + * @param message kick message that player will see on kick + * @since 0.13.0 + */ + public void kickPlayer(UUID playerUUID, BaseComponent[] message) { + kickPlayer(playerUUID, BungeeComponentSerializer.get().deserialize(message)); + } + + // LEGACY API FOR BACKWARD COMPATIBILITY /**