I don't think this is possible outside of using BungeeCord, other than writing to a website, and having the other server read from that site, however I am not a web programmer, so I wouldn't know how to do that. Sorry for not being very descriptive.
Trying To Send commands to Bukkit server using sockets
-
15-10-2022 - |
Question
I am new to programming in Java and would like to send messages from a client to a server using If Statements.
So I'm developing a Bukkit Plugin that will be used on a server WITHOUT BungeeCord. What I would like to do is when someone sends a command (ex:On server 1) that my plugin recognizes, I would like it to execute on that server and send the command to another server for it to execute it.
if (cmd.equalsIgnoreCase("OTWG"))
{
if (args[0].equalsIgnoreCase("kick"))
{
if (sender instanceof Player)
{ // prevents possible NPE
if (sender.hasPermission("net.OTWG.kick"))
{
if (args.length == 1)
{
sender.sendMessage(ChatColor.DARK_RED + "[OTWG] " + ChatColor.GRAY + "Please enter a players name!");
return true;
}
else if (args.length >= 2)
{ // Corrected from: args.length > 1
Player target = Bukkit.getServer().getPlayerExact(args[1]);
if (target != null)
{ // prevents possible NPE
target.kickPlayer(ChatColor.DARK_RED + "[OTWG] " + ChatColor.GRAY + "You were kicked by " + sender.getName());
Bukkit.getServer().broadcastMessage(ChatColor.DARK_RED + "[OTWG]" + ChatColor.GRAY + "The player " + target.getName() + " was kicked by " + sender.getName());
return true;
}
}
}
else
{
sender.sendMessage(ChatColor.DARK_RED + "[OTWG] " + ChatColor.GRAY + "You do not have the permissions to do this action.");
}
}
else
{
if (sender.hasPermission("net.OTWG.kick"))
{
if (args.length == 1)
{
sender.sendMessage(ChatColor.DARK_RED + "[OTWG] " + ChatColor.GRAY + "Please enter a players name!");
return true;
}
else if (args.length >= 2)
{ // Corrected from: args.length > 1
Player target = Bukkit.getServer().getPlayerExact(args[1]);
if (target != null)
{ // prevents possible NPE
target.kickPlayer(ChatColor.DARK_RED + "[OTWG] " + ChatColor.GRAY + "You were kicked by " + sender.getName());
Bukkit.getServer().broadcastMessage(ChatColor.DARK_RED + "[OTWG]" + ChatColor.GRAY + "The player " + target.getName() + " was kicked by " + sender.getName());
return true;
}
}
}
else
{
sender.sendMessage(ChatColor.DARK_RED + "[OTWG] " + ChatColor.GRAY + "You do not have the permissions to do this action.");
}
}
}
}
So when, for example, someone sends the kick command, and the person is on the other server, it will send the command o the other server and the server will then execute it.
Now for my problem.
I'm having a bit of trouble getting it so that when I say (Ex: /OTWG kick {Player}), it sends it to the other server for it to execute it.
How would I go about doing this?
Solution