2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-05-03 11:40:29 +00:00

20 Commits

Author SHA1 Message Date
2391692dd3 bump version to 0.7.3 2022-06-29 18:16:33 +04:00
39c45b3eab change password field in the config 2022-06-29 18:16:16 +04:00
b3bc51b96f FIX mistake in pubsub listener as its resending spam to pubsub 2022-06-29 18:11:19 +04:00
08c4901f47 removed .png file, updated gitignore 2022-06-29 17:47:25 +04:00
a39c4654fb center 2022-06-17 06:10:29 +04:00
2ceac5a079 move supported redis versions up 2022-06-17 06:03:56 +04:00
814dabbb6a update supported redis versions 2022-06-17 06:02:20 +04:00
mohammed Alteniji
1a76c260b8 add fork into the title 2022-06-17 05:08:29 +04:00
24c9407358 remove useless line 2022-06-15 08:10:22 +04:00
eee36923c1 readd commands after i forgotten about them 2022-06-15 06:32:22 +04:00
6e02ab70db remove not needed BungeEvents submodule and merge it to bungee plugin 2022-06-15 06:05:30 +04:00
mohammed Alteniji
9493576067 Merge pull request #30 from Simonsator/develop
Use the correct jitpack dependency in the Readme
2022-05-27 17:05:34 +04:00
mohammed Alteniji
02c9c3c75a Update README.md 2022-05-27 17:05:01 +04:00
Simonsator
0326c4490a Use the correct jitpack dependency
The previously mentioned dependency does not exist. "RedisBungee-Bungee" iwith the group id "com.github.limework.redisbungee" is the correct one
2022-05-26 10:27:28 +02:00
d34db3da44 update readme 2022-05-26 05:02:31 +04:00
5e18c4adb5 update readme 2022-05-26 04:50:08 +04:00
ade1604987 update readme, fix complation, 0.7.2 2022-05-26 00:53:25 +04:00
7b2db2899e update gitignore 2022-05-26 00:42:40 +04:00
bdda7c13c9 update readme, fix relocation 2022-05-25 12:50:26 +04:00
mohammed Alteniji
9696726fb5 Update README.md 2022-05-25 09:11:19 +04:00
17 changed files with 516 additions and 121 deletions

7
.gitignore vendored
View File

@@ -3,6 +3,10 @@
.project
.settings
# random files
.png
.jpg
# netbeans
nbproject
nbactions.xml
@@ -32,5 +36,8 @@ manifest.mf
*.iws
.idea/
*.versionBackup
*.versionsBackup
# java docs
javadoc

View File

@@ -1,6 +1,4 @@
# RedisBungee By Limework
[![RedisBungee Build](https://github.com/proxiodev/RedisBungee/actions/workflows/maven.yml/badge.svg)](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml) [![](https://jitpack.io/v/limework/redisbungee.svg)](https://jitpack.io/#limework/redisbungee)
# RedisBungee fork By Limework
Spigot link: [click](https://www.spigotmc.org/resources/redisbungee.87700/)
@@ -8,39 +6,66 @@ The main project of RedisBungee is no longer maintained, so we have forked the p
RedisBungee uses [Redis](https://redis.io) to Synchronize data between [BungeeCord](https://github.com/SpigotMC/BungeeCord) proxies
## Notice 1: about older versions of redis than redis 6.0
## Supported Redis versions
| Redis version | Supported |
|:-------------:|:---------:|
| 1.x.x | ✖ |
| 2.x.x | ✖ |
| 3.x.x | ✖ |
| 4.x.x | ✖ |
| 5.x.x | ✖ |
| 6.x.x | ✔ |
| 7.x.x | ✔ |
any versions of redis-bungee 0.6.4 or above only supports 6.0
Do not Open issues regarding it.
## Implementing RedisBungee in your plugin: [![RedisBungee Build](https://github.com/proxiodev/RedisBungee/actions/workflows/maven.yml/badge.svg)](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml) [![](https://jitpack.io/v/limework/redisbungee.svg)](https://jitpack.io/#limework/redisbungee)
RedisBungee is distributed as a [maven](https://maven.apache.org) project.
first, install it to your maven local repo as we don't have public maven repo.
```
git clone https://github.com/ProxioDev/RedisBungee.git
cd RedisBungee
mvn clean install
```
then to import for bungeecord use:
```
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-Bungee</artifactId>
<version>0.7.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
```
Second method by using jitpack [![](https://jitpack.io/v/limework/redisbungee.svg)](https://jitpack.io/#limework/redisbungee)
first, add this repository
```
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
```
then add this in your dependencies
```
<dependency>
<groupId>com.github.limework.redisbungee</groupId>
<artifactId>RedisBungee-Bungee</artifactId>
<version>0.7.2</version>
<scope>provided</scope>
</dependency>
```
## Notice 2: users on git.limework.net
please create the issues on GitHub as its main project source.
## Compiling
RedisBungee is distributed as a [maven](https://maven.apache.org) project.
To compile the plugin:
git clone https://github.com/Limework/RedisBungee.git .
mvn clean package
mvn clean install # to install it in your maven local repo
then you should find it in target folder.
if you want to use it on your project considering you have installed it in your local repo
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>
## Javadocs
Check out our Java docs on github pages
https://proxiodev.github.io/RedisBungee-JavaDocs/0.7.0-SNAPSHOT
https://proxiodev.github.io/RedisBungee-JavaDocs/0.7.2-SNAPSHOT
## Configuration

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>RedisBungee</artifactId>
<groupId>com.imaginarycode.minecraft</groupId>
<version>0.7.0-SNAPSHOT</version>
<version>0.7.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -22,10 +22,64 @@
<destDir>${project.name}</destDir>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<relocations>
<relocation>
<pattern>redis.clients.jedis</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.jedis
</shadedPattern>
</relocation>
<relocation>
<pattern>redis.clients.util</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.jedisutil
</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.pool</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.commonspool
</shadedPattern>
</relocation>
<relocation>
<pattern>com.squareup.okhttp</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.okhttp
</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.okio
</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.google
</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.json
</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.checkframework
</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
-->
</plugins>
</build>
<dependencies>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>

View File

@@ -21,7 +21,6 @@ public class PubSubListener implements Runnable {
@Override
public void run() {
boolean broken = false;
try (Jedis rsc = plugin.requestJedis()) {
try {
@@ -42,16 +41,11 @@ public class PubSubListener implements Runnable {
- redis.clients.jedis.exceptions.JedisConnectionException: JedisPubSub was not subscribed to a Jedis instance
*/
}
broken = true;
}
} catch (JedisConnectionException e) {
plugin.logWarn("PubSub error, attempting to recover in 5 secs.");
plugin.executeAsyncAfter(this, TimeUnit.SECONDS, 5);
}
if (broken) {
run();
}
}
public void addChannel(String... channel) {

View File

@@ -9,9 +9,10 @@ import java.util.List;
public class RedisBungeeConfiguration {
private final String serverId;
private final List<InetAddress> exemptAddresses;
private final boolean overrideBungeeCommands;
private static RedisBungeeConfiguration config;
public RedisBungeeConfiguration(String serverId, List<String> exemptAddresses) {
public RedisBungeeConfiguration(String serverId, List<String> exemptAddresses, boolean overrideBungeeCommands) {
this.serverId = serverId;
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
@@ -20,6 +21,7 @@ public class RedisBungeeConfiguration {
}
this.exemptAddresses = addressBuilder.build();
config = this;
this.overrideBungeeCommands = overrideBungeeCommands;
}
public String getServerId() {
@@ -30,6 +32,10 @@ public class RedisBungeeConfiguration {
return exemptAddresses;
}
public boolean doOverrideBungeeCommands() {
return overrideBungeeCommands;
}
public static RedisBungeeConfiguration getConfig() {
return config;
}

View File

@@ -5,7 +5,7 @@
# Get Redis from http://redis.io/
redis-server: 127.0.0.1
redis-port: 6379
# OPTIONAL: If your Redis server uses AUTH, set the password required.
# OPTIONAL but recommended: If your Redis server uses AUTH, set the password required.
redis-password: ""
# Maximum connections that will be maintained to the Redis server.
# The default is 10. This setting should be left as-is unless you have some wildly

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>RedisBungee</artifactId>
<groupId>com.imaginarycode.minecraft</groupId>
<version>0.7.0-SNAPSHOT</version>
<version>0.7.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -39,6 +39,16 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<source>8</source>
<reportOutputDirectory>../javadoc</reportOutputDirectory>
<destDir>${project.name}</destDir>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
@@ -46,11 +56,8 @@
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<goals><goal>shade</goal></goals>
<configuration>
<!--
<relocations>
<relocation>
<pattern>redis.clients.jedis</pattern>
@@ -77,8 +84,22 @@
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.okio
</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.google
</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.json
</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.checkframework
</shadedPattern>
</relocation>
</relocations>
-->
</configuration>
</execution>
</executions>
@@ -90,12 +111,7 @@
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-API</artifactId>
<version>0.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-BungeeEvents</artifactId>
<version>0.7.0-SNAPSHOT</version>
<version>${parent.version}</version>
</dependency>
<dependency>
<groupId>net.md-5</groupId>

View File

@@ -405,10 +405,6 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
}
}, 0, 3, TimeUnit.SECONDS);
dataManager = new BungeeDataManager(this);
// glist command
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.GlistCommand(this));
getProxy().getPluginManager().registerListener(this, new RedisBungeeListener(this, configuration.getExemptAddresses()));
getProxy().getPluginManager().registerListener(this, dataManager);
psl = new PubSubListener(this);
@@ -479,6 +475,18 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
}
getProxy().registerChannel("legacy:redisbungee");
getProxy().registerChannel("RedisBungee");
// register commands
if (configuration.doOverrideBungeeCommands()) {
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.GlistCommand(this));
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.FindCommand(this));
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.LastSeenCommand(this));
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.IpCommand(this));
}
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.SendToAll(this));
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.ServerId(this));
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.ServerIds(this));
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.PlayerProxyCommand(this));
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.PlistCommand(this));
}
@Override
@@ -526,7 +534,6 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
final boolean useSSL = yamlConfiguration.getBoolean("useSSL", false);
String redisPassword = yamlConfiguration.getString("redis-password", "");
String serverId = yamlConfiguration.getString("server-id");
final String randomUUID = UUID.randomUUID().toString();
// check redis password
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
@@ -550,7 +557,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
} else {
getLogger().info("Loaded server id " + serverId + '.');
}
this.configuration = new RedisBungeeConfiguration(serverId, yamlConfiguration.getStringList("exempt-ip-addresses"));
this.configuration = new RedisBungeeConfiguration(serverId, yamlConfiguration.getStringList("exempt-ip-addresses"), yamlConfiguration.getBoolean("register-bungee-commands", true));
if (redisServer != null && !redisServer.isEmpty()) {
try {

View File

@@ -0,0 +1,74 @@
package com.imaginarycode.minecraft.redisbungee;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.BaseComponent;
import java.util.Collection;
import java.util.Collections;
public class RedisBungeeCommandSender implements CommandSender {
private static final RedisBungeeCommandSender singleton;
static {
singleton = new RedisBungeeCommandSender();
}
public static RedisBungeeCommandSender getSingleton() {
return singleton;
}
@Override
public String getName() {
return "RedisBungee";
}
@Override
public void sendMessage(String s) {
}
@Override
public void sendMessages(String... strings) {
}
@Override
public void sendMessage(BaseComponent... baseComponents) {
}
@Override
public void sendMessage(BaseComponent baseComponent) {
}
@Override
public Collection<String> getGroups() {
return null;
}
@Override
public void addGroups(String... strings) {
}
@Override
public void removeGroups(String... strings) {
}
@Override
public boolean hasPermission(String s) {
return true;
}
@Override
public void setPermission(String s, boolean b) {
}
@Override
public Collection<String> getPermissions() {
return Collections.emptySet();
}
}

View File

@@ -13,6 +13,7 @@ import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
import com.imaginarycode.minecraft.redisbungee.internal.RedisUtil;
import com.imaginarycode.minecraft.redisbungee.internal.util.RedisCallable;
import net.md_5.bungee.api.AbstractReconnectHandler;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
@@ -254,7 +255,7 @@ public class RedisBungeeListener extends AbstractRedisBungeeListener<LoginEvent,
if (message.startsWith("/"))
message = message.substring(1);
plugin.logInfo("Invoking command via PubSub: /" + message);
plugin.sendProxyCommand(message);
((Plugin) plugin).getProxy().getPluginManager().dispatchCommand(RedisBungeeCommandSender.getSingleton(), message);
}
}
}

View File

@@ -4,15 +4,21 @@ import com.google.common.base.Joiner;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.internal.RedisBungeePlugin;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
@@ -25,22 +31,28 @@ import java.util.UUID;
* @since 0.2.3
*/
public class RedisBungeeCommands {
private static final BaseComponent[] NO_PLAYER_SPECIFIED =
new ComponentBuilder("You must specify a player name.").color(ChatColor.RED).create();
private static final BaseComponent[] PLAYER_NOT_FOUND =
new ComponentBuilder("No such player found.").color(ChatColor.RED).create();
private static final BaseComponent[] NO_COMMAND_SPECIFIED =
new ComponentBuilder("You must specify a command to be run.").color(ChatColor.RED).create();
private static String playerPlural(int num) {
return num == 1 ? num + " player is" : num + " players are";
}
public static class GlistCommand extends Command {
private final RedisBungeePlugin<?> plugin;
private final RedisBungeeBungeePlugin plugin;
public GlistCommand(RedisBungeePlugin<?> plugin) {
public GlistCommand(RedisBungeeBungeePlugin plugin) {
super("glist", "bungeecord.command.list", "redisbungee", "rglist");
this.plugin = plugin;
}
@Override
public void execute(final CommandSender sender, final String[] args) {
plugin.executeAsync(new Runnable() {
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
int count = plugin.getApi().getPlayerCount();
@@ -74,5 +86,258 @@ public class RedisBungeeCommands {
}
}
public static class FindCommand extends Command {
private final RedisBungeeBungeePlugin plugin;
public FindCommand(RedisBungeeBungeePlugin plugin) {
super("find", "bungeecord.command.find", "rfind");
this.plugin = plugin;
}
@Override
public void execute(final CommandSender sender, final String[] args) {
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
if (args.length > 0) {
UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0], true);
if (uuid == null) {
sender.sendMessage(PLAYER_NOT_FOUND);
return;
}
ServerInfo si = plugin.getProxy().getServerInfo(plugin.getApi().getServerFor(uuid));
if (si != null) {
TextComponent message = new TextComponent();
message.setColor(ChatColor.BLUE);
message.setText(args[0] + " is on " + si.getName() + ".");
sender.sendMessage(message);
} else {
sender.sendMessage(PLAYER_NOT_FOUND);
}
} else {
sender.sendMessage(NO_PLAYER_SPECIFIED);
}
}
});
}
}
public static class LastSeenCommand extends Command {
private final RedisBungeeBungeePlugin plugin;
public LastSeenCommand(RedisBungeeBungeePlugin plugin) {
super("lastseen", "redisbungee.command.lastseen", "rlastseen");
this.plugin = plugin;
}
@Override
public void execute(final CommandSender sender, final String[] args) {
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
if (args.length > 0) {
UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0], true);
if (uuid == null) {
sender.sendMessage(PLAYER_NOT_FOUND);
return;
}
long secs = plugin.getApi().getLastOnline(uuid);
TextComponent message = new TextComponent();
if (secs == 0) {
message.setColor(ChatColor.GREEN);
message.setText(args[0] + " is currently online.");
} else if (secs != -1) {
message.setColor(ChatColor.BLUE);
message.setText(args[0] + " was last online on " + new SimpleDateFormat().format(secs) + ".");
} else {
message.setColor(ChatColor.RED);
message.setText(args[0] + " has never been online.");
}
sender.sendMessage(message);
} else {
sender.sendMessage(NO_PLAYER_SPECIFIED);
}
}
});
}
}
public static class IpCommand extends Command {
private final RedisBungeeBungeePlugin plugin;
public IpCommand(RedisBungeeBungeePlugin plugin) {
super("ip", "redisbungee.command.ip", "playerip", "rip", "rplayerip");
this.plugin = plugin;
}
@Override
public void execute(final CommandSender sender, final String[] args) {
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
if (args.length > 0) {
UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0], true);
if (uuid == null) {
sender.sendMessage(PLAYER_NOT_FOUND);
return;
}
InetAddress ia = plugin.getApi().getPlayerIp(uuid);
if (ia != null) {
TextComponent message = new TextComponent();
message.setColor(ChatColor.GREEN);
message.setText(args[0] + " is connected from " + ia.toString() + ".");
sender.sendMessage(message);
} else {
sender.sendMessage(PLAYER_NOT_FOUND);
}
} else {
sender.sendMessage(NO_PLAYER_SPECIFIED);
}
}
});
}
}
public static class PlayerProxyCommand extends Command {
private final RedisBungeeBungeePlugin plugin;
public PlayerProxyCommand(RedisBungeeBungeePlugin plugin) {
super("pproxy", "redisbungee.command.pproxy");
this.plugin = plugin;
}
@Override
public void execute(final CommandSender sender, final String[] args) {
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
if (args.length > 0) {
UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0], true);
if (uuid == null) {
sender.sendMessage(PLAYER_NOT_FOUND);
return;
}
String proxy = plugin.getApi().getProxy(uuid);
if (proxy != null) {
TextComponent message = new TextComponent();
message.setColor(ChatColor.GREEN);
message.setText(args[0] + " is connected to " + proxy + ".");
sender.sendMessage(message);
} else {
sender.sendMessage(PLAYER_NOT_FOUND);
}
} else {
sender.sendMessage(NO_PLAYER_SPECIFIED);
}
}
});
}
}
public static class SendToAll extends Command {
private final RedisBungeeBungeePlugin plugin;
public SendToAll(RedisBungeeBungeePlugin plugin) {
super("sendtoall", "redisbungee.command.sendtoall", "rsendtoall");
this.plugin = plugin;
}
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length > 0) {
String command = Joiner.on(" ").skipNulls().join(args);
plugin.getApi().sendProxyCommand(command);
TextComponent message = new TextComponent();
message.setColor(ChatColor.GREEN);
message.setText("Sent the command /" + command + " to all proxies.");
sender.sendMessage(message);
} else {
sender.sendMessage(NO_COMMAND_SPECIFIED);
}
}
}
public static class ServerId extends Command {
private final RedisBungeeBungeePlugin plugin;
public ServerId(RedisBungeeBungeePlugin plugin) {
super("serverid", "redisbungee.command.serverid", "rserverid");
this.plugin = plugin;
}
@Override
public void execute(CommandSender sender, String[] args) {
TextComponent textComponent = new TextComponent();
textComponent.setText("You are on " + plugin.getApi().getServerId() + ".");
textComponent.setColor(ChatColor.YELLOW);
sender.sendMessage(textComponent);
}
}
public static class ServerIds extends Command {
private final RedisBungeeBungeePlugin plugin;
public ServerIds(RedisBungeeBungeePlugin plugin) {
super("serverids", "redisbungee.command.serverids");
this.plugin =plugin;
}
@Override
public void execute(CommandSender sender, String[] strings) {
TextComponent textComponent = new TextComponent();
textComponent.setText("All server IDs: " + Joiner.on(", ").join(plugin.getApi().getAllServers()));
textComponent.setColor(ChatColor.YELLOW);
sender.sendMessage(textComponent);
}
}
public static class PlistCommand extends Command {
private final RedisBungeeBungeePlugin plugin;
public PlistCommand(RedisBungeeBungeePlugin plugin) {
super("plist", "redisbungee.command.plist", "rplist");
this.plugin = plugin;
}
@Override
public void execute(final CommandSender sender, final String[] args) {
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
String proxy = args.length >= 1 ? args[0] : plugin.getConfiguration().getServerId();
if (!plugin.getServerIds().contains(proxy)) {
sender.sendMessage(new ComponentBuilder(proxy + " is not a valid proxy. See /serverids for valid proxies.").color(ChatColor.RED).create());
return;
}
Set<UUID> players = plugin.getApi().getPlayersOnProxy(proxy);
BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW)
.append(playerPlural(players.size()) + " currently on proxy " + proxy + ".").create();
if (args.length >= 2 && args[1].equals("showall")) {
Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers();
Multimap<String, String> human = HashMultimap.create();
for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) {
if (players.contains(entry.getValue())) {
human.put(entry.getKey(), plugin.getUuidTranslator().getNameFromUuid(entry.getValue(), false));
}
}
for (String server : new TreeSet<>(human.keySet())) {
TextComponent serverName = new TextComponent();
serverName.setColor(ChatColor.RED);
serverName.setText("[" + server + "] ");
TextComponent serverCount = new TextComponent();
serverCount.setColor(ChatColor.YELLOW);
serverCount.setText("(" + human.get(server).size() + "): ");
TextComponent serverPlayers = new TextComponent();
serverPlayers.setColor(ChatColor.WHITE);
serverPlayers.setText(Joiner.on(", ").join(human.get(server)));
sender.sendMessage(serverName, serverCount, serverPlayers);
}
sender.sendMessage(playersOnline);
} else {
sender.sendMessage(playersOnline);
sender.sendMessage(new ComponentBuilder("To see all players online, use /plist " + proxy + " showall.").color(ChatColor.YELLOW).create());
}
}
});
}
}
}

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>RedisBungee</artifactId>
<groupId>com.imaginarycode.minecraft</groupId>
<version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>RedisBungee-BungeeEvents</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<source>8</source>
<reportOutputDirectory>../javadoc</reportOutputDirectory>
<destDir>${project.name}</destDir>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@@ -7,7 +7,7 @@
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<packaging>pom</packaging>
<version>0.7.0-SNAPSHOT</version>
<version>0.7.3-SNAPSHOT</version>
<build>
<plugins>
<plugin>
@@ -23,11 +23,8 @@
<modules>
<module>RedisBungee-API</module>
<module>RedisBungee-Bungee</module>
<module>RedisBungee-BungeeEvents</module>
</modules>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
@@ -38,7 +35,7 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.2.1</version>
<version>4.2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -60,4 +57,5 @@
<scope>test</scope>
</dependency>
</dependencies>
</project>