From 14224f9f902a235c2e22279f10fd9547ee534e0d Mon Sep 17 00:00:00 2001 From: Niilyx _ <43385037+Niilyx@users.noreply.github.com> Date: Sun, 23 Jun 2024 02:55:20 +0200 Subject: [PATCH] fixed /hasperm and slight flaw in permission system (regarding MV-Core) --- src/main/java/fr/efreicraft/ecatup/commands/HasPerm.java | 8 +++++--- src/main/java/fr/efreicraft/ecatup/players/ECPlayer.java | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/efreicraft/ecatup/commands/HasPerm.java b/src/main/java/fr/efreicraft/ecatup/commands/HasPerm.java index 617e6c7..6033378 100644 --- a/src/main/java/fr/efreicraft/ecatup/commands/HasPerm.java +++ b/src/main/java/fr/efreicraft/ecatup/commands/HasPerm.java @@ -12,6 +12,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,12 +41,13 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command if (!player.isOnline()) fromDB = true; permission = permission.toLowerCase(); + if (permission.endsWith(".*")) permission = permission.substring(0, permission.indexOf(".*")); if (fromDB) { try { List perms = PlayerService.getPermissionOfPlayer(player.getUniqueId().toString()); for (Permission p : perms) { - if (p.getName().equalsIgnoreCase(permission)) { + if (p.getName().startsWith(permission)) { MessageUtils.sendMessage(sender, MessageUtils.ChatPrefix.SERVER, "%s possède la permission &a[%s]&r dans [%s].".formatted(player.getName(), permission, String.join(",", p.getServerTypes()))); return true; @@ -71,7 +73,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command for (Permission p : ecPlayer.getAnimusPlayer().getPerms()) { - if (p.getName().equalsIgnoreCase(permission)) { + if (p.getName().startsWith(permission)) { MessageUtils.sendMessage(sender, MessageUtils.ChatPrefix.SERVER, "%s possède la permission &a[%s]&r dans [%s].".formatted(player.getName(), permission, String.join(",", p.getServerTypes()))); return true; @@ -87,7 +89,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command @Override public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (args.length == 1) return Bukkit.getOnlinePlayers().stream().map(String::valueOf).sorted().toList(); + if (args.length == 1) return Bukkit.getOnlinePlayers().stream().map(Player::getName).sorted().toList(); if (args.length == 3) return List.of("true", "false"); return null; } diff --git a/src/main/java/fr/efreicraft/ecatup/players/ECPlayer.java b/src/main/java/fr/efreicraft/ecatup/players/ECPlayer.java index b00e4ec..0f6db87 100644 --- a/src/main/java/fr/efreicraft/ecatup/players/ECPlayer.java +++ b/src/main/java/fr/efreicraft/ecatup/players/ECPlayer.java @@ -241,6 +241,9 @@ public void addPlayerPermissions() { for (String permission : permissions) { if(permission.endsWith(".*")) { List wildcardPermissions = getWildcardPermissions(permission); + + // certains plugins n'enregistrent pas leurs permissions (*ahem* Multiverse-Core) + attachment.setPermission(permission, true); for (String wildcardPermission : wildcardPermissions) { attachment.setPermission(wildcardPermission, true); }