text = new ArrayList<>(config.getStringList(this.getPath()));
- if (text.isEmpty()) {
- text.add(config.getString(this.getPath(), "<" + this.getPath() + ">"));
- }
-
- //String text = !list.isEmpty() ? String.join("\\n", list) : config.getString(this.getPath(), "<" + this.getPath() + ">");
- this.setMessage(new LegacyLangMessage(plugin, text));
-
- return this.getMessage();
- }
-
- @NotNull
- public LegacyLangMessage getMessage() {
- return message;
- }
-
- public void setMessage(@NotNull LegacyLangMessage message) {
- this.message = message;
- }
-}
diff --git a/src/main/java/su/nightexpress/nightcore/language/legacy/LegacyMessageOption.java b/src/main/java/su/nightexpress/nightcore/language/legacy/LegacyMessageOption.java
deleted file mode 100644
index 6a7617c..0000000
--- a/src/main/java/su/nightexpress/nightcore/language/legacy/LegacyMessageOption.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package su.nightexpress.nightcore.language.legacy;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.util.regex.Pattern;
-
-@Deprecated
-public enum LegacyMessageOption {
-
- PREFIX("prefix"),
- SOUND("sound"),
- TYPE("type"),
- PAPI("papi"),
- ;
-
- private final Pattern pattern;
-
- LegacyMessageOption(@NotNull String name) {
- this.pattern = Pattern.compile(name + ":(?:'|\")(.*?)(?:'|\")(?=>|\\s|$)");
- }
-
- @NotNull
- public Pattern getPattern() {
- return pattern;
- }
-}
diff --git a/src/main/java/su/nightexpress/nightcore/language/legacy/LegacyMessageOptions.java b/src/main/java/su/nightexpress/nightcore/language/legacy/LegacyMessageOptions.java
deleted file mode 100644
index f62a985..0000000
--- a/src/main/java/su/nightexpress/nightcore/language/legacy/LegacyMessageOptions.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package su.nightexpress.nightcore.language.legacy;
-
-import org.bukkit.Sound;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import su.nightexpress.nightcore.language.message.OutputType;
-import su.nightexpress.nightcore.util.NumberUtil;
-import su.nightexpress.nightcore.util.Plugins;
-import su.nightexpress.nightcore.util.StringUtil;
-import su.nightexpress.nightcore.util.regex.TimedMatcher;
-
-@Deprecated
-public class LegacyMessageOptions {
-
- private OutputType type;
- private boolean hasPrefix;
- private boolean papi;
- private Sound sound;
- private int[] titleTimes;
-
- public LegacyMessageOptions() {
- this.type = OutputType.CHAT;
- this.hasPrefix = true;
- }
-
- @NotNull
- public LegacyMessageOptions copy() {
- LegacyMessageOptions copy = new LegacyMessageOptions();
- copy.type = this.type;
- copy.hasPrefix = this.hasPrefix;
- copy.papi = this.papi;
- copy.sound = this.sound;
- copy.titleTimes = this.titleTimes;
- return copy;
- }
-
- public void read(@NotNull String matchOptions) {
- for (LegacyMessageOption option : LegacyMessageOption.values()) {
- TimedMatcher matcherParam = TimedMatcher.create(option.getPattern(), matchOptions);
- if (!matcherParam.find()) continue;
-
- String optionValue = matcherParam.getMatcher().group(1).stripLeading();
- switch (option) {
- case TYPE -> {
- String[] split = optionValue.split(":");
- this.type = StringUtil.getEnum(split[0], OutputType.class).orElse(OutputType.CHAT);
- if (this.type == OutputType.TITLES) {
- this.titleTimes = new int[3];
- if (split.length >= 4) {
- this.titleTimes[0] = NumberUtil.getInteger(split[1]);
- this.titleTimes[1] = NumberUtil.getAnyInteger(split[2], -1);
- this.titleTimes[2] = NumberUtil.getInteger(split[3]);
- }
-
- if (this.titleTimes[1] < 0) this.titleTimes[1] = Short.MAX_VALUE;
- }
- }
- case PREFIX -> this.hasPrefix = Boolean.parseBoolean(optionValue);
- case PAPI -> this.papi = Boolean.parseBoolean(optionValue) && Plugins.hasPlaceholderAPI();
- case SOUND -> this.sound = StringUtil.getEnum(optionValue, Sound.class).orElse(null);
- }
- }
- }
-
- @NotNull
- public OutputType getType() {
- return type;
- }
-
- public boolean hasPrefix() {
- return this.hasPrefix;
- }
-
- public boolean hasPlaceholderAPI() {
- return this.papi;
- }
-
- @Nullable
- public Sound getSound() {
- return sound;
- }
-
- public int[] getTitleTimes() {
- return titleTimes;
- }
-}
diff --git a/src/main/java/su/nightexpress/nightcore/menu/impl/EditorMenu.java b/src/main/java/su/nightexpress/nightcore/menu/impl/EditorMenu.java
index 9e80fad..fdb6ead 100644
--- a/src/main/java/su/nightexpress/nightcore/menu/impl/EditorMenu.java
+++ b/src/main/java/su/nightexpress/nightcore/menu/impl/EditorMenu.java
@@ -10,7 +10,6 @@ import su.nightexpress.nightcore.dialog.Dialog;
import su.nightexpress.nightcore.dialog.DialogHandler;
import su.nightexpress.nightcore.language.entry.LangItem;
import su.nightexpress.nightcore.language.entry.LangString;
-import su.nightexpress.nightcore.language.legacy.LegacyLangString;
import su.nightexpress.nightcore.menu.MenuViewer;
import su.nightexpress.nightcore.menu.item.ItemHandler;
import su.nightexpress.nightcore.menu.item.MenuItem;
@@ -85,16 +84,6 @@ public abstract class EditorMenu extends AbstractM
return menuItem;
}
- @Deprecated
- public void handleInput(@NotNull MenuViewer viewer, @NotNull LegacyLangString prompt, @NotNull DialogHandler handler) {
- this.handleInput(viewer.getPlayer(), prompt, handler);
- }
-
- @Deprecated
- public void handleInput(@NotNull Player player, @NotNull LegacyLangString prompt, @NotNull DialogHandler handler) {
- this.handleInput(player, prompt.getString(), handler);
- }
-
@NotNull
public Dialog handleInput(@NotNull MenuViewer viewer, @NotNull LangString prompt, @NotNull DialogHandler handler) {
return this.handleInput(viewer.getPlayer(), prompt, handler);
diff --git a/src/main/java/su/nightexpress/nightcore/util/Colors.java b/src/main/java/su/nightexpress/nightcore/util/Colors.java
deleted file mode 100644
index 5ac3c48..0000000
--- a/src/main/java/su/nightexpress/nightcore/util/Colors.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package su.nightexpress.nightcore.util;
-
-@Deprecated
-public class Colors {
-
- public static final String BOLD = "&l";
- public static final String WHITE = "#e8f2f2";
- public static final String GRAY = "#aaa8a8";
- public static final String GREEN = "#74ea31";
- public static final String YELLOW = "#ead931";
- public static final String ORANGE = "#ea9631";
- public static final String RED = "#ea3131";
- public static final String BLUE = "#3196ea";
- public static final String CYAN = "#31eace";
- public static final String PURPLE = "#bd31ea";
- public static final String PINK = "#ea31b2";
-
- public static final String DARK_GRAY = "#6c6c62";
- public static final String LIGHT_GRAY = "#d4d9d8";
- public static final String LIGHT_GREEN = "#aefd5e";
- public static final String LIGHT_YELLOW = "#ffeea2";
- public static final String LIGHT_ORANGE = "#fdba5e";
- public static final String LIGHT_RED = "#fd5e5e";
- public static final String LIGHT_BLUE = "#5e9dfd";
- public static final String LIGHT_CYAN = "#5edefd";
- public static final String LIGHT_PURPLE = "#e39fff";
- public static final String LIGHT_PINK = "#fd8ddb";
-
-}
diff --git a/src/main/java/su/nightexpress/nightcore/util/NumberUtil.java b/src/main/java/su/nightexpress/nightcore/util/NumberUtil.java
index aa77476..6e44e07 100644
--- a/src/main/java/su/nightexpress/nightcore/util/NumberUtil.java
+++ b/src/main/java/su/nightexpress/nightcore/util/NumberUtil.java
@@ -41,6 +41,12 @@ public class NumberUtil {
return CoreConfig.NUMBER_FORMAT.get().format(value);
}
+ @NotNull
+ public static String compact(double value) {
+ Pair pair = formatCompact(value);
+ return pair.getFirst() + pair.getSecond();
+ }
+
@NotNull
public static Pair formatCompact(double value) {
boolean negative = false;
diff --git a/src/main/java/su/nightexpress/nightcore/util/Players.java b/src/main/java/su/nightexpress/nightcore/util/Players.java
index bb3c286..e81936a 100644
--- a/src/main/java/su/nightexpress/nightcore/util/Players.java
+++ b/src/main/java/su/nightexpress/nightcore/util/Players.java
@@ -133,7 +133,7 @@ public class Players {
@Deprecated
public static void sendRichMessage(@NotNull CommandSender sender, @NotNull String message) {
- if (!(sender instanceof Player player)) {
+ if (!(sender instanceof Player)) {
sender.sendMessage(Colorizer.apply(NexParser.toPlainText(message)));
return;
}
diff --git a/src/main/java/su/nightexpress/nightcore/util/text/NightMessage.java b/src/main/java/su/nightexpress/nightcore/util/text/NightMessage.java
index 9c17f1f..cb26637 100644
--- a/src/main/java/su/nightexpress/nightcore/util/text/NightMessage.java
+++ b/src/main/java/su/nightexpress/nightcore/util/text/NightMessage.java
@@ -38,7 +38,7 @@ public class NightMessage {
registerTags(Tags.BOLD, Tags.ITALIC, Tags.OBFUSCATED, Tags.STRIKETHROUGH, Tags.UNDERLINED);
registerTags(
- Tags.FONT, Tags.HEX_COLOR, Tags.GRADIENT,
+ Tags.FONT, Tags.HEX_COLOR, Tags.HEX_COLOR_SHORT, Tags.GRADIENT,
Tags.HOVER, Tags.CLICK,
Tags.LINE_BREAK, Tags.RESET
);
diff --git a/src/main/java/su/nightexpress/nightcore/util/text/decoration/ColorDecorator.java b/src/main/java/su/nightexpress/nightcore/util/text/decoration/ColorDecorator.java
new file mode 100644
index 0000000..b8c3415
--- /dev/null
+++ b/src/main/java/su/nightexpress/nightcore/util/text/decoration/ColorDecorator.java
@@ -0,0 +1,21 @@
+package su.nightexpress.nightcore.util.text.decoration;
+
+import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.api.chat.BaseComponent;
+import org.jetbrains.annotations.NotNull;
+
+import java.awt.*;
+
+public class ColorDecorator implements Decorator {
+
+ private final Color color;
+
+ public ColorDecorator(@NotNull Color color) {
+ this.color = color;
+ }
+
+ @Override
+ public void decorate(@NotNull BaseComponent component) {
+ component.setColor(ChatColor.of(this.color));
+ }
+}
diff --git a/src/main/java/su/nightexpress/nightcore/util/text/tag/StandardTags.java b/src/main/java/su/nightexpress/nightcore/util/text/tag/StandardTags.java
deleted file mode 100644
index ea13422..0000000
--- a/src/main/java/su/nightexpress/nightcore/util/text/tag/StandardTags.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package su.nightexpress.nightcore.util.text.tag;
-
-@Deprecated
-public class StandardTags {
-
- /*public static final String WHITE = Tags.WHITE.getFullName();
- public static final String GRAY = Tags.GRAY.getFullName();
- public static final String GREEN = Tags.GREEN.getFullName();
- public static final String YELLOW = Tags.YELLOW.getFullName();
- public static final String ORANGE = Tags.ORANGE.getFullName();
- public static final String RED = Tags.RED.getFullName();
- public static final String BLUE = Tags.BLUE.getFullName();
- public static final String CYAN = Tags.CYAN.getFullName();
- public static final String PURPLE = Tags.PURPLE.getFullName();
- public static final String PINK = Tags.PINK.getFullName();
-
- public static final String DARK_GRAY = Tags.DARK_GRAY.getFullName();
- public static final String LIGHT_GRAY = Tags.LIGHT_GRAY.getFullName();
- public static final String LIGHT_GREEN = Tags.LIGHT_GREEN.getFullName();
- public static final String LIGHT_YELLOW = Tags.LIGHT_YELLOW.getFullName();
- public static final String LIGHT_ORANGE = Tags.LIGHT_ORANGE.getFullName();
- public static final String LIGHT_RED = Tags.LIGHT_RED.getFullName();
- public static final String LIGHT_BLUE = Tags.LIGHT_BLUE.getFullName();
- public static final String LIGHT_CYAN = Tags.LIGHT_CYAN.getFullName();
- public static final String LIGHT_PURPLE = Tags.LIGHT_PURPLE.getFullName();
- public static final String LIGHT_PINK = Tags.LIGHT_PINK.getFullName();*/
-}
diff --git a/src/main/java/su/nightexpress/nightcore/util/text/tag/Tags.java b/src/main/java/su/nightexpress/nightcore/util/text/tag/Tags.java
index f2dc2e1..4c44229 100644
--- a/src/main/java/su/nightexpress/nightcore/util/text/tag/Tags.java
+++ b/src/main/java/su/nightexpress/nightcore/util/text/tag/Tags.java
@@ -4,13 +4,14 @@ import su.nightexpress.nightcore.util.text.tag.impl.*;
public class Tags {
- public static final ClickTag CLICK = new ClickTag();
- public static final FontTag FONT = new FontTag();
- public static final GradientTag GRADIENT = new GradientTag();
- public static final HexColorTag HEX_COLOR = new HexColorTag();
- public static final HoverTag HOVER = new HoverTag();
- public static final LineBreakTag LINE_BREAK = new LineBreakTag();
- public static final ResetTag RESET = new ResetTag();
+ public static final ClickTag CLICK = new ClickTag();
+ public static final FontTag FONT = new FontTag();
+ public static final GradientTag GRADIENT = new GradientTag();
+ public static final HexColorTag HEX_COLOR = new HexColorTag();
+ public static final ShortHexColorTag HEX_COLOR_SHORT = new ShortHexColorTag();
+ public static final HoverTag HOVER = new HoverTag();
+ public static final LineBreakTag LINE_BREAK = new LineBreakTag();
+ public static final ResetTag RESET = new ResetTag();
public static final FontStyleTag BOLD = new FontStyleTag("b", FontStyleTag.Style.BOLD);
public static final FontStyleTag ITALIC = new FontStyleTag("i", FontStyleTag.Style.ITALIC);
diff --git a/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/GradientTag.java b/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/GradientTag.java
index 28afed5..67b735a 100644
--- a/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/GradientTag.java
+++ b/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/GradientTag.java
@@ -24,7 +24,7 @@ public class GradientTag extends Tag implements DecoratorParser {
@Override
public boolean conflictsWith(@NotNull Tag tag) {
- return super.conflictsWith(tag) || tag instanceof ColorTag || tag instanceof HexColorTag;
+ return super.conflictsWith(tag) || tag instanceof ColorTag || tag instanceof ShortHexColorTag || tag instanceof HexColorTag;
}
@Override
@@ -55,6 +55,6 @@ public class GradientTag extends Tag implements DecoratorParser {
GradientDecorator decorator = new GradientDecorator(from, to);
- return new ParsedDecorator(decorator, 15 + tagLength);
+ return new ParsedDecorator(decorator, 15 + tagLength); // x2 hex (7+7), +1 for semicolon between
}
}
diff --git a/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/HexColorTag.java b/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/HexColorTag.java
index 6fc52d6..103adc1 100644
--- a/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/HexColorTag.java
+++ b/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/HexColorTag.java
@@ -2,16 +2,17 @@ package su.nightexpress.nightcore.util.text.tag.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import su.nightexpress.nightcore.util.text.decoration.DecoratorParser;
-import su.nightexpress.nightcore.util.text.decoration.ParsedDecorator;
+import su.nightexpress.nightcore.util.text.decoration.*;
import su.nightexpress.nightcore.util.text.tag.api.Tag;
import java.awt.*;
public class HexColorTag extends Tag implements DecoratorParser {
+ public static final String NAME = "color";
+
public HexColorTag() {
- super("#");
+ super(NAME);
}
@Override
@@ -21,21 +22,23 @@ public class HexColorTag extends Tag implements DecoratorParser {
@Override
public boolean conflictsWith(@NotNull Tag tag) {
- return super.conflictsWith(tag) || tag instanceof ColorTag || tag instanceof GradientTag;
+ return tag instanceof ColorTag || tag instanceof HexColorTag;
}
@Override
@Nullable
public ParsedDecorator parse(@NotNull String content) {
- Color color;
+ int tagLength = this.getName().length() + 1; // 1 for semicolon
+ content = content.substring(tagLength);
try {
- color = Color.decode(content);
+ Color color = Color.decode(content);
+ ColorDecorator decorator = new ColorDecorator(color);
+
+ return new ParsedDecorator(decorator, 7 + tagLength);
}
catch (NumberFormatException exception) {
return null;
}
-
- return new ParsedDecorator(new ColorTag(color), 7);
}
}
diff --git a/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/ShortHexColorTag.java b/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/ShortHexColorTag.java
new file mode 100644
index 0000000..d711e6f
--- /dev/null
+++ b/src/main/java/su/nightexpress/nightcore/util/text/tag/impl/ShortHexColorTag.java
@@ -0,0 +1,42 @@
+package su.nightexpress.nightcore.util.text.tag.impl;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import su.nightexpress.nightcore.util.text.decoration.DecoratorParser;
+import su.nightexpress.nightcore.util.text.decoration.ParsedDecorator;
+import su.nightexpress.nightcore.util.text.tag.api.Tag;
+
+import java.awt.*;
+
+@Deprecated
+public class ShortHexColorTag extends Tag implements DecoratorParser {
+
+ public ShortHexColorTag() {
+ super("#");
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ @Override
+ public boolean conflictsWith(@NotNull Tag tag) {
+ return super.conflictsWith(tag) || tag instanceof ColorTag || tag instanceof GradientTag;
+ }
+
+ @Override
+ @Nullable
+ public ParsedDecorator parse(@NotNull String content) {
+ Color color;
+
+ try {
+ color = Color.decode(content);
+ }
+ catch (NumberFormatException exception) {
+ return null;
+ }
+
+ return new ParsedDecorator(new ColorTag(color), 7);
+ }
+}