mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2026-06-04 12:59:45 +08:00
chore(platform): Make "velocity" to "adventure".
This commit is contained in:
@@ -14,12 +14,14 @@
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
|
||||
<deps.adventure.version>4.24.0</deps.adventure.version>
|
||||
</properties>
|
||||
<artifactId>mineconfiguration-velocity</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MineConfiguration-Velocity</name>
|
||||
<description>轻松(做)配置,适用于Velocity的版本,可用JSON与YAML格式。</description>
|
||||
<name>MineConfiguration-Adventure</name>
|
||||
<description>轻松(做)配置,适用于基于Adventure的平台(如Velocity、Paper),可用JSON与YAML格式。</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -38,12 +40,29 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>${deps.adventure.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||
<version>${deps.adventure.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-plain</artifactId>
|
||||
<version>${deps.adventure.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>${deps.adventure.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cc.carm.lib.mineconfiguration.velocity;
|
||||
package cc.carm.lib.mineconfiguration.adventure;
|
||||
|
||||
import cc.carm.lib.configuration.Configuration;
|
||||
import cc.carm.lib.configuration.source.ConfigurationHolder;
|
||||
+10
-2
@@ -1,4 +1,4 @@
|
||||
package cc.carm.lib.mineconfiguration.velocity.value;
|
||||
package cc.carm.lib.mineconfiguration.adventure.value;
|
||||
|
||||
import cc.carm.lib.configuration.value.ValueManifest;
|
||||
import cc.carm.lib.configuration.value.text.ConfiguredText;
|
||||
@@ -6,15 +6,23 @@ import cc.carm.lib.configuration.value.text.data.TextContents;
|
||||
import cc.carm.lib.easyplugin.utils.ColorParser;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class ConfiguredMessage extends ConfiguredText<Component, Audience> {
|
||||
|
||||
public static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.legacySection();
|
||||
|
||||
public static AtomicReference<ComponentSerializer<?, ?, String>> SERIALIZER = new AtomicReference<>(LEGACY_SERIALIZER);
|
||||
|
||||
@NotNull
|
||||
|
||||
public static ConfiguredMessage.Builder create() {
|
||||
return new Builder();
|
||||
}
|
||||
@@ -41,7 +49,7 @@ public class ConfiguredMessage extends ConfiguredText<Component, Audience> {
|
||||
public Builder() {
|
||||
super();
|
||||
this.parser = (receiver, message) -> ColorParser.parse(message);
|
||||
this.compiler = (receiver, message) -> Component.text(message);
|
||||
this.compiler = (receiver, message) -> SERIALIZER.get().deserialize(message);
|
||||
this.dispatcher = (receiver, message) -> message.forEach(receiver::sendMessage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user