消失插件我的世界

Vanish Plugin 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);
                }
}