From 9ed5847c0a7ffe8cb55428bc98027ef73566f2d4 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 9 Jun 2018 06:20:31 +1000 Subject: [PATCH] Fixes #1768 --- .../sponge/util/SpongeCommand.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java index 16037a44d..872502a6a 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java @@ -1,10 +1,12 @@ package com.plotsquared.sponge.util; import com.google.common.collect.ImmutableList; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.sponge.SpongeMain; import org.spongepowered.api.command.CommandCallable; import org.spongepowered.api.command.CommandException; @@ -15,12 +17,7 @@ import org.spongepowered.api.text.Text; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; public class SpongeCommand implements CommandCallable { @@ -56,14 +53,22 @@ public class SpongeCommand implements CommandCallable { return Collections.singletonList(MainCommand.getInstance().toString()); } Collection objects = MainCommand.getInstance().tab(player, args, arguments.endsWith(" ")); - if (objects == null) { - return ImmutableList.of(); + if (objects != null && !objects.isEmpty()) { + List result = new ArrayList<>(); + for (Object o : objects) { + result.add(o.toString()); + } + return result; } - List result = new ArrayList<>(); - for (Object o : objects) { - result.add(o.toString()); + List names = new ArrayList<>(); + String startsWith = arguments.endsWith(" ") ? "" : args[args.length - 1]; + for (Map.Entry entry : UUIDHandler.getPlayers().entrySet()) { + String name = entry.getKey(); + if (name.startsWith(startsWith)) { + names.add(name); + } } - return result; + return names; } @Override