mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
Add /pproxy command to request the proxy where a player is connected.
This commit is contained in:
parent
6fadd9e4c6
commit
b38ff5d1b4
@ -270,6 +270,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.SendToAll(this));
|
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.SendToAll(this));
|
||||||
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.ServerId(this));
|
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.ServerId(this));
|
||||||
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.ServerIds());
|
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.ServerIds());
|
||||||
|
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.PlayerProxyCommand(this));
|
||||||
api = new RedisBungeeAPI(this);
|
api = new RedisBungeeAPI(this);
|
||||||
getProxy().getPluginManager().registerListener(this, new RedisBungeeListener(this));
|
getProxy().getPluginManager().registerListener(this, new RedisBungeeListener(this));
|
||||||
getProxy().getPluginManager().registerListener(this, dataManager);
|
getProxy().getPluginManager().registerListener(this, dataManager);
|
||||||
|
@ -134,6 +134,17 @@ public class RedisBungeeAPI {
|
|||||||
return plugin.getDataManager().getIp(player);
|
return plugin.getDataManager().getIp(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the RedisBungee proxy ID this player is connected to.
|
||||||
|
*
|
||||||
|
* @param player the player to fetch the IP for
|
||||||
|
* @return the proxy the player is connected to, or null if they are offline
|
||||||
|
* @since 0.3.3
|
||||||
|
*/
|
||||||
|
public final String getProxy(@NonNull UUID player) {
|
||||||
|
return plugin.getDataManager().getProxy(player);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a proxy command to all proxies.
|
* Sends a proxy command to all proxies.
|
||||||
*
|
*
|
||||||
|
@ -200,6 +200,42 @@ class RedisBungeeCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class PlayerProxyCommand extends Command {
|
||||||
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
|
PlayerProxyCommand(RedisBungee 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 = RedisBungee.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 {
|
public static class SendToAll extends Command {
|
||||||
private final RedisBungee plugin;
|
private final RedisBungee plugin;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user