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("addProperties", this::suggestAddProperties);
|
||||||
registerStaticCompletion("livingEntities", this::suggestEntities);
|
registerStaticCompletion("livingEntities", this::suggestEntities);
|
||||||
registerStaticCompletion("pasteTypes", this::suggestPasteTypes);
|
registerStaticCompletion("pasteTypes", this::suggestPasteTypes);
|
||||||
|
registerStaticCompletion("toggles", this::suggestToggles);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Collection<String> suggestToggles() {
|
||||||
|
return Arrays.asList("on", "off");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -146,19 +146,14 @@ public class MVCommandContexts extends PaperCommandContexts {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Player derivePlayer(@NotNull BukkitCommandExecutionContext context) {
|
private Player derivePlayer(@NotNull BukkitCommandExecutionContext context) {
|
||||||
boolean mustBeSelf = context.hasFlag("onlyself");
|
if (!context.hasFlag("other")) {
|
||||||
String error = (mustBeSelf)
|
return getPlayerFromSelf(context, "You must be a player to run this command.");
|
||||||
? "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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerIdentifier = context.getFirstArg();
|
String playerIdentifier = context.getFirstArg();
|
||||||
if (playerIdentifier == null) {
|
if (playerIdentifier == null) {
|
||||||
if (context.hasFlag("defaultself")) {
|
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.");
|
throw new InvalidCommandArgument("You need to specify a player.");
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class AnchorCommand extends MultiverseCommand {
|
|||||||
@CommandPermission("multiverse.core.anchor.create")
|
@CommandPermission("multiverse.core.anchor.create")
|
||||||
@Syntax("<name>")
|
@Syntax("<name>")
|
||||||
@Description("Create a new anchor point.")
|
@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) {
|
@NotNull @Single @Flags("type=anchor name") String anchorName) {
|
||||||
|
|
||||||
player.sendMessage((this.plugin.getAnchorManager().saveAnchorLocation(anchorName, player.getLocation()))
|
player.sendMessage((this.plugin.getAnchorManager().saveAnchorLocation(anchorName, player.getLocation()))
|
||||||
@ -61,7 +61,7 @@ public class AnchorCommand extends MultiverseCommand {
|
|||||||
@CommandCompletion("@anchors")
|
@CommandCompletion("@anchors")
|
||||||
@Description("Delete an existing anchor point.")
|
@Description("Delete an existing anchor point.")
|
||||||
public void onDeleteAnchorCommand(@NotNull CommandSender sender,
|
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))
|
sender.sendMessage((this.plugin.getAnchorManager().deleteAnchor(anchorName))
|
||||||
? "Anchor '" + anchorName + "' was successfully " + ChatColor.RED + "deleted!"
|
? "Anchor '" + anchorName + "' was successfully " + ChatColor.RED + "deleted!"
|
||||||
|
@ -28,7 +28,7 @@ public class BedCommand extends MultiverseCommand {
|
|||||||
@Subcommand("bed")
|
@Subcommand("bed")
|
||||||
@CommandPermission("multiverse.core.bed")
|
@CommandPermission("multiverse.core.bed")
|
||||||
@Description("Takes your current respawn point.")
|
@Description("Takes your current respawn point.")
|
||||||
public void onBedCommand(@NotNull @Flags("onlyself") Player player) {
|
public void onBedCommand(@NotNull Player player) {
|
||||||
Location bedLocation = player.getBedSpawnLocation();
|
Location bedLocation = player.getBedSpawnLocation();
|
||||||
if (bedLocation == null) {
|
if (bedLocation == null) {
|
||||||
player.sendMessage("You do have a respawn point set!");
|
player.sendMessage("You do have a respawn point set!");
|
||||||
|
@ -35,11 +35,11 @@ public class DebugCommand extends MultiverseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("debug")
|
@Subcommand("debug")
|
||||||
@CommandCompletion("on|off|@range:3")
|
@CommandCompletion("@toggles|@range:3")
|
||||||
@Syntax("<level>")
|
@Syntax("<level>")
|
||||||
@Description("Change debug level.")
|
@Description("Change debug level.")
|
||||||
public void onChangeDebugCommand(@NotNull CommandSender sender,
|
public void onChangeDebugCommand(@NotNull CommandSender sender,
|
||||||
@NotNull @Single String debugLevel) {
|
@NotNull @Single String debugLevel) {
|
||||||
|
|
||||||
int parsedLevel = parseDebugLevel(debugLevel);
|
int parsedLevel = parseDebugLevel(debugLevel);
|
||||||
if (parsedLevel == -1) {
|
if (parsedLevel == -1) {
|
||||||
|
@ -35,7 +35,7 @@ public class SetSpawnCommand extends MultiverseCommand {
|
|||||||
@CommandAlias("mv")
|
@CommandAlias("mv")
|
||||||
public class SetSpawn extends BaseCommand {
|
public class SetSpawn extends BaseCommand {
|
||||||
|
|
||||||
@Subcommand("setspawn|")
|
@Subcommand("setspawn")
|
||||||
@CommandPermission("multiverse.core.spawn.set")
|
@CommandPermission("multiverse.core.spawn.set")
|
||||||
@Syntax("[world x y z [yaw pitch]]")
|
@Syntax("[world x y z [yaw pitch]]")
|
||||||
@CommandCompletion("@MVWorlds")
|
@CommandCompletion("@MVWorlds")
|
||||||
@ -52,7 +52,7 @@ public class SetSpawnCommand extends MultiverseCommand {
|
|||||||
@CommandCompletion("@MVWorlds")
|
@CommandCompletion("@MVWorlds")
|
||||||
@Description("Sets the spawn for the current world.")
|
@Description("Sets the spawn for the current world.")
|
||||||
public void onModifySetSpawnCommand(@NotNull CommandSender sender,
|
public void onModifySetSpawnCommand(@NotNull CommandSender sender,
|
||||||
@NotNull @Flags("other,defaultself,fallbackself") Location location) {
|
@NotNull @Flags("other,defaultself,fallbackself") Location location) {
|
||||||
|
|
||||||
doSpawnSet(sender, 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!");
|
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