Skip to content

Commit c4e4e31

Browse files
authored
Merge pull request #3368 from Multiverse/perf/suggest-destination
Minor perf improvement to suggestDestinationsWithPerms
2 parents 3e4ded5 + 4ef8390 commit c4e4e31

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/org/mvplugins/multiverse/core/command/MVCommandCompletions.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.bukkit.Material;
2828
import org.bukkit.World;
2929
import org.bukkit.command.CommandSender;
30+
import org.bukkit.entity.Entity;
3031
import org.bukkit.entity.Player;
3132
import org.bukkit.entity.SpawnCategory;
3233
import org.jetbrains.annotations.NotNull;
@@ -224,18 +225,19 @@ private Collection<String> suggestDestinations(BukkitCommandCompletionContext co
224225
// Most likely console did not specify a player
225226
return Collections.<String>emptyList();
226227
}
227-
if (context.hasConfig("othersOnly") && (players.length == 1 && players[0].equals(context.getIssuer().getIssuer()))) {
228+
CommandSender sender = context.getIssuer().getIssuer();
229+
if (context.hasConfig("othersOnly") && (players.length == 1 && players[0].equals(sender))) {
228230
return Collections.<String>emptyList();
229231
}
230-
return suggestDestinationsWithPerms(context.getIssuer().getIssuer(), players, context.getInput());
232+
return suggestDestinationsWithPerms(sender, Arrays.asList(players), context.getInput());
231233
})
232234
.getOrElse(Collections.emptyList());
233235
}
234236

235-
private Collection<String> suggestDestinationsWithPerms(CommandSender teleporter, Player[] players, String deststring) {
237+
private Collection<String> suggestDestinationsWithPerms(CommandSender teleporter, List<Entity> teleportees, String deststring) {
236238
return destinationsProvider.suggestDestinations(teleporter, deststring).stream()
237239
.filter(packet -> corePermissionsChecker
238-
.checkDestinationPacketPermission(teleporter, Arrays.asList(players), packet))
240+
.checkDestinationPacketPermission(teleporter, teleportees, packet))
239241
.map(DestinationSuggestionPacket::parsableString)
240242
.toList();
241243
}

0 commit comments

Comments
 (0)