1
mirror of https://github.com/CarmJos/MineConfiguration.git synced 2026-06-05 06:51:49 +08:00

Compare commits

...

17 Commits

Author SHA1 Message Date
carm 3d1639362b feat(value): 适配Manifest更新 2023-03-15 22:51:06 +08:00
dependabot[bot] ce205e10fe chore(deps): bump maven-surefire-plugin from 2.22.2 to 3.0.0 (#23)
Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 2.22.2 to 3.0.0.
- [Release notes](https://github.com/apache/maven-surefire/releases)
- [Commits](https://github.com/apache/maven-surefire/compare/surefire-2.22.2...surefire-3.0.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-15 14:01:38 +08:00
dependabot[bot] 8e4e712936 chore(deps): bump easyplugin-color from 1.5.3 to 1.5.4 (#22)
Bumps [easyplugin-color](https://github.com/CarmJos/EasyPlugin) from 1.5.3 to 1.5.4.
- [Release notes](https://github.com/CarmJos/EasyPlugin/releases)
- [Commits](https://github.com/CarmJos/EasyPlugin/compare/1.5.3...1.5.4)

---
updated-dependencies:
- dependency-name: cc.carm.lib:easyplugin-color
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-15 14:01:13 +08:00
dependabot[bot] c3d9c65a86 chore(deps): bump easyplugin-color from 1.5.2 to 1.5.3 (#21)
Bumps [easyplugin-color](https://github.com/CarmJos/EasyPlugin) from 1.5.2 to 1.5.3.
- [Release notes](https://github.com/CarmJos/EasyPlugin/releases)
- [Commits](https://github.com/CarmJos/EasyPlugin/compare/1.5.2...1.5.3)

---
updated-dependencies:
- dependency-name: cc.carm.lib:easyplugin-color
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-08 18:32:44 +08:00
dependabot[bot] ebddeff78d chore(deps): bump annotations from 24.0.0 to 24.0.1 (#20)
Bumps [annotations](https://github.com/JetBrains/java-annotations) from 24.0.0 to 24.0.1.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](https://github.com/JetBrains/java-annotations/commits)

---
updated-dependencies:
- dependency-name: org.jetbrains:annotations
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-03 12:58:40 +08:00
dependabot[bot] afcdc2c378 chore(deps): bump maven-compiler-plugin from 3.10.1 to 3.11.0 (#19)
Bumps [maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.10.1 to 3.11.0.
- [Release notes](https://github.com/apache/maven-compiler-plugin/releases)
- [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.10.1...maven-compiler-plugin-3.11.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-compiler-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-28 18:19:42 +08:00
carm 5905b25c73 chore(update): 适配上游版本更新。 2023-02-19 17:31:43 +08:00
carm 31f51c9b96 chore(update): 适配上游版本更新。 2023-02-19 17:28:58 +08:00
carm eb8f279e0b chore(update): 适配上游版本更新。 2023-02-19 17:28:45 +08:00
carm e291c3a109 chore(update): 适配上游版本更新。 2023-02-19 04:22:14 +08:00
carm 433f780608 chore(update): 适配上游版本更新。 2023-02-19 04:22:02 +08:00
carm 385f6dd22f chore(color): 使用由 EasyPlugin 提供的ColorParser。 2023-02-18 20:46:16 +08:00
dependabot[bot] 04168d4d12 chore(deps): bump maven-javadoc-plugin from 3.4.1 to 3.5.0 (#18)
Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.4.1 to 3.5.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.4.1...maven-javadoc-plugin-3.5.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-16 19:24:11 +08:00
carm 143e0c2283 chore(update): 适配上游版本更新。 2023-02-11 21:54:59 +08:00
carm 4b4f90ee38 chore(update): 适配上游版本更新。 2023-02-11 21:54:35 +08:00
dependabot[bot] 97d24c7027 chore(deps): bump annotations from 23.1.0 to 24.0.0 (#17)
Bumps [annotations](https://github.com/JetBrains/java-annotations) from 23.1.0 to 24.0.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](https://github.com/JetBrains/java-annotations/compare/23.1.0...24.0.0)

---
updated-dependencies:
- dependency-name: org.jetbrains:annotations
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-12 22:15:52 +08:00
carm d1b01ffed5 build(scm): 修复错误的scm地址 2022-12-18 04:54:29 +08:00
32 changed files with 155 additions and 342 deletions
+8 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>mineconfiguration-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>2.3.0</version>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
@@ -28,6 +28,13 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-color</artifactId>
<version>${deps.easyplugin.version}</version>
<scope>compile</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>net.md-5</groupId>
@@ -1,16 +1,18 @@
package cc.carm.lib.mineconfiguration.common.builder.message;
import cc.carm.lib.configuration.core.builder.CommonConfigBuilder;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.common.data.AbstractText;
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
import cc.carm.lib.mineconfiguration.common.value.ConfigMessageList;
import cc.carm.lib.configuration.core.builder.CommonConfigBuilder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
@@ -67,4 +69,11 @@ public abstract class MessageListBuilder<M, R, T extends AbstractText<R>, B exte
@Override
public abstract @NotNull ConfigMessageList<M, T, R> build();
protected @NotNull ValueManifest<List<T>> buildManifest(@NotNull List<T> emptyValue) {
return new ValueManifest<>(
this.provider, this.path, this.headerComments, this.inlineComment,
Optional.ofNullable(this.defaultValue).orElse(emptyValue)
);
}
}
@@ -1,13 +1,15 @@
package cc.carm.lib.mineconfiguration.common.builder.message;
import cc.carm.lib.configuration.core.builder.CommonConfigBuilder;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.common.data.AbstractText;
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
import cc.carm.lib.mineconfiguration.common.value.ConfigMessage;
import cc.carm.lib.configuration.core.builder.CommonConfigBuilder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
@@ -64,4 +66,10 @@ public abstract class MessageValueBuilder<M, R, T extends AbstractText<R>, B ext
@Override
public abstract @NotNull ConfigMessage<M, T, R> build();
protected @NotNull ValueManifest<T> buildManifest(@NotNull T emptyValue) {
return new ValueManifest<>(
this.provider, this.path, this.headerComments, this.inlineComment,
Optional.ofNullable(this.defaultValue).orElse(emptyValue)
);
}
}
@@ -1,211 +0,0 @@
package cc.carm.lib.mineconfiguration.common.utils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* 颜色解析器,来自EasyPlugin项目。
* <br> 普通颜色 格式 {@code &+颜色代码 },如 {@literal &c} 、{@literal &a}
* <br> RGB颜色(版本需要≥1.14) 格式 {@code &(#XXXXXX) },如 {@literal &(#aaaaaa)}
* <br> 渐变RBG颜色(版本需要≥1.14) 格式 {@code &<#XXXXXX>FOOBAR&<#XXXXXX> }
* <p> 注意:当使用渐变RGB颜色时,普通颜色代码与RGB颜色代码将失效。
*
* @author CarmJos
* @since 1.4.18
*/
public class ColorParser {
public static final Pattern HEX_PATTERN = Pattern.compile("&\\(&?#([\\da-fA-F]{6})\\)");
public static final Pattern GRADIENT_PATTERN = Pattern.compile("&<&?#([\\da-fA-F]{6})>");
public static final Pattern COLOR_PATTERN = Pattern.compile("([&§][0-9a-fA-FrRxX])+"); // 会影响颜色的代码
public static final Pattern FORMAT_PATTERN = Pattern.compile("([&§][0-9a-fA-Fk-oK-OrRxX])+"); // MC可用的格式化代码
/**
* 清除一条消息中的全部颜色代码 (包括RGB颜色代码与渐变颜色代码)
*
* @param text 源消息内容
* @return 清理颜色后的消息
*/
public static @NotNull String clear(@NotNull String text) {
text = HEX_PATTERN.matcher(text).replaceAll("");
text = GRADIENT_PATTERN.matcher(text).replaceAll("");
text = COLOR_PATTERN.matcher(text).replaceAll("");
return text;
}
/**
* 对一条消息进行颜色解析,包括普通颜色代码、RGB颜色代码与RBG渐变代码。
*
* @param text 源消息内容
* @return 解析后的消息
*/
public static @NotNull String parse(@NotNull String text) {
return parseBaseColor(parseGradientColor(parseHexColor(text)));
}
/**
* 对多条消息进行颜色解析,包括普通颜色代码、RGB颜色代码与RBG渐变代码。
*
* @param texts 源消息内容
* @return 解析后的消息
*/
public static @NotNull String[] parse(@NotNull String... texts) {
return parse(Arrays.asList(texts)).toArray(new String[0]);
}
/**
* 对多条消息进行颜色解析,包括普通颜色代码、RGB颜色代码与RBG渐变代码。
*
* @param texts 源消息内容
* @return 解析后的消息
*/
public static @NotNull List<String> parse(@NotNull Collection<String> texts) {
return texts.stream().map(ColorParser::parse).collect(Collectors.toList());
}
/**
* 解析消息中的基本颜色代码格式 {@code &+颜色代码 },如 {@literal &c} 、{@literal &a}
*
* @param text 消息内容
* @return RGB处理后的消息
* @see net.md_5.bungee.api.ChatColor
*/
public static String parseBaseColor(final String text) {
return text.replaceAll("&", "§").replace("§§", "&");
}
/**
* 解析消息中的RGB颜色代码(版本需要≥1.14) 格式 {@code &(#XXXXXX) },如 {@literal &(#aaaaaa)}
*
* @param text 消息内容
* @return RGB处理后的消息
*/
public static String parseHexColor(String text) {
Matcher matcher = HEX_PATTERN.matcher(text);
while (matcher.find()) {
text = matcher.replaceFirst(buildHexColor(matcher.group(1)).toLowerCase());
matcher.reset(text);
}
return text;
}
/**
* 对一条消息进行RGB渐变处理(版本需要≥1.14),格式 {@code &<#XXXXXX>FOOBAR&<#XXXXXX> }。
*
* @param text 消息内容
* @return RGB渐变处理后的消息
*/
public static @NotNull String parseGradientColor(@NotNull String text) {
List<String> colors = new ArrayList<>();
Matcher matcher = ColorParser.GRADIENT_PATTERN.matcher(text);
while (matcher.find()) colors.add(matcher.group(1));
if (colors.isEmpty()) return text; // 无渐变颜色,直接跳出
String[] parts = ColorParser.GRADIENT_PATTERN.split(text);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < parts.length; i++) {
String startHex = i - 1 >= 0 && colors.size() > i - 1 ? colors.get(i - 1) : null; // 本条消息的起始颜色
String endHex = colors.size() > i ? colors.get(i) : null; // 本条消息的结束颜色
builder.append(gradientText(parts[i], startHex, endHex));
}
return builder.toString();
}
public static @NotNull String gradientText(@NotNull String text,
@Nullable Color startColor, @Nullable Color endColor) {
Objects.requireNonNull(text, "Text to be gradient should not be null!");
if (startColor == null || endColor == null || text.isEmpty()) {
// 起始颜色有任一为空,则不进行渐变上色。
// 若有起始颜色,则代表其跟在某个渐变之后,应当添加"&r"阻断前面的渐变。
return (startColor != null ? "&r" : "") + text;
}
// 用于记录消息中特殊格式的位置
// 在渐变中,允许使用格式字符与颜色字符来改变其中某个字的颜色/格式,以支持更多形式内容。
LinkedHashMap<Integer, String> extraFormats = new LinkedHashMap<>();
Matcher matcher = ColorParser.FORMAT_PATTERN.matcher(text);
while (matcher.find()) {
extraFormats.put(matcher.start(), matcher.group());
text = matcher.replaceFirst("");
matcher.reset(text);
}
if (text.length() == 1) {
// 当只有一个实际字符时,无需进行渐变计算,直接返回 中间颜色+起始格式(如果有)+消息 即可。
return colorText(text, extraFormats.get(0), buildHexColor(mediumHex(startColor, endColor)));
}
String[] characters = text.split("");
int step = characters.length; // 变换次数
// 决定每种颜色变换的方向
int rDirection = startColor.getRed() < endColor.getRed() ? 1 : -1;
int gDirection = startColor.getGreen() < endColor.getGreen() ? 1 : -1;
int bDirection = startColor.getBlue() < endColor.getBlue() ? 1 : -1;
// 决定每种颜色每次变换的度
int rStep = Math.abs(startColor.getRed() - endColor.getRed()) / (step - 1);
int gStep = Math.abs(startColor.getGreen() - endColor.getGreen()) / (step - 1);
int bStep = Math.abs(startColor.getBlue() - endColor.getBlue()) / (step - 1);
String[] hexes = IntStream.range(0, step).mapToObj(i -> colorToHex(
startColor.getRed() + rStep * i * rDirection,
startColor.getGreen() + gStep * i * gDirection,
startColor.getBlue() + bStep * i * bDirection
)).toArray(String[]::new);
return IntStream.range(0, characters.length)
.mapToObj(i -> colorText(characters[i], extraFormats.get(i), buildHexColor(hexes[i])))
.collect(Collectors.joining());
}
protected static String gradientText(@NotNull String text, @Nullable String startHex, @Nullable String endHex) {
return gradientText(text,
startHex == null ? null : Color.decode("0x" + startHex),
endHex == null ? null : Color.decode("0x" + endHex)
);
}
private static String mediumHex(@NotNull Color start, @NotNull Color end) {
return colorToHex(
Math.abs(start.getRed() - end.getRed()) / 2,
Math.abs(start.getGreen() - end.getGreen()) / 2,
Math.abs(start.getBlue() - end.getBlue()) / 2
);
}
private static String colorText(String message, @Nullable String format, @Nullable String color) {
if (format != null && COLOR_PATTERN.matcher(format).find()) {
// format中存在影响颜色的内容,则当前消息的颜色会被覆盖。
// 为了减少最终消息的长度,故直接返回键入的FORMAT和对应消息的内容。
return format + message;
}
return (color == null ? "" : color) + (format == null ? "" : parseBaseColor(format)) + message;
}
protected static String colorToHex(Color color) {
return colorToHex(color.getRed(), color.getGreen(), color.getBlue());
}
protected static String colorToHex(int r, int g, int b) {
// 将R、G、B转换为16进制(若非2位则补0)输出
return String.format("%02X%02X%02X", r, g, b);
}
protected static String buildHexColor(String hexCode) {
return Arrays.stream(hexCode.split("")).map(s -> '§' + s)
.collect(Collectors.joining("", '§' + "x", ""));
}
}
@@ -41,21 +41,21 @@ public interface BaseMessage<R, M> {
/**
* 为某位接收者解析此消息。
*
* @param sender 接收者
* @param receiver 接收者
* @param placeholders 消息中的变量与对应参数
* @return 解析变量后的消息内容
*/
@Nullable M parse(@Nullable R sender, @NotNull Map<String, Object> placeholders);
@Nullable M parse(@Nullable R receiver, @NotNull Map<String, Object> placeholders);
/**
* 为某位接收者解析此消息。
*
* @param sender 接收者
* @param values 已定变量的对应参数
* @param receiver 接收者
* @param values 已定变量的对应参数
* @return 解析变量后的消息内容
*/
default @Nullable M parse(@Nullable R sender, @Nullable Object... values) {
return parse(sender, ParamsUtils.buildParams(getParams(), values));
default @Nullable M parse(@Nullable R receiver, @Nullable Object... values) {
return parse(receiver, ParamsUtils.buildParams(getParams(), values));
}
/**
@@ -1,13 +1,12 @@
package cc.carm.lib.mineconfiguration.common.value;
import cc.carm.lib.configuration.core.function.ConfigValueParser;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
import cc.carm.lib.mineconfiguration.common.data.AbstractText;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
@@ -22,15 +21,15 @@ public abstract class ConfigMessage<M, T extends AbstractText<R>, R>
protected final @NotNull Function<String, T> textBuilder;
public ConfigMessage(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@NotNull Class<T> textClazz, @NotNull T defaultMessage, @NotNull String[] params,
public ConfigMessage(@NotNull ValueManifest<T> manifest,
@NotNull Class<T> textClazz, @NotNull String[] params,
@NotNull BiFunction<@Nullable R, @NotNull String, @Nullable M> messageParser,
@NotNull BiConsumer<@NotNull R, @NotNull M> sendFunction,
@NotNull Function<String, T> textBuilder) {
super(
provider, sectionPath, headerComments, inlineComments, textClazz, defaultMessage,
ConfigValueParser.castToString().andThen((s, d) -> textBuilder.apply(s)), AbstractText::getMessage
manifest, textClazz,
ConfigValueParser.castToString().andThen((s, d) -> textBuilder.apply(s)),
AbstractText::getMessage
);
this.params = params;
this.messageParser = messageParser;
@@ -62,5 +61,5 @@ public abstract class ConfigMessage<M, T extends AbstractText<R>, R>
protected T buildText(String value) {
return textBuilder.apply(value);
}
}
@@ -1,7 +1,7 @@
package cc.carm.lib.mineconfiguration.common.value;
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
import cc.carm.lib.mineconfiguration.common.data.AbstractText;
import org.jetbrains.annotations.NotNull;
@@ -24,15 +24,15 @@ public abstract class ConfigMessageList<M, T extends AbstractText<R>, R>
protected final @NotNull Function<String, T> textBuilder;
public ConfigMessageList(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@NotNull Class<T> textClazz, @NotNull List<T> messages, @NotNull String[] params,
public ConfigMessageList(@NotNull ValueManifest<List<T>> manifest,
@NotNull Class<T> textClazz, @NotNull String[] params,
@NotNull BiFunction<@Nullable R, @NotNull String, @Nullable M> messageParser,
@NotNull BiConsumer<@NotNull R, @NotNull List<M>> sendFunction,
@NotNull Function<String, @NotNull T> textBuilder) {
super(
provider, sectionPath, headerComments, inlineComments, textClazz, messages,
ConfigDataFunction.castToString().andThen(textBuilder::apply), AbstractText::getMessage
manifest, textClazz,
ConfigDataFunction.castToString().andThen(textBuilder::apply),
AbstractText::getMessage
);
this.params = params;
this.messageParser = messageParser;
@@ -68,12 +68,25 @@ public abstract class ConfigMessageList<M, T extends AbstractText<R>, R>
.collect(Collectors.toList());
}
public @Nullable M parseToLine(@Nullable R receiver, @NotNull Map<String, Object> placeholders) {
List<T> list = get();
if (list.isEmpty()) return null;
List<String> messages = list.stream().map(T::getMessage).collect(Collectors.toList());
if (String.join("", messages).isEmpty()) return null;
String combined = String.join("\n", messages);
T text = textBuilder.apply(combined);
return text.parse(this.messageParser, receiver, placeholders);
}
public void setMessages(@NotNull String... values) {
setMessages(values.length == 0 ? null : Arrays.asList(values));
}
public void setMessages(@Nullable List<String> values) {
if (values == null || values.isEmpty()) {
if (values == null) {
set(null);
} else {
set(buildText(values));
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>mineconfiguration-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>2.3.0</version>
<version>2.5.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -1,6 +1,7 @@
package cc.carm.lib.mineconfiguration.bukkit;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
import cc.carm.lib.mineconfiguration.bukkit.builder.CraftConfigBuilder;
import cc.carm.lib.mineconfiguration.bukkit.source.CraftConfigProvider;
@@ -16,10 +17,8 @@ public abstract class CraftConfigValue<T> extends CachedConfigValue<T> {
return new CraftConfigBuilder();
}
public CraftConfigValue(@Nullable CraftConfigProvider provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@Nullable T defaultValue) {
super(provider, sectionPath, headerComments, inlineComments, defaultValue);
public CraftConfigValue(@NotNull ValueManifest<T> manifest) {
super(manifest);
}
public CraftConfigProvider getBukkitProvider() {
@@ -1,5 +1,6 @@
package cc.carm.lib.mineconfiguration.bukkit.builder.item;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.bukkit.builder.AbstractCraftBuilder;
import cc.carm.lib.mineconfiguration.bukkit.data.ItemConfig;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredItem;
@@ -110,8 +111,12 @@ public class ItemConfigBuilder extends AbstractCraftBuilder<ItemConfig, ItemConf
@Override
public @NotNull ConfiguredItem build() {
ItemConfig defaultItem = Optional.ofNullable(this.defaultValue).orElse(buildDefault());
return new ConfiguredItem(this.provider, this.path, this.headerComments, this.inlineComment, defaultItem, buildParams());
return new ConfiguredItem(
new ValueManifest<>(
this.provider, this.path, this.headerComments, this.inlineComment,
Optional.ofNullable(this.defaultValue).orElse(buildDefault())
), buildParams()
);
}
protected final String[] buildParams() {
@@ -1,5 +1,6 @@
package cc.carm.lib.mineconfiguration.bukkit.builder.message;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.bukkit.data.TextConfig;
import cc.carm.lib.mineconfiguration.bukkit.utils.TextParser;
import cc.carm.lib.mineconfiguration.common.builder.message.MessageConfigBuilder;
@@ -8,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Optional;
import java.util.function.BiFunction;
public class CraftMessageBuilder extends MessageConfigBuilder<CommandSender, TextConfig> {
@@ -9,7 +9,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Optional;
import java.util.function.BiFunction;
public class CraftMessageListBuilder<M>
@@ -27,8 +26,7 @@ public class CraftMessageListBuilder<M>
@Override
public @NotNull ConfiguredMessageList<M> build() {
return new ConfiguredMessageList<>(
this.provider, this.path, this.headerComments, this.inlineComment,
Optional.ofNullable(this.defaultValue).orElse(TextConfig.of(new ArrayList<>())),
buildManifest(TextConfig.of(new ArrayList<>())),
ParamsUtils.formatParams(this.paramFormatter, this.params),
this.messageParser, this.sendFunction
);
@@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
import java.util.function.BiFunction;
public class CraftMessageValueBuilder<M>
@@ -26,8 +25,7 @@ public class CraftMessageValueBuilder<M>
@Override
public @NotNull ConfiguredMessage<M> build() {
return new ConfiguredMessage<>(
this.provider, this.path, this.headerComments, this.inlineComment,
Optional.ofNullable(this.defaultValue).orElse(TextConfig.of("")),
buildManifest(TextConfig.of("")),
ParamsUtils.formatParams(this.paramFormatter, this.params),
this.messageParser, this.sendHandler
);
@@ -21,7 +21,7 @@ public class SerializableBuilder<T extends ConfigurationSerializable>
@Override
public @NotNull ConfiguredSerializable<T> build() {
return new ConfiguredSerializable<>(this.provider, this.path, this.headerComments, this.inlineComment, this.valueClass, this.defaultValue);
return new ConfiguredSerializable<>(buildManifest(), valueClass);
}
}
@@ -40,7 +40,7 @@ public class SoundConfigBuilder extends AbstractCraftBuilder<SoundConfig, SoundC
@Override
public @NotNull ConfiguredSound build() {
return new ConfiguredSound(this.provider, this.path, this.headerComments, this.inlineComment, this.defaultValue);
return new ConfiguredSound(buildManifest());
}
}
@@ -89,8 +89,7 @@ public class TitleConfigBuilder extends AbstractCraftBuilder<TitleConfig, TitleC
@Override
public @NotNull ConfiguredTitle build() {
return new ConfiguredTitle(
this.provider, this.path, this.headerComments, this.inlineComment,
this.defaultValue, ParamsUtils.formatParams(this.paramFormatter, this.params),
buildManifest(), ParamsUtils.formatParams(this.paramFormatter, this.params),
this.sendConsumer, this.fadeIn, this.stay, this.fadeOut
);
}
@@ -1,6 +1,6 @@
package cc.carm.lib.mineconfiguration.bukkit.utils;
import cc.carm.lib.mineconfiguration.common.utils.ColorParser;
import cc.carm.lib.easyplugin.utils.ColorParser;
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@@ -2,11 +2,11 @@ package cc.carm.lib.mineconfiguration.bukkit.value;
import cc.carm.lib.configuration.core.function.ConfigValueParser;
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.configuration.core.value.type.ConfiguredSection;
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
import cc.carm.lib.mineconfiguration.bukkit.builder.item.ItemConfigBuilder;
import cc.carm.lib.mineconfiguration.bukkit.data.ItemConfig;
import cc.carm.lib.mineconfiguration.bukkit.source.CraftConfigProvider;
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -14,7 +14,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ConfiguredItem extends ConfiguredSection<ItemConfig> {
@@ -33,11 +32,9 @@ public class ConfiguredItem extends ConfiguredSection<ItemConfig> {
protected final @NotNull String[] params;
public ConfiguredItem(@Nullable CraftConfigProvider provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@Nullable ItemConfig defaultValue, @NotNull String[] params) {
public ConfiguredItem(@NotNull ValueManifest<ItemConfig> manifest, @NotNull String[] params) {
super(
provider, sectionPath, headerComments, inlineComments, ItemConfig.class, defaultValue,
manifest, ItemConfig.class,
getItemParser(), ItemConfig::serialize
);
this.params = params;
@@ -1,6 +1,6 @@
package cc.carm.lib.mineconfiguration.bukkit.value;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
import cc.carm.lib.mineconfiguration.bukkit.builder.message.CraftMessageValueBuilder;
import cc.carm.lib.mineconfiguration.bukkit.data.TextConfig;
@@ -35,12 +35,10 @@ public class ConfiguredMessage<M> extends ConfigMessage<M, TextConfig, CommandSe
return asString().defaults(defaultMessage).build();
}
public ConfiguredMessage(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@NotNull TextConfig defaultMessage, @NotNull String[] params,
public ConfiguredMessage(@NotNull ValueManifest<TextConfig> manifest, @NotNull String[] params,
@NotNull BiFunction<@Nullable CommandSender, @NotNull String, @Nullable M> messageParser,
@NotNull BiConsumer<@NotNull CommandSender, @NotNull M> sendFunction) {
super(provider, sectionPath, headerComments, inlineComments, TextConfig.class, defaultMessage, params, messageParser, sendFunction, TextConfig::of);
super(manifest, TextConfig.class, params, messageParser, sendFunction, TextConfig::of);
}
@Override
@@ -1,6 +1,6 @@
package cc.carm.lib.mineconfiguration.bukkit.value;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
import cc.carm.lib.mineconfiguration.bukkit.builder.message.CraftMessageListBuilder;
import cc.carm.lib.mineconfiguration.bukkit.data.TextConfig;
@@ -31,12 +31,10 @@ public class ConfiguredMessageList<M> extends ConfigMessageList<M, TextConfig, C
return asStrings().defaults(defaultMessages).build();
}
public ConfiguredMessageList(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@NotNull List<TextConfig> messages, @NotNull String[] params,
public ConfiguredMessageList(@NotNull ValueManifest<List<TextConfig>> manifest, @NotNull String[] params,
@NotNull BiFunction<@Nullable CommandSender, @NotNull String, @Nullable M> messageParser,
@NotNull BiConsumer<@NotNull CommandSender, @NotNull List<M>> sendFunction) {
super(provider, sectionPath, headerComments, inlineComments, TextConfig.class, messages, params, messageParser, sendFunction, TextConfig::of);
super(manifest, TextConfig.class, params, messageParser, sendFunction, TextConfig::of);
}
@Override
@@ -1,12 +1,11 @@
package cc.carm.lib.mineconfiguration.bukkit.value;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
import cc.carm.lib.mineconfiguration.bukkit.source.CraftConfigProvider;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Optional;
public class ConfiguredSerializable<T extends ConfigurationSerializable> extends CraftConfigValue<T> {
@@ -22,10 +21,8 @@ public class ConfiguredSerializable<T extends ConfigurationSerializable> extends
protected final @NotNull Class<T> valueClass;
public ConfiguredSerializable(@Nullable CraftConfigProvider provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@NotNull Class<T> valueClass, @Nullable T defaultValue) {
super(provider, sectionPath, headerComments, inlineComments, defaultValue);
public ConfiguredSerializable(@NotNull ValueManifest<T> manifest, @NotNull Class<T> valueClass) {
super(manifest);
this.valueClass = valueClass;
}
@@ -1,7 +1,7 @@
package cc.carm.lib.mineconfiguration.bukkit.value;
import cc.carm.lib.configuration.core.function.ConfigValueParser;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
import cc.carm.lib.mineconfiguration.bukkit.builder.sound.SoundConfigBuilder;
@@ -9,9 +9,7 @@ import cc.carm.lib.mineconfiguration.bukkit.data.SoundConfig;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Optional;
public class ConfiguredSound extends ConfiguredValue<SoundConfig> {
@@ -44,10 +42,8 @@ public class ConfiguredSound extends ConfiguredValue<SoundConfig> {
return CraftConfigValue.builder().createSound().defaults(soundName, volume, pitch).build();
}
public ConfiguredSound(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@Nullable SoundConfig defaultValue) {
super(provider, sectionPath, headerComments, inlineComments, SoundConfig.class, defaultValue, getSoundParser(), SoundConfig::serialize);
public ConfiguredSound(@NotNull ValueManifest<SoundConfig> manifest) {
super(manifest, SoundConfig.class, getSoundParser(), SoundConfig::serialize);
}
public void setSound(@NotNull Sound sound) {
@@ -1,8 +1,8 @@
package cc.carm.lib.mineconfiguration.bukkit.value;
import cc.carm.lib.configuration.core.function.ConfigValueParser;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.configuration.core.value.type.ConfiguredSection;
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
import cc.carm.lib.mineconfiguration.bukkit.builder.title.TitleConfigBuilder;
@@ -15,8 +15,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
public class ConfiguredTitle extends ConfiguredSection<TitleConfig> {
@@ -40,12 +42,10 @@ public class ConfiguredTitle extends ConfiguredSection<TitleConfig> {
protected final int stay;
protected final int fadeOut;
public ConfiguredTitle(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@Nullable TitleConfig defaultValue, @NotNull String[] params,
public ConfiguredTitle(@NotNull ValueManifest<TitleConfig> manifest, @NotNull String[] params,
@NotNull TitleSendConsumer sendConsumer,
int fadeIn, int stay, int fadeOut) {
super(provider, sectionPath, headerComments, inlineComments, TitleConfig.class, defaultValue, getTitleParser(), TitleConfig::serialize);
super(manifest, TitleConfig.class, getTitleParser(), TitleConfig::serialize);
this.sendConsumer = sendConsumer;
this.params = params;
this.fadeIn = fadeIn;
@@ -102,6 +102,16 @@ public class ConfiguredTitle extends ConfiguredSection<TitleConfig> {
Bukkit.getOnlinePlayers().forEach(onlinePlayer -> send(onlinePlayer, placeholders));
}
public void sendToEach(@NotNull Function<@NotNull Player, Object[]> eachValues) {
sendToEach(null, eachValues);
}
public void sendToEach(@Nullable Predicate<Player> limiter,
@NotNull Function<@NotNull Player, Object[]> eachValues) {
Predicate<Player> predicate = Optional.ofNullable(limiter).orElse(r -> true);
Bukkit.getOnlinePlayers().stream().filter(predicate)
.forEach(r -> send(r, ParamsUtils.buildParams(params, eachValues.apply(r))));
}
public static ConfigValueParser<ConfigurationWrapper<?>, TitleConfig> getTitleParser() {
return (s, d) -> TitleConfig.deserialize(s);
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>mineconfiguration-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>2.3.0</version>
<version>2.5.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -1,14 +1,12 @@
package cc.carm.lib.mineconfiguration.bungee;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
import cc.carm.lib.mineconfiguration.bungee.builder.BungeeConfigBuilder;
import cc.carm.lib.mineconfiguration.bungee.source.BungeeConfigProvider;
import cc.carm.lib.mineconfiguration.bungee.source.BungeeSectionWrapper;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.impl.CachedConfigValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public abstract class BungeeConfigValue<T> extends CachedConfigValue<T> {
@@ -16,10 +14,8 @@ public abstract class BungeeConfigValue<T> extends CachedConfigValue<T> {
return new BungeeConfigBuilder();
}
public BungeeConfigValue(@Nullable BungeeConfigProvider provider, @Nullable String configPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@Nullable T defaultValue) {
super(provider, configPath, headerComments, inlineComments, defaultValue);
public BungeeConfigValue(@NotNull ValueManifest<T> manifest) {
super(manifest);
}
public BungeeConfigProvider getBukkitProvider() {
@@ -1,8 +1,8 @@
package cc.carm.lib.mineconfiguration.bungee.builder.message;
import cc.carm.lib.mineconfiguration.bungee.data.MessageText;
import cc.carm.lib.easyplugin.utils.ColorParser;
import cc.carm.lib.mineconfiguration.bungee.data.TextConfig;
import cc.carm.lib.mineconfiguration.common.builder.message.MessageConfigBuilder;
import cc.carm.lib.mineconfiguration.common.utils.ColorParser;
import net.md_5.bungee.api.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -10,11 +10,11 @@ import org.jetbrains.annotations.Nullable;
import java.util.function.BiFunction;
@SuppressWarnings("deprecation")
public class BungeeMessageBuilder extends MessageConfigBuilder<CommandSender, MessageText> {
public class BungeeMessageBuilder extends MessageConfigBuilder<CommandSender, TextConfig> {
public BungeeMessageBuilder() {
super(CommandSender.class, MessageText.class);
super(CommandSender.class, TextConfig.class);
}
@Override
@@ -1,6 +1,7 @@
package cc.carm.lib.mineconfiguration.bungee.builder.message;
import cc.carm.lib.mineconfiguration.bungee.data.MessageText;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.bungee.data.TextConfig;
import cc.carm.lib.mineconfiguration.bungee.value.ConfiguredMessageList;
import cc.carm.lib.mineconfiguration.common.builder.message.MessageListBuilder;
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
@@ -13,10 +14,10 @@ import java.util.Optional;
import java.util.function.BiFunction;
public class BungeeMessageListBuilder<M>
extends MessageListBuilder<M, CommandSender, MessageText, BungeeMessageListBuilder<M>> {
extends MessageListBuilder<M, CommandSender, TextConfig, BungeeMessageListBuilder<M>> {
public BungeeMessageListBuilder(@NotNull BiFunction<@Nullable CommandSender, @NotNull String, @Nullable M> parser) {
super(CommandSender.class, MessageText::of, parser);
super(CommandSender.class, TextConfig::of, parser);
}
@Override
@@ -27,8 +28,7 @@ public class BungeeMessageListBuilder<M>
@Override
public @NotNull ConfiguredMessageList<M> build() {
return new ConfiguredMessageList<>(
this.provider, this.path, this.headerComments, this.inlineComment,
Optional.ofNullable(this.defaultValue).orElse(MessageText.of(new ArrayList<>())),
buildManifest(TextConfig.of(new ArrayList<>())),
ParamsUtils.formatParams(this.paramFormatter, this.params),
this.messageParser, this.sendFunction
);
@@ -1,6 +1,6 @@
package cc.carm.lib.mineconfiguration.bungee.builder.message;
import cc.carm.lib.mineconfiguration.bungee.data.MessageText;
import cc.carm.lib.mineconfiguration.bungee.data.TextConfig;
import cc.carm.lib.mineconfiguration.bungee.value.ConfiguredMessage;
import cc.carm.lib.mineconfiguration.common.builder.message.MessageValueBuilder;
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
@@ -8,14 +8,13 @@ import net.md_5.bungee.api.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
import java.util.function.BiFunction;
public class BungeeMessageValueBuilder<M>
extends MessageValueBuilder<M, CommandSender, MessageText, BungeeMessageValueBuilder<M>> {
extends MessageValueBuilder<M, CommandSender, TextConfig, BungeeMessageValueBuilder<M>> {
public BungeeMessageValueBuilder(@NotNull BiFunction<@Nullable CommandSender, @NotNull String, @Nullable M> parser) {
super(CommandSender.class, MessageText::new, parser);
super(CommandSender.class, TextConfig::new, parser);
}
@Override
@@ -26,8 +25,7 @@ public class BungeeMessageValueBuilder<M>
@Override
public @NotNull ConfiguredMessage<M> build() {
return new ConfiguredMessage<>(
this.provider, this.path, this.headerComments, this.inlineComment,
Optional.ofNullable(this.defaultValue).orElse(MessageText.of("")),
buildManifest(TextConfig.of("")),
ParamsUtils.formatParams(this.paramFormatter, this.params),
this.messageParser, this.sendHandler
);
@@ -11,24 +11,24 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class MessageText extends AbstractText<CommandSender> {
public class TextConfig extends AbstractText<CommandSender> {
public MessageText(@NotNull String message) {
public TextConfig(@NotNull String message) {
super(CommandSender.class, message);
}
@Contract("!null,-> !null")
public static @Nullable MessageText of(@Nullable String message) {
public static @Nullable TextConfig of(@Nullable String message) {
if (message == null) return null;
else return new MessageText(message);
else return new TextConfig(message);
}
public static @NotNull List<MessageText> of(@Nullable List<String> messages) {
public static @NotNull List<TextConfig> of(@Nullable List<String> messages) {
if (messages == null || messages.isEmpty()) return new ArrayList<>();
else return messages.stream().map(MessageText::of).collect(Collectors.toList());
else return messages.stream().map(TextConfig::of).collect(Collectors.toList());
}
public static @NotNull List<MessageText> of(@NotNull String... messages) {
public static @NotNull List<TextConfig> of(@NotNull String... messages) {
return of(Arrays.asList(messages));
}
@@ -1,9 +1,9 @@
package cc.carm.lib.mineconfiguration.bungee.value;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.bungee.BungeeConfigValue;
import cc.carm.lib.mineconfiguration.bungee.builder.message.BungeeMessageValueBuilder;
import cc.carm.lib.mineconfiguration.bungee.data.MessageText;
import cc.carm.lib.mineconfiguration.bungee.data.TextConfig;
import cc.carm.lib.mineconfiguration.common.value.ConfigMessage;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@@ -16,7 +16,7 @@ import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
public class ConfiguredMessage<M> extends ConfigMessage<M, MessageText, CommandSender> {
public class ConfiguredMessage<M> extends ConfigMessage<M, TextConfig, CommandSender> {
@NotNull
public static <M> BungeeMessageValueBuilder<@Nullable M> create(@NotNull BiFunction<@Nullable CommandSender, @NotNull String, @Nullable M> messageParser) {
@@ -35,12 +35,10 @@ public class ConfiguredMessage<M> extends ConfigMessage<M, MessageText, CommandS
return asString().defaults(defaultMessage).build();
}
public ConfiguredMessage(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@NotNull MessageText defaultMessage, @NotNull String[] params,
public ConfiguredMessage(@NotNull ValueManifest<TextConfig> manifest, @NotNull String[] params,
@NotNull BiFunction<@Nullable CommandSender, @NotNull String, @Nullable M> messageParser,
@NotNull BiConsumer<@NotNull CommandSender, @NotNull M> sendFunction) {
super(provider, sectionPath, headerComments, inlineComments, MessageText.class, defaultMessage, params, messageParser, sendFunction, MessageText::of);
super(manifest, TextConfig.class, params, messageParser, sendFunction, TextConfig::of);
}
@Override
@@ -1,10 +1,10 @@
package cc.carm.lib.mineconfiguration.bungee.value;
import cc.carm.lib.configuration.core.value.ValueManifest;
import cc.carm.lib.mineconfiguration.bungee.BungeeConfigValue;
import cc.carm.lib.mineconfiguration.bungee.builder.message.BungeeMessageListBuilder;
import cc.carm.lib.mineconfiguration.bungee.data.MessageText;
import cc.carm.lib.mineconfiguration.bungee.data.TextConfig;
import cc.carm.lib.mineconfiguration.common.value.ConfigMessageList;
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import org.jetbrains.annotations.NotNull;
@@ -13,11 +13,10 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
public class ConfiguredMessageList<M> extends ConfigMessageList<M, MessageText, CommandSender> {
public class ConfiguredMessageList<M> extends ConfigMessageList<M, TextConfig, CommandSender> {
@NotNull
public static <M> BungeeMessageListBuilder<M> create(@NotNull BiFunction<@Nullable CommandSender, @NotNull String, @Nullable M> messageParser) {
@@ -32,12 +31,10 @@ public class ConfiguredMessageList<M> extends ConfigMessageList<M, MessageText,
return asStrings().defaults(defaultMessages).build();
}
public ConfiguredMessageList(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@NotNull List<MessageText> messages, @NotNull String[] params,
public ConfiguredMessageList(@NotNull ValueManifest<List<TextConfig>> manifest, @NotNull String[] params,
@NotNull BiFunction<@Nullable CommandSender, @NotNull String, @Nullable M> messageParser,
@NotNull BiConsumer<@NotNull CommandSender, @NotNull List<M>> sendFunction) {
super(provider, sectionPath, headerComments, inlineComments, MessageText.class, messages, params, messageParser, sendFunction, MessageText::of);
super(manifest, TextConfig.class, params, messageParser, sendFunction, TextConfig::of);
}
@Override
+9 -7
View File
@@ -9,12 +9,14 @@
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<deps.easyconfifuration.version>3.3.1</deps.easyconfifuration.version>
<deps.easyconfifuration.version>3.5.0</deps.easyconfifuration.version>
<deps.easyplugin.version>1.5.4</deps.easyplugin.version>
</properties>
<groupId>cc.carm.lib</groupId>
<artifactId>mineconfiguration-parent</artifactId>
<version>2.3.0</version>
<version>2.5.0</version>
<packaging>pom</packaging>
<modules>
<module>common</module>
@@ -37,7 +39,7 @@
</developers>
<scm>
<connection>scm:git:git@github.com:CarmJos/Easy.MineConfiguration</connection>
<connection>scm:git:git@github.com:CarmJos/MineConfiguration</connection>
<developerConnection>scm:git:git@github.com:CarmJos/MineConfiguration.git</developerConnection>
<url>https://github.com/CarmJos/MineConfiguration</url>
<tag>HEAD</tag>
@@ -106,7 +108,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.1.0</version>
<version>24.0.1</version>
<scope>provided</scope>
</dependency>
@@ -119,7 +121,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
@@ -158,7 +160,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
<configuration>
<source>${project.jdk.version}</source>
<target>${project.jdk.version}</target>
@@ -193,7 +195,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
<configuration>
<classifier>javadoc</classifier>
<detectJavaApiLink>false</detectJavaApiLink>