mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2026-06-04 13:55:03 +08:00
feat(deps): Update with EasyConfiguration
This commit is contained in:
+13
-2
@@ -8,6 +8,7 @@ import cc.carm.lib.configuration.source.section.ConfigureSection;
|
||||
import cc.carm.lib.configuration.value.ValueManifest;
|
||||
import cc.carm.lib.configuration.value.standard.ConfiguredValue;
|
||||
import cc.carm.lib.configuration.value.text.function.ContentHandler;
|
||||
import cc.carm.lib.easyplugin.utils.ColorParser;
|
||||
import com.cryptomorin.xseries.XItemStack;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -19,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -37,12 +39,15 @@ public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
}
|
||||
);
|
||||
|
||||
protected final @NotNull BiFunction<Player, String, String> parser;
|
||||
protected final @NotNull UnaryOperator<String> paramBuilder;
|
||||
protected final @NotNull String[] params;
|
||||
|
||||
public ConfiguredItem(@NotNull ValueManifest<ItemStack, ItemStack> manifest, ValueAdapter<ItemStack> adapter,
|
||||
@NotNull BiFunction<Player, String, String> parser,
|
||||
@NotNull UnaryOperator<String> paramBuilder, @NotNull String[] params) {
|
||||
super(manifest, adapter);
|
||||
this.parser = parser;
|
||||
this.paramBuilder = paramBuilder;
|
||||
this.params = params;
|
||||
}
|
||||
@@ -82,7 +87,7 @@ public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
}
|
||||
|
||||
public @NotNull PreparedItem prepare(@NotNull Object... values) {
|
||||
return PreparedItem.of(player -> get()).params(params).placeholders(values);
|
||||
return PreparedItem.of(player -> get()).parser(parser).params(params).placeholders(values);
|
||||
}
|
||||
|
||||
public void modifyItem(Consumer<ItemStack> modifier) {
|
||||
@@ -118,6 +123,7 @@ public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
|
||||
protected @Nullable ItemStack item = null;
|
||||
protected @NotNull String[] params = new String[0];
|
||||
protected @NotNull BiFunction<Player, String, String> parser = (player, message) -> ColorParser.parse(message);
|
||||
protected @NotNull UnaryOperator<String> paramFormatter = ContentHandler.DEFAULT_PARAM_BUILDER;
|
||||
|
||||
public Builder() {
|
||||
@@ -186,6 +192,11 @@ public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
return defaultFlags(new LinkedHashSet<>(Arrays.asList(flags)));
|
||||
}
|
||||
|
||||
public Builder parser(@NotNull BiFunction<Player, String, String> parser) {
|
||||
this.parser = parser;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder formatParam(@NotNull UnaryOperator<String> paramFormatter) {
|
||||
this.paramFormatter = paramFormatter;
|
||||
return self();
|
||||
@@ -208,7 +219,7 @@ public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
|
||||
@Override
|
||||
public @NotNull ConfiguredItem build() {
|
||||
return new ConfiguredItem(buildManifest(), ITEM_ADAPTER, paramFormatter, params);
|
||||
return new ConfiguredItem(buildManifest(), ITEM_ADAPTER, parser, paramFormatter, params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class PreparedItem extends ItemModifier<PreparedItem, ItemStack> {
|
||||
super(itemProvider);
|
||||
}
|
||||
|
||||
public @Nullable ItemStack get(Player player) {
|
||||
public @Nullable ItemStack get(@Nullable Player player) {
|
||||
@Nullable ItemStack item = itemProvider.apply(player);
|
||||
if (item == null) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user