mongodb reactive stream driver
parent
84ade4ac37
commit
1ca0a07b3a
241
pom.xml
241
pom.xml
|
@ -1,126 +1,131 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>net.krakatoa.proxy</groupId>
|
<groupId>net.krakatoa.proxy</groupId>
|
||||||
<artifactId>KraProxySystem</artifactId>
|
<artifactId>KraProxySystem</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>14</maven.compiler.source>
|
<maven.compiler.source>14</maven.compiler.source>
|
||||||
<maven.compiler.target>14</maven.compiler.target>
|
<maven.compiler.target>14</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean install</defaultGoal>
|
<defaultGoal>clean install</defaultGoal>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<descriptorRefs>
|
<descriptorRefs>
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
</descriptorRefs>
|
</descriptorRefs>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>single</goal>
|
<goal>single</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<id>make-assembly</id>
|
<id>make-assembly</id>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>9</source>
|
<source>9</source>
|
||||||
<target>9</target>
|
<target>9</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.msgpack</groupId>
|
<groupId>org.msgpack</groupId>
|
||||||
<artifactId>msgpack-core</artifactId>
|
<artifactId>msgpack-core</artifactId>
|
||||||
<version>0.9.0</version>
|
<version>0.9.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.redisson</groupId>
|
<groupId>org.redisson</groupId>
|
||||||
<artifactId>redisson</artifactId>
|
<artifactId>redisson</artifactId>
|
||||||
<version>3.17.0</version>
|
<version>3.17.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-api</artifactId>
|
<artifactId>bungeecord-api</artifactId>
|
||||||
<version>1.17-R0.1-SNAPSHOT</version>
|
<version>1.17-R0.1-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<version>1.18.22</version>
|
<version>1.18.22</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>mongodb-driver-async</artifactId>
|
<artifactId>mongodb-driver-async</artifactId>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<version>3.12.10</version> <!-- 3.0.4 -->
|
<version>3.12.10</version> <!-- 3.0.4 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.dytanic.cloudnet</groupId>
|
<groupId>de.dytanic.cloudnet</groupId>
|
||||||
<artifactId>cloudnet-bridge</artifactId>
|
<artifactId>cloudnet-bridge</artifactId>
|
||||||
<version>3.4.0-RELEASE</version>
|
<version>3.4.0-RELEASE</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.dytanic.cloudnet</groupId>
|
<groupId>de.dytanic.cloudnet</groupId>
|
||||||
<artifactId>cloudnet-driver</artifactId>
|
<artifactId>cloudnet-driver</artifactId>
|
||||||
<version>3.4.0-RELEASE</version>
|
<version>3.4.0-RELEASE</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>earth.krakatoa</groupId>
|
<groupId>earth.krakatoa</groupId>
|
||||||
<artifactId>KraSocketClient</artifactId>
|
<artifactId>KraSocketClient</artifactId>
|
||||||
<version>1.2-SNAPSHOT</version>
|
<version>1.2-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>earth.krakatoa</groupId>
|
||||||
|
<artifactId>KraCore</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>bungeecord-repo</id>
|
<id>bungeecord-repo</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
</repository>
|
</repository>
|
||||||
<!-- https://github.com/TooTallNate/Java-WebSocket -->
|
<!-- https://github.com/TooTallNate/Java-WebSocket -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype-nexus-snapshots</id>
|
<id>sonatype-nexus-snapshots</id>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
<snapshots>
|
<snapshots>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>krakatoa-earth</id>
|
<id>krakatoa-earth</id>
|
||||||
<url>https://repo.krakatoa.umbach.dev/repository/krakatoa-earth/</url>
|
<url>https://repo.krakatoa.umbach.dev/repository/krakatoa-earth/</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
<snapshots>
|
<snapshots>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>cloudnet-releases</id>
|
<id>cloudnet-releases</id>
|
||||||
<url>https://repo.cloudnetservice.eu/repository/releases/</url>
|
<url>https://repo.cloudnetservice.eu/repository/releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</project>
|
</project>
|
|
@ -5,6 +5,11 @@ import earth.krakatao.KraSocketClientConfig;
|
||||||
import earth.krakatao.events.KraSocketClientEventInitiater;
|
import earth.krakatao.events.KraSocketClientEventInitiater;
|
||||||
import earth.krakatao.events.KraSocketClientEventInterface;
|
import earth.krakatao.events.KraSocketClientEventInterface;
|
||||||
import earth.krakatao.protocol.KraSocketClientProtocol;
|
import earth.krakatao.protocol.KraSocketClientProtocol;
|
||||||
|
import earth.krakatoa.core.config.MongoConfig;
|
||||||
|
import earth.krakatoa.core.config.RedisConfig;
|
||||||
|
import earth.krakatoa.core.mongo.MongoManager;
|
||||||
|
import earth.krakatoa.core.redis.RedisManager;
|
||||||
|
import earth.krakatoa.core.util.Formatter;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
@ -16,9 +21,6 @@ import net.krakatoa.proxy.listener.LoginListener;
|
||||||
import net.krakatoa.proxy.listener.PlayerDisconnectListener;
|
import net.krakatoa.proxy.listener.PlayerDisconnectListener;
|
||||||
import net.krakatoa.proxy.listener.PostLoginListener;
|
import net.krakatoa.proxy.listener.PostLoginListener;
|
||||||
import net.krakatoa.proxy.listener.SocketClientMessageListener;
|
import net.krakatoa.proxy.listener.SocketClientMessageListener;
|
||||||
import net.krakatoa.proxy.mongo.MongoManager;
|
|
||||||
import net.krakatoa.proxy.redis.RedisManager;
|
|
||||||
import net.krakatoa.proxy.util.Formatter;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.api.plugin.PluginManager;
|
import net.md_5.bungee.api.plugin.PluginManager;
|
||||||
|
|
||||||
|
@ -62,12 +64,13 @@ public class ProxySystem extends Plugin {
|
||||||
|
|
||||||
this.kraSocketClient.getSocketClient().connect();
|
this.kraSocketClient.getSocketClient().connect();
|
||||||
|
|
||||||
this.mongoManager = new MongoManager(this.configHandler.getMongodbHost(),
|
this.mongoManager = new MongoManager(
|
||||||
this.configHandler.getMongodbPort(), this.configHandler.getMongodbUsername(),
|
new MongoConfig(this.configHandler.getMongodbHost(), this.configHandler.getMongodbPort(),
|
||||||
this.configHandler.getMongodbPassword());
|
this.configHandler.getMongodbUsername(), this.configHandler.getMongodbPassword(),
|
||||||
this.mongoManager.connect(this.configHandler.getMongodbDatabase());
|
this.configHandler.getMongodbDatabase()));
|
||||||
|
|
||||||
this.redisManager = new RedisManager("redis://127.0.0.1:6379");
|
this.redisManager = new RedisManager(
|
||||||
|
new RedisConfig(this.configHandler.getRedisHost(), this.configHandler.getRedisPort()));
|
||||||
this.redisManager.connect();
|
this.redisManager.connect();
|
||||||
|
|
||||||
loadListeners();
|
loadListeners();
|
||||||
|
@ -79,9 +82,8 @@ public class ProxySystem extends Plugin {
|
||||||
this.kraSocketClient.getSocketClient().getConnection().close();
|
this.kraSocketClient.getSocketClient().getConnection().close();
|
||||||
this.kraSocketClient.getSocketClient().getConnection().closeConnection(1, "");
|
this.kraSocketClient.getSocketClient().getConnection().closeConnection(1, "");
|
||||||
|
|
||||||
this.mongoManager.getMongoClient().close();
|
this.mongoManager.shutdown();
|
||||||
|
this.redisManager.shutdown();
|
||||||
this.redisManager.close();
|
|
||||||
|
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,7 @@ public class KrakatoapCommand extends Command {
|
||||||
.getKraSocketClientProtocol()
|
.getKraSocketClientProtocol()
|
||||||
.getReceivedQueueMessages().size())));
|
.getReceivedQueueMessages().size())));
|
||||||
|
|
||||||
String uuid = ProxySystem.getInstance().getFormatter()
|
String uuid = ProxySystem.getInstance().getFormatter().formatUuid(player.getUniqueId());
|
||||||
.formatUuid(player.getUniqueId().toString());
|
|
||||||
|
|
||||||
RMap<String, String> map = ProxySystem.getInstance().getRedisManager()
|
RMap<String, String> map = ProxySystem.getInstance().getRedisManager()
|
||||||
.getRedissonClient()
|
.getRedissonClient()
|
||||||
|
|
|
@ -11,6 +11,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import org.bson.Document;
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
import org.redisson.api.RMap;
|
import org.redisson.api.RMap;
|
||||||
|
|
||||||
|
@ -29,25 +30,29 @@ public class PlayerDisconnectListener implements Listener {
|
||||||
.getMap("player:" + uuid);
|
.getMap("player:" + uuid);
|
||||||
|
|
||||||
// mongo
|
// mongo
|
||||||
ProxySystem.getInstance().getMongoManager().getPlayers()
|
Document document = (Document) ProxySystem.getInstance().getMongoManager()
|
||||||
.find(Filters.eq("uuid", uuid))
|
.getPlayersCollection()
|
||||||
.first((document, throwable) -> {
|
.find(Filters.eq("uuid", uuid)).first();
|
||||||
if (document != null) {
|
|
||||||
List<Bson> updatesList = new ArrayList<>();
|
|
||||||
|
|
||||||
map.forEach((key, value) -> {
|
if (document != null) {
|
||||||
if (!Objects.equals(key, "_id") && !Objects.equals(key, "uuid")) {
|
List<Bson> updatesList = new ArrayList<>();
|
||||||
updatesList.add(Updates.set(key, value));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Bson updates = Updates.combine(updatesList);
|
map.forEach((key, value) -> {
|
||||||
|
if (!Objects.equals(key, "_id") && !Objects.equals(key, "uuid")) {
|
||||||
|
updatesList.add(Updates.set(key, value));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
UpdateOptions options = new UpdateOptions().upsert(true);
|
Bson updates = Updates.combine(updatesList);
|
||||||
|
|
||||||
System.out.println("doc: " + document.keySet());
|
UpdateOptions options = new UpdateOptions().upsert(true);
|
||||||
|
|
||||||
ProxySystem.getInstance().getMongoManager().getPlayers()
|
System.out.println("doc: " + document.keySet());
|
||||||
|
|
||||||
|
ProxySystem.getInstance().getMongoManager().getPlayersCollection()
|
||||||
|
.updateOne(Filters.eq("uuid", uuid), updates);
|
||||||
|
/*
|
||||||
|
ProxySystem.getInstance().getMongoManager().getPlayersCollection()
|
||||||
.updateOne(document, updates, options, (result, t) -> {
|
.updateOne(document, updates, options, (result, t) -> {
|
||||||
System.out.println(result == null);
|
System.out.println(result == null);
|
||||||
|
|
||||||
|
@ -55,11 +60,10 @@ public class PlayerDisconnectListener implements Listener {
|
||||||
System.out.println("Modified document count: " + result.getModifiedCount());
|
System.out.println("Modified document count: " + result.getModifiedCount());
|
||||||
System.out.println("Upserted id: " + result.getUpsertedId());
|
System.out.println("Upserted id: " + result.getUpsertedId());
|
||||||
}
|
}
|
||||||
});
|
}); */
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Mongo player is null on disconnect");
|
System.out.println("Mongo player is null on disconnect");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// redis
|
// redis
|
||||||
if (!map.isEmpty()) {
|
if (!map.isEmpty()) {
|
||||||
|
|
|
@ -37,110 +37,107 @@ public class PostLoginListener implements Listener {
|
||||||
String uuid = ProxySystem.getInstance().getFormatter()
|
String uuid = ProxySystem.getInstance().getFormatter()
|
||||||
.formatUuid(proxiedPlayer.getUniqueId().toString());
|
.formatUuid(proxiedPlayer.getUniqueId().toString());
|
||||||
|
|
||||||
ProxySystem.getInstance().getMongoManager().getPlayers()
|
Document document = (Document) ProxySystem.getInstance().getMongoManager()
|
||||||
.find(Filters.eq("uuid", uuid))
|
.getPlayersCollection()
|
||||||
.first((document, throwable) -> {
|
.find(Filters.eq("uuid", uuid)).first();
|
||||||
if (document == null) { // new player - create entries in databases
|
|
||||||
System.out.println("create player in db");
|
|
||||||
String voiceWebCode = generateVoiceWebCode(uuid);
|
|
||||||
|
|
||||||
document = new Document("uuid", uuid).append("voiceWebCode", voiceWebCode);
|
if (document == null) { // new player - create entries in databases
|
||||||
|
System.out.println("create player in db");
|
||||||
|
String voiceWebCode = generateVoiceWebCode(uuid);
|
||||||
|
|
||||||
ProxySystem.getInstance().getMongoManager().getPlayers()
|
document = new Document("uuid", uuid).append("voiceWebCode", voiceWebCode);
|
||||||
.insertOne(document, (unused, throwable1) -> {
|
|
||||||
System.out.println("insertOne");
|
|
||||||
});
|
|
||||||
|
|
||||||
sendVoiceWebCodeUrl(proxiedPlayer, voiceWebCode);
|
ProxySystem.getInstance().getMongoManager().getPlayersCollection().insertOne(document);
|
||||||
|
|
||||||
// redis
|
sendVoiceWebCodeUrl(proxiedPlayer, voiceWebCode);
|
||||||
|
|
||||||
RMap<String, String> map = ProxySystem.getInstance().getRedisManager()
|
// redis
|
||||||
.getRedissonClient()
|
|
||||||
.getMap("player:" + uuid);
|
|
||||||
|
|
||||||
if (map.isEmpty()) {
|
RMap<String, String> map = ProxySystem.getInstance().getRedisManager()
|
||||||
map.put("uuid", uuid);
|
.getRedissonClient()
|
||||||
map.put("voiceWebCode", "voiceWebCode");
|
.getMap("player:" + uuid);
|
||||||
|
|
||||||
ProxySystem.getInstance().getLogger().info("PUT !");
|
if (map.isEmpty()) {
|
||||||
} else {
|
map.put("uuid", uuid);
|
||||||
ProxySystem.getInstance().getLogger()
|
map.put("voiceWebCode", "voiceWebCode");
|
||||||
.warning("REDIS player " + uuid + " exists in the cache, but should not exist");
|
|
||||||
}
|
|
||||||
} else { // player found in the database
|
|
||||||
|
|
||||||
// redis
|
ProxySystem.getInstance().getLogger().info("PUT !");
|
||||||
ProxySystem.getInstance().getLogger().info("mongodb player " + document.keySet());
|
} else {
|
||||||
|
ProxySystem.getInstance().getLogger()
|
||||||
|
.warning("REDIS player " + uuid + " exists in the cache, but should not exist");
|
||||||
|
}
|
||||||
|
} else { // player found in the database
|
||||||
|
|
||||||
RMap<String, String> map = ProxySystem.getInstance().getRedisManager()
|
// redis
|
||||||
.getRedissonClient()
|
ProxySystem.getInstance().getLogger().info("mongodb player " + document.keySet());
|
||||||
.getMap("player:" + uuid);
|
|
||||||
|
|
||||||
if (map.isEmpty()) {
|
RMap<String, String> map = ProxySystem.getInstance().getRedisManager()
|
||||||
map.put("uuid", uuid);
|
.getRedissonClient()
|
||||||
map.put("voiceWebCode", "voiceWebCode");
|
.getMap("player:" + uuid);
|
||||||
|
|
||||||
document.forEach((key, value) -> {
|
if (map.isEmpty()) {
|
||||||
if (!Objects.equals(key, "_id")) {
|
map.put("uuid", uuid);
|
||||||
ProxySystem.getInstance().getLogger()
|
map.put("voiceWebCode", "voiceWebCode");
|
||||||
.info("key " + key + " value " + value.toString());
|
|
||||||
map.put(key, value.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ProxySystem.getInstance().getLogger().info("PUT !");
|
|
||||||
} else {
|
|
||||||
ProxySystem.getInstance().getLogger()
|
|
||||||
.warning("REDIS player " + uuid + " exists in the cache, but should not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if both sockets connected
|
document.forEach((key, value) -> {
|
||||||
int cmdID = ProxySystem.getInstance().getKraSocketClientProtocol().generateCmdID();
|
if (!Objects.equals(key, "_id")) {
|
||||||
|
ProxySystem.getInstance().getLogger()
|
||||||
Document finalDocument = document;
|
.info("key " + key + " value " + value.toString());
|
||||||
Consumer<KraSocketClientProtocolMessage> consumer = value -> {
|
map.put(key, value.toString());
|
||||||
if (value.getArgs().equals("1")) {
|
|
||||||
// connected! Send player to game server
|
|
||||||
System.out.println(
|
|
||||||
proxiedPlayer.getName() + " sockets connected! Send player to game server");
|
|
||||||
proxiedPlayer.sendMessage(
|
|
||||||
new TextComponent("§bWillkommen zurück §6" + proxiedPlayer.getDisplayName()));
|
|
||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().schedule(ProxySystem.getInstance(), () -> {
|
|
||||||
ServerInfo serverInfos = ProxyServer.getInstance().getServerInfo("NewYork-1");
|
|
||||||
proxiedPlayer.connect(serverInfos);
|
|
||||||
}, 2L, TimeUnit.SECONDS);
|
|
||||||
} else {
|
|
||||||
// not connected! Send voice url
|
|
||||||
System.out.println(
|
|
||||||
proxiedPlayer.getName() + " sockets not connected! Send voice url");
|
|
||||||
|
|
||||||
String voiceWebCode = generateVoiceWebCode(uuid);
|
|
||||||
|
|
||||||
Bson updates = Updates.combine(Updates.set("voiceWebCode", voiceWebCode));
|
|
||||||
|
|
||||||
UpdateOptions options = new UpdateOptions().upsert(true);
|
|
||||||
|
|
||||||
ProxySystem.getInstance().getMongoManager().getPlayers()
|
|
||||||
.updateOne(finalDocument, updates, options, (updateResult, throwable1) -> {
|
|
||||||
});
|
|
||||||
|
|
||||||
System.out.println("voiceWebCode " + voiceWebCode);
|
|
||||||
|
|
||||||
sendVoiceWebCodeUrl(proxiedPlayer, voiceWebCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(
|
|
||||||
"consumer response value " + value.getUuid() + " " + value.getCmdID());
|
|
||||||
};
|
|
||||||
|
|
||||||
ProxySystem.getInstance().getKraSocketClient().getSocketClient()
|
|
||||||
.SendMessage(new KraSocketClientProtocolMessage(
|
|
||||||
KraSocketClientProtocolStatus.GET.getStatus(), cmdID,
|
|
||||||
KraSocketClientProtocolDest.BACKEND.getStatus(), proxiedPlayer.getUniqueId(),
|
|
||||||
(short) 10, "", consumer));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
ProxySystem.getInstance().getLogger().info("PUT !");
|
||||||
|
} else {
|
||||||
|
ProxySystem.getInstance().getLogger()
|
||||||
|
.warning("REDIS player " + uuid + " exists in the cache, but should not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if both sockets connected
|
||||||
|
int cmdID = ProxySystem.getInstance().getKraSocketClientProtocol().generateCmdID();
|
||||||
|
|
||||||
|
Document finalDocument = document;
|
||||||
|
Consumer<KraSocketClientProtocolMessage> consumer = value -> {
|
||||||
|
if (value.getArgs().equals("1")) {
|
||||||
|
// connected! Send player to game server
|
||||||
|
System.out.println(
|
||||||
|
proxiedPlayer.getName() + " sockets connected! Send player to game server");
|
||||||
|
proxiedPlayer.sendMessage(
|
||||||
|
new TextComponent("§bWillkommen zurück §6" + proxiedPlayer.getDisplayName()));
|
||||||
|
|
||||||
|
ProxyServer.getInstance().getScheduler().schedule(ProxySystem.getInstance(), () -> {
|
||||||
|
ServerInfo serverInfos = ProxyServer.getInstance().getServerInfo("NewYork-1");
|
||||||
|
proxiedPlayer.connect(serverInfos);
|
||||||
|
}, 2L, TimeUnit.SECONDS);
|
||||||
|
} else {
|
||||||
|
// not connected! Send voice url
|
||||||
|
System.out.println(
|
||||||
|
proxiedPlayer.getName() + " sockets not connected! Send voice url");
|
||||||
|
|
||||||
|
String voiceWebCode = generateVoiceWebCode(uuid);
|
||||||
|
|
||||||
|
Bson updates = Updates.combine(Updates.set("voiceWebCode", voiceWebCode));
|
||||||
|
|
||||||
|
UpdateOptions options = new UpdateOptions().upsert(true);
|
||||||
|
|
||||||
|
ProxySystem.getInstance().getMongoManager().getPlayersCollection()
|
||||||
|
.updateOne(finalDocument, updates, options);
|
||||||
|
|
||||||
|
System.out.println("voiceWebCode " + voiceWebCode);
|
||||||
|
|
||||||
|
sendVoiceWebCodeUrl(proxiedPlayer, voiceWebCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(
|
||||||
|
"consumer response value " + value.getUuid() + " " + value.getCmdID());
|
||||||
|
};
|
||||||
|
|
||||||
|
ProxySystem.getInstance().getKraSocketClient().getSocketClient()
|
||||||
|
.SendMessage(new KraSocketClientProtocolMessage(
|
||||||
|
KraSocketClientProtocolStatus.GET.getStatus(), cmdID,
|
||||||
|
KraSocketClientProtocolDest.BACKEND.getStatus(), proxiedPlayer.getUniqueId(),
|
||||||
|
(short) 10, "", consumer));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MessageBufferPacker packer = MessagePack.newDefaultBufferPacker();
|
MessageBufferPacker packer = MessagePack.newDefaultBufferPacker();
|
||||||
|
|
Loading…
Reference in New Issue