From a6d4e21b85b13299f8169de3142b84ab71d7413d Mon Sep 17 00:00:00 2001 From: benwoo1110 <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 5 Mar 2021 12:19:06 +0800 Subject: [PATCH] Remove PlayerWorld. --- .../commandTools/MVCommandConditions.java | 12 ----- .../commandTools/MVCommandContexts.java | 22 -------- .../commandTools/contexts/PlayerWorld.java | 52 ------------------- .../commandTools/flags/MVFlags.java | 2 - 4 files changed, 88 deletions(-) delete mode 100644 src/main/java/com/onarandombox/MultiverseCore/commandTools/contexts/PlayerWorld.java diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandConditions.java b/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandConditions.java index 864d0589..dcd995e2 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandConditions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandConditions.java @@ -16,7 +16,6 @@ import co.aikar.commands.ConditionFailedException; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MultiverseWorld; -import com.onarandombox.MultiverseCore.commandtools.contexts.PlayerWorld; import com.onarandombox.MultiverseCore.enums.AddProperties; import com.onarandombox.MultiverseCore.enums.WorldValidationResult; import org.bukkit.ChatColor; @@ -46,7 +45,6 @@ public class MVCommandConditions { conditions.addCondition(String.class, "validWorldFolder", this::checkValidWorldFolder); conditions.addCondition(String.class, "validAddProperty", this::checkValidAddProperty); conditions.addCondition(MultiverseWorld.class, "hasWorldAccess", this::checkHasWorldAccess); - conditions.addCondition(PlayerWorld.class, "selfOtherPerm", this::checkSelfOtherPerm); } private void checkIsMVWorld(@NotNull ConditionContext context, @@ -195,14 +193,4 @@ public class MVCommandConditions { world.getColoredWorldString(), ChatColor.RED)); } } - - private void checkSelfOtherPerm(@NotNull ConditionContext context, - @NotNull BukkitCommandExecutionContext executionContext, - @NotNull PlayerWorld player) { - - String permNode = context.getConfig() + (player.isSender(executionContext.getSender()) ? ".self" : ".other"); - if (!executionContext.getSender().hasPermission(permNode)) { - throw new ConditionFailedException("You do not have permission to run this command."); - } - } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandContexts.java b/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandContexts.java index 25c749da..7374ed8b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandContexts.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandContexts.java @@ -18,7 +18,6 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.commandtools.contexts.RequiredPlayer; import com.onarandombox.MultiverseCore.commandtools.contexts.GameRuleProperty; import com.onarandombox.MultiverseCore.commandtools.contexts.PageFilter; -import com.onarandombox.MultiverseCore.commandtools.contexts.PlayerWorld; import com.onarandombox.MultiverseCore.commandtools.display.ContentFilter; import com.onarandombox.MultiverseCore.commandtools.display.page.PageDisplay; import com.onarandombox.MultiverseCore.commands.EnvironmentCommand; @@ -60,7 +59,6 @@ public class MVCommandContexts extends PaperCommandContexts { registerContext(RequiredPlayer.class, this::deriveRequiredPlayer); registerIssuerOnlyContext(Player.class, this::derivePlayer); - registerIssuerAwareContext(PlayerWorld.class, this::derivePlayerWorld); registerIssuerAwareContext(MultiverseWorld.class, this::deriveMultiverseWorld); registerContext(World.Environment.class, this::deriveEnvironment); registerIssuerAwareContext(GameRuleProperty.class, this::deriveGameRuleProperty); @@ -90,26 +88,6 @@ public class MVCommandContexts extends PaperCommandContexts { return new RequiredPlayer(player); } - @NotNull - private PlayerWorld derivePlayerWorld(@NotNull BukkitCommandExecutionContext context) { - Player player = derivePlayer(context); - if (player == null) { - if (context.isOptional()) { - return null; - } - // Tho this should not happen as player parsing is handled by derivePlayer. - throw new InvalidCommandArgument("Invalid player name!"); - } - - MultiverseWorld world = getPlayerWorld( - player, - false, - String.format("Something went wrong parsing player '%s'...", player.getName()) - ); - - return new PlayerWorld(player, world); - } - @Nullable private MultiverseWorld deriveMultiverseWorld(@NotNull BukkitCommandExecutionContext context) { if (!context.hasFlag("other")) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandTools/contexts/PlayerWorld.java b/src/main/java/com/onarandombox/MultiverseCore/commandTools/contexts/PlayerWorld.java deleted file mode 100644 index 21a7c713..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/commandTools/contexts/PlayerWorld.java +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * Multiverse 2 Copyright (c) the Multiverse Team 2020. * - * Multiverse 2 is licensed under the BSD License. * - * For more information please check the README.md file included * - * with this project. * - ******************************************************************************/ - -package com.onarandombox.MultiverseCore.commandtools.contexts; - -import com.onarandombox.MultiverseCore.api.MultiverseWorld; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Player and its corresponding {@link MultiverseWorld}. - */ -public class PlayerWorld { - - private final Player player; - private final MultiverseWorld world; - - public PlayerWorld(@NotNull Player player, - @Nullable MultiverseWorld world) { - - this.player = player; - this.world = world; - } - - public boolean isSender(@Nullable CommandSender sender) { - return player.equals(sender); - } - - @NotNull - public Player getPlayer() { - return player; - } - - @Nullable - public MultiverseWorld getWorld() { - return world; - } - - @Override - public String toString() { - return "CommandPlayer{" + - "player=" + player + - ", world=" + world + - '}'; - } -} diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandTools/flags/MVFlags.java b/src/main/java/com/onarandombox/MultiverseCore/commandTools/flags/MVFlags.java index 93828503..f038da1a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandTools/flags/MVFlags.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandTools/flags/MVFlags.java @@ -127,7 +127,5 @@ public class MVFlags { } }; - static void register(CommandFlag flag) { - } }