Overload ContentDisplay#forContent with defaults for list and map.

This commit is contained in:
Jeremy Wood 2021-07-06 15:54:49 -04:00
parent 44248b4178
commit d1ce8e57a0
2 changed files with 21 additions and 1 deletions

View File

@ -76,7 +76,6 @@ public class GamerulesCommand extends MultiverseCommand {
ContentDisplay.forContent(getGameRuleMap(world))
.header("=== Gamerules for %s%s%s ===", ChatColor.AQUA, world.getName(), ChatColor.WHITE)
.displayHandler(DisplayHandlers.INLINE_MAP)
.colorTool(ColorAlternator.with(ChatColor.GREEN, ChatColor.GOLD))
.setting(DisplaySettings.OPERATOR, ": ")
.show(sender);

View File

@ -5,6 +5,7 @@ import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.WeakHashMap;
@ -29,6 +30,26 @@ public class ContentDisplay<T> {
return new Builder<>(content);
}
/**
* Creates a ContentDisplay.Builder for the given collection of content.
*
* @param content The content to be displayed.
* @return A new Builder.
*/
public static Builder<Collection<String>> forContent(Collection<String> content) {
return new Builder<>(content).displayHandler(DisplayHandlers.LIST);
}
/**
* Creates a ContentDisplay.Builder for the given map of content.
*
* @param content The content to be displayed.
* @return A new Builder.
*/
public static Builder<Map<String, Object>> forContent(Map<String, Object> content) {
return new Builder<>(content).displayHandler(DisplayHandlers.INLINE_MAP);
}
private final T contents;
private CommandSender sender;