mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-04-08 16:10:26 +00:00
welcome adventure api
MiniMessage is now used for Messages.yml fix bug when from is null when server change
This commit is contained in:
@@ -23,6 +23,13 @@ dependencies {
|
||||
api("com.squareup.okhttp:okhttp:2.7.5")
|
||||
api("org.spongepowered:configurate-yaml:$configurateVersion")
|
||||
api("com.github.ben-manes.caffeine:caffeine:3.1.8")
|
||||
|
||||
api("net.kyori:adventure-api:4.14.0")
|
||||
api("net.kyori:adventure-text-serializer-gson:4.14.0")
|
||||
api("net.kyori:adventure-text-serializer-legacy:4.14.0")
|
||||
api("net.kyori:adventure-text-serializer-plain:4.14.0")
|
||||
api("net.kyori:adventure-text-minimessage:4.14.0")
|
||||
|
||||
// tests
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import redis.clients.jedis.Jedis;
|
||||
@@ -347,8 +348,9 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* calls {@link #getUuidFromName(String)} to get uuid
|
||||
*
|
||||
* @param playerName player name
|
||||
* @param message kick message that player will see on kick
|
||||
* @param message kick message that player will see on kick
|
||||
* @since 0.8.0
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
public void kickPlayer(String playerName, String message) {
|
||||
@@ -361,11 +363,38 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @param playerUUID player name
|
||||
* @param message kick message that player will see on kick
|
||||
* @since 0.8.0
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void kickPlayer(UUID playerUUID, String message) {
|
||||
kickPlayer(playerUUID, Component.text(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicks a player from the network
|
||||
* calls {@link #getUuidFromName(String)} to get uuid
|
||||
*
|
||||
* @param playerName player name
|
||||
* @param message kick message that player will see on kick
|
||||
* @since 0.12.0
|
||||
*/
|
||||
|
||||
public void kickPlayer(String playerName, Component message) {
|
||||
kickPlayer(getUuidFromName(playerName), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicks a player from the network
|
||||
*
|
||||
* @param playerUUID player name
|
||||
* @param message kick message that player will see on kick
|
||||
* @since 0.12.0
|
||||
*/
|
||||
public void kickPlayer(UUID playerUUID, Component message) {
|
||||
this.plugin.playerDataManager().kickPlayer(playerUUID, message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This gives you instance of Jedis
|
||||
*
|
||||
|
||||
@@ -19,6 +19,8 @@ import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNe
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisPipelineTask;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.ClusterPipeline;
|
||||
import redis.clients.jedis.Pipeline;
|
||||
@@ -85,7 +87,7 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
||||
}
|
||||
UUID uuid = UUID.fromString(data.getString("uuid"));
|
||||
String message = data.getString("message");
|
||||
plugin.handlePlatformKick(uuid, message);
|
||||
plugin.handlePlatformKick(uuid, COMPONENT_SERIALIZER.deserialize(message));
|
||||
return;
|
||||
}
|
||||
if (event.getChannel().equals("redisbungee-serverchange")) {
|
||||
@@ -95,7 +97,8 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
||||
return;
|
||||
}
|
||||
UUID uuid = UUID.fromString(data.getString("uuid"));
|
||||
String from = data.getString("from");
|
||||
String from = null;
|
||||
if (data.has("from")) from = data.getString("from");
|
||||
String to = data.getString("to");
|
||||
plugin.fireEvent(plugin.createPlayerChangedServerNetworkEvent(uuid, from, to));
|
||||
return;
|
||||
@@ -133,12 +136,14 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
||||
handleServerChangeRedis(uuid, to);
|
||||
}
|
||||
|
||||
public void kickPlayer(UUID uuid, String message) {
|
||||
private final JSONComponentSerializer COMPONENT_SERIALIZER =JSONComponentSerializer.json();
|
||||
|
||||
public void kickPlayer(UUID uuid, Component message) {
|
||||
if (!plugin.handlePlatformKick(uuid, message)) { // handle locally before SENDING a message
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("proxy", plugin.configuration().getProxyId());
|
||||
data.put("uuid", uuid);
|
||||
data.put("message", message);
|
||||
data.put("message", COMPONENT_SERIALIZER.serialize(message));
|
||||
plugin.proxyDataManager().sendChannelMessage("redisbungee-kick", data.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfigurati
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.EventsPlatform;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDTranslator;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.UUID;
|
||||
@@ -76,7 +77,7 @@ public interface RedisBungeePlugin<P> extends EventsPlatform {
|
||||
|
||||
public String getPlayerName(UUID player);
|
||||
|
||||
boolean handlePlatformKick(UUID uuid, String message);
|
||||
boolean handlePlatformKick(UUID uuid, Component message);
|
||||
|
||||
public String getPlayerServerName(P player);
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ public class RedisBungeeConfiguration {
|
||||
return overrideBungeeCommands;
|
||||
}
|
||||
|
||||
public ImmutableMap<MessageType, String> getMessages() {
|
||||
return messages;
|
||||
public String getMessage(MessageType messageType) {
|
||||
return this.messages.get(messageType);
|
||||
}
|
||||
|
||||
public boolean kickWhenOnline() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# this config file is for messages for players and command messages
|
||||
# Note this uses legacy formating which § for color codes
|
||||
# this might get replaced soon with mini message for both, velocity and bungeecord
|
||||
logged-in-other-location: "§cYou logged in from another location!"
|
||||
already-logged-in: "§cYou are already logged in!"
|
||||
# Note this uses MiniMessage format https://docs.advntr.dev/minimessage/format.html
|
||||
|
||||
logged-in-other-location: "<color:red>You logged in from another location!"
|
||||
already-logged-in: "<color:red>You are already logged in!"
|
||||
Reference in New Issue
Block a user