diff --git a/RedisBungee-API/pom.xml b/RedisBungee-API/pom.xml
index ef777dc..f4f791b 100644
--- a/RedisBungee-API/pom.xml
+++ b/RedisBungee-API/pom.xml
@@ -5,7 +5,7 @@
RedisBungee
com.imaginarycode.minecraft
- 0.8.1-SNAPSHOT
+ 0.9.0-SNAPSHOT
4.0.0
diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/AbstractRedisBungeeListener.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/AbstractRedisBungeeListener.java
index 45f9607..64b42ab 100644
--- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/AbstractRedisBungeeListener.java
+++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/AbstractRedisBungeeListener.java
@@ -23,10 +23,6 @@ import java.util.Map;
public abstract class AbstractRedisBungeeListener {
- protected static final String ALREADY_LOGGED_IN = "§cYou are already logged on to this server. \n\nIt may help to try logging in again in a few minutes.\nIf this does not resolve your issue, please contact staff.";
-
- protected static final String ONLINE_MODE_RECONNECT = "§cWhoops! You need to reconnect\n\nWe found someone online using your username. They were kicked and you may reconnect.\nIf this does not work, please contact staff.";
-
protected final RedisBungeePlugin> plugin;
protected final List exemptAddresses;
protected final Gson gson = new Gson();
diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/ConfigLoader.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/ConfigLoader.java
index 195730a..02d32dd 100644
--- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/ConfigLoader.java
+++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/ConfigLoader.java
@@ -11,6 +11,8 @@
package com.imaginarycode.minecraft.redisbungee.api.config;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.TypeToken;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
@@ -82,7 +84,7 @@ public interface ConfigLoader {
} else {
plugin.logInfo("Loaded proxy id " + proxyId);
}
- RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerLegacyCommands, overrideBungeeCommands);
+ RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerLegacyCommands, overrideBungeeCommands, getMessagesFromPath(createMessagesFile(dataFolder)));
Summoner> summoner;
RedisBungeeMode redisBungeeMode;
if (node.getNode("cluster-mode-enabled").getBoolean(false)) {
@@ -130,6 +132,29 @@ public interface ConfigLoader {
void onConfigLoad(RedisBungeeConfiguration configuration, Summoner> summoner, RedisBungeeMode mode);
+ default ImmutableMap getMessagesFromPath(Path path) throws IOException {
+ final YAMLConfigurationLoader yamlConfigurationFileLoader = YAMLConfigurationLoader.builder().setPath(path).build();
+ ConfigurationNode node = yamlConfigurationFileLoader.load();
+ HashMap messages = new HashMap<>();
+ messages.put(RedisBungeeConfiguration.MessageType.LOGGED_IN_OTHER_LOCATION, node.getNode("logged-in-other-location").getString("§cLogged in from another location."));
+ return ImmutableMap.copyOf(messages);
+ }
+
+ default Path createMessagesFile(Path dataFolder) throws IOException {
+ if (Files.notExists(dataFolder)) {
+ Files.createDirectory(dataFolder);
+ }
+ Path file = dataFolder.resolve("messages.yml");
+ if (Files.notExists(file)) {
+ try (InputStream in = getClass().getClassLoader().getResourceAsStream("messages.yml")) {
+ Files.createFile(file);
+ assert in != null;
+ Files.copy(in, file, StandardCopyOption.REPLACE_EXISTING);
+ }
+ }
+ return file;
+ }
+
default Path createConfigFile(Path dataFolder) throws IOException {
if (Files.notExists(dataFolder)) {
Files.createDirectory(dataFolder);
diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java
index 4df0245..04807e3 100644
--- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java
+++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java
@@ -11,12 +11,21 @@
package com.imaginarycode.minecraft.redisbungee.api.config;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
import com.google.common.net.InetAddresses;
import java.net.InetAddress;
+import java.util.HashMap;
import java.util.List;
public class RedisBungeeConfiguration {
+
+ public enum MessageType {
+ LOGGED_IN_OTHER_LOCATION
+ }
+
+ private final ImmutableMap messages;
public static final int CONFIG_VERSION = 1;
private final String proxyId;
private final List exemptAddresses;
@@ -25,9 +34,9 @@ public class RedisBungeeConfiguration {
private final boolean overrideBungeeCommands;
- public RedisBungeeConfiguration(String proxyId, List exemptAddresses, boolean registerLegacyCommands, boolean overrideBungeeCommands) {
+ public RedisBungeeConfiguration(String proxyId, List exemptAddresses, boolean registerLegacyCommands, boolean overrideBungeeCommands, ImmutableMap messages) {
this.proxyId = proxyId;
-
+ this.messages = messages;
ImmutableList.Builder addressBuilder = ImmutableList.builder();
for (String s : exemptAddresses) {
addressBuilder.add(InetAddresses.forString(s));
@@ -52,4 +61,8 @@ public class RedisBungeeConfiguration {
public boolean doOverrideBungeeCommands() {
return overrideBungeeCommands;
}
+
+ public ImmutableMap getMessages() {
+ return messages;
+ }
}
diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/player/PlayerUtils.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/player/PlayerUtils.java
index 8d1a8af..0f6423a 100644
--- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/player/PlayerUtils.java
+++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/player/PlayerUtils.java
@@ -14,30 +14,46 @@ import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUt
public class PlayerUtils {
public static void cleanUpPlayer(String uuid, UnifiedJedis rsc, boolean firePayload) {
+ final long timestamp = System.currentTimeMillis();
+ final boolean isKickedFromOtherLocation = isKickedOtherLocation(uuid, rsc);
rsc.srem("proxy:" + AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId() + ":usersOnline", uuid);
- rsc.hdel("player:" + uuid, "server", "ip", "proxy");
- long timestamp = System.currentTimeMillis();
- rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
- if (firePayload) {
+ if (!isKickedFromOtherLocation) {
+ rsc.hdel("player:" + uuid, "server", "ip", "proxy");
+ rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
+ }
+ if (firePayload && !isKickedFromOtherLocation) {
playerQuitPayload(uuid, rsc, timestamp);
}
}
+ public static void setKickedOtherLocation(String uuid, UnifiedJedis unifiedJedis) {
+ // set anything for sake of exists check. then expire it after 2 seconds in case proxy fails to unset it.
+ unifiedJedis.set("kicked-other-location::" + uuid, "0");
+ unifiedJedis.expire("kicked-other-location::" + uuid, 2);
+ }
+
+ public static boolean isKickedOtherLocation(String uuid, UnifiedJedis unifiedJedis) {
+ return unifiedJedis.exists("kicked-other-location::" + uuid);
+ }
+
+
public static void createPlayer(UUID uuid, UnifiedJedis unifiedJedis, String currentServer, InetAddress hostname, boolean fireEvent) {
if (currentServer != null) {
unifiedJedis.hset("player:" + uuid, "server", currentServer);
}
+ final boolean isKickedFromOtherLocation = isKickedOtherLocation(uuid.toString(), unifiedJedis);
Map playerData = new HashMap<>(4);
playerData.put("online", "0");
playerData.put("ip", hostname.getHostName());
playerData.put("proxy", AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId());
unifiedJedis.sadd("proxy:" + AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId() + ":usersOnline", uuid.toString());
- unifiedJedis.hmset("player:" + uuid, playerData);
+ unifiedJedis.hset("player:" + uuid, playerData);
- if (fireEvent) {
+ if (fireEvent && !isKickedFromOtherLocation) {
playerJoinPayload(uuid, unifiedJedis, hostname);
}
+
}
diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDTranslator.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDTranslator.java
index 7bd829e..788b683 100644
--- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDTranslator.java
+++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDTranslator.java
@@ -191,7 +191,7 @@ public final class UUIDTranslator {
public void persistInfo(String name, UUID uuid, UnifiedJedis unifiedJedis) {
addToMaps(name, uuid);
String json = gson.toJson(uuidToNameMap.get(uuid));
- unifiedJedis.hmset("uuid-cache", ImmutableMap.of(name.toLowerCase(), json, uuid.toString(), json));
+ unifiedJedis.hset("uuid-cache", ImmutableMap.of(name.toLowerCase(), json, uuid.toString(), json));
}
private static class CachedUUIDEntry {
diff --git a/RedisBungee-API/src/main/resources/messages.yml b/RedisBungee-API/src/main/resources/messages.yml
new file mode 100644
index 0000000..bcf05b4
--- /dev/null
+++ b/RedisBungee-API/src/main/resources/messages.yml
@@ -0,0 +1 @@
+logged-in-other-location: "§cYou logged in from another location!"
\ No newline at end of file
diff --git a/RedisBungee-Bungee/pom.xml b/RedisBungee-Bungee/pom.xml
index fe0d19f..09e4ac2 100644
--- a/RedisBungee-Bungee/pom.xml
+++ b/RedisBungee-Bungee/pom.xml
@@ -5,7 +5,7 @@
RedisBungee
com.imaginarycode.minecraft
- 0.8.1-SNAPSHOT
+ 0.9.0-SNAPSHOT
4.0.0
diff --git a/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeBungeeListener.java b/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeBungeeListener.java
index 8be3750..df7d486 100644
--- a/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeBungeeListener.java
+++ b/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeBungeeListener.java
@@ -17,6 +17,7 @@ import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.imaginarycode.minecraft.redisbungee.api.AbstractRedisBungeeListener;
+import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
import com.imaginarycode.minecraft.redisbungee.api.util.player.PlayerUtils;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
@@ -47,7 +48,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener(plugin) {
@@ -57,27 +58,9 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener
RedisBungee
com.imaginarycode.minecraft
- 0.8.1-SNAPSHOT
+ 0.9.0-SNAPSHOT
4.0.0
diff --git a/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeVelocityListener.java b/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeVelocityListener.java
index 23a2643..f119cef 100644
--- a/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeVelocityListener.java
+++ b/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeVelocityListener.java
@@ -17,6 +17,7 @@ import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.imaginarycode.minecraft.redisbungee.api.AbstractRedisBungeeListener;
+import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
import com.imaginarycode.minecraft.redisbungee.api.util.player.PlayerUtils;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
@@ -36,6 +37,7 @@ import com.velocitypowered.api.event.proxy.ProxyPingEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.ServerPing;
+import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import redis.clients.jedis.UnifiedJedis;
@@ -54,7 +56,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener(plugin) {
@Override
@@ -63,23 +65,9 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener players = original.stream()
- .map(uuid -> plugin.getUuidTranslator().getNameFromUuid(uuid, false))
- .collect(Collectors.toSet());
+ .map(uuid -> plugin.getUuidTranslator().getNameFromUuid(uuid, false))
+ .collect(Collectors.toSet());
out.writeUTF(Joiner.on(',').join(players));
break;
case "PlayerCount":
@@ -246,7 +234,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListenercom.imaginarycode.minecraft
RedisBungee
pom
- 0.8.1-SNAPSHOT
+ 0.9.0-SNAPSHOT