Merge pull request #1986 from dualspiral/bugfix/null-suggestions

Fix errors with tab completion on Sponge.
This commit is contained in:
Jesse Boyd 2018-06-09 05:11:27 +10:00 committed by GitHub
commit eca67c7d84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package com.plotsquared.sponge.util;
import com.google.common.collect.ImmutableList;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -47,7 +48,7 @@ public class SpongeCommand implements CommandCallable {
public List<String> getSuggestions(CommandSource source, String arguments, Location<World> targetPosition)
throws CommandException {
if (!(source instanceof Player)) {
return null;
return ImmutableList.of();
}
PlotPlayer player = SpongeUtil.getPlayer((Player) source);
String[] args = arguments.split(" ");
@ -56,13 +57,13 @@ public class SpongeCommand implements CommandCallable {
}
Collection objects = MainCommand.getInstance().tab(player, args, arguments.endsWith(" "));
if (objects == null) {
return null;
return ImmutableList.of();
}
List<String> result = new ArrayList<>();
for (Object o : objects) {
result.add(o.toString());
}
return result.isEmpty() ? null : result;
return result;
}
@Override