package net.minecraft.server.packs.repository; import java.util.function.UnaryOperator; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; public interface PackSource { UnaryOperator NO_DECORATION = UnaryOperator.identity(); PackSource DEFAULT = create(NO_DECORATION, true); PackSource BUILT_IN = create(decorateWithSource("pack.source.builtin"), true); PackSource FEATURE = create(decorateWithSource("pack.source.feature"), false); PackSource WORLD = create(decorateWithSource("pack.source.world"), true); PackSource SERVER = create(decorateWithSource("pack.source.server"), true); Component decorate(Component name); boolean shouldAddAutomatically(); static PackSource create(UnaryOperator decorator, boolean shouldAddAutomatically) { return new PackSource() { @Override public Component decorate(Component name) { return (Component)decorator.apply(name); } @Override public boolean shouldAddAutomatically() { return shouldAddAutomatically; } }; } private static UnaryOperator decorateWithSource(String translationKey) { Component component = Component.translatable(translationKey); return component2 -> Component.translatable("pack.nameAndSource", component2, component).withStyle(ChatFormatting.GRAY); } }