我是Java编程新手,希望使用If语句从客户端向服务器发送消息。
所以我正在开发一个Bukkit插件,它将在没有BungeeCord的服务器上使用。我想做的是当有人发送我的插件识别的命令(例如:在服务器1上)时,我希望它在该服务器上执行并将命令发送到另一台服务器以便它执行它。
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.");
}
}
}
}
因此,例如,当某人发送kick命令,并且该人员在另一台服务器上时,它将向另一台服务器发送命令,然后服务器将执行该命令。
现在我的问题。
我遇到了一些麻烦,所以当我说(例如:/ OTWG kick {Player})时,它会将它发送到另一台服务器以便执行它。
我将如何做到这一点?
答案 0 :(得分:1)
除了写一个网站,让其他服务器从该网站读取外,我认为这不可能在使用BungeeCord之外,但是我不是网络程序员,所以我不知道该怎么做那。很抱歉没有描述性。