Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
d38bd5e41f | |||
52e25a0433 | |||
cc33304ad4 |
@@ -49,9 +49,9 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// 对于 Bukkit 插件
|
// 对于 Bukkit 插件
|
||||||
compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.3")
|
compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.4")
|
||||||
// 对于 BungeeCord 插件
|
// 对于 BungeeCord 插件
|
||||||
compileOnly("cn.hamster3.mc.plugin:ball-bungee:1.6.3")
|
compileOnly("cn.hamster3.mc.plugin:ball-bungee:1.6.4")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -77,13 +77,13 @@ dependencies {
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hamster3.mc.plugin</groupId>
|
<groupId>cn.hamster3.mc.plugin</groupId>
|
||||||
<artifactId>ball-bukkit</artifactId>
|
<artifactId>ball-bukkit</artifactId>
|
||||||
<version>1.6.3</version>
|
<version>1.6.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--对于 BungeeCord 插件-->
|
<!--对于 BungeeCord 插件-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hamster3.mc.plugin</groupId>
|
<groupId>cn.hamster3.mc.plugin</groupId>
|
||||||
<artifactId>ball-bungee</artifactId>
|
<artifactId>ball-bungee</artifactId>
|
||||||
<version>1.6.3</version>
|
<version>1.6.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -105,6 +105,7 @@ public abstract class BallAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void enable() throws SQLException, InterruptedException {
|
protected void enable() throws SQLException, InterruptedException {
|
||||||
|
CoreAPI.getInstance().getExecutorService().submit(() -> redisSub.subscribe(BallRedisListener.INSTANCE, BALL_CHANNEL));
|
||||||
try (Jedis jedis = CoreAPI.getInstance().getJedisPool().getResource()) {
|
try (Jedis jedis = CoreAPI.getInstance().getJedisPool().getResource()) {
|
||||||
String key = "HamsterBall:ServerInfo:" + localServerInfo.getId();
|
String key = "HamsterBall:ServerInfo:" + localServerInfo.getId();
|
||||||
if (jedis.exists(key)) {
|
if (jedis.exists(key)) {
|
||||||
@@ -179,7 +180,6 @@ public abstract class BallAPI {
|
|||||||
}
|
}
|
||||||
getLogger().info("从数据库中加载了 " + allServerInfo.size() + " 条服务器信息");
|
getLogger().info("从数据库中加载了 " + allServerInfo.size() + " 条服务器信息");
|
||||||
getLogger().info("从数据库中加载了 " + allPlayerInfo.size() + " 条玩家信息");
|
getLogger().info("从数据库中加载了 " + allPlayerInfo.size() + " 条玩家信息");
|
||||||
subscribeRaw(BALL_CHANNEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void disable() throws SQLException, InterruptedException {
|
protected void disable() throws SQLException, InterruptedException {
|
||||||
@@ -521,13 +521,14 @@ public abstract class BallAPI {
|
|||||||
* @param channels 频道名称
|
* @param channels 频道名称
|
||||||
*/
|
*/
|
||||||
public void subscribeRaw(@NotNull String... channels) {
|
public void subscribeRaw(@NotNull String... channels) {
|
||||||
CoreAPI.getInstance().getExecutorService().submit(() -> {
|
BallRedisListener.INSTANCE.subscribe(channels);
|
||||||
try {
|
// CoreAPI.getInstance().getExecutorService().submit(() -> {
|
||||||
redisSub.subscribe(BallRedisListener.INSTANCE, channels);
|
// try {
|
||||||
} catch (Exception | Error e) {
|
// redisSub.subscribe(BallRedisListener.INSTANCE, channels);
|
||||||
e.printStackTrace();
|
// } catch (Exception | Error e) {
|
||||||
}
|
// e.printStackTrace();
|
||||||
});
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -536,9 +537,10 @@ public abstract class BallAPI {
|
|||||||
* @param patterns 频道名称正则表达式
|
* @param patterns 频道名称正则表达式
|
||||||
*/
|
*/
|
||||||
public void subscribePatterns(@NotNull String patterns) {
|
public void subscribePatterns(@NotNull String patterns) {
|
||||||
CoreAPI.getInstance().getExecutorService().submit(
|
BallRedisListener.INSTANCE.psubscribe(patterns);
|
||||||
() -> redisSub.psubscribe(BallRedisListener.INSTANCE, patterns)
|
// CoreAPI.getInstance().getExecutorService().submit(
|
||||||
);
|
// () -> redisSub.psubscribe(BallRedisListener.INSTANCE, patterns)
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -546,22 +548,22 @@ public abstract class BallAPI {
|
|||||||
* <p>
|
* <p>
|
||||||
* 会自动加上 config 中设置的频道前缀
|
* 会自动加上 config 中设置的频道前缀
|
||||||
*
|
*
|
||||||
* @param channel 频道名称
|
* @param channels 频道名称
|
||||||
*/
|
*/
|
||||||
public void unsubscribe(@NotNull String... channel) {
|
public void unsubscribe(@NotNull String... channels) {
|
||||||
for (int i = 0; i < channel.length; i++) {
|
for (int i = 0; i < channels.length; i++) {
|
||||||
channel[i] = ballConfig.getChannelPrefix() + channel[i];
|
channels[i] = ballConfig.getChannelPrefix() + channels[i];
|
||||||
}
|
}
|
||||||
BallRedisListener.INSTANCE.unsubscribe(channel);
|
unsubscribeRaw(channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 忽略频道前缀配置,取消订阅 redis 消息频道
|
* 忽略频道前缀配置,取消订阅 redis 消息频道
|
||||||
*
|
*
|
||||||
* @param channel 频道名称
|
* @param channels 频道名称
|
||||||
*/
|
*/
|
||||||
public void unsubscribeIgnorePrefix(@NotNull String... channel) {
|
public void unsubscribeRaw(@NotNull String... channels) {
|
||||||
BallRedisListener.INSTANCE.unsubscribe(channel);
|
BallRedisListener.INSTANCE.unsubscribe(channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "cn.hamster3.mc.plugin"
|
group = "cn.hamster3.mc.plugin"
|
||||||
version = "1.6.3"
|
version = "1.6.4"
|
||||||
description = "基于 Redis 的 Minecraft 服务端通用消息中间件"
|
description = "基于 Redis 的 Minecraft 服务端通用消息中间件"
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
Reference in New Issue
Block a user