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