diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java index 6c9f02d..9bf525b 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java @@ -159,6 +159,15 @@ public final class RedisBungee extends Plugin implements Listener { return ia; } + final void sendProxyCommand(String proxyId, String command) { + Jedis jedis = pool.getResource(); + try { + jedis.publish("redisbungee-" + proxyId, command); + } finally { + pool.returnResource(jedis); + } + } + @Override public void onEnable() { plugin = this; diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java index 3c3c87e..0cf771b 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java @@ -94,4 +94,21 @@ public class RedisBungeeAPI { public final InetAddress getPlayerIp(@NonNull String player) { return plugin.getIpAddress(player); } + + /** + * Sends a proxy command to all proxies. + * @param command the command to send and execute + */ + public final void sendProxyCommand(String command) { + plugin.sendProxyCommand("allservers", command); + } + + /** + * Sends a proxy command to the proxy with the given ID. + * @param proxyId a proxy ID + * @param command the command to send and execute + */ + public final void sendProxyCommand(String proxyId, String command) { + plugin.sendProxyCommand(proxyId, command); + } }