mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
fix: handle negative perms with perm restricted warps, close #779
This commit is contained in:
1 parent
72f7b390a1
commit
412e25a1d7
6 files changed
+31
-15
No files matched your search
@@ -161,9 +161,9 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
|
||||
.ifPresent(executor::sendMessage);
|
||||
return Optional.empty();
|
||||
}
|
||||
if (executor instanceof OnlineUser user && plugin.getSettings().getGeneral().isPermissionRestrictWarps()
|
||||
&& !user.hasPermission(Warp.getWildcardPermission())
|
||||
&& !user.hasPermission(Warp.getPermission(warpName))) {
|
||||
if (executor instanceof OnlineUser user
|
||||
&& plugin.getSettings().getGeneral().isPermissionRestrictWarps()
|
||||
&& !Warp.hasPermission(user, warpName)) {
|
||||
plugin.getLocales().getLocale("error_warp_invalid", warpName)
|
||||
.ifPresent(executor::sendMessage);
|
||||
return Optional.empty();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.william278.huskhomes.position;
|
||||
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -72,18 +73,16 @@ public class Warp extends SavedPosition {
|
||||
return USE_PERMISSION_FORMAT.formatted(warpName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getWildcardPermission() {
|
||||
return USE_PERMISSION_WILDCARD;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPermission() {
|
||||
return Warp.getPermission(getName());
|
||||
}
|
||||
|
||||
public boolean hasPermission(@NotNull CommandUser user) {
|
||||
return user.hasPermission(Warp.getWildcardPermission()) || user.hasPermission(getPermission());
|
||||
return Warp.hasPermission(user, getName());
|
||||
}
|
||||
|
||||
public static boolean hasPermission(@NotNull CommandUser user, @NotNull String warpName) {
|
||||
final String warpPermission = getPermission(warpName);
|
||||
if (user.isPermissionSet(warpPermission)) {
|
||||
return user.hasPermission(warpPermission);
|
||||
}
|
||||
return user.hasPermission(USE_PERMISSION_WILDCARD);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,8 @@ public interface CommandUser {
|
||||
@NotNull
|
||||
Audience getAudience();
|
||||
|
||||
boolean isPermissionSet(@NotNull String permission);
|
||||
|
||||
boolean hasPermission(@NotNull String permission);
|
||||
|
||||
default void sendMessage(@NotNull Component component) {
|
||||
|
||||
@@ -36,6 +36,11 @@ public final class ConsoleUser implements CommandUser {
|
||||
return new ConsoleUser(audience);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(@NotNull String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(@NotNull String permission) {
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user