From 0be6b721cf688f7a1f46089fdc7f070dcf1ac85a Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Wed, 4 May 2022 18:36:46 +0200 Subject: [PATCH] Use stream to get size padding --- .../commands/impl/local/CommandDump.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java index 3f633b2..7976943 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java @@ -139,14 +139,9 @@ public final class CommandDump extends PlaceholderCommand { ) .collect(Collectors.toList()); - int size = 0; - - for (final String name : expansions.stream().map(PlaceholderExpansion::getIdentifier) - .collect(Collectors.toList())) { - if (name.length() > size) { - size = name.length(); - } - } + int size = expansions.stream().map(e -> e.getIdentifier().length()) + .max(Integer::compareTo) + .orElse(0); for (final PlaceholderExpansion expansion : expansions) { builder.append(" ") @@ -197,13 +192,10 @@ public final class CommandDump extends PlaceholderCommand { List plugins = Arrays.stream(plugin.getServer().getPluginManager().getPlugins()) .sorted(Comparator.comparing(Plugin::getName)) .collect(Collectors.toList()); - - for (final String pluginName : plugins.stream().map(Plugin::getName) - .collect(Collectors.toList())) { - if (pluginName.length() > size) { - size = pluginName.length(); - } - } + + size = plugins.stream().map(pl -> pl.getName().length()) + .max(Integer::compareTo) + .orElse(0); for (final Plugin other : plugins) { builder.append(" ")