mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
This release adds support for BungeeCord 1.13 and later, as well as adding support for recovering pub/sub channels and a version bump.
This commit is contained in:
parent
d5dcb7d3fc
commit
429ed39160
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.imaginarycode.minecraft</groupId>
|
||||
<artifactId>RedisBungee</artifactId>
|
||||
<version>0.4</version>
|
||||
<version>0.5</version>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
|
@ -368,6 +368,7 @@ public final class RedisBungee extends Plugin {
|
||||
}
|
||||
}, 0, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
getProxy().registerChannel("legacy:RedisBungee");
|
||||
getProxy().registerChannel("RedisBungee");
|
||||
}
|
||||
|
||||
@ -501,13 +502,18 @@ public final class RedisBungee extends Plugin {
|
||||
class PubSubListener implements Runnable {
|
||||
private JedisPubSubHandler jpsh;
|
||||
|
||||
private Set<String> addedChannels = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean broken = false;
|
||||
try (Jedis rsc = pool.getResource()) {
|
||||
try {
|
||||
jpsh = new JedisPubSubHandler();
|
||||
rsc.subscribe(jpsh, "redisbungee-" + configuration.getServerId(), "redisbungee-allservers", "redisbungee-data");
|
||||
addedChannels.add("redisbungee-" + configuration.getServerId());
|
||||
addedChannels.add("redisbungee-allservers");
|
||||
addedChannels.add("redisbungee-data");
|
||||
rsc.subscribe(jpsh, addedChannels.toArray(new String[0]));
|
||||
} catch (Exception e) {
|
||||
// FIXME: Extremely ugly hack
|
||||
// Attempt to unsubscribe this instance and try again.
|
||||
@ -522,6 +528,9 @@ public final class RedisBungee extends Plugin {
|
||||
}
|
||||
broken = true;
|
||||
}
|
||||
} catch (JedisConnectionException e) {
|
||||
getLogger().log(Level.INFO, "PubSub error, attempting to recover in 5 secs.");
|
||||
getProxy().getScheduler().schedule(RedisBungee.this, PubSubListener.this, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
if (broken) {
|
||||
@ -530,14 +539,17 @@ public final class RedisBungee extends Plugin {
|
||||
}
|
||||
|
||||
public void addChannel(String... channel) {
|
||||
addedChannels.addAll(Arrays.asList(channel));
|
||||
jpsh.subscribe(channel);
|
||||
}
|
||||
|
||||
public void removeChannel(String... channel) {
|
||||
addedChannels.removeAll(Arrays.asList(channel));
|
||||
jpsh.unsubscribe(channel);
|
||||
}
|
||||
|
||||
public void poison() {
|
||||
addedChannels.clear();
|
||||
jpsh.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,8 @@ public class RedisBungeeListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(final PluginMessageEvent event) {
|
||||
if (event.getTag().equals("RedisBungee") && event.getSender() instanceof Server) {
|
||||
if ((event.getTag().equals("legacy:RedisBungee") || event.getTag().equals("RedisBungee")) && event.getSender() instanceof Server) {
|
||||
final String currentChannel = event.getTag();
|
||||
final byte[] data = Arrays.copyOf(event.getData(), event.getData().length);
|
||||
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
|
||||
@Override
|
||||
@ -244,7 +245,7 @@ public class RedisBungeeListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
((Server) event.getSender()).sendData("RedisBungee", out.toByteArray());
|
||||
((Server) event.getSender()).sendData(currentChannel, out.toByteArray());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: RedisBungee
|
||||
main: com.imaginarycode.minecraft.redisbungee.RedisBungee
|
||||
version: 0.3.10
|
||||
author: tuxed
|
||||
# This is used so that we can automagically override default BungeeCord behavior.
|
||||
version: 0.5
|
||||
author: chunkr
|
||||
# This is used so that we can automatically override default BungeeCord behavior.
|
||||
softDepends: ["cmd_find", "cmd_list"]
|
Loading…
Reference in New Issue
Block a user