This commit is contained in:
nulli0n committed 2025-06-17 21:52:56 +05:00
1 parent 90e5941e6d
commit bf33a5e57d
22 files changed
+194 -103

No files matched your search

+2 -2
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>nightcore</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</parent>
<artifactId>bridge</artifactId>
@@ -35,7 +35,7 @@
<dependency>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>utils</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</dependency>
</dependencies>
@@ -19,6 +19,7 @@ public enum Version {
MC_1_21_3("1.21.3", 4082),
MC_1_21_4("1.21.4", 4189),
MC_1_21_5("1.21.5", 4325),
MC_1_21_6("1.21.6", 4435),
UNKNOWN("Unknown", 0),
;
@@ -58,6 +59,8 @@ public enum Version {
@NotNull
public static Version getCurrent() {
if (current == null) throw new IllegalStateException("Version is not initialized!");
return current;
}
+5 -5
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>nightcore</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</parent>
<artifactId>main</artifactId>
@@ -53,25 +53,25 @@
<dependency>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>bridge</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>utils</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>paper</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>spigot</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</dependency>
<dependency>
@@ -24,13 +24,13 @@ public class CoreLang {
});
public static final LangString COMMAND_ARGUMENT_FORMAT_REQUIRED = LangString.of("Command.Argument.Type.Required",
LIGHT_RED.enclose("<" + GENERIC_NAME + ">"));
LIGHT_RED.wrap("<" + GENERIC_NAME + ">"));
public static final LangString COMMAND_ARGUMENT_FORMAT_OPTIONAL = LangString.of("Command.Argument.Type.Optional",
LIGHT_YELLOW.enclose("[" + GENERIC_NAME + "]"));
LIGHT_YELLOW.wrap("[" + GENERIC_NAME + "]"));
public static final LangString COMMAND_FLAG_FORMAT = LangString.of("Command.Flag.Format",
LIGHT_GRAY.enclose("[" + GENERIC_NAME + "]"));
LIGHT_GRAY.wrap("[" + GENERIC_NAME + "]"));
public static final LangString COMMAND_ARGUMENT_NAME_GENERIC = LangString.of("Command.Argument.Name.Generic", "value");
public static final LangString COMMAND_ARGUMENT_NAME_TYPE = LangString.of("Command.Argument.Name.Type", "type");
@@ -48,16 +48,16 @@ public class CoreLang {
public static final LangText COMMAND_HELP_LIST = LangText.of("Command.Help.List",
TAG_NO_PREFIX,
" ",
" " + YELLOW.enclose(BOLD.enclose(GENERIC_NAME)) + GRAY.enclose(" - ") + YELLOW.enclose(BOLD.enclose("Commands:")),
" " + YELLOW.wrap(BOLD.wrap(GENERIC_NAME)) + GRAY.wrap(" - ") + YELLOW.wrap(BOLD.wrap("Commands:")),
" ",
GRAY.enclose(" " + RED.enclose(BOLD.enclose("<>")) + " - Required, " + GREEN.enclose(BOLD.enclose("[]")) + " - Optional."),
GRAY.wrap(" " + RED.wrap(BOLD.wrap("<>")) + " - Required, " + GREEN.wrap(BOLD.wrap("[]")) + " - Optional."),
" ",
GENERIC_ENTRY,
" "
);
public static final LangString COMMAND_HELP_ENTRY = LangString.of("Command.Help.Entry",
" " + YELLOW.enclose("/" + COMMAND_LABEL) + " " + ORANGE.enclose(COMMAND_USAGE) + GRAY.enclose(" - " + COMMAND_DESCRIPTION)
" " + YELLOW.wrap("/" + COMMAND_LABEL) + " " + ORANGE.wrap(COMMAND_USAGE) + GRAY.wrap(" - " + COMMAND_DESCRIPTION)
);
public static final LangString COMMAND_HELP_DESC = LangString.of("Command.Help.Desc", "Show help page.");
@@ -66,7 +66,7 @@ public class CoreLang {
public static final LangString COMMAND_RELOAD_DESC = LangString.of("Command.Reload.Desc", "Reload the plugin.");
public static final LangText COMMAND_RELOAD_DONE = LangText.of("Command.Reload.Done",
LIGHT_GRAY.enclose("Plugin " + LIGHT_GREEN.enclose("reloaded") + "!"));
LIGHT_GRAY.wrap("Plugin " + LIGHT_GREEN.wrap("reloaded") + "!"));
public static final LangString TIME_DAY = LangString.of("Time.Day", GENERIC_AMOUNT + "d.");
public static final LangString TIME_HOUR = LangString.of("Time.Hour", GENERIC_AMOUNT + "h.");
@@ -74,10 +74,10 @@ public class CoreLang {
public static final LangString TIME_SECOND = LangString.of("Time.Sec", GENERIC_AMOUNT + "sec.");
public static final LangString TIME_DELIMITER = LangString.of("Time.Delimiter", " ");
public static final LangString OTHER_YES = LangString.of("Other.Yes", GREEN.enclose("Yes"));
public static final LangString OTHER_NO = LangString.of("Other.No", RED.enclose("No"));
public static final LangString OTHER_ENABLED = LangString.of("Other.Enabled", GREEN.enclose("Enabled"));
public static final LangString OTHER_DISABLED = LangString.of("Other.Disabled", RED.enclose("Disabled"));
public static final LangString OTHER_YES = LangString.of("Other.Yes", GREEN.wrap("Yes"));
public static final LangString OTHER_NO = LangString.of("Other.No", RED.wrap("No"));
public static final LangString OTHER_ENABLED = LangString.of("Other.Enabled", GREEN.wrap("Enabled"));
public static final LangString OTHER_DISABLED = LangString.of("Other.Disabled", RED.wrap("Disabled"));
public static final LangString OTHER_ANY = LangString.of("Other.Any", "Any");
public static final LangString OTHER_NONE = LangString.of("Other.None", "None");
public static final LangString OTHER_NEVER = LangString.of("Other.Never", "Never");
@@ -85,68 +85,68 @@ public class CoreLang {
public static final LangString OTHER_UNLIMITED = LangString.of("Other.Unlimited", "Unlimited");
public static final LangString OTHER_INFINITY = LangString.of("Other.Infinity", "∞");
public static final LangString ENTRY_GOOD = LangString.of("Entry.Good", GREEN.enclose("✔") + " " + GRAY.enclose(GENERIC_ENTRY));
public static final LangString ENTRY_BAD = LangString.of("Entry.Bad", RED.enclose("✘") + " " + GRAY.enclose(GENERIC_ENTRY));
public static final LangString ENTRY_WARN = LangString.of("Entry.Warn", ORANGE.enclose("[❗]") + " " + GRAY.enclose(GENERIC_ENTRY));
public static final LangString ENTRY_GOOD = LangString.of("Entry.Good", GREEN.wrap("✔") + " " + GRAY.wrap(GENERIC_ENTRY));
public static final LangString ENTRY_BAD = LangString.of("Entry.Bad", RED.wrap("✘") + " " + GRAY.wrap(GENERIC_ENTRY));
public static final LangString ENTRY_WARN = LangString.of("Entry.Warn", ORANGE.wrap("[❗]") + " " + GRAY.wrap(GENERIC_ENTRY));
public static final LangText ERROR_INVALID_PLAYER = LangText.of("Error.Invalid_Player",
RED.enclose("Invalid player!"));
RED.wrap("Invalid player!"));
public static final LangText ERROR_INVALID_WORLD = LangText.of("Error.Invalid_World",
RED.enclose("Invalid world!"));
RED.wrap("Invalid world!"));
public static final LangText ERROR_INVALID_NUMBER = LangText.of("Error.Invalid_Number",
RED.enclose("Invalid number!"));
RED.wrap("Invalid number!"));
@Deprecated
public static final LangText ERROR_INVALID_MATERIAL = LangText.of("Error.InvalidMaterial",
RED.enclose("Invalid material!"));
RED.wrap("Invalid material!"));
@Deprecated
public static final LangText ERROR_INVALID_ENCHANTMENT = LangText.of("Error.InvalidEnchantment",
RED.enclose("Invalid enchantment!"));
RED.wrap("Invalid enchantment!"));
/*public static final LangText ERROR_INVALID_POTION_EFFECT = LangText.of("Error.InvalidPotionEffectType",
LIGHT_GRAY.enclose(LIGHT_RED.enclose(GENERIC_VALUE) + " is not a valid potion effect type!"));
LIGHT_GRAY.wrap(LIGHT_RED.wrap(GENERIC_VALUE) + " is not a valid potion effect type!"));
public static final LangText ERROR_INVALID_ATTRIBUTE = LangText.of("Error.InvalidAttribute",
LIGHT_GRAY.enclose(LIGHT_RED.enclose(GENERIC_VALUE) + " is not a valid attribute!"));*/
LIGHT_GRAY.wrap(LIGHT_RED.wrap(GENERIC_VALUE) + " is not a valid attribute!"));*/
public static final LangText ERROR_NO_PERMISSION = LangText.of("Error.NoPermission",
RED.enclose("You don't have permissions to do that!"));
RED.wrap("You don't have permissions to do that!"));
public static final LangText ERROR_COMMAND_PARSE_FLAG = LangText.of("Error.Command.ParseFlag",
LIGHT_GRAY.enclose("Invalid value " + LIGHT_RED.enclose(GENERIC_VALUE) + " for " + LIGHT_RED.enclose(GENERIC_NAME) + " flag."));
LIGHT_GRAY.wrap("Invalid value " + LIGHT_RED.wrap(GENERIC_VALUE) + " for " + LIGHT_RED.wrap(GENERIC_NAME) + " flag."));
public static final LangText ERROR_COMMAND_PARSE_ARGUMENT = LangText.of("Error.Command.ParseArgument",
LIGHT_GRAY.enclose("Invalid value " + LIGHT_RED.enclose(GENERIC_VALUE) + " for " + LIGHT_RED.enclose(GENERIC_NAME) + " argument."));
LIGHT_GRAY.wrap("Invalid value " + LIGHT_RED.wrap(GENERIC_VALUE) + " for " + LIGHT_RED.wrap(GENERIC_NAME) + " argument."));
public static final LangText ERROR_COMMAND_INVALID_PLAYER_ARGUMENT = LangText.of("Error.Command.Argument.InvalidPlayer",
LIGHT_GRAY.enclose(LIGHT_RED.enclose("Can not find player " + GENERIC_VALUE) + "!"));
LIGHT_GRAY.wrap(LIGHT_RED.wrap("Can not find player " + GENERIC_VALUE) + "!"));
public static final LangText ERROR_COMMAND_INVALID_WORLD_ARGUMENT = LangText.of("Error.Command.Argument.InvalidWorld",
LIGHT_GRAY.enclose(LIGHT_RED.enclose("Can not find world " + GENERIC_VALUE) + "!"));
LIGHT_GRAY.wrap(LIGHT_RED.wrap("Can not find world " + GENERIC_VALUE) + "!"));
public static final LangText ERROR_COMMAND_INVALID_NUMBER_ARGUMENT = LangText.of("Error.Command.Argument.InvalidNumber",
LIGHT_GRAY.enclose(LIGHT_RED.enclose(GENERIC_VALUE) + " is not a valid number!"));
LIGHT_GRAY.wrap(LIGHT_RED.wrap(GENERIC_VALUE) + " is not a valid number!"));
public static final LangText ERROR_COMMAND_INVALID_MATERIAL_ARGUMENT = LangText.of("Error.Command.Argument.InvalidMaterial",
LIGHT_GRAY.enclose(LIGHT_RED.enclose(GENERIC_VALUE) + " is not a valid material!"));
LIGHT_GRAY.wrap(LIGHT_RED.wrap(GENERIC_VALUE) + " is not a valid material!"));
public static final LangText ERROR_COMMAND_INVALID_ENCHANTMENT_ARGUMENT = LangText.of("Error.Command.Argument.InvalidEnchantment",
LIGHT_GRAY.enclose(LIGHT_RED.enclose(GENERIC_VALUE) + " is not a valid enchantment!"));
LIGHT_GRAY.wrap(LIGHT_RED.wrap(GENERIC_VALUE) + " is not a valid enchantment!"));
public static final LangText ERROR_COMMAND_NOT_YOURSELF = LangText.of("Error.Command.NotYourself",
RED.enclose("This command can not be used on yourself."));
RED.wrap("This command can not be used on yourself."));
public static final LangText ERROR_COMMAND_PLAYER_ONLY = LangText.of("Error.Command.PlayerOnly",
RED.enclose("This command is for players only."));
RED.wrap("This command is for players only."));
public static final LangText ERROR_COMMAND_USAGE = LangText.of("Error.Command.Usage",
TAG_NO_PREFIX,
" ",
RED.enclose("Error: ") + GRAY.enclose("Wrong arguments!"),
RED.enclose("Usage: ") + YELLOW.enclose("/" + COMMAND_LABEL) + " " + ORANGE.enclose(COMMAND_USAGE),
RED.wrap("Error: ") + GRAY.wrap("Wrong arguments!"),
RED.wrap("Usage: ") + YELLOW.wrap("/" + COMMAND_LABEL) + " " + ORANGE.wrap(COMMAND_USAGE),
" "
);
@@ -154,47 +154,47 @@ public class CoreLang {
public static final LangText EDITOR_ACTION_EXIT = LangText.of("Editor.Action.Exit",
TAG_NO_PREFIX,
"",
GRAY.enclose("Click " +
CLICK.enclose(
HOVER.enclose(GREEN.enclose("[Here]"), HoverEventType.SHOW_TEXT, GRAY.enclose("Click to cancel")),
GRAY.wrap("Click " +
CLICK.wrap(
HOVER.wrap(GREEN.wrap("[Here]"), HoverEventType.SHOW_TEXT, GRAY.wrap("Click to cancel")),
ClickEventType.RUN_COMMAND, "/" + Dialog.EXIT
)
+ " to leave input mode."),
"");
public static final LangString DIALOG_HEADER = LangString.of("Dialog.Header",
LIGHT_YELLOW.enclose(GENERIC_TIME));
LIGHT_YELLOW.wrap(GENERIC_TIME));
public static final LangString DIALOG_DEFAULT_PROMPT = LangString.of("Dialog.DefaultPrompt",
LIGHT_GRAY.enclose("Enter " + LIGHT_GREEN.enclose("[Value]")));
LIGHT_GRAY.wrap("Enter " + LIGHT_GREEN.wrap("[Value]")));
public static final LangText DIALOG_INFO_EXIT = LangText.of("Dialog.Info.Exit",
TAG_NO_PREFIX,
"",
GRAY.enclose("Click " +
GRAY.wrap("Click " +
CLICK.wrapRunCommand(
HOVER.wrapShowText(GREEN.enclose("[Here]"), GRAY.enclose("Click to cancel.")),
HOVER.wrapShowText(GREEN.wrap("[Here]"), GRAY.wrap("Click to cancel.")),
"/" + DialogManager.EXIT
)
+ " to leave input mode."),
"");
@Deprecated
public static final LangString EDITOR_INPUT_HEADER_MAIN = LangString.of("Editor.Input.Header.Main", GREEN.enclose(BOLD.enclose("Input Mode")));
public static final LangString EDITOR_INPUT_HEADER_MAIN = LangString.of("Editor.Input.Header.Main", GREEN.wrap(BOLD.wrap("Input Mode")));
@Deprecated
public static final LangString EDITOR_INPUT_HEADER_ERROR = LangString.of("Editor.Input.Header.Error", RED.enclose(BOLD.enclose("ERROR")));
public static final LangString EDITOR_INPUT_HEADER_ERROR = LangString.of("Editor.Input.Header.Error", RED.wrap(BOLD.wrap("ERROR")));
@Deprecated
public static final LangString EDITOR_INPUT_ERROR_NOT_INTEGER = LangString.of("Editor.Input.Error.NotInteger", GRAY.enclose("Expecting " + RED.enclose("whole") + " number!"));
public static final LangString EDITOR_INPUT_ERROR_NOT_INTEGER = LangString.of("Editor.Input.Error.NotInteger", GRAY.wrap("Expecting " + RED.wrap("whole") + " number!"));
@Deprecated
public static final LangString EDITOR_INPUT_ERROR_GENERIC = LangString.of("Editor.Input.Error.Generic", GRAY.enclose("Invalid value!"));
public static final LangString EDITOR_INPUT_ERROR_GENERIC = LangString.of("Editor.Input.Error.Generic", GRAY.wrap("Invalid value!"));
public static final LangString EDITOR_BUTTON_NAME = LangString.of("Editor.Button.Name",
LIGHT_YELLOW.enclose(BOLD.enclose(GENERIC_NAME))
LIGHT_YELLOW.wrap(BOLD.wrap(GENERIC_NAME))
);
public static final LangString EDITOR_BUTTON_DESCRIPTION = LangString.of("Editor.Button.Description",
GRAY.enclose(GENERIC_ENTRY)
GRAY.wrap(GENERIC_ENTRY)
);
public static final LangString EDITOR_BUTTON_CURRENT_DEFAULT_NAME = LangString.of("Editor.Button.Current.DefaultName",
@@ -202,27 +202,27 @@ public class CoreLang {
);
public static final LangString EDITOR_BUTTON_CURRENT_INFO = LangString.of("Editor.Button.Current.Info",
LIGHT_YELLOW.enclose("● " + LIGHT_GRAY.enclose(GENERIC_NAME + ": ") + GENERIC_VALUE)
LIGHT_YELLOW.wrap("● " + LIGHT_GRAY.wrap(GENERIC_NAME + ": ") + GENERIC_VALUE)
);
public static final LangString EDITOR_BUTTON_CLICK_KEY = LangString.of("Editor.Button.ClickKey",
LIGHT_YELLOW.enclose("[▶]") + " " + LIGHT_GRAY.enclose(GENERIC_NAME + " to " + LIGHT_YELLOW.enclose(GENERIC_VALUE) + ".")
LIGHT_YELLOW.wrap("[▶]") + " " + LIGHT_GRAY.wrap(GENERIC_NAME + " to " + LIGHT_YELLOW.wrap(GENERIC_VALUE) + ".")
);
@Deprecated
public static final LangItem EDITOR_ITEM_CLOSE = LangItem.of("Editor.Generic.Close", LIGHT_RED.enclose(BOLD.enclose("Exit")));
public static final LangItem EDITOR_ITEM_CLOSE = LangItem.of("Editor.Generic.Close", LIGHT_RED.wrap(BOLD.wrap("Exit")));
@Deprecated
public static final LangItem EDITOR_ITEM_RETURN = LangItem.of("Editor.Generic.Return", LIGHT_GRAY.enclose(BOLD.enclose("Return")));
public static final LangItem EDITOR_ITEM_RETURN = LangItem.of("Editor.Generic.Return", LIGHT_GRAY.wrap(BOLD.wrap("Return")));
@Deprecated
public static final LangItem EDITOR_ITEM_NEXT_PAGE = LangItem.of("Editor.Generic.NextPage", LIGHT_GRAY.enclose("Next Page →"));
public static final LangItem EDITOR_ITEM_NEXT_PAGE = LangItem.of("Editor.Generic.NextPage", LIGHT_GRAY.wrap("Next Page →"));
@Deprecated
public static final LangItem EDITOR_ITEM_PREVIOUS_PAGE = LangItem.of("Editor.Generic.PreviousPage", LIGHT_GRAY.enclose("← Previous Page"));
public static final LangItem EDITOR_ITEM_PREVIOUS_PAGE = LangItem.of("Editor.Generic.PreviousPage", LIGHT_GRAY.wrap("← Previous Page"));
public static final LangUIButton EDITOR_ITEM_EXIT = LangUIButton.builder("Editor.Item.Exit", LIGHT_RED.enclose(BOLD.enclose("Exit"))).build();
public static final LangUIButton EDITOR_ITEM_BACK = LangUIButton.builder("Editor.Item.Return", LIGHT_GRAY.enclose(BOLD.enclose("Return"))).build();
public static final LangUIButton EDITOR_ITEM_NEXT = LangUIButton.builder("Editor.Item.NextPage", LIGHT_GRAY.enclose(UNBOLD.enclose("Next Page →"))).build();
public static final LangUIButton EDITOR_ITEM_PREVIOUS = LangUIButton.builder("Editor.Item.PreviousPage", LIGHT_GRAY.enclose(UNBOLD.enclose("← Previous Page"))).build();
public static final LangUIButton EDITOR_ITEM_EXIT = LangUIButton.builder("Editor.Item.Exit", LIGHT_RED.wrap(UNDERLINED.wrap("Exit"))).formatted(false).build();
public static final LangUIButton EDITOR_ITEM_BACK = LangUIButton.builder("Editor.Item.Return", WHITE.wrap(UNDERLINED.wrap("Return"))).formatted(false).build();
public static final LangUIButton EDITOR_ITEM_NEXT = LangUIButton.builder("Editor.Item.NextPage", LIGHT_YELLOW.wrap(UNDERLINED.wrap("Next Page") + " →")).formatted(false).build();
public static final LangUIButton EDITOR_ITEM_PREVIOUS = LangUIButton.builder("Editor.Item.PreviousPage", LIGHT_YELLOW.wrap("← " + UNDERLINED.wrap("Previous Page"))).formatted(false).build();
@NotNull
public static String getYesOrNo(boolean value) {
@@ -9,4 +9,6 @@ public interface LangElement {
void write(@NotNull FileConfig config);
void load(@NotNull NightCorePlugin plugin);
void load(@NotNull FileConfig config);
}
@@ -45,8 +45,11 @@ public class LangEnum<E extends Enum<E>> implements LangElement {
}
public void load(@NotNull NightCorePlugin plugin) {
FileConfig config = plugin.getLang();
this.load(plugin.getLang());
}
@Override
public void load(@NotNull FileConfig config) {
Stream.of(this.clazz.getEnumConstants()).forEach(con -> {
String def = this.defaultsMap.getOrDefault(con, StringUtil.capitalizeUnderscored(con.name()));
String text = ConfigValue.create(this.path + "." + con.name(), def).read(config);
@@ -45,8 +45,11 @@ public class LangItem extends LangEntry {
@Override
public void load(@NotNull NightCorePlugin plugin) {
FileConfig config = plugin.getLang();
this.load(plugin.getLang());
}
@Override
public void load(@NotNull FileConfig config) {
if (!config.contains(this.path)) {
this.write(config);
}
@@ -36,8 +36,11 @@ public class LangKeyed<E extends Keyed> implements LangElement {
}
public void load(@NotNull NightCorePlugin plugin) {
FileConfig config = plugin.getLang();
this.load(plugin.getLang());
}
@Override
public void load(@NotNull FileConfig config) {
BukkitThing.allFromRegistry(this.registry).forEach(keyed -> {
String namespace = BukkitThing.toString(keyed);
String localized = StringUtil.capitalizeUnderscored(namespace);
@@ -35,8 +35,11 @@ public class LangRegistry<E extends Keyed> implements LangElement {
}
public void load(@NotNull NightCorePlugin plugin) {
FileConfig config = plugin.getLang();
this.load(plugin.getLang());
}
@Override
public void load(@NotNull FileConfig config) {
BukkitThing.getAll(this.registry).forEach(keyed -> {
String value = BukkitThing.getValue(keyed);
String localized = StringUtil.capitalizeUnderscored(value);
@@ -27,8 +27,11 @@ public class LangString extends LangEntry {
@Override
public void load(@NotNull NightCorePlugin plugin) {
FileConfig config = plugin.getLang();
this.load(plugin.getLang());
}
@Override
public void load(@NotNull FileConfig config) {
if (!config.contains(this.path)) {
this.write(config);
}
@@ -1,6 +1,7 @@
package su.nightexpress.nightcore.language.entry;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.NightCorePlugin;
import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.language.message.LangMessage;
@@ -36,8 +37,15 @@ public class LangText extends LangEntry {
@Override
public void load(@NotNull NightCorePlugin plugin) {
FileConfig config = plugin.getLang();
this.load(plugin.getLang(), plugin.getPrefix());
}
@Override
public void load(@NotNull FileConfig config) {
this.load(config, null);
}
public void load(@NotNull FileConfig config, @Nullable String defaultPrefix) {
if (!config.contains(this.path)) {
this.write(config);
}
@@ -47,7 +55,7 @@ public class LangText extends LangEntry {
text.add(config.getString(this.path, this.path));
}
this.setMessage(LangMessage.parse(plugin, String.join(Placeholders.TAG_LINE_BREAK, text)));
this.setMessage(LangMessage.parse(String.join(Placeholders.TAG_LINE_BREAK, text), defaultPrefix));
}
@NotNull
@@ -44,8 +44,11 @@ public class LangUIButton implements LangElement {
@Override
public void load(@NotNull NightCorePlugin plugin) {
FileConfig config = plugin.getLang();
this.load(plugin.getLang());
}
@Override
public void load(@NotNull FileConfig config) {
if (!config.contains(this.path) || (!config.contains(this.path + ".ClickActions") && !this.defaults.clickActions.isEmpty())) {
this.write(config);
}
@@ -1,6 +1,7 @@
package su.nightexpress.nightcore.language.message;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@@ -8,10 +9,7 @@ import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.NightCorePlugin;
import su.nightexpress.nightcore.language.tag.MessageTag;
import su.nightexpress.nightcore.language.tag.MessageTags;
import su.nightexpress.nightcore.util.NumberUtil;
import su.nightexpress.nightcore.util.Placeholders;
import su.nightexpress.nightcore.util.Players;
import su.nightexpress.nightcore.util.StringUtil;
import su.nightexpress.nightcore.util.*;
import su.nightexpress.nightcore.util.bukkit.NightSound;
import su.nightexpress.nightcore.util.placeholder.Replacer;
import su.nightexpress.nightcore.util.text.NightMessage;
@@ -26,18 +24,28 @@ import java.util.function.UnaryOperator;
public class LangMessage {
private final NightCorePlugin plugin;
//private final NightCorePlugin plugin;
private final String defaultText;
private final MessageOptions options;
private TextRoot message;
@Deprecated
public LangMessage(@NotNull NightCorePlugin plugin, @NotNull String defaultText, @NotNull MessageOptions options) {
this(plugin, defaultText, options, null);
this(defaultText, options);
}
@Deprecated
public LangMessage(@NotNull NightCorePlugin plugin, @NotNull String defaultText, @NotNull MessageOptions options, @Nullable String prefix) {
this.plugin = plugin;
this(defaultText, options, prefix);
}
public LangMessage(@NotNull String defaultText, @NotNull MessageOptions options) {
this(defaultText, options, null);
}
public LangMessage(@NotNull String defaultText, @NotNull MessageOptions options, @Nullable String prefix) {
//this.plugin = plugin;
this.defaultText = defaultText;
this.options = options;
@@ -55,10 +63,13 @@ public class LangMessage {
@NotNull
public LangMessage setPrefix(@Nullable String prefix) {
boolean init = this.message == null;
this.message = NightMessage.from(prefix == null || !options.hasPrefix() ? defaultText : prefix + defaultText);
OutputType type = this.options.getOutputType();
if (type != OutputType.CHAT) prefix = null;
if (init && this.options.getOutputType() != OutputType.TITLES) {
boolean notCompiled = this.message == null;
this.message = NightMessage.from(prefix == null || !this.options.hasPrefix() ? this.defaultText : prefix + this.defaultText);
if (notCompiled && type != OutputType.TITLES) {
this.message.compile();
}
return this;
@@ -66,14 +77,20 @@ public class LangMessage {
@Deprecated
private LangMessage(@NotNull LangMessage from) {
this.plugin = from.plugin;
//this.plugin = from.plugin;
this.defaultText = from.defaultText;
this.options = from.options.copy();
this.message = from.message.copy();
}
@NotNull
@Deprecated
public static LangMessage parse(@NotNull NightCorePlugin plugin, @NotNull String string) {
return parse(string, plugin.getPrefix());
}
@NotNull
public static LangMessage parse(@NotNull String string, @Nullable String defPrefix) {
MessageOptions options = new MessageOptions();
StringBuilder builder = new StringBuilder();
@@ -163,7 +180,7 @@ public class LangMessage {
}
String text = builder.toString();
String prefix = options.getOutputType() == OutputType.CHAT && options.hasPrefix() ? plugin.getPrefix() : null;
String prefix = options.getOutputType() == OutputType.CHAT && options.hasPrefix() ? defPrefix : null;
// Remove completely empty lines.
// Especially useful for message tags lines without extra text.
@@ -176,7 +193,7 @@ public class LangMessage {
}
String strippedText = stripper.toString();
return new LangMessage(plugin, strippedText, options, prefix);
return new LangMessage(strippedText, options, prefix);
}
// @NotNull
@@ -251,7 +268,7 @@ public class LangMessage {
if (this.isDisabled()) return;
Players.getOnline().forEach(player -> this.send(player, consumer));
this.send(plugin.getServer().getConsoleSender(), consumer);
this.send(Bukkit.getServer().getConsoleSender(), consumer);
}
public void send(@NotNull CommandSender sender) {
@@ -2,7 +2,9 @@ package su.nightexpress.nightcore.manager;
import org.jetbrains.annotations.NotNull;
import su.nightexpress.nightcore.NightCorePlugin;
import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.ui.menu.Menu;
import su.nightexpress.nightcore.ui.menu.data.ConfigBased;
import su.nightexpress.nightcore.util.bukkit.NightTask;
import su.nightexpress.nightcore.util.wrapper.UniTask;
@@ -15,7 +17,7 @@ public abstract class AbstractManager<P extends NightCorePlugin> extends SimpleM
protected final Set<SimpeListener> listeners;
protected final Set<Menu> menus;
protected final List<UniTask> tasks;
@Deprecated protected final List<UniTask> tasks;
protected final List<NightTask> taskList;
public AbstractManager(@NotNull P plugin) {
@@ -46,11 +48,19 @@ public abstract class AbstractManager<P extends NightCorePlugin> extends SimpleM
}
@NotNull
@Deprecated
protected <T extends Menu> T addMenu(@NotNull T menu) {
this.menus.add(menu);
return menu;
}
@NotNull
protected <T extends Menu & ConfigBased> T addMenu(@NotNull T menu, @NotNull String path, @NotNull String file) {
this.menus.add(menu);
menu.load(FileConfig.loadOrExtract(this.plugin, path, file));
return menu;
}
protected void addTask(@NotNull Runnable runnable, int interval) {
this.addTask(NightTask.create(plugin, runnable, interval));
}
@@ -1,12 +1,12 @@
package su.nightexpress.nightcore.ui.menu.item;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.core.CoreLang;
import su.nightexpress.nightcore.ui.menu.Menu;
import su.nightexpress.nightcore.ui.menu.MenuViewer;
import su.nightexpress.nightcore.util.Placeholders;
import su.nightexpress.nightcore.util.bukkit.NightItem;
public class MenuItem {
@@ -32,21 +32,21 @@ public class MenuItem {
@NotNull
public static Builder buildNextPage(@NotNull Menu menu, int slot) {
return builder(NightItem.asCustomHead(Placeholders.SKIN_ARROW_RIGHT).localized(CoreLang.EDITOR_ITEM_NEXT))
return builder(NightItem.fromType(Material.ARROW).localized(CoreLang.EDITOR_ITEM_NEXT))
.setHandler(ItemHandler.forNextPage(menu))
.setSlots(slot);
}
@NotNull
public static Builder buildPreviousPage(@NotNull Menu menu, int slot) {
return builder(NightItem.asCustomHead(Placeholders.SKIN_ARROW_LEFT).localized(CoreLang.EDITOR_ITEM_PREVIOUS))
return builder(NightItem.fromType(Material.ARROW).localized(CoreLang.EDITOR_ITEM_PREVIOUS))
.setHandler(ItemHandler.forPreviousPage(menu))
.setSlots(slot);
}
@NotNull
public static Builder buildExit(@NotNull Menu menu, int slot) {
return builder(NightItem.asCustomHead(Placeholders.SKIN_WRONG_MARK).localized(CoreLang.EDITOR_ITEM_EXIT))
return builder(NightItem.fromType(Material.IRON_DOOR).localized(CoreLang.EDITOR_ITEM_EXIT))
.setHandler(ItemHandler.forClose(menu))
.setSlots(slot);
}
@@ -58,7 +58,7 @@ public class MenuItem {
@NotNull
public static Builder buildReturn(@NotNull Menu menu, int slot, @NotNull ItemClick click, @Nullable ItemOptions options) {
return builder(NightItem.asCustomHead(Placeholders.SKIN_ARROW_DOWN).localized(CoreLang.EDITOR_ITEM_BACK))
return builder(NightItem.fromType(Material.IRON_DOOR).localized(CoreLang.EDITOR_ITEM_BACK))
.setHandler(ItemHandler.forReturn(menu, click, options))
.setSlots(slot);
}
@@ -8,6 +8,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MenuType;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.Engine;
@@ -22,6 +23,7 @@ import su.nightexpress.nightcore.ui.menu.click.ClickResult;
import su.nightexpress.nightcore.ui.menu.data.Linked;
import su.nightexpress.nightcore.ui.menu.item.ItemHandler;
import su.nightexpress.nightcore.ui.menu.item.MenuItem;
import su.nightexpress.nightcore.util.ItemUtil;
import su.nightexpress.nightcore.util.Lists;
import su.nightexpress.nightcore.util.Placeholders;
import su.nightexpress.nightcore.util.bukkit.NightItem;
@@ -182,6 +184,14 @@ public abstract class AbstractMenu<P extends NightPlugin> implements Menu {
for (int slot : menuItem.getSlots()) {
if (slot < 0 || slot >= inventory.getSize()) continue;
inventory.setItem(slot, itemStack);
// Do not yet use new NightItem#getItemStackUpdated method here, until we ensure there are no inventory content relies in #onReady.
if (item.getPlayerProfile() != null) {
item.getPlayerProfile().update().thenAccept(updated -> {
ItemUtil.editMeta(itemStack, SkullMeta.class, updated::apply);
inventory.setItem(slot, itemStack);
});
}
}
});
@@ -21,6 +21,7 @@ import su.nightexpress.nightcore.util.placeholder.Replacer;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
/**
@@ -145,6 +146,21 @@ public class NightItem implements Writeable {
return stack;
}
/**
* Updates ItemStack's properties that are potentially to block the server's main thread, such as PlayerProfile in PLAYER_HEAD items.
* @return a completable future that gets completed with the updated ItemStack properties once it is available.
*/
@NotNull
public CompletableFuture<ItemStack> getItemStackUpdated() {
NightProfile profile = this.getPlayerProfile();
if (profile == null) return CompletableFuture.supplyAsync(this::getItemStack);
return profile.update().thenCompose(updated -> {
this.meta.setPlayerProfile(updated);
return CompletableFuture.supplyAsync(this::getItemStack);
});
}
@NotNull
public NightMeta getMeta() {
return this.meta;
@@ -3,6 +3,7 @@ package su.nightexpress.nightcore.util.bukkit;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.enchantments.Enchantment;
@@ -134,11 +135,16 @@ public class NightMeta implements Writeable {
}
//displayMeta.setHideComponents(!meta.getItemFlags().isEmpty());
if (meta instanceof LeatherArmorMeta armorMeta) {
displayMeta.setColor(armorMeta.getColor());
}
else if (meta instanceof PotionMeta potionMeta) {
displayMeta.setColor(potionMeta.getColor());
switch (meta) {
case LeatherArmorMeta armorMeta -> displayMeta.setColor(armorMeta.getColor());
case PotionMeta potionMeta -> displayMeta.setColor(potionMeta.getColor());
case FireworkEffectMeta effectMeta -> {
FireworkEffect effect = effectMeta.getEffect();
if (effect != null && !effect.getColors().isEmpty()) {
displayMeta.setColor(effect.getColors().getFirst());
}
}
default -> {}
}
return displayMeta;
@@ -267,7 +273,7 @@ public class NightMeta implements Writeable {
config.set(path + ".Enchant_Glint", this.enchantGlint ? true : null);
config.set(path + ".Hide_Components", this.hiddenComponents != null && !this.hiddenComponents.isEmpty() ? true : null);
config.set(path + ".Hide_Tooltip", this.hideTooltip ? true : null);
config.set(path + ".Color", this.color == null ? null : color.getRed() + "," + color.getBlue() + "," + color.getGreen());
config.set(path + ".Color", this.color == null ? null : color.getRed() + "," + color.getGreen() + "," + color.getBlue());
}
public void apply(@NotNull ItemStack itemStack) {
@@ -315,6 +321,7 @@ public class NightMeta implements Writeable {
switch (meta) {
case LeatherArmorMeta armorMeta -> armorMeta.setColor(this.color);
case PotionMeta potionMeta -> potionMeta.setColor(this.color);
case FireworkEffectMeta effectMeta -> effectMeta.setEffect(FireworkEffect.builder().withColor(this.color).build());
default -> {}
}
}
+2 -2
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>nightcore</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</parent>
<artifactId>paper</artifactId>
@@ -35,7 +35,7 @@
<dependency>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>bridge</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</dependency>
</dependencies>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>nightcore</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
<packaging>pom</packaging>
<modules>
<module>main</module>
+2 -2
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>nightcore</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</parent>
<artifactId>spigot</artifactId>
@@ -35,7 +35,7 @@
<dependency>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>bridge</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</dependency>
</dependencies>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>su.nightexpress.nightcore</groupId>
<artifactId>nightcore</artifactId>
<version>2.7.6.1</version>
<version>2.7.7</version>
</parent>
<artifactId>utils</artifactId>