mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-29 14:06:30 +01:00
Add playerOnly flag to tab-complete suggestions.
This commit is contained in:
parent
22afd094b2
commit
e88828f420
@ -27,6 +27,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import sun.rmi.runtime.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
@ -122,12 +123,11 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestToggles() {
|
||||
return Arrays.asList("on", "off");
|
||||
private Collection<String> suggestMVWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestMVWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||
return this.worldManager.getMVWorlds().parallelStream()
|
||||
.unordered()
|
||||
.map(MultiverseWorld::getName)
|
||||
@ -136,11 +136,19 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestUnloadedWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.worldManager.getUnloadedWorlds();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestPotentialWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Collection<MultiverseWorld> worlds = this.worldManager.getMVWorlds();
|
||||
Set<String> knownWorlds = worlds.parallelStream()
|
||||
.unordered()
|
||||
@ -158,10 +166,14 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestLocation(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Logging.info("location");
|
||||
Player player = context.getPlayer();
|
||||
if (player == null) {
|
||||
return Collections.singletonList("0");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
@ -195,6 +207,10 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestDestinations(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.plugin.getDestFactory().getIdentifiers().parallelStream()
|
||||
.unordered()
|
||||
.filter(id -> !id.isEmpty())
|
||||
@ -204,9 +220,18 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestAnchors(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.plugin.getAnchorManager().getAnchors(context.getPlayer());
|
||||
}
|
||||
|
||||
private boolean isPlayerOnly(@NotNull BukkitCommandCompletionContext context) {
|
||||
String config = context.getConfig();
|
||||
return config != null && context.getPlayer() == null && config.equals("playerOnly");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestMVConfig() {
|
||||
final Set<String> configOptions = this.plugin.getMVConfig().serialize().keySet();
|
||||
@ -254,4 +279,9 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
.map(p -> p.toString().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestToggles() {
|
||||
return Arrays.asList("on", "off");
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
|
||||
@Subcommand("tp|teleport")
|
||||
@Syntax("[player] <destination>")
|
||||
@CommandCompletion("@players|@MVWorlds|@destinations @MVWorlds|@destinations")
|
||||
@CommandCompletion("@players|@MVWorlds:playerOnly|@destinations:playerOnly @MVWorlds|@destinations")
|
||||
@Description("Allows you to the teleport to a location on your server!")
|
||||
public void doTeleportCommand(@NotNull CommandSender sender,
|
||||
|
||||
@ -73,8 +73,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
|
||||
@CommandAlias("mvtp")
|
||||
@Syntax("[player] <destination>")
|
||||
//TODO ACF: playerOnly flag
|
||||
@CommandCompletion("@players|@MVWorlds|@destinations @MVWorlds|@destinations")
|
||||
@CommandCompletion("@players|@MVWorlds:playerOnly|@destinations:playerOnly @MVWorlds|@destinations")
|
||||
@Description("Alias for /mv tp")
|
||||
public void doTeleportCommand(@NotNull CommandSender sender,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user