mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
Change Plugin instance of Bungeecord to RedisBungee to maintain old plugin compatibility
This commit is contained in:
parent
2ae9b5d480
commit
64af12044e
@ -10,14 +10,6 @@ Velocity*: *version 3.1.2 or above is only supported, any version below that mig
|
|||||||
This fork ensures compatibility with old plugins, so it should work as drop replacement,
|
This fork ensures compatibility with old plugins, so it should work as drop replacement,
|
||||||
but since Api has been split from the platform there some changes that have to be done, so your plugin might not work if:
|
but since Api has been split from the platform there some changes that have to be done, so your plugin might not work if:
|
||||||
|
|
||||||
* your plugin has used Internal classes of RedisBungee like getting the `JedisPool` or something else.
|
|
||||||
because `RedisBungee.java` is no longer an Plugin for example:
|
|
||||||
```java
|
|
||||||
// this will be broken
|
|
||||||
RedisBungee plugin = (RedisBungee) ProxyServer.getInstance().getPluginManager().getPlugin("RedisBungee");
|
|
||||||
JedisPool jedisPool = plugin.getPool();
|
|
||||||
|
|
||||||
```
|
|
||||||
* your plugin have used the Method `RedisBungeeAPI#getServerFor(UUID player)` as it was returning `net.md_5.bungee.api.config.ServerInfo`
|
* your plugin have used the Method `RedisBungeeAPI#getServerFor(UUID player)` as it was returning `net.md_5.bungee.api.config.ServerInfo`
|
||||||
now it returns `String`.
|
now it returns `String`.
|
||||||
|
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee;
|
|
||||||
|
|
||||||
import redis.clients.jedis.JedisPool;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This used to be old plugin instance of redis-bungee, but now it's used to get the api for old plugins
|
|
||||||
*
|
|
||||||
* @deprecated its deprecated but won't be removed, so please use {@link RedisBungeeAPI#getRedisBungeeApi()}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class RedisBungee {
|
|
||||||
|
|
||||||
private static RedisBungeeAPI api;
|
|
||||||
|
|
||||||
public RedisBungee(RedisBungeeAPI api) {
|
|
||||||
RedisBungee.api = api;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This returns an instance of {@link RedisBungeeAPI}
|
|
||||||
*
|
|
||||||
* @deprecated Please use {@link RedisBungeeAPI#getRedisBungeeApi()} this class intended to for old plugins that no longer updated.
|
|
||||||
*
|
|
||||||
* @return the {@link RedisBungeeAPI} object instance.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static RedisBungeeAPI getApi() {
|
|
||||||
return api;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public JedisPool getPool() {
|
|
||||||
return api.getJedisPool();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -19,7 +19,7 @@ import java.util.*;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungeeAPI#getRedisBungeeApi()}
|
* This class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungeeAPI#getRedisBungeeApi()}
|
||||||
* or somehow you got the Plugin instance by you can call the api using {@link RedisBungeePlugin#getApi()}.
|
* or somehow you got the Plugin instance by you can call the api using {@link RedisBungeePlugin#getRedisBungeeApi()}.
|
||||||
*
|
*
|
||||||
* @author tuxed
|
* @author tuxed
|
||||||
* @since 0.2.3 | updated 0.7.0
|
* @since 0.2.3 | updated 0.7.0
|
||||||
@ -38,7 +38,6 @@ public class RedisBungeeAPI {
|
|||||||
"redisbungee-" + plugin.getConfiguration().getProxyId(),
|
"redisbungee-" + plugin.getConfiguration().getProxyId(),
|
||||||
"redisbungee-data"
|
"redisbungee-data"
|
||||||
);
|
);
|
||||||
new RedisBungee(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,6 @@ import com.google.gson.JsonParser;
|
|||||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
|
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
|
||||||
import redis.clients.jedis.UnifiedJedis;
|
import redis.clients.jedis.UnifiedJedis;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -50,7 +49,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
|||||||
return plugin.isPlayerOnAServer(player) ? plugin.getPlayerServerName(player) : null;
|
return plugin.isPlayerOnAServer(player) ? plugin.getPlayerServerName(player) : null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return serverCache.get(uuid, new RedisTask<String>(plugin.getApi()) {
|
return serverCache.get(uuid, new RedisTask<String>(plugin.getRedisBungeeApi()) {
|
||||||
@Override
|
@Override
|
||||||
public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
||||||
return Objects.requireNonNull(unifiedJedis.hget("player:" + uuid, "server"), "user not found");
|
return Objects.requireNonNull(unifiedJedis.hget("player:" + uuid, "server"), "user not found");
|
||||||
@ -73,7 +72,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
|||||||
return plugin.getConfiguration().getProxyId();
|
return plugin.getConfiguration().getProxyId();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return proxyCache.get(uuid, new RedisTask<String>(plugin.getApi()) {
|
return proxyCache.get(uuid, new RedisTask<String>(plugin.getRedisBungeeApi()) {
|
||||||
@Override
|
@Override
|
||||||
public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
||||||
return Objects.requireNonNull(unifiedJedis.hget("player:" + uuid, "proxy"), "user not found");
|
return Objects.requireNonNull(unifiedJedis.hget("player:" + uuid, "proxy"), "user not found");
|
||||||
@ -94,7 +93,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
|||||||
return plugin.getPlayerIp(player);
|
return plugin.getPlayerIp(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return ipCache.get(uuid, new RedisTask<InetAddress>(plugin.getApi()) {
|
return ipCache.get(uuid, new RedisTask<InetAddress>(plugin.getRedisBungeeApi()) {
|
||||||
@Override
|
@Override
|
||||||
public InetAddress unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
public InetAddress unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
||||||
String result = unifiedJedis.hget("player:" + uuid, "ip");
|
String result = unifiedJedis.hget("player:" + uuid, "ip");
|
||||||
@ -118,7 +117,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return lastOnlineCache.get(uuid, new RedisTask<Long>(plugin.getApi()) {
|
return lastOnlineCache.get(uuid, new RedisTask<Long>(plugin.getRedisBungeeApi()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
public Long unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
||||||
|
@ -101,7 +101,7 @@ public interface RedisBungeePlugin<P> extends EventsPlatform, ConfigLoader {
|
|||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
RedisBungeeAPI getApi();
|
RedisBungeeAPI getRedisBungeeApi();
|
||||||
|
|
||||||
UUIDTranslator getUuidTranslator();
|
UUIDTranslator getUuidTranslator();
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummone
|
|||||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
|
||||||
import redis.clients.jedis.Jedis;
|
|
||||||
import redis.clients.jedis.UnifiedJedis;
|
import redis.clients.jedis.UnifiedJedis;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@ -29,7 +28,7 @@ public abstract class RedisTask<V> implements Runnable, Callable<V> {
|
|||||||
|
|
||||||
public RedisTask(RedisBungeePlugin<?> plugin) {
|
public RedisTask(RedisBungeePlugin<?> plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.api = plugin.getApi();
|
this.api = plugin.getRedisBungeeApi();
|
||||||
this.summoner = api.getSummoner();
|
this.summoner = api.getSummoner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,6 @@ import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
|||||||
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
|
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import redis.clients.jedis.Jedis;
|
|
||||||
import redis.clients.jedis.JedisCluster;
|
|
||||||
import redis.clients.jedis.Pipeline;
|
|
||||||
import redis.clients.jedis.UnifiedJedis;
|
import redis.clients.jedis.UnifiedJedis;
|
||||||
import redis.clients.jedis.exceptions.JedisException;
|
import redis.clients.jedis.exceptions.JedisException;
|
||||||
|
|
||||||
@ -73,7 +70,7 @@ public final class UUIDTranslator {
|
|||||||
if (!plugin.isOnlineMode()) {
|
if (!plugin.isOnlineMode()) {
|
||||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player).getBytes(Charsets.UTF_8));
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player).getBytes(Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
RedisTask<UUID> redisTask = new RedisTask<UUID>(plugin.getApi()) {
|
RedisTask<UUID> redisTask = new RedisTask<UUID>(plugin.getRedisBungeeApi()) {
|
||||||
@Override
|
@Override
|
||||||
public UUID unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
public UUID unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
||||||
String stored = unifiedJedis.hget("uuid-cache", player.toLowerCase());
|
String stored = unifiedJedis.hget("uuid-cache", player.toLowerCase());
|
||||||
@ -138,7 +135,7 @@ public final class UUIDTranslator {
|
|||||||
uuidToNameMap.remove(player);
|
uuidToNameMap.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
RedisTask<String> redisTask = new RedisTask<String>(plugin.getApi()) {
|
RedisTask<String> redisTask = new RedisTask<String>(plugin.getRedisBungeeApi()) {
|
||||||
@Override
|
@Override
|
||||||
public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
|
||||||
String stored = unifiedJedis.hget("uuid-cache", player.toString());
|
String stored = unifiedJedis.hget("uuid-cache", player.toString());
|
||||||
|
@ -33,9 +33,10 @@ import java.util.concurrent.*;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
|
|
||||||
public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin<ProxiedPlayer> {
|
public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlayer> {
|
||||||
|
|
||||||
|
private static RedisBungeeAPI apiStatic;
|
||||||
|
|
||||||
private RedisBungeeAPI api;
|
private RedisBungeeAPI api;
|
||||||
private RedisBungeeMode redisBungeeMode;
|
private RedisBungeeMode redisBungeeMode;
|
||||||
@ -81,7 +82,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RedisBungeeAPI getApi() {
|
public RedisBungeeAPI getRedisBungeeApi() {
|
||||||
return this.api;
|
return this.api;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +202,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
|
|||||||
}
|
}
|
||||||
// init the api class
|
// init the api class
|
||||||
this.api = new RedisBungeeAPI(this);
|
this.api = new RedisBungeeAPI(this);
|
||||||
|
apiStatic = this.api;
|
||||||
// init the http lib
|
// init the http lib
|
||||||
httpClient = new OkHttpClient();
|
httpClient = new OkHttpClient();
|
||||||
Dispatcher dispatcher = new Dispatcher(getExecutorService());
|
Dispatcher dispatcher = new Dispatcher(getExecutorService());
|
||||||
@ -325,4 +327,21 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
|
|||||||
this.redisBungeeMode = mode;
|
this.redisBungeeMode = mode;
|
||||||
this.summoner = summoner;
|
this.summoner = summoner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns an instance of {@link RedisBungeeAPI}
|
||||||
|
*
|
||||||
|
* @deprecated Please use {@link RedisBungeeAPI#getRedisBungeeApi()} this class intended to for old plugins that no longer updated.
|
||||||
|
*
|
||||||
|
* @return the {@link RedisBungeeAPI} object instance.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static RedisBungeeAPI getApi() {
|
||||||
|
return apiStatic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public JedisPool getPool() {
|
||||||
|
return api.getJedisPool();
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,9 +20,6 @@ import net.md_5.bungee.api.event.*;
|
|||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import redis.clients.jedis.Jedis;
|
|
||||||
import redis.clients.jedis.JedisCluster;
|
|
||||||
import redis.clients.jedis.Pipeline;
|
|
||||||
import redis.clients.jedis.UnifiedJedis;
|
import redis.clients.jedis.UnifiedJedis;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@ -155,7 +152,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
|
|||||||
original = plugin.getPlayers();
|
original = plugin.getPlayers();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
original = plugin.getApi().getPlayersOnServer(type);
|
original = plugin.getRedisBungeeApi().getPlayersOnServer(type);
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +170,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
|
|||||||
} else {
|
} else {
|
||||||
out.writeUTF(type);
|
out.writeUTF(type);
|
||||||
try {
|
try {
|
||||||
out.writeInt(plugin.getApi().getPlayersOnServer(type).size());
|
out.writeInt(plugin.getRedisBungeeApi().getPlayersOnServer(type).size());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
out.writeInt(0);
|
out.writeInt(0);
|
||||||
}
|
}
|
||||||
@ -183,12 +180,12 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
|
|||||||
String user = in.readUTF();
|
String user = in.readUTF();
|
||||||
out.writeUTF("LastOnline");
|
out.writeUTF("LastOnline");
|
||||||
out.writeUTF(user);
|
out.writeUTF(user);
|
||||||
out.writeLong(plugin.getApi().getLastOnline(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(user, true))));
|
out.writeLong(plugin.getRedisBungeeApi().getLastOnline(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(user, true))));
|
||||||
break;
|
break;
|
||||||
case "ServerPlayers":
|
case "ServerPlayers":
|
||||||
String type1 = in.readUTF();
|
String type1 = in.readUTF();
|
||||||
out.writeUTF("ServerPlayers");
|
out.writeUTF("ServerPlayers");
|
||||||
Multimap<String, UUID> multimap = plugin.getApi().getServerToPlayers();
|
Multimap<String, UUID> multimap = plugin.getRedisBungeeApi().getServerToPlayers();
|
||||||
|
|
||||||
boolean includesUsers;
|
boolean includesUsers;
|
||||||
|
|
||||||
@ -224,7 +221,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
|
|||||||
String username = in.readUTF();
|
String username = in.readUTF();
|
||||||
out.writeUTF("PlayerProxy");
|
out.writeUTF("PlayerProxy");
|
||||||
out.writeUTF(username);
|
out.writeUTF(username);
|
||||||
out.writeUTF(plugin.getApi().getProxy(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(username, true))));
|
out.writeUTF(plugin.getRedisBungeeApi().getProxy(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(username, true))));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -238,7 +235,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
|
|||||||
@Override
|
@Override
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPubSubMessage(PubSubMessageEvent event) {
|
public void onPubSubMessage(PubSubMessageEvent event) {
|
||||||
if (event.getChannel().equals("redisbungee-allservers") || event.getChannel().equals("redisbungee-" + plugin.getApi().getProxyId())) {
|
if (event.getChannel().equals("redisbungee-allservers") || event.getChannel().equals("redisbungee-" + plugin.getRedisBungeeApi().getProxyId())) {
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
if (message.startsWith("/"))
|
if (message.startsWith("/"))
|
||||||
message = message.substring(1);
|
message = message.substring(1);
|
||||||
|
@ -3,8 +3,8 @@ package com.imaginarycode.minecraft.redisbungee.commands;
|
|||||||
import com.google.common.base.Joiner;
|
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.RedisBungee;
|
||||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeBungeePlugin;
|
|
||||||
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;
|
||||||
@ -41,9 +41,9 @@ public class RedisBungeeCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class GlistCommand extends Command {
|
public static class GlistCommand extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
public GlistCommand(RedisBungeeBungeePlugin plugin) {
|
public GlistCommand(RedisBungee plugin) {
|
||||||
super("glist", "bungeecord.command.list", "redisbungee", "rglist");
|
super("glist", "bungeecord.command.list", "redisbungee", "rglist");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -53,11 +53,11 @@ public class RedisBungeeCommands {
|
|||||||
plugin.getProxy().getScheduler().runAsync(plugin, 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.getRedisBungeeApi().getPlayerCount();
|
||||||
BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW)
|
BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW)
|
||||||
.append(playerPlural(count) + " currently online.").create();
|
.append(playerPlural(count) + " currently online.").create();
|
||||||
if (args.length > 0 && args[0].equals("showall")) {
|
if (args.length > 0 && args[0].equals("showall")) {
|
||||||
Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers();
|
Multimap<String, UUID> serverToPlayers = plugin.getRedisBungeeApi().getServerToPlayers();
|
||||||
Multimap<String, String> human = HashMultimap.create();
|
Multimap<String, String> human = HashMultimap.create();
|
||||||
for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) {
|
for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) {
|
||||||
// if for any reason UUID translation fails just return the uuid as name, to make command finish executing.
|
// if for any reason UUID translation fails just return the uuid as name, to make command finish executing.
|
||||||
@ -87,9 +87,9 @@ public class RedisBungeeCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class FindCommand extends Command {
|
public static class FindCommand extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
public FindCommand(RedisBungeeBungeePlugin plugin) {
|
public FindCommand(RedisBungee plugin) {
|
||||||
super("find", "bungeecord.command.find", "rfind");
|
super("find", "bungeecord.command.find", "rfind");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ServerInfo si = plugin.getProxy().getServerInfo(plugin.getApi().getServerFor(uuid));
|
ServerInfo si = plugin.getProxy().getServerInfo(plugin.getRedisBungeeApi().getServerFor(uuid));
|
||||||
if (si != null) {
|
if (si != null) {
|
||||||
TextComponent message = new TextComponent();
|
TextComponent message = new TextComponent();
|
||||||
message.setColor(ChatColor.BLUE);
|
message.setColor(ChatColor.BLUE);
|
||||||
@ -123,9 +123,9 @@ public class RedisBungeeCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class LastSeenCommand extends Command {
|
public static class LastSeenCommand extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
public LastSeenCommand(RedisBungeeBungeePlugin plugin) {
|
public LastSeenCommand(RedisBungee plugin) {
|
||||||
super("lastseen", "redisbungee.command.lastseen", "rlastseen");
|
super("lastseen", "redisbungee.command.lastseen", "rlastseen");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long secs = plugin.getApi().getLastOnline(uuid);
|
long secs = plugin.getRedisBungeeApi().getLastOnline(uuid);
|
||||||
TextComponent message = new TextComponent();
|
TextComponent message = new TextComponent();
|
||||||
if (secs == 0) {
|
if (secs == 0) {
|
||||||
message.setColor(ChatColor.GREEN);
|
message.setColor(ChatColor.GREEN);
|
||||||
@ -163,9 +163,9 @@ public class RedisBungeeCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class IpCommand extends Command {
|
public static class IpCommand extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
public IpCommand(RedisBungeeBungeePlugin plugin) {
|
public IpCommand(RedisBungee plugin) {
|
||||||
super("ip", "redisbungee.command.ip", "playerip", "rip", "rplayerip");
|
super("ip", "redisbungee.command.ip", "playerip", "rip", "rplayerip");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InetAddress ia = plugin.getApi().getPlayerIp(uuid);
|
InetAddress ia = plugin.getRedisBungeeApi().getPlayerIp(uuid);
|
||||||
if (ia != null) {
|
if (ia != null) {
|
||||||
TextComponent message = new TextComponent();
|
TextComponent message = new TextComponent();
|
||||||
message.setColor(ChatColor.GREEN);
|
message.setColor(ChatColor.GREEN);
|
||||||
@ -199,9 +199,9 @@ public class RedisBungeeCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class PlayerProxyCommand extends Command {
|
public static class PlayerProxyCommand extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
public PlayerProxyCommand(RedisBungeeBungeePlugin plugin) {
|
public PlayerProxyCommand(RedisBungee plugin) {
|
||||||
super("pproxy", "redisbungee.command.pproxy");
|
super("pproxy", "redisbungee.command.pproxy");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String proxy = plugin.getApi().getProxy(uuid);
|
String proxy = plugin.getRedisBungeeApi().getProxy(uuid);
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
TextComponent message = new TextComponent();
|
TextComponent message = new TextComponent();
|
||||||
message.setColor(ChatColor.GREEN);
|
message.setColor(ChatColor.GREEN);
|
||||||
@ -235,9 +235,9 @@ public class RedisBungeeCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class SendToAll extends Command {
|
public static class SendToAll extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
public SendToAll(RedisBungeeBungeePlugin plugin) {
|
public SendToAll(RedisBungee plugin) {
|
||||||
super("sendtoall", "redisbungee.command.sendtoall", "rsendtoall");
|
super("sendtoall", "redisbungee.command.sendtoall", "rsendtoall");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ public class RedisBungeeCommands {
|
|||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
String command = Joiner.on(" ").skipNulls().join(args);
|
String command = Joiner.on(" ").skipNulls().join(args);
|
||||||
plugin.getApi().sendProxyCommand(command);
|
plugin.getRedisBungeeApi().sendProxyCommand(command);
|
||||||
TextComponent message = new TextComponent();
|
TextComponent message = new TextComponent();
|
||||||
message.setColor(ChatColor.GREEN);
|
message.setColor(ChatColor.GREEN);
|
||||||
message.setText("Sent the command /" + command + " to all proxies.");
|
message.setText("Sent the command /" + command + " to all proxies.");
|
||||||
@ -258,9 +258,9 @@ public class RedisBungeeCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class ServerId extends Command {
|
public static class ServerId extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
public ServerId(RedisBungeeBungeePlugin plugin) {
|
public ServerId(RedisBungee plugin) {
|
||||||
super("serverid", "redisbungee.command.serverid", "rserverid");
|
super("serverid", "redisbungee.command.serverid", "rserverid");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -268,15 +268,15 @@ public class RedisBungeeCommands {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
TextComponent textComponent = new TextComponent();
|
TextComponent textComponent = new TextComponent();
|
||||||
textComponent.setText("You are on " + plugin.getApi().getProxyId() + ".");
|
textComponent.setText("You are on " + plugin.getRedisBungeeApi().getProxyId() + ".");
|
||||||
textComponent.setColor(ChatColor.YELLOW);
|
textComponent.setColor(ChatColor.YELLOW);
|
||||||
sender.sendMessage(textComponent);
|
sender.sendMessage(textComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ServerIds extends Command {
|
public static class ServerIds extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
public ServerIds(RedisBungeeBungeePlugin plugin) {
|
public ServerIds(RedisBungee plugin) {
|
||||||
super("serverids", "redisbungee.command.serverids");
|
super("serverids", "redisbungee.command.serverids");
|
||||||
this.plugin =plugin;
|
this.plugin =plugin;
|
||||||
}
|
}
|
||||||
@ -284,16 +284,16 @@ public class RedisBungeeCommands {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] strings) {
|
public void execute(CommandSender sender, String[] strings) {
|
||||||
TextComponent textComponent = new TextComponent();
|
TextComponent textComponent = new TextComponent();
|
||||||
textComponent.setText("All server IDs: " + Joiner.on(", ").join(plugin.getApi().getAllProxies()));
|
textComponent.setText("All server IDs: " + Joiner.on(", ").join(plugin.getRedisBungeeApi().getAllProxies()));
|
||||||
textComponent.setColor(ChatColor.YELLOW);
|
textComponent.setColor(ChatColor.YELLOW);
|
||||||
sender.sendMessage(textComponent);
|
sender.sendMessage(textComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PlistCommand extends Command {
|
public static class PlistCommand extends Command {
|
||||||
private final RedisBungeeBungeePlugin plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
public PlistCommand(RedisBungeeBungeePlugin plugin) {
|
public PlistCommand(RedisBungee plugin) {
|
||||||
super("plist", "redisbungee.command.plist", "rplist");
|
super("plist", "redisbungee.command.plist", "rplist");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -308,11 +308,11 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(new ComponentBuilder(proxy + " is not a valid proxy. See /serverids for valid proxies.").color(ChatColor.RED).create());
|
sender.sendMessage(new ComponentBuilder(proxy + " is not a valid proxy. See /serverids for valid proxies.").color(ChatColor.RED).create());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<UUID> players = plugin.getApi().getPlayersOnProxy(proxy);
|
Set<UUID> players = plugin.getRedisBungeeApi().getPlayersOnProxy(proxy);
|
||||||
BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW)
|
BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW)
|
||||||
.append(playerPlural(players.size()) + " currently on proxy " + proxy + ".").create();
|
.append(playerPlural(players.size()) + " currently on proxy " + proxy + ".").create();
|
||||||
if (args.length >= 2 && args[1].equals("showall")) {
|
if (args.length >= 2 && args[1].equals("showall")) {
|
||||||
Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers();
|
Multimap<String, UUID> serverToPlayers = plugin.getRedisBungeeApi().getServerToPlayers();
|
||||||
Multimap<String, String> human = HashMultimap.create();
|
Multimap<String, String> human = HashMultimap.create();
|
||||||
for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) {
|
for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) {
|
||||||
if (players.contains(entry.getValue())) {
|
if (players.contains(entry.getValue())) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: RedisBungee
|
name: RedisBungee
|
||||||
main: com.imaginarycode.minecraft.redisbungee.RedisBungeeBungeePlugin
|
main: com.imaginarycode.minecraft.redisbungee.RedisBungee
|
||||||
version: ${project.parent.version}-${git.commit.id.abbrev}
|
version: ${project.parent.version}-${git.commit.id.abbrev}
|
||||||
author: "astei, ProxioDev"
|
author: "astei, ProxioDev"
|
||||||
# This is used so that we can automatically override default BungeeCord behavior.
|
# This is used so that we can automatically override default BungeeCord behavior.
|
||||||
|
@ -27,9 +27,6 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import redis.clients.jedis.Jedis;
|
|
||||||
import redis.clients.jedis.JedisCluster;
|
|
||||||
import redis.clients.jedis.Pipeline;
|
|
||||||
import redis.clients.jedis.UnifiedJedis;
|
import redis.clients.jedis.UnifiedJedis;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@ -159,7 +156,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
|
|||||||
original = plugin.getPlayers();
|
original = plugin.getPlayers();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
original = plugin.getApi().getPlayersOnServer(type);
|
original = plugin.getRedisBungeeApi().getPlayersOnServer(type);
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,7 +174,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
|
|||||||
} else {
|
} else {
|
||||||
out.writeUTF(type);
|
out.writeUTF(type);
|
||||||
try {
|
try {
|
||||||
out.writeInt(plugin.getApi().getPlayersOnServer(type).size());
|
out.writeInt(plugin.getRedisBungeeApi().getPlayersOnServer(type).size());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
out.writeInt(0);
|
out.writeInt(0);
|
||||||
}
|
}
|
||||||
@ -187,12 +184,12 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
|
|||||||
String user = in.readUTF();
|
String user = in.readUTF();
|
||||||
out.writeUTF("LastOnline");
|
out.writeUTF("LastOnline");
|
||||||
out.writeUTF(user);
|
out.writeUTF(user);
|
||||||
out.writeLong(plugin.getApi().getLastOnline(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(user, true))));
|
out.writeLong(plugin.getRedisBungeeApi().getLastOnline(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(user, true))));
|
||||||
break;
|
break;
|
||||||
case "ServerPlayers":
|
case "ServerPlayers":
|
||||||
String type1 = in.readUTF();
|
String type1 = in.readUTF();
|
||||||
out.writeUTF("ServerPlayers");
|
out.writeUTF("ServerPlayers");
|
||||||
Multimap<String, UUID> multimap = plugin.getApi().getServerToPlayers();
|
Multimap<String, UUID> multimap = plugin.getRedisBungeeApi().getServerToPlayers();
|
||||||
|
|
||||||
boolean includesUsers;
|
boolean includesUsers;
|
||||||
|
|
||||||
@ -228,7 +225,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
|
|||||||
String username = in.readUTF();
|
String username = in.readUTF();
|
||||||
out.writeUTF("PlayerProxy");
|
out.writeUTF("PlayerProxy");
|
||||||
out.writeUTF(username);
|
out.writeUTF(username);
|
||||||
out.writeUTF(plugin.getApi().getProxy(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(username, true))));
|
out.writeUTF(plugin.getRedisBungeeApi().getProxy(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(username, true))));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -243,7 +240,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
|
|||||||
@Override
|
@Override
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPubSubMessage(PubSubMessageEvent event) {
|
public void onPubSubMessage(PubSubMessageEvent event) {
|
||||||
if (event.getChannel().equals("redisbungee-allservers") || event.getChannel().equals("redisbungee-" + plugin.getApi().getProxyId())) {
|
if (event.getChannel().equals("redisbungee-allservers") || event.getChannel().equals("redisbungee-" + plugin.getRedisBungeeApi().getProxyId())) {
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
if (message.startsWith("/"))
|
if (message.startsWith("/"))
|
||||||
message = message.substring(1);
|
message = message.substring(1);
|
||||||
|
@ -96,10 +96,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
this.httpClient.setDispatcher(dispatcher);
|
this.httpClient.setDispatcher(dispatcher);
|
||||||
NameFetcher.setHttpClient(httpClient);
|
NameFetcher.setHttpClient(httpClient);
|
||||||
UUIDFetcher.setHttpClient(httpClient);
|
UUIDFetcher.setHttpClient(httpClient);
|
||||||
// keeping this lol
|
|
||||||
new RedisBungee(api);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +130,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RedisBungeeAPI getApi() {
|
public RedisBungeeAPI getRedisBungeeApi() {
|
||||||
return this.api;
|
return this.api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,9 @@ package com.imaginarycode.minecraft.redisbungee.commands;
|
|||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
@ -54,11 +52,11 @@ public class RedisBungeeCommands {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(final Invocation invocation) {
|
public void execute(final Invocation invocation) {
|
||||||
plugin.getProxy().getScheduler().buildTask(plugin, () -> {
|
plugin.getProxy().getScheduler().buildTask(plugin, () -> {
|
||||||
int count = plugin.getApi().getPlayerCount();
|
int count = plugin.getRedisBungeeApi().getPlayerCount();
|
||||||
Component playersOnline = Component.text(playerPlural(count) + " currently online.", NamedTextColor.YELLOW);
|
Component playersOnline = Component.text(playerPlural(count) + " currently online.", NamedTextColor.YELLOW);
|
||||||
CommandSource sender = invocation.source();
|
CommandSource sender = invocation.source();
|
||||||
if (invocation.arguments().length > 0 && invocation.arguments()[0].equals("showall")) {
|
if (invocation.arguments().length > 0 && invocation.arguments()[0].equals("showall")) {
|
||||||
Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers();
|
Multimap<String, UUID> serverToPlayers = plugin.getRedisBungeeApi().getServerToPlayers();
|
||||||
Multimap<String, String> human = HashMultimap.create();
|
Multimap<String, String> human = HashMultimap.create();
|
||||||
serverToPlayers.forEach((key, value) -> {
|
serverToPlayers.forEach((key, value) -> {
|
||||||
// if for any reason UUID translation fails just return the uuid as name, to make command finish executing.
|
// if for any reason UUID translation fails just return the uuid as name, to make command finish executing.
|
||||||
@ -103,7 +101,7 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ServerInfo si = plugin.getProxy().getServer(plugin.getApi().getServerFor(uuid)).map(RegisteredServer::getServerInfo).orElse(null);
|
ServerInfo si = plugin.getProxy().getServer(plugin.getRedisBungeeApi().getServerFor(uuid)).map(RegisteredServer::getServerInfo).orElse(null);
|
||||||
if (si != null) {
|
if (si != null) {
|
||||||
Component message = Component.text(args[0] + " is on " + si.getName() + ".", NamedTextColor.BLUE);
|
Component message = Component.text(args[0] + " is on " + si.getName() + ".", NamedTextColor.BLUE);
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
@ -140,7 +138,7 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long secs = plugin.getApi().getLastOnline(uuid);
|
long secs = plugin.getRedisBungeeApi().getLastOnline(uuid);
|
||||||
TextComponent.Builder message = Component.text();
|
TextComponent.Builder message = Component.text();
|
||||||
if (secs == 0) {
|
if (secs == 0) {
|
||||||
message.color(NamedTextColor.GREEN);
|
message.color(NamedTextColor.GREEN);
|
||||||
@ -183,7 +181,7 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InetAddress ia = plugin.getApi().getPlayerIp(uuid);
|
InetAddress ia = plugin.getRedisBungeeApi().getPlayerIp(uuid);
|
||||||
if (ia != null) {
|
if (ia != null) {
|
||||||
TextComponent message = Component.text(args[0] + " is connected from " + ia.toString() + ".", NamedTextColor.GREEN);
|
TextComponent message = Component.text(args[0] + " is connected from " + ia.toString() + ".", NamedTextColor.GREEN);
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
@ -220,7 +218,7 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String proxy = plugin.getApi().getProxy(uuid);
|
String proxy = plugin.getRedisBungeeApi().getProxy(uuid);
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
TextComponent message = Component.text(args[0] + " is connected to " + proxy + ".", NamedTextColor.GREEN);
|
TextComponent message = Component.text(args[0] + " is connected to " + proxy + ".", NamedTextColor.GREEN);
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
@ -253,7 +251,7 @@ public class RedisBungeeCommands {
|
|||||||
CommandSource sender = invocation.source();
|
CommandSource sender = invocation.source();
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
String command = Joiner.on(" ").skipNulls().join(args);
|
String command = Joiner.on(" ").skipNulls().join(args);
|
||||||
plugin.getApi().sendProxyCommand(command);
|
plugin.getRedisBungeeApi().sendProxyCommand(command);
|
||||||
TextComponent message = Component.text("Sent the command /" + command + " to all proxies.", NamedTextColor.GREEN);
|
TextComponent message = Component.text("Sent the command /" + command + " to all proxies.", NamedTextColor.GREEN);
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
} else {
|
} else {
|
||||||
@ -276,7 +274,7 @@ public class RedisBungeeCommands {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Invocation invocation) {
|
public void execute(Invocation invocation) {
|
||||||
invocation.source().sendMessage(Component.text("You are on " + plugin.getApi().getProxyId() + ".", NamedTextColor.YELLOW));
|
invocation.source().sendMessage(Component.text("You are on " + plugin.getRedisBungeeApi().getProxyId() + ".", NamedTextColor.YELLOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -295,7 +293,7 @@ public class RedisBungeeCommands {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(Invocation invocation) {
|
public void execute(Invocation invocation) {
|
||||||
invocation.source().sendMessage(
|
invocation.source().sendMessage(
|
||||||
Component.text("All server IDs: " + Joiner.on(", ").join(plugin.getApi().getAllProxies()), NamedTextColor.YELLOW));
|
Component.text("All server IDs: " + Joiner.on(", ").join(plugin.getRedisBungeeApi().getAllProxies()), NamedTextColor.YELLOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -321,10 +319,10 @@ public class RedisBungeeCommands {
|
|||||||
sender.sendMessage(Component.text(proxy + " is not a valid proxy. See /serverids for valid proxies.", NamedTextColor.RED));
|
sender.sendMessage(Component.text(proxy + " is not a valid proxy. See /serverids for valid proxies.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<UUID> players = plugin.getApi().getPlayersOnProxy(proxy);
|
Set<UUID> players = plugin.getRedisBungeeApi().getPlayersOnProxy(proxy);
|
||||||
Component playersOnline = Component.text(playerPlural(players.size()) + " currently on proxy " + proxy + ".", NamedTextColor.YELLOW);
|
Component playersOnline = Component.text(playerPlural(players.size()) + " currently on proxy " + proxy + ".", NamedTextColor.YELLOW);
|
||||||
if (args.length >= 2 && args[1].equals("showall")) {
|
if (args.length >= 2 && args[1].equals("showall")) {
|
||||||
Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers();
|
Multimap<String, UUID> serverToPlayers = plugin.getRedisBungeeApi().getServerToPlayers();
|
||||||
Multimap<String, String> human = HashMultimap.create();
|
Multimap<String, String> human = HashMultimap.create();
|
||||||
serverToPlayers.forEach((key, value) -> {
|
serverToPlayers.forEach((key, value) -> {
|
||||||
if (players.contains(value)) {
|
if (players.contains(value)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user