mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-26 20:47:01 +01:00
Add toggles completion and remove need for onlyself flag.
This commit is contained in:
parent
b953f1a011
commit
cee6f68439
@ -53,6 +53,12 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
registerStaticCompletion("addProperties", this::suggestAddProperties);
|
||||
registerStaticCompletion("livingEntities", this::suggestEntities);
|
||||
registerStaticCompletion("pasteTypes", this::suggestPasteTypes);
|
||||
registerStaticCompletion("toggles", this::suggestToggles);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestToggles() {
|
||||
return Arrays.asList("on", "off");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -146,19 +146,14 @@ public class MVCommandContexts extends PaperCommandContexts {
|
||||
|
||||
@Nullable
|
||||
private Player derivePlayer(@NotNull BukkitCommandExecutionContext context) {
|
||||
boolean mustBeSelf = context.hasFlag("onlyself");
|
||||
String error = (mustBeSelf)
|
||||
? "You must be a player to run this command."
|
||||
: "You need to specify a player from console.";
|
||||
|
||||
if (mustBeSelf || !context.hasFlag("other")) {
|
||||
return getPlayerFromSelf(context, error);
|
||||
if (!context.hasFlag("other")) {
|
||||
return getPlayerFromSelf(context, "You must be a player to run this command.");
|
||||
}
|
||||
|
||||
String playerIdentifier = context.getFirstArg();
|
||||
if (playerIdentifier == null) {
|
||||
if (context.hasFlag("defaultself")) {
|
||||
return getPlayerFromSelf(context, error);
|
||||
return getPlayerFromSelf(context, "You need to specify a player from console.");
|
||||
}
|
||||
throw new InvalidCommandArgument("You need to specify a player.");
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class AnchorCommand extends MultiverseCommand {
|
||||
@CommandPermission("multiverse.core.anchor.create")
|
||||
@Syntax("<name>")
|
||||
@Description("Create a new anchor point.")
|
||||
public void onCreateAnchorCommand(@NotNull @Flags("onlyself") Player player,
|
||||
public void onCreateAnchorCommand(@NotNull Player player,
|
||||
@NotNull @Single @Flags("type=anchor name") String anchorName) {
|
||||
|
||||
player.sendMessage((this.plugin.getAnchorManager().saveAnchorLocation(anchorName, player.getLocation()))
|
||||
@ -61,7 +61,7 @@ public class AnchorCommand extends MultiverseCommand {
|
||||
@CommandCompletion("@anchors")
|
||||
@Description("Delete an existing anchor point.")
|
||||
public void onDeleteAnchorCommand(@NotNull CommandSender sender,
|
||||
@NotNull @Flags("type=anchor name") String anchorName) {
|
||||
@NotNull @Single @Flags("type=anchor name") String anchorName) {
|
||||
|
||||
sender.sendMessage((this.plugin.getAnchorManager().deleteAnchor(anchorName))
|
||||
? "Anchor '" + anchorName + "' was successfully " + ChatColor.RED + "deleted!"
|
||||
|
@ -28,7 +28,7 @@ public class BedCommand extends MultiverseCommand {
|
||||
@Subcommand("bed")
|
||||
@CommandPermission("multiverse.core.bed")
|
||||
@Description("Takes your current respawn point.")
|
||||
public void onBedCommand(@NotNull @Flags("onlyself") Player player) {
|
||||
public void onBedCommand(@NotNull Player player) {
|
||||
Location bedLocation = player.getBedSpawnLocation();
|
||||
if (bedLocation == null) {
|
||||
player.sendMessage("You do have a respawn point set!");
|
||||
|
@ -35,11 +35,11 @@ public class DebugCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
@Subcommand("debug")
|
||||
@CommandCompletion("on|off|@range:3")
|
||||
@CommandCompletion("@toggles|@range:3")
|
||||
@Syntax("<level>")
|
||||
@Description("Change debug level.")
|
||||
public void onChangeDebugCommand(@NotNull CommandSender sender,
|
||||
@NotNull @Single String debugLevel) {
|
||||
@NotNull @Single String debugLevel) {
|
||||
|
||||
int parsedLevel = parseDebugLevel(debugLevel);
|
||||
if (parsedLevel == -1) {
|
||||
|
@ -35,7 +35,7 @@ public class SetSpawnCommand extends MultiverseCommand {
|
||||
@CommandAlias("mv")
|
||||
public class SetSpawn extends BaseCommand {
|
||||
|
||||
@Subcommand("setspawn|")
|
||||
@Subcommand("setspawn")
|
||||
@CommandPermission("multiverse.core.spawn.set")
|
||||
@Syntax("[world x y z [yaw pitch]]")
|
||||
@CommandCompletion("@MVWorlds")
|
||||
@ -52,7 +52,7 @@ public class SetSpawnCommand extends MultiverseCommand {
|
||||
@CommandCompletion("@MVWorlds")
|
||||
@Description("Sets the spawn for the current world.")
|
||||
public void onModifySetSpawnCommand(@NotNull CommandSender sender,
|
||||
@NotNull @Flags("other,defaultself,fallbackself") Location location) {
|
||||
@NotNull @Flags("other,defaultself,fallbackself") Location location) {
|
||||
|
||||
doSpawnSet(sender, location);
|
||||
}
|
||||
@ -121,6 +121,4 @@ public class SetSpawnCommand extends MultiverseCommand {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user