feat: 使用 MiniMessage 读取消息
This commit is contained in:
@@ -73,5 +73,4 @@ public abstract class CoreAPI {
|
||||
*/
|
||||
@NotNull
|
||||
public abstract Gson getHumanGson();
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package cn.hamster3.mc.plugin.core.common.data;
|
||||
|
||||
import cn.hamster3.mc.plugin.core.common.util.CoreUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@SuppressWarnings({"unused", "UnusedReturnValue", "PatternValidation"})
|
||||
@Data
|
||||
@Getter
|
||||
public class DisplayMessage {
|
||||
private Component message;
|
||||
private Component actionbar;
|
||||
@@ -85,12 +85,24 @@ public class DisplayMessage {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage setMessage(@Nullable Component message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage setActionbar(@NotNull String actionbar) {
|
||||
this.actionbar = Component.text(actionbar);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage setActionbar(@NotNull Component actionbar) {
|
||||
this.actionbar = actionbar;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage setTitle(@Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut) {
|
||||
this.title = Title.title(
|
||||
@@ -105,6 +117,26 @@ public class DisplayMessage {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage setTitle(@Nullable Component title, @Nullable Component subtitle, int fadeIn, int stay, int fadeOut) {
|
||||
this.title = Title.title(
|
||||
title == null ? Component.empty() : title,
|
||||
subtitle == null ? Component.empty() : subtitle,
|
||||
Title.Times.times(
|
||||
Ticks.duration(fadeIn),
|
||||
Ticks.duration(stay),
|
||||
Ticks.duration(fadeOut)
|
||||
)
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage setTitle(@Nullable Title title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage setSound(@NotNull String sound, float volume, float pitch) {
|
||||
this.sound = Sound.sound(Key.key(sound), Sound.Source.MASTER, volume, pitch);
|
||||
@@ -123,6 +155,12 @@ public class DisplayMessage {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage setSound(@Nullable Sound sound) {
|
||||
this.sound = sound;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DisplayMessage replace(@NotNull TextReplacementConfig... replacements) {
|
||||
DisplayMessage copy = copy();
|
||||
|
@@ -1,8 +1,11 @@
|
||||
package cn.hamster3.mc.plugin.core.common.util;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Deprecated
|
||||
@SuppressWarnings("unused")
|
||||
public class Pair<K, V> implements Serializable {
|
||||
@@ -14,14 +17,6 @@ public class Pair<K, V> implements Serializable {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
Reference in New Issue
Block a user