mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-23 11:05:24 +01:00
Optimise some streams.
This commit is contained in:
parent
a783f773b3
commit
a05d4581f6
@ -48,14 +48,17 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
|||||||
|
|
||||||
private Collection<String> suggestDestinations(@NotNull BukkitCommandCompletionContext context) {
|
private Collection<String> suggestDestinations(@NotNull BukkitCommandCompletionContext context) {
|
||||||
//TODO: There is one empty dest need to remove.
|
//TODO: There is one empty dest need to remove.
|
||||||
return this.plugin.getDestFactory().getIdentifiers().stream()
|
return this.plugin.getDestFactory().getIdentifiers().parallelStream()
|
||||||
|
.unordered()
|
||||||
|
.filter(id -> !id.isEmpty())
|
||||||
.map(id -> id + ":")
|
.map(id -> id + ":")
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Collection<String> suggestMVWorlds(@NotNull BukkitCommandCompletionContext context) {
|
private Collection<String> suggestMVWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||||
return this.worldManager.getMVWorlds().stream()
|
return this.worldManager.getMVWorlds().parallelStream()
|
||||||
|
.unordered()
|
||||||
.map(MultiverseWorld::getName)
|
.map(MultiverseWorld::getName)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -69,11 +72,13 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
|||||||
private Collection<String> suggestPotentialWorlds(@NotNull BukkitCommandCompletionContext context) {
|
private Collection<String> suggestPotentialWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||||
//TODO: Should be more efficient
|
//TODO: Should be more efficient
|
||||||
//TODO: this should be in WorldManager API
|
//TODO: this should be in WorldManager API
|
||||||
List<String> knownWorlds = this.worldManager.getMVWorlds().stream()
|
List<String> knownWorlds = this.worldManager.getMVWorlds().parallelStream()
|
||||||
|
.unordered()
|
||||||
.map(MultiverseWorld::getName)
|
.map(MultiverseWorld::getName)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return Arrays.stream(this.plugin.getServer().getWorldContainer().listFiles())
|
return Arrays.stream(this.plugin.getServer().getWorldContainer().listFiles()).parallel()
|
||||||
|
.unordered()
|
||||||
.filter(File::isDirectory)
|
.filter(File::isDirectory)
|
||||||
.filter(file -> !knownWorlds.contains(file.getName()))
|
.filter(file -> !knownWorlds.contains(file.getName()))
|
||||||
.map(File::getName)
|
.map(File::getName)
|
||||||
|
@ -204,7 +204,8 @@ public class MVCommandContexts extends PaperCommandContexts {
|
|||||||
|
|
||||||
List<Player> matchedPlayers;
|
List<Player> matchedPlayers;
|
||||||
try {
|
try {
|
||||||
matchedPlayers = this.plugin.getServer().selectEntities(sender, playerIdentifier).stream()
|
matchedPlayers = this.plugin.getServer().selectEntities(sender, playerIdentifier).parallelStream()
|
||||||
|
.unordered()
|
||||||
.filter(e -> e instanceof Player)
|
.filter(e -> e instanceof Player)
|
||||||
.map(e -> ((Player) e))
|
.map(e -> ((Player) e))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -241,6 +241,7 @@ public class PageDisplay {
|
|||||||
|
|
||||||
private void doEndPadding() {
|
private void doEndPadding() {
|
||||||
IntStream.range(0, contentLinesPerPage - contentToShowIndex.size())
|
IntStream.range(0, contentLinesPerPage - contentToShowIndex.size())
|
||||||
|
.unordered()
|
||||||
.mapToObj(i -> " ")
|
.mapToObj(i -> " ")
|
||||||
.forEach(sender::sendMessage);
|
.forEach(sender::sendMessage);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user