【问题标题】:Vanish Plugin Minecraft消失插件 Minecraft
【发布时间】:2020-08-12 17:37:15
【问题描述】:

我制作了一个消失插件,但我无法制作它,以便服务器管理员可以在该人消失时看到他们。我想这样做,如果他们获得许可,他们可以看到人消失。

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;
    }
}

【问题讨论】:

    标签: java plugins minecraft


    【解决方案1】:
        for (Player people : Bukkit.getOnlinePlayers()) {
                        people.hidePlayer(plugin, player);
                    }
    

    这个代码sn-p就是问题所在。如果其他玩家有权查看该玩家,您必须添加一个 if 查询。例如以下代码:

        for (Player people : Bukkit.getOnlinePlayers()) {
                        if(!people.hasPermission("xyz.vanish"){
                        people.hidePlayer(plugin, player);
                    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-02
      • 2021-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多