Vanish插件Minecraft

huangapple go评论99阅读模式
英文:

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

请注意,我已经将HTML实体编码(如")还原为正常的引号字符,以便您可以正确使用代码。

英文:

I have made a vanish plugin but I'm having trouble with making it so server admins can see the person when they are in vanish. I want to make it so if they have permission they can see people in vanish.

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

答案1

得分: 0

Sure, here's the translated code snippet:

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

Please note that I've corrected the syntax error in the original code by adding a closing parenthesis after hasPermission("xyz.vanish").

英文:
    for (Player people : Bukkit.getOnlinePlayers()) {
                    people.hidePlayer(plugin, player);
                }

this code snippet is the problem. You have to add a if query if the other player have the permissions to see the player. As example the following code:

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

huangapple
  • 本文由 发表于 2020年8月13日 01:37:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/63381945.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定