mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-05-03 11:40:29 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2391692dd3 | |||
| 39c45b3eab | |||
| b3bc51b96f | |||
| 08c4901f47 | |||
| a39c4654fb | |||
| 2ceac5a079 | |||
| 814dabbb6a | |||
|
|
1a76c260b8 | ||
| 24c9407358 | |||
| eee36923c1 | |||
| 6e02ab70db | |||
|
|
9493576067 | ||
|
|
02c9c3c75a | ||
|
|
0326c4490a | ||
| d34db3da44 | |||
| 5e18c4adb5 | |||
| ade1604987 | |||
| 7b2db2899e |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -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
|
||||
64
README.md
64
README.md
@@ -1,6 +1,4 @@
|
||||
# RedisBungee By Limework
|
||||
|
||||
[](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml) [](https://jitpack.io/#limework/redisbungee)
|
||||
# RedisBungee fork By Limework
|
||||
|
||||
Spigot link: [click](https://www.spigotmc.org/resources/redisbungee.87700/)
|
||||
|
||||
@@ -8,16 +6,20 @@ 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.
|
||||
|
||||
## Notice 2: users on git.limework.net
|
||||
## Implementing RedisBungee in your plugin: [](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml) [](https://jitpack.io/#limework/redisbungee)
|
||||
|
||||
please create the issues on GitHub as its main project source.
|
||||
|
||||
## Compiling
|
||||
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.
|
||||
@@ -26,28 +28,44 @@ git clone https://github.com/ProxioDev/RedisBungee.git
|
||||
cd RedisBungee
|
||||
mvn clean install
|
||||
```
|
||||
If you want to have `RedisBungeeAPI` class
|
||||
then to import for bungeecord use:
|
||||
```
|
||||
<dependency>
|
||||
<groupId>com.imaginarycode.minecraft</groupId>
|
||||
<artifactId>RedisBungee-API</artifactId>
|
||||
<version>0.7.1-SNAPSHOT</version>
|
||||
<artifactId>RedisBungee-Bungee</artifactId>
|
||||
<version>0.7.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
```
|
||||
and if you want to use the events Import RedisBungee-BungeeEvents which for bungeecord
|
||||
`note: you need API imported too`
|
||||
Second method by using jitpack [](https://jitpack.io/#limework/redisbungee)
|
||||
|
||||
first, add this repository
|
||||
```
|
||||
<dependency>
|
||||
<groupId>com.imaginarycode.minecraft</groupId>
|
||||
<artifactId>RedisBungee-BungeeEvents</artifactId>
|
||||
<version>0.7.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<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.
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>RedisBungee</artifactId>
|
||||
<groupId>com.imaginarycode.minecraft</groupId>
|
||||
<version>0.7.1-SNAPSHOT</version>
|
||||
<version>0.7.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<destDir>${project.name}</destDir>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@@ -29,9 +30,6 @@
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
@@ -79,43 +77,10 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>31.1-jre</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>4.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>2.11.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>2.7.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>RedisBungee</artifactId>
|
||||
<groupId>com.imaginarycode.minecraft</groupId>
|
||||
<version>0.7.1-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,9 +56,7 @@
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<goals><goal>shade</goal></goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
@@ -103,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>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
36
pom.xml
36
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>com.imaginarycode.minecraft</groupId>
|
||||
<artifactId>RedisBungee</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>0.7.1-SNAPSHOT</version>
|
||||
<version>0.7.3-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -23,7 +23,39 @@
|
||||
<modules>
|
||||
<module>RedisBungee-API</module>
|
||||
<module>RedisBungee-Bungee</module>
|
||||
<module>RedisBungee-BungeeEvents</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>31.1-jre</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>4.2.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>2.11.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>2.7.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user