mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 12:05:14 +01:00
Remove PlayerWorld.
This commit is contained in:
parent
55cf19b1d8
commit
a6d4e21b85
@ -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<BukkitCommandIssuer> context,
|
||||
@ -195,14 +193,4 @@ public class MVCommandConditions {
|
||||
world.getColoredWorldString(), ChatColor.RED));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSelfOtherPerm(@NotNull ConditionContext<BukkitCommandIssuer> 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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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")) {
|
||||
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -127,7 +127,5 @@ public class MVFlags {
|
||||
}
|
||||
};
|
||||
|
||||
static void register(CommandFlag<?> flag) {
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user