Compare commits
2 Commits
7cc71b2a3d
...
ebcd6d1a58
Author | SHA1 | Date |
---|---|---|
|
ebcd6d1a58 | |
|
8665d4b3f2 |
5
pom.xml
5
pom.xml
|
@ -45,6 +45,11 @@
|
|||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
<version>6.1.8.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.krakatoa.proxy.listener.PlayerDisconnectListener;
|
|||
import net.krakatoa.proxy.listener.PostLoginListener;
|
||||
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.PluginManager;
|
||||
|
@ -36,6 +37,7 @@ public class ProxySystem extends Plugin {
|
|||
private KraSocketClientEventInitiater kraSocketClientEventInitiater;
|
||||
private KraSocketClientEventInterface kraSocketClientEventInterface;
|
||||
private MongoManager mongoManager;
|
||||
private RedisManager redisManager;
|
||||
|
||||
private MongoCollection<Document> players;
|
||||
|
||||
|
@ -64,12 +66,15 @@ public class ProxySystem extends Plugin {
|
|||
|
||||
this.kraSocketClient.getSocketClient().connect();
|
||||
|
||||
mongoManager = new MongoManager(configHandler.getMongodbHost(),
|
||||
configHandler.getMongodbPort(), configHandler.getMongodbUsername(),
|
||||
configHandler.getMongodbPassword());
|
||||
mongoManager.connect(configHandler.getMongodbDatabase());
|
||||
this.mongoManager = new MongoManager(this.configHandler.getMongodbHost(),
|
||||
this.configHandler.getMongodbPort(), this.configHandler.getMongodbUsername(),
|
||||
this.configHandler.getMongodbPassword());
|
||||
this.mongoManager.connect(this.configHandler.getMongodbDatabase());
|
||||
|
||||
players = mongoManager.getMongoDatabase().getCollection("players");
|
||||
this.players = this.mongoManager.getMongoDatabase().getCollection("players");
|
||||
|
||||
this.redisManager = new RedisManager("redis://localhost");
|
||||
this.redisManager.connect();
|
||||
|
||||
loadListeners();
|
||||
loadCommands();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.krakatoa.proxy.listener;
|
||||
|
||||
import net.krakatoa.proxy.ProxySystem;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
|
@ -11,6 +12,9 @@ public class PlayerDisconnectListener implements Listener {
|
|||
public void onDisconnect(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer proxiedPlayer = event.getPlayer();
|
||||
|
||||
ProxySystem.getInstance().getRedisManager().getCommands()
|
||||
.getdel("player:" + proxiedPlayer.getUniqueId().toString());
|
||||
|
||||
//String uuid = ProxySystem.getInstance().getFormatter()
|
||||
// .formatUuid(proxiedPlayer.getUniqueId().toString());
|
||||
|
||||
|
|
|
@ -97,6 +97,9 @@ public class PostLoginListener implements Listener {
|
|||
(short) 10, "", consumer));
|
||||
}
|
||||
});
|
||||
|
||||
ProxySystem.getInstance().getRedisManager().getCommands()
|
||||
.set("player:" + proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
|
||||
}
|
||||
|
||||
public void sendVoiceWebCodeUrl(ProxiedPlayer proxiedPlayer, String voiceWebCode) {
|
||||
|
|
|
@ -14,6 +14,7 @@ public class MongoManager {
|
|||
private final String username;
|
||||
private final String password;
|
||||
|
||||
// TODO: search for replacements for deprecated methods
|
||||
@Getter
|
||||
private MongoDatabase mongoDatabase;
|
||||
@Getter
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package net.krakatoa.proxy.redis;
|
||||
|
||||
import io.lettuce.core.RedisClient;
|
||||
import io.lettuce.core.api.StatefulRedisConnection;
|
||||
import io.lettuce.core.api.sync.RedisStringCommands;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RedisManager {
|
||||
|
||||
private final String connectionUri;
|
||||
|
||||
private RedisClient client;
|
||||
private StatefulRedisConnection<String, String> connection;
|
||||
private RedisStringCommands<String, String> commands;
|
||||
|
||||
public void connect() {
|
||||
this.client = RedisClient.create(this.getConnectionUri());
|
||||
this.connection = client.connect();
|
||||
this.commands = connection.sync();
|
||||
|
||||
commands.set("test", "im here");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue