More command refactor work

This commit is contained in:
William278 committed 2023-03-17 18:57:52 +00:00
1 parent f746d67339
commit 3bde5305d7
4 files changed
+9 -10

No files matched your search

@@ -1,7 +1,6 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.SavedPosition;
import net.william278.paginedown.PaginatedList;
import org.jetbrains.annotations.NotNull;
@@ -10,7 +9,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
public abstract class ListCommand<T extends SavedPosition> extends Command {
public abstract class ListCommand extends Command {
protected final Map<UUID, PaginatedList> cachedLists;
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.stream.Collectors;
public class PrivateHomeListCommand extends ListCommand<Home> {
public class PrivateHomeListCommand extends ListCommand {
protected PrivateHomeListCommand(@NotNull HuskHomes plugin) {
super("homelist", List.of("homes"), "[player] [page]", plugin);
@@ -42,11 +42,11 @@ public class PrivateHomeListCommand extends ListCommand<Home> {
}
final User user = targetUser.get();
if (executor instanceof OnlineUser onlineUser && !user.getUuid().equals(onlineUser.getUuid())) {
if (!executor.hasPermission(getPermission("other"))) {
plugin.getLocales().getLocale("error_no_permission").ifPresent(executor::sendMessage);
return;
}
if (executor instanceof OnlineUser onlineUser && !user.getUuid().equals(onlineUser.getUuid())
&& !executor.hasPermission(getPermission("other"))) {
plugin.getLocales().getLocale("error_no_permission")
.ifPresent(executor::sendMessage);
return;
}
if (cachedLists.containsKey(user.getUuid())) {
@@ -12,7 +12,7 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class PublicHomeListCommand extends ListCommand<Home> {
public class PublicHomeListCommand extends ListCommand {
protected PublicHomeListCommand(@NotNull HuskHomes plugin) {
@@ -12,7 +12,7 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class WarpListCommand extends ListCommand<Warp> {
public class WarpListCommand extends ListCommand {
protected WarpListCommand(@NotNull HuskHomes plugin) {
super("homelist", List.of("homes"), "[player] [page]", plugin);