mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2026-06-14 08:11:08 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c1026f37e | |||
| 112e34e1b4 | |||
| ce4ceaef73 | |||
| 10ad1c8fcd | |||
| abdbd88946 | |||
| 517b661a13 | |||
| 4ddd2a3454 | |||
| 50f7eb31bb | |||
| e44e74a512 | |||
| 051049eee2 | |||
| c4010bb642 | |||
| 420eb93366 | |||
| b346fc7600 |
+10
-10
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mineconfiguration-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>3.0.3</version>
|
||||
<version>3.1.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
@@ -23,29 +23,29 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-core</artifactId>
|
||||
<version>${deps.easyconfifuration.version}</version>
|
||||
<artifactId>configured-core</artifactId>
|
||||
<version>${deps.configured.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-feature-commentable</artifactId>
|
||||
<version>${deps.easyconfifuration.version}</version>
|
||||
<artifactId>configured-feature-commentable</artifactId>
|
||||
<version>${deps.configured.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-feature-file</artifactId>
|
||||
<version>${deps.easyconfifuration.version}</version>
|
||||
<artifactId>configured-feature-file</artifactId>
|
||||
<version>${deps.configured.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-feature-text</artifactId>
|
||||
<version>${deps.easyconfifuration.version}</version>
|
||||
<artifactId>configured-feature-text</artifactId>
|
||||
<version>${deps.configured.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.20-R0.2-deprecated+build.19</version>
|
||||
<version>1.21-R0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mineconfiguration-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>3.0.3</version>
|
||||
<version>3.1.2</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -40,7 +40,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.cryptomorin</groupId>
|
||||
<artifactId>XSeries</artifactId>
|
||||
<version>13.0.0</version>
|
||||
<version>13.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+11
-3
@@ -8,17 +8,25 @@ import cc.carm.lib.mineconfiguration.common.AbstractConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MineConfiguration extends AbstractConfiguration<ConfigurationHolder<BukkitSource>> {
|
||||
|
||||
public static ConfigurationHolder<BukkitSource> from(File file, String source) {
|
||||
public static ConfigurationHolder<BukkitSource> from(@NotNull File file,
|
||||
@Nullable String source) {
|
||||
return BukkitConfigFactory.from(file).resourcePath(source).build();
|
||||
}
|
||||
|
||||
public static ConfigurationHolder<BukkitSource> from(Plugin plugin, String fileName) {
|
||||
return from(new File(plugin.getDataFolder(), fileName), fileName);
|
||||
public static ConfigurationHolder<BukkitSource> from(@NotNull Plugin plugin,
|
||||
@NotNull String fileName) {
|
||||
return from(plugin, fileName, null);
|
||||
}
|
||||
|
||||
public static ConfigurationHolder<BukkitSource> from(@NotNull Plugin plugin,
|
||||
@NotNull String fileName, @Nullable String resource) {
|
||||
return from(new File(plugin.getDataFolder(), fileName), resource);
|
||||
}
|
||||
|
||||
public MineConfiguration(@NotNull JavaPlugin plugin) {
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ public class ConfiguredMessage<M> extends ConfiguredText<M, CommandSender> {
|
||||
return asString().defaults(messages).build();
|
||||
}
|
||||
|
||||
public ConfiguredMessage(@NotNull ValueManifest<TextContents> manifest,
|
||||
public ConfiguredMessage(@NotNull ValueManifest<TextContents, TextContents> manifest,
|
||||
@NotNull BiFunction<CommandSender, String, String> parser,
|
||||
@NotNull BiFunction<CommandSender, String, M> compiler,
|
||||
@NotNull BiConsumer<CommandSender, List<M>> dispatcher,
|
||||
@@ -46,7 +46,7 @@ public class ConfiguredMessage<M> extends ConfiguredText<M, CommandSender> {
|
||||
super(manifest, parser, compiler, dispatcher, params);
|
||||
}
|
||||
|
||||
public void sendActionBar(Player player, Object... values) {
|
||||
public void sendActionBar(@NotNull Player player, Object... values) {
|
||||
ActionBar.sendActionBar(player, prepare(values).parseLine(player, (sender, message) -> message));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ public class ConfiguredSound extends ConfiguredValue<SoundConfig> {
|
||||
}
|
||||
);
|
||||
|
||||
public ConfiguredSound(@NotNull ValueManifest<SoundConfig> manifest, @NotNull ValueAdapter<SoundConfig> adapter) {
|
||||
public ConfiguredSound(@NotNull ValueManifest<SoundConfig, SoundConfig> manifest, @NotNull ValueAdapter<SoundConfig> adapter) {
|
||||
super(manifest, adapter);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ConfiguredSound extends ConfiguredValue<SoundConfig> {
|
||||
Optional.ofNullable(get()).ifPresent(s -> s.playAt(location));
|
||||
}
|
||||
|
||||
public static class Builder extends AbstractConfigBuilder<SoundConfig, ConfiguredSound, ConfigurationHolder<?>, Builder> {
|
||||
public static class Builder extends AbstractConfigBuilder<SoundConfig, SoundConfig, ConfiguredSound, ConfigurationHolder<?>, Builder> {
|
||||
|
||||
protected @NotNull ValueAdapter<SoundConfig> adapter = SOUND_ADAPTER;
|
||||
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ public class ConfiguredTitle extends ConfiguredValue<TitleConfig> {
|
||||
protected final @NotNull UnaryOperator<String> paramBuilder;
|
||||
protected final @NotNull String[] params;
|
||||
|
||||
public ConfiguredTitle(@NotNull ValueManifest<TitleConfig> manifest, ValueAdapter<TitleConfig> adapter,
|
||||
public ConfiguredTitle(@NotNull ValueManifest<TitleConfig, TitleConfig> manifest, ValueAdapter<TitleConfig> adapter,
|
||||
@NotNull UnaryOperator<String> paramBuilder, @NotNull String[] params,
|
||||
@NotNull ConfiguredTitle.TitleConsumer sendConsumer) {
|
||||
super(manifest, adapter);
|
||||
@@ -150,7 +150,7 @@ public class ConfiguredTitle extends ConfiguredValue<TitleConfig> {
|
||||
|
||||
}
|
||||
|
||||
public static class Builder extends AbstractConfigBuilder<TitleConfig, ConfiguredTitle, ConfigurationHolder<?>, Builder> {
|
||||
public static class Builder extends AbstractConfigBuilder<TitleConfig, TitleConfig, ConfiguredTitle, ConfigurationHolder<?>, Builder> {
|
||||
|
||||
protected @NotNull ValueAdapter<TitleConfig> adapter = TITLE_ADAPTER;
|
||||
protected @NotNull TitleConfig title = TitleConfig.of(null, null);
|
||||
|
||||
+12
-12
@@ -7,7 +7,7 @@ import cc.carm.lib.configuration.source.ConfigurationHolder;
|
||||
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,8 +19,8 @@ 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;
|
||||
|
||||
public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
|
||||
@@ -37,13 +37,13 @@ public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
}
|
||||
);
|
||||
|
||||
protected final @NotNull UnaryOperator<String> paramBuilder;
|
||||
protected final @NotNull BiFunction<Player, String, String> parser;
|
||||
protected final @NotNull String[] params;
|
||||
|
||||
public ConfiguredItem(@NotNull ValueManifest<ItemStack> manifest, ValueAdapter<ItemStack> adapter,
|
||||
@NotNull UnaryOperator<String> paramBuilder, @NotNull String[] params) {
|
||||
public ConfiguredItem(@NotNull ValueManifest<ItemStack, ItemStack> manifest, ValueAdapter<ItemStack> adapter,
|
||||
@NotNull BiFunction<Player, String, String> parser, @NotNull String[] params) {
|
||||
super(manifest, adapter);
|
||||
this.paramBuilder = paramBuilder;
|
||||
this.parser = parser;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,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) {
|
||||
@@ -114,11 +114,11 @@ public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
}
|
||||
|
||||
|
||||
public static class Builder extends AbstractConfigBuilder<ItemStack, ConfiguredItem, ConfigurationHolder<?>, Builder> {
|
||||
public static class Builder extends AbstractConfigBuilder<ItemStack, ItemStack, ConfiguredItem, ConfigurationHolder<?>, Builder> {
|
||||
|
||||
protected @Nullable ItemStack item = null;
|
||||
protected @NotNull String[] params = new String[0];
|
||||
protected @NotNull UnaryOperator<String> paramFormatter = ContentHandler.DEFAULT_PARAM_BUILDER;
|
||||
protected @NotNull BiFunction<Player, String, String> parser = (player, message) -> ColorParser.parse(message);
|
||||
|
||||
public Builder() {
|
||||
super(ConfigurationHolder.class, ITEM_TYPE);
|
||||
@@ -186,8 +186,8 @@ public class ConfiguredItem extends ConfiguredValue<ItemStack> {
|
||||
return defaultFlags(new LinkedHashSet<>(Arrays.asList(flags)));
|
||||
}
|
||||
|
||||
public Builder formatParam(@NotNull UnaryOperator<String> paramFormatter) {
|
||||
this.paramFormatter = paramFormatter;
|
||||
public Builder parser(@NotNull BiFunction<Player, String, String> parser) {
|
||||
this.parser = parser;
|
||||
return self();
|
||||
}
|
||||
|
||||
@@ -208,7 +208,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, params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-3
@@ -20,13 +20,10 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public abstract class ItemModifier<S extends ItemModifier<S, R>, R>
|
||||
extends ContentHandler<Player, S> {
|
||||
|
||||
public static final @NotNull Pattern LORE_INSERT_PATTERN = Pattern.compile("^(?:\\{(.*)})?#(.*)#(?:\\{(-?\\d+)(?:,(-?\\d+))?})?$");
|
||||
|
||||
protected final @NotNull Function<@NotNull Player, @Nullable ItemStack> itemProvider;
|
||||
|
||||
protected @NotNull BiConsumer<ItemStack, Player> itemConsumer;
|
||||
|
||||
+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;
|
||||
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ public class ConfiguredNotify extends ConfiguredList<NotifyConfig> {
|
||||
protected final @NotNull UnaryOperator<String> paramBuilder;
|
||||
protected final @NotNull String[] params;
|
||||
|
||||
public ConfiguredNotify(@NotNull ValueManifest<List<NotifyConfig>> manifest,
|
||||
public ConfiguredNotify(@NotNull ValueManifest<List<NotifyConfig>, NotifyConfig> manifest,
|
||||
@NotNull ValueAdapter<NotifyConfig> adapter,
|
||||
@NotNull UnaryOperator<String> paramBuilder, @NotNull String[] params) {
|
||||
super(manifest, ArrayList::new, adapter);
|
||||
@@ -65,7 +65,7 @@ public class ConfiguredNotify extends ConfiguredList<NotifyConfig> {
|
||||
}
|
||||
|
||||
|
||||
public static class NotifyBuilder extends AbstractConfigBuilder<List<NotifyConfig>, ConfiguredNotify, ConfigurationHolder<?>, NotifyBuilder> {
|
||||
public static class NotifyBuilder extends AbstractConfigBuilder<List<NotifyConfig>, NotifyConfig, ConfiguredNotify, ConfigurationHolder<?>, NotifyBuilder> {
|
||||
|
||||
protected final @NotNull List<NotifyConfig> notifications = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mineconfiguration-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>3.0.3</version>
|
||||
<version>3.1.2</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-yaml</artifactId>
|
||||
<version>${deps.easyconfifuration.version}</version>
|
||||
<artifactId>configured-yaml</artifactId>
|
||||
<version>${deps.configured.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20-R0.2</version>
|
||||
<version>1.21-R0.2</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ public class MineConfiguration extends AbstractConfiguration<ConfigurationHolder
|
||||
|
||||
public MineConfiguration(@NotNull File pluginDataFolder) {
|
||||
super(
|
||||
YAMLConfigFactory.from(pluginDataFolder, "config.yml").resourcePath("config.yml").build(),
|
||||
YAMLConfigFactory.from(pluginDataFolder, "messages.yml").resourcePath("messages.yml").build()
|
||||
YAMLConfigFactory.from(pluginDataFolder, "config.yml").build(),
|
||||
YAMLConfigFactory.from(pluginDataFolder, "messages.yml").build()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class ConfiguredMessage extends ConfiguredText<BaseComponent[], CommandSe
|
||||
return create().defaults(messages).build();
|
||||
}
|
||||
|
||||
public ConfiguredMessage(@NotNull ValueManifest<TextContents> manifest,
|
||||
public ConfiguredMessage(@NotNull ValueManifest<TextContents, TextContents> manifest,
|
||||
@NotNull BiFunction<CommandSender, String, String> parser,
|
||||
@NotNull BiFunction<CommandSender, String, BaseComponent[]> compiler,
|
||||
@NotNull BiConsumer<CommandSender, List<BaseComponent[]>> dispatcher,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mineconfiguration-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>3.0.3</version>
|
||||
<version>3.1.2</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyconfiguration-yaml</artifactId>
|
||||
<version>${deps.easyconfifuration.version}</version>
|
||||
<artifactId>configured-yaml</artifactId>
|
||||
<version>${deps.configured.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ public class MineConfiguration extends AbstractConfiguration<ConfigurationHolder
|
||||
|
||||
public MineConfiguration(@NotNull File pluginDataFolder) {
|
||||
super(
|
||||
YAMLConfigFactory.from(pluginDataFolder, "config.yml").resourcePath("config.yml").build(),
|
||||
YAMLConfigFactory.from(pluginDataFolder, "messages.yml").resourcePath("messages.yml").build()
|
||||
YAMLConfigFactory.from(pluginDataFolder, "config.yml").build(),
|
||||
YAMLConfigFactory.from(pluginDataFolder, "messages.yml").build()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class ConfiguredMessage extends ConfiguredText<Component, Audience> {
|
||||
return create().defaults(messages).build();
|
||||
}
|
||||
|
||||
public ConfiguredMessage(@NotNull ValueManifest<TextContents> manifest,
|
||||
public ConfiguredMessage(@NotNull ValueManifest<TextContents, TextContents> manifest,
|
||||
@NotNull BiFunction<Audience, String, String> parser,
|
||||
@NotNull BiFunction<Audience, String, Component> compiler,
|
||||
@NotNull BiConsumer<Audience, List<Component>> dispatcher,
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
|
||||
<deps.easyconfifuration.version>4.0.10</deps.easyconfifuration.version>
|
||||
<deps.configured.version>4.1.3</deps.configured.version>
|
||||
<deps.yamlcommentwriter.version>1.2.1</deps.yamlcommentwriter.version>
|
||||
<deps.easyplugin.version>1.5.12</deps.easyplugin.version>
|
||||
</properties>
|
||||
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>mineconfiguration-parent</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<version>3.1.2</version>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>common</module>
|
||||
@@ -128,7 +128,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
<configuration>
|
||||
<useSystemClassLoader>false</useSystemClassLoader>
|
||||
</configuration>
|
||||
|
||||
Reference in New Issue
Block a user