Fix list and TAB completion issues; close #272, #273

This commit is contained in:
William committed 2022-11-27 20:17:23 +00:00
1 parent 1dc45b8286
commit b7cf0fa590
18 files changed
+111 -67

No files matched your search

@@ -1,5 +1,6 @@
package net.william278.huskhomes.position;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -16,13 +17,14 @@ public class Server {
this.name = (name != null ? name : "server");
}
@SuppressWarnings("unused")
public Server() {
}
@Override
public boolean equals(Object other) {
public boolean equals(@NotNull Object other) {
// If the name of this server matches another, the servers are the same.
if (other instanceof Server server) {
// If the name of this server matches another, the servers are the same.
return server.name.equalsIgnoreCase(this.name);
}
return super.equals(other);
@@ -1,5 +1,6 @@
package net.william278.huskhomes.position;
import net.william278.huskhomes.player.OnlineUser;
import net.william278.huskhomes.util.Permission;
import org.intellij.lang.annotations.Subst;
import org.jetbrains.annotations.NotNull;
@@ -27,16 +28,40 @@ public class Warp extends SavedPosition {
super(position, meta);
}
@NotNull
@Subst("huskhomes.command.warp")
public String getPermissionNode() {
return getPermissionNode(meta.name);
}
/**
* Get the permission node for a warp
*
* @param warp The warp name
* @return The permission node
*/
@NotNull
@Subst("huskhomes.command.warp")
public static String getPermissionNode(@NotNull String warp) {
return Permission.COMMAND_WARP + "." + warp;
}
/**
* Check if a {@link OnlineUser} has permission to teleport to this warp
*
* @param restrictWarps Whether to restrict warps to permission nodes
* @param user The {@link OnlineUser} to check
* @return true if the user has permission to teleport to this warp
*/
public boolean hasPermission(boolean restrictWarps, @NotNull OnlineUser user) {
return hasPermission(restrictWarps, user, meta.name);
}
/**
* Check if a {@link OnlineUser} has permission to teleport to this warp
*
* @param restrictWarps Whether to restrict warps to permission nodes
* @param user The {@link OnlineUser} to check
* @param warp The warp name to check
* @return true if the user has permission to teleport to this warp
*/
public static boolean hasPermission(boolean restrictWarps, @NotNull OnlineUser user, @NotNull String warp) {
return !restrictWarps || (user.hasPermission(Permission.COMMAND_SET_WARP.node)
|| user.hasPermission(getPermissionNode(warp)));
}
}
@@ -38,6 +38,7 @@ public class World {
this.environment = environment;
}
@SuppressWarnings("unused")
public World() {
}
@@ -51,4 +52,11 @@ public class World {
CUSTOM
}
@Override
public boolean equals(@NotNull Object obj) {
if (obj instanceof World world) {
return world.uuid.equals(uuid);
}
return super.equals(obj);
}
}