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

18 Commits
0.7.1 ... 0.7.3

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
17 changed files with 466 additions and 146 deletions

9
.gitignore vendored
View File

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

View File

@@ -1,6 +1,4 @@
# RedisBungee By Limework # RedisBungee fork 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)
Spigot link: [click](https://www.spigotmc.org/resources/redisbungee.87700/) Spigot link: [click](https://www.spigotmc.org/resources/redisbungee.87700/)
@@ -8,17 +6,21 @@ 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 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: [![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)
please create the issues on GitHub as its main project source. RedisBungee is distributed as a [maven](https://maven.apache.org) project.
## 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. 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 cd RedisBungee
mvn clean install mvn clean install
``` ```
If you want to have `RedisBungeeAPI` class then to import for bungeecord use:
``` ```
<dependency> <dependency>
<groupId>com.imaginarycode.minecraft</groupId> <groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-API</artifactId> <artifactId>RedisBungee-Bungee</artifactId>
<version>0.7.1-SNAPSHOT</version> <version>0.7.2-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
``` ```
and if you want to use the events Import RedisBungee-BungeeEvents which for bungeecord Second method by using jitpack [![](https://jitpack.io/v/limework/redisbungee.svg)](https://jitpack.io/#limework/redisbungee)
`note: you need API imported too`
first, add this repository
``` ```
<dependency> <repositories>
<groupId>com.imaginarycode.minecraft</groupId> <repository>
<artifactId>RedisBungee-BungeeEvents</artifactId> <id>jitpack.io</id>
<version>0.7.1-SNAPSHOT</version> <url>https://jitpack.io</url>
<scope>provided</scope> </repository>
</dependency> </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 ## 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 ## Configuration

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>RedisBungee</artifactId> <artifactId>RedisBungee</artifactId>
<groupId>com.imaginarycode.minecraft</groupId> <groupId>com.imaginarycode.minecraft</groupId>
<version>0.7.1-SNAPSHOT</version> <version>0.7.3-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -22,6 +22,7 @@
<destDir>${project.name}</destDir> <destDir>${project.name}</destDir>
</configuration> </configuration>
</plugin> </plugin>
<!--
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
@@ -29,9 +30,6 @@
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration> <configuration>
<relocations> <relocations>
<relocation> <relocation>
@@ -79,43 +77,10 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
-->
</plugins> </plugins>
</build> </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> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>

View File

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

View File

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

View File

@@ -5,7 +5,7 @@
# Get Redis from http://redis.io/ # Get Redis from http://redis.io/
redis-server: 127.0.0.1 redis-server: 127.0.0.1
redis-port: 6379 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: "" redis-password: ""
# Maximum connections that will be maintained to the Redis server. # 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 # The default is 10. This setting should be left as-is unless you have some wildly

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>RedisBungee</artifactId> <artifactId>RedisBungee</artifactId>
<groupId>com.imaginarycode.minecraft</groupId> <groupId>com.imaginarycode.minecraft</groupId>
<version>0.7.1-SNAPSHOT</version> <version>0.7.3-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -39,6 +39,16 @@
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </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> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
@@ -46,9 +56,7 @@
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
<goals> <goals><goal>shade</goal></goals>
<goal>shade</goal>
</goals>
<configuration> <configuration>
<relocations> <relocations>
<relocation> <relocation>
@@ -103,12 +111,7 @@
<dependency> <dependency>
<groupId>com.imaginarycode.minecraft</groupId> <groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-API</artifactId> <artifactId>RedisBungee-API</artifactId>
<version>0.7.0-SNAPSHOT</version> <version>${parent.version}</version>
</dependency>
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-BungeeEvents</artifactId>
<version>0.7.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.md-5</groupId> <groupId>net.md-5</groupId>

View File

@@ -405,10 +405,6 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
} }
}, 0, 3, TimeUnit.SECONDS); }, 0, 3, TimeUnit.SECONDS);
dataManager = new BungeeDataManager(this); 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, new RedisBungeeListener(this, configuration.getExemptAddresses()));
getProxy().getPluginManager().registerListener(this, dataManager); getProxy().getPluginManager().registerListener(this, dataManager);
psl = new PubSubListener(this); psl = new PubSubListener(this);
@@ -479,6 +475,18 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
} }
getProxy().registerChannel("legacy:redisbungee"); getProxy().registerChannel("legacy:redisbungee");
getProxy().registerChannel("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 @Override
@@ -526,7 +534,6 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
final boolean useSSL = yamlConfiguration.getBoolean("useSSL", false); final boolean useSSL = yamlConfiguration.getBoolean("useSSL", false);
String redisPassword = yamlConfiguration.getString("redis-password", ""); String redisPassword = yamlConfiguration.getString("redis-password", "");
String serverId = yamlConfiguration.getString("server-id"); String serverId = yamlConfiguration.getString("server-id");
final String randomUUID = UUID.randomUUID().toString();
// check redis password // check redis password
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) { if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
@@ -550,7 +557,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
} else { } else {
getLogger().info("Loaded server id " + serverId + '.'); 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()) { if (redisServer != null && !redisServer.isEmpty()) {
try { 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.RedisUtil;
import com.imaginarycode.minecraft.redisbungee.internal.util.RedisCallable; import com.imaginarycode.minecraft.redisbungee.internal.util.RedisCallable;
import net.md_5.bungee.api.AbstractReconnectHandler; 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.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.connection.Server;
@@ -254,7 +255,7 @@ public class RedisBungeeListener extends AbstractRedisBungeeListener<LoginEvent,
if (message.startsWith("/")) if (message.startsWith("/"))
message = message.substring(1); message = message.substring(1);
plugin.logInfo("Invoking command via PubSub: /" + message); 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.HashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.internal.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.internal.RedisBungeePlugin;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.TextComponent; 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 net.md_5.bungee.api.plugin.Command;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.UUID; import java.util.UUID;
@@ -25,22 +31,28 @@ import java.util.UUID;
* @since 0.2.3 * @since 0.2.3
*/ */
public class RedisBungeeCommands { 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) { private static String playerPlural(int num) {
return num == 1 ? num + " player is" : num + " players are"; return num == 1 ? num + " player is" : num + " players are";
} }
public static class GlistCommand extends Command { 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"); super("glist", "bungeecord.command.list", "redisbungee", "rglist");
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public void execute(final CommandSender sender, final String[] args) { public void execute(final CommandSender sender, final String[] args) {
plugin.executeAsync(new Runnable() { plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
int count = plugin.getApi().getPlayerCount(); 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>

36
pom.xml
View File

@@ -7,7 +7,7 @@
<groupId>com.imaginarycode.minecraft</groupId> <groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId> <artifactId>RedisBungee</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>0.7.1-SNAPSHOT</version> <version>0.7.3-SNAPSHOT</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@@ -23,7 +23,39 @@
<modules> <modules>
<module>RedisBungee-API</module> <module>RedisBungee-API</module>
<module>RedisBungee-Bungee</module> <module>RedisBungee-Bungee</module>
<module>RedisBungee-BungeeEvents</module>
</modules> </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> </project>