mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
Fix wrong permissions getting registered
This commit is contained in:
6 files changed
+21
-12
No files matched your search
@@ -60,18 +60,18 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register permissions
|
// Register permissions
|
||||||
addPermission(command.getPermission(), command.getUsage(), command.isOperatorCommand());
|
addPermission(command.getPermission(), command.getUsage(), getPermissionDefault(command.isOperatorCommand()));
|
||||||
final List<Permission> childNodes = command.getAdditionalPermissions()
|
final List<Permission> childNodes = command.getAdditionalPermissions()
|
||||||
.entrySet().stream()
|
.entrySet().stream()
|
||||||
.map((entry) -> addPermission(entry.getKey(), "", entry.getValue()))
|
.map((entry) -> addPermission(entry.getKey(), "", getPermissionDefault(entry.getValue())))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.toList();
|
.toList();
|
||||||
addPermission(command.getPermission("*"), command.getUsage(), command.isOperatorCommand(),
|
addPermission(command.getPermission("*"), command.getUsage(), PermissionDefault.FALSE,
|
||||||
childNodes.toArray(new Permission[0]));
|
childNodes.toArray(new Permission[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Permission addPermission(@NotNull String node, @NotNull String description, boolean operatorCommand, @NotNull Permission... children) {
|
private Permission addPermission(@NotNull String node, @NotNull String description, @NotNull PermissionDefault permissionDefault, @NotNull Permission... children) {
|
||||||
final Map<String, Boolean> childNodes = Arrays.stream(children)
|
final Map<String, Boolean> childNodes = Arrays.stream(children)
|
||||||
.map(Permission::getName)
|
.map(Permission::getName)
|
||||||
.collect(HashMap::new, (map, child) -> map.put(child, true), HashMap::putAll);
|
.collect(HashMap::new, (map, child) -> map.put(child, true), HashMap::putAll);
|
||||||
@@ -83,15 +83,20 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
Permission permission;
|
Permission permission;
|
||||||
if (description.isEmpty()) {
|
if (description.isEmpty()) {
|
||||||
permission = new Permission(node, operatorCommand ? PermissionDefault.OP : PermissionDefault.TRUE, childNodes);
|
permission = new Permission(node, permissionDefault, childNodes);
|
||||||
} else {
|
} else {
|
||||||
permission = new Permission(node, description, operatorCommand ? PermissionDefault.OP : PermissionDefault.TRUE, childNodes);
|
permission = new Permission(node, description, permissionDefault, childNodes);
|
||||||
}
|
}
|
||||||
manager.addPermission(permission);
|
manager.addPermission(permission);
|
||||||
|
|
||||||
return permission;
|
return permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static PermissionDefault getPermissionDefault(boolean isOperatorCommand) {
|
||||||
|
return isOperatorCommand ? PermissionDefault.OP : PermissionDefault.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commands available on the Bukkit HuskHomes implementation
|
* Commands available on the Bukkit HuskHomes implementation
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -78,4 +78,4 @@ commands:
|
|||||||
back:
|
back:
|
||||||
usage: /back
|
usage: /back
|
||||||
huskhomes:
|
huskhomes:
|
||||||
usage: /huskhomes [about|help|reload|update|migrate]
|
usage: /huskhomes [about|help|reload|update]
|
||||||
@@ -9,12 +9,14 @@ import net.william278.huskhomes.user.OnlineUser;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class BackCommand extends InGameCommand {
|
public class BackCommand extends InGameCommand {
|
||||||
|
|
||||||
protected BackCommand(@NotNull HuskHomes plugin) {
|
protected BackCommand(@NotNull HuskHomes plugin) {
|
||||||
super("back", List.of(), "", plugin);
|
super("back", List.of(), "", plugin);
|
||||||
|
addAdditionalPermissions(Map.of("death", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
|||||||
|
|
||||||
public EditWarpCommand(@NotNull HuskHomes plugin) {
|
public EditWarpCommand(@NotNull HuskHomes plugin) {
|
||||||
super("editwarp", List.of(), Warp.class, List.of("rename", "description", "relocate"), plugin);
|
super("editwarp", List.of(), Warp.class, List.of("rename", "description", "relocate"), plugin);
|
||||||
|
setOperatorCommand(true);
|
||||||
addAdditionalPermissions(arguments.stream()
|
addAdditionalPermissions(arguments.stream()
|
||||||
.collect(HashMap::new, (m, e) -> m.put(getPermission(e), false), HashMap::putAll));
|
.collect(HashMap::new, (m, e) -> m.put(getPermission(e), false), HashMap::putAll));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,13 @@ public abstract class Node implements Executable {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getPermission(@NotNull String... child) {
|
public String getPermission(@NotNull String... child) {
|
||||||
return new StringJoiner(".")
|
final StringJoiner joiner = new StringJoiner(".")
|
||||||
.add(PERMISSION_PREFIX)
|
.add(PERMISSION_PREFIX)
|
||||||
.add(getName())
|
.add(getName());
|
||||||
.add(String.join(".", child))
|
for (final String node : child) {
|
||||||
.toString();
|
joiner.add(node);
|
||||||
|
}
|
||||||
|
return joiner.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOperatorCommand() {
|
public boolean isOperatorCommand() {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ public class WarpCommand extends SavedPositionCommand<Warp> {
|
|||||||
|
|
||||||
protected WarpCommand(@NotNull HuskHomes plugin) {
|
protected WarpCommand(@NotNull HuskHomes plugin) {
|
||||||
super("warp", List.of(), Warp.class, List.of(), plugin);
|
super("warp", List.of(), Warp.class, List.of(), plugin);
|
||||||
setOperatorCommand(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user