7 Commits
1.6.2 ... 1.6.3

9 changed files with 60 additions and 52 deletions

View File

@@ -1,6 +1,6 @@
# [HamsterBall](https://git.airgame.net/MiniDay/hamster-ball) # [HamsterBall](https://git.airgame.net/MiniDay/hamster-ball)
仓鼠球:一个基于 Redis 的 Minecraft 服务端通用消息中间件原HamsterService 基于 Redis 的 Minecraft 服务端通用消息中间件
该插件依赖于 [仓鼠核心](https://git.airgame.net/MiniDay/hamster-core) 该插件依赖于 [仓鼠核心](https://git.airgame.net/MiniDay/hamster-core)
@@ -49,9 +49,9 @@ repositories {
dependencies { dependencies {
// 对于 Bukkit 插件 // 对于 Bukkit 插件
compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.2") compileOnly("cn.hamster3.mc.plugin:ball-bukkit:1.6.3")
// 对于 BungeeCord 插件 // 对于 BungeeCord 插件
compileOnly("cn.hamster3.mc.plugin:ball-bungee:1.6.2") compileOnly("cn.hamster3.mc.plugin:ball-bungee:1.6.3")
} }
``` ```
@@ -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.2</version> <version>1.6.3</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.2</version> <version>1.6.3</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -4,8 +4,15 @@ version: ${version}
api-version: 1.13 api-version: 1.13
author: MiniDay author: MiniDay
description: ${description}
website: https://git.airgame.net/MiniDay/hamster-ball website: https://git.airgame.net/MiniDay/hamster-ball
description: 仓鼠球:一个基于 Redis 的 Minecraft 服务端通用消息中间件原HamsterService
UPDATE_CHECKER:
VERSION: ${version}
CHECK_TYPE: GITEA_RELEASES
GIT_BASE_URL: https://git.airgame.net
GIT_REPO: MiniDay/hamster-ball
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-ball/
load: STARTUP load: STARTUP

View File

@@ -1,6 +0,0 @@
version: ${version}
CHECK_TYPE: GITEA_RELEASES
GIT_BASE_URL: https://git.airgame.net
GIT_REPO: MiniDay/hamster-ball
GIT_TOKEN: a44a69a4d1b8601bf6091403247759cd28764d5e
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-ball/

View File

@@ -3,7 +3,15 @@ main: cn.hamster3.mc.plugin.ball.bungee.HamsterBallPlugin
version: ${version} version: ${version}
author: MiniDay author: MiniDay
description: 仓鼠球:一个基于 Redis 的 Minecraft 服务端通用消息中间件原HamsterService description: ${description}
website: https://git.airgame.net/MiniDay/hamster-ball
UPDATE_CHECKER:
VERSION: ${version}
CHECK_TYPE: GITEA_RELEASES
GIT_BASE_URL: https://git.airgame.net
GIT_REPO: MiniDay/hamster-ball
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-ball/
depend: depend:
- HamsterCore - HamsterCore

View File

@@ -1,6 +0,0 @@
version: ${version}
CHECK_TYPE: GITEA_RELEASES
GIT_BASE_URL: https://git.airgame.net
GIT_REPO: MiniDay/hamster-ball
GIT_TOKEN: a44a69a4d1b8601bf6091403247759cd28764d5e
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-ball/

View File

@@ -506,26 +506,28 @@ public abstract class BallAPI {
* <p> * <p>
* 会自动加上 config 中设置的频道前缀 * 会自动加上 config 中设置的频道前缀
* *
* @param channel 频道名称 * @param channels 频道名称
*/ */
public void subscribe(@NotNull String... channel) { public void subscribe(@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];
} }
CoreAPI.getInstance().getExecutorService().submit( subscribeRaw(channels);
() -> redisSub.subscribe(BallRedisListener.INSTANCE, channel)
);
} }
/** /**
* 忽略频道前缀配置,订阅 redis 消息频道 * 忽略频道前缀配置,订阅 redis 消息频道
* *
* @param channel 频道名称 * @param channels 频道名称
*/ */
public void subscribeRaw(@NotNull String... channel) { public void subscribeRaw(@NotNull String... channels) {
CoreAPI.getInstance().getExecutorService().submit( CoreAPI.getInstance().getExecutorService().submit(() -> {
() -> redisSub.subscribe(BallRedisListener.INSTANCE, channel) try {
); redisSub.subscribe(BallRedisListener.INSTANCE, channels);
} catch (Exception | Error e) {
e.printStackTrace();
}
});
} }
/** /**

View File

@@ -15,19 +15,26 @@ public class BallRedisListener extends JedisPubSub {
@Override @Override
public void onMessage(String channel, String message) { public void onMessage(String channel, String message) {
if (channel.startsWith(BallAPI.getInstance().getBallConfig().getChannelPrefix())) { CoreAPI.getInstance().getExecutorService().submit(() -> {
channel = channel.substring(BallAPI.getInstance().getBallConfig().getChannelPrefix().length()); try {
} String finalChannel = channel;
BallMessage ballMessage = CoreAPI.getInstance().getGson().fromJson(message, BallMessage.class); if (finalChannel.startsWith(BallAPI.getInstance().getBallConfig().getChannelPrefix())) {
BallAPI ballAPI = BallAPI.getInstance(); finalChannel = finalChannel.substring(BallAPI.getInstance().getBallConfig().getChannelPrefix().length());
EventBus eventBus = ballAPI.getEventBus(); }
if (ballMessage.getReceiverType() != null && ballMessage.getReceiverType() != ballAPI.getLocalServerInfo().getType()) { BallMessage ballMessage = CoreAPI.getInstance().getGson().fromJson(message, BallMessage.class);
return; BallAPI ballAPI = BallAPI.getInstance();
} EventBus eventBus = ballAPI.getEventBus();
if (ballMessage.getReceiverID() != null && !ballAPI.isLocalServer(ballMessage.getReceiverID())) { if (ballMessage.getReceiverType() != null && ballMessage.getReceiverType() != ballAPI.getLocalServerInfo().getType()) {
return; return;
} }
eventBus.post(new MessageReceivedEvent(channel, ballMessage)); if (ballMessage.getReceiverID() != null && !ballAPI.isLocalServer(ballMessage.getReceiverID())) {
return;
}
eventBus.post(new MessageReceivedEvent(finalChannel, ballMessage));
} catch (Exception | Error e) {
e.printStackTrace();
}
});
} }
@Override @Override

View File

@@ -1,6 +1,5 @@
version: ${version} VERSION: ${version}
CHECK_TYPE: GITEA_RELEASES CHECK_TYPE: GITEA_RELEASES
GIT_BASE_URL: https://git.airgame.net GIT_BASE_URL: https://git.airgame.net
GIT_REPO: MiniDay/hamster-ball GIT_REPO: MiniDay/hamster-ball
GIT_TOKEN: a44a69a4d1b8601bf6091403247759cd28764d5e
DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-ball/ DOWNLOAD_URL: https://jenkins.airgame.net/job/opensource/job/hamster-ball/

View File

@@ -5,7 +5,8 @@ plugins {
} }
group = "cn.hamster3.mc.plugin" group = "cn.hamster3.mc.plugin"
version = "1.6.2" version = "1.6.3"
description = "基于 Redis 的 Minecraft 服务端通用消息中间件"
subprojects { subprojects {
apply { apply {
@@ -16,6 +17,7 @@ subprojects {
group = rootProject.group group = rootProject.group
version = rootProject.version version = rootProject.version
description = rootProject.description
repositories { repositories {
maven("https://maven.airgame.net/maven-public/") maven("https://maven.airgame.net/maven-public/")
@@ -43,11 +45,6 @@ subprojects {
from(rootProject.file("LICENSE")) from(rootProject.file("LICENSE"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
} }
processResources {
filesMatching("update.yml") {
expand(rootProject.properties)
}
}
build { build {
dependsOn(shadowJar) dependsOn(shadowJar)
} }