library changed to redisson
parent
7e44b6ab63
commit
f750945e6e
6
pom.xml
6
pom.xml
|
@ -51,9 +51,9 @@
|
|||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
<version>6.1.8.RELEASE</version>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>3.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ProxySystem extends Plugin {
|
|||
|
||||
this.players = this.mongoManager.getMongoDatabase().getCollection("players");
|
||||
|
||||
this.redisManager = new RedisManager("redis://localhost");
|
||||
this.redisManager = new RedisManager("redis://127.0.0.1:6379");
|
||||
this.redisManager.connect();
|
||||
|
||||
loadListeners();
|
||||
|
@ -88,7 +88,7 @@ public class ProxySystem extends Plugin {
|
|||
this.mongoManager.getMongoClient().close();
|
||||
|
||||
//this.redisManager.getConnection().close();
|
||||
this.redisManager.getClient().shutdown();
|
||||
//this.redisManager.getClient().shutdown();
|
||||
|
||||
instance = null;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Map;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import net.krakatoa.proxy.ProxySystem;
|
||||
import net.krakatoa.proxy.redis.PlayerTest;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
|
@ -30,6 +31,7 @@ import org.bson.conversions.Bson;
|
|||
import org.msgpack.core.MessageBufferPacker;
|
||||
import org.msgpack.core.MessagePack;
|
||||
import org.msgpack.core.MessageUnpacker;
|
||||
import org.redisson.api.RBucket;
|
||||
|
||||
public class PostLoginListener implements Listener {
|
||||
|
||||
|
@ -114,7 +116,7 @@ public class PostLoginListener implements Listener {
|
|||
|
||||
packer.close();
|
||||
|
||||
ProxySystem.getInstance().getRedisManager().getRedisKeyCommands()
|
||||
/* ProxySystem.getInstance().getRedisManager().getRedisKeyCommands()
|
||||
.set("player:" + proxiedPlayer.getUniqueId().toString(),
|
||||
packer.toByteArray());
|
||||
/*
|
||||
|
@ -125,8 +127,15 @@ public class PostLoginListener implements Listener {
|
|||
map.put("skin", "steve");
|
||||
map.put("money", "101001");
|
||||
map.put("state", "online");
|
||||
ProxySystem.getInstance().getRedisManager().getRedisHashCommands()
|
||||
.hset("player", proxiedPlayer.getUniqueId().toString(), map);
|
||||
//ProxySystem.getInstance().getRedisManager().getRedisHashCommands()
|
||||
// .hset("player", proxiedPlayer.getUniqueId().toString(), map);
|
||||
|
||||
RBucket<PlayerTest> bucket = ProxySystem.getInstance().getRedisManager().getRedissonClient()
|
||||
.getBucket("player:" + proxiedPlayer.getUniqueId().toString());
|
||||
|
||||
PlayerTest playerTest = bucket.get();
|
||||
|
||||
ProxySystem.getInstance().getLogger().info("playerTest " + playerTest);
|
||||
|
||||
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(packer.toByteArray());
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package net.krakatoa.proxy.redis;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PlayerTest {
|
||||
|
||||
private String name;
|
||||
private int money;
|
||||
private String car;
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package net.krakatoa.proxy.redis;
|
||||
|
||||
import io.lettuce.core.dynamic.Commands;
|
||||
import java.util.Map;
|
||||
|
||||
public interface RedisHashCommands extends Commands {
|
||||
|
||||
//Mono<Long> hdel(Key key, Key... fields);
|
||||
|
||||
//Mono<Boolean> hset(Key key, Key field, Value value);
|
||||
|
||||
Boolean hset(String key, String field, String value);
|
||||
|
||||
Long hset(String key, String field, String... value);
|
||||
|
||||
Long hset(String key, String field, Map<String, String> map);
|
||||
|
||||
//Mono<String> hmset(Key key, Map<Key, Value> map);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package net.krakatoa.proxy.redis;
|
||||
|
||||
import io.lettuce.core.dynamic.Commands;
|
||||
import io.lettuce.core.dynamic.annotation.Key;
|
||||
|
||||
public interface RedisKeyCommands extends Commands {
|
||||
|
||||
String get(String key);
|
||||
|
||||
String set(String key, byte[] byteArray);
|
||||
|
||||
String set(String key, String value);
|
||||
|
||||
Long del(Key... keys);
|
||||
|
||||
Long del(String key);
|
||||
}
|
|
@ -1,28 +1,29 @@
|
|||
package net.krakatoa.proxy.redis;
|
||||
|
||||
import io.lettuce.core.RedisClient;
|
||||
import io.lettuce.core.dynamic.RedisCommandFactory;
|
||||
import lombok.Data;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.config.Config;
|
||||
|
||||
@Data
|
||||
public class RedisManager {
|
||||
|
||||
private final String connectionUri;
|
||||
|
||||
private RedisClient client;
|
||||
private Config config;
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
//private StatefulRedisConnection<String, String> connection;
|
||||
//private RedisStringCommands<String, String> commands;
|
||||
//private RedisKeyReactiveCommands<String, String> keyReactiveCommands;
|
||||
|
||||
private RedisKeyCommands redisKeyCommands;
|
||||
private RedisHashCommands redisHashCommands;
|
||||
|
||||
public void connect() {
|
||||
this.client = RedisClient.create(this.getConnectionUri());
|
||||
RedisCommandFactory factory = new RedisCommandFactory(client.connect());
|
||||
factory.setVerifyCommandMethods(false);
|
||||
this.redisKeyCommands = factory.getCommands(RedisKeyCommands.class);
|
||||
this.redisHashCommands = factory.getCommands(RedisHashCommands.class);
|
||||
this.config = new Config();
|
||||
this.config.useSingleServer().setAddress(this.connectionUri);
|
||||
|
||||
this.redissonClient = Redisson.create(this.config);
|
||||
|
||||
//this.connection = client.connect();
|
||||
//this.commands = connection.sync();
|
||||
//this.keyReactiveCommands = this.connection.reactive();
|
||||
|
|
Loading…
Reference in New Issue