mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-26 02:27:56 +01:00
Add send command, closes issue #197
This commit is contained in:
parent
f5b4e1242d
commit
c059345802
@ -92,7 +92,7 @@ public class BungeeCord extends ProxyServer
|
||||
* Plugin manager.
|
||||
*/
|
||||
@Getter
|
||||
public final PluginManager pluginManager = new PluginManager(this);
|
||||
public final PluginManager pluginManager = new PluginManager( this );
|
||||
@Getter
|
||||
@Setter
|
||||
private ReconnectHandler reconnectHandler;
|
||||
@ -113,6 +113,7 @@ public class BungeeCord extends ProxyServer
|
||||
getPluginManager().registerCommand( new CommandAlert() );
|
||||
getPluginManager().registerCommand( new CommandBungee() );
|
||||
getPluginManager().registerCommand( new CommandPerms() );
|
||||
getPluginManager().registerCommand( new CommandSend() );
|
||||
|
||||
registerChannel( "BungeeCord" );
|
||||
}
|
||||
|
69
proxy/src/main/java/net/md_5/bungee/command/CommandSend.java
Normal file
69
proxy/src/main/java/net/md_5/bungee/command/CommandSend.java
Normal file
@ -0,0 +1,69 @@
|
||||
package net.md_5.bungee.command;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
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.plugin.Command;
|
||||
|
||||
public class CommandSend extends Command
|
||||
{
|
||||
|
||||
public CommandSend()
|
||||
{
|
||||
super( "send", "bungeecord.command.send" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args)
|
||||
{
|
||||
if ( args.length != 2 )
|
||||
{
|
||||
sender.sendMessage( ChatColor.RED + "Not enough arguments, usage: /send <player|all|current> <target>" );
|
||||
return;
|
||||
}
|
||||
ServerInfo target = ProxyServer.getInstance().getServerInfo( args[1] );
|
||||
if ( target == null )
|
||||
{
|
||||
sender.sendMessage( ChatColor.RED + "Target server does not exist" );
|
||||
}
|
||||
|
||||
if ( args[0].equalsIgnoreCase( "all" ) )
|
||||
{
|
||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() )
|
||||
{
|
||||
summon( p, target, sender );
|
||||
}
|
||||
} else if ( args[0].equalsIgnoreCase( "current" ) )
|
||||
{
|
||||
if ( !( sender instanceof ProxiedPlayer ) )
|
||||
{
|
||||
sender.sendMessage( ChatColor.RED + "Only in game players can use this command" );
|
||||
}
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
for ( ProxiedPlayer p : player.getServer().getInfo().getPlayers() )
|
||||
{
|
||||
summon( p, target, sender );
|
||||
}
|
||||
} else
|
||||
{
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer( args[0] );
|
||||
if ( player == null )
|
||||
{
|
||||
sender.sendMessage( ChatColor.RED + "That player is not online" );
|
||||
}
|
||||
summon( player, target, sender );
|
||||
}
|
||||
sender.sendMessage( ChatColor.GREEN + "Successfully summoned player(s)" );
|
||||
}
|
||||
|
||||
private void summon(ProxiedPlayer player, ServerInfo target, CommandSender sender)
|
||||
{
|
||||
if ( player.getServer().getInfo() != target )
|
||||
{
|
||||
player.connect( target );
|
||||
player.sendMessage( ChatColor.GOLD + "Summoned to " + target.getName() + " by " + sender.getName() );
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user