如何解决消失的插件Minecraft
我制作了一个消失的插件,但是在制作时遇到了麻烦,因此服务器管理员可以在消失时看到该人。我要这样做,以便在获得许可的情况下可以看到消失的人。
public class VanishCommand implements CommandExecutor {
VanishPlugin plugin;
public VanishCommand(VanishPlugin plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender,Command command,String label,String[] args) {
Player p = (Player) sender;
if (p.hasPermission("vanish.vanish")) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (plugin.invisible_list.contains(player)) {
for (Player people : Bukkit.getOnlinePlayers()) {
people.showPlayer(plugin,player);
}
plugin.invisible_list.remove(player);
player.sendMessage("§cYou Are Now Un Vanished§r");
} else if (!plugin.invisible_list.contains(player)) {
for (Player people : Bukkit.getOnlinePlayers()) {
people.hidePlayer(plugin,player);
}
plugin.invisible_list.add(player);
player.sendMessage("§aYou Are Now Vanished!§r");
}
}
}
return true;
}
}
解决方法
for (Player people : Bukkit.getOnlinePlayers()) {
people.hidePlayer(plugin,player);
}
此代码段就是问题。您必须添加一个if查询,以便其他玩家有权查看该玩家。例如,以下代码:
for (Player people : Bukkit.getOnlinePlayers()) {
if(!people.hasPermission("xyz.vanish"){
people.hidePlayer(plugin,player);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。