NUMBER_FORMAT = ConfigValue.create("Engine.Number_Format",
- UniFormatter.of("#,###.##", RoundingMode.HALF_EVEN),
+ UniFormatter.of("#,###.###", RoundingMode.HALF_EVEN),
"Control over how numerical data is formatted and rounded.",
"Allowed modes: " + StringUtil.inlineEnum(RoundingMode.class, ", "),
"A tutorial can be found here: https://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html"
diff --git a/src/main/java/su/nightexpress/nightcore/database/AbstractUser.java b/src/main/java/su/nightexpress/nightcore/database/AbstractUser.java
index 1346808..ba8122a 100644
--- a/src/main/java/su/nightexpress/nightcore/database/AbstractUser.java
+++ b/src/main/java/su/nightexpress/nightcore/database/AbstractUser.java
@@ -37,8 +37,8 @@ public abstract class AbstractUser implements DataUse
}
- private long getTimestamp(int seconds) {
- return seconds < 0 ? -1L : System.currentTimeMillis() + 1000L * seconds;
+ private long getTimestamp(double seconds) {
+ return seconds < 0 ? -1L : System.currentTimeMillis() + (long) (1000D * seconds);
}
public boolean isCacheExpired() {
@@ -81,7 +81,7 @@ public abstract class AbstractUser
implements DataUse
}
@Override
- public void setAutoSaveIn(int seconds) {
+ public void setAutoSaveIn(double seconds) {
this.autoSaveIn = this.getTimestamp(seconds);
}
diff --git a/src/main/java/su/nightexpress/nightcore/database/AbstractUserManager.java b/src/main/java/su/nightexpress/nightcore/database/AbstractUserManager.java
index 82feed1..7992012 100644
--- a/src/main/java/su/nightexpress/nightcore/database/AbstractUserManager.java
+++ b/src/main/java/su/nightexpress/nightcore/database/AbstractUserManager.java
@@ -240,7 +240,11 @@ public abstract class AbstractUserManager
, U extend
user.setName(player.getName());
user.setLastOnline(System.currentTimeMillis());
}
- this.scheduleSave(user);
+ if (this.isScheduledToSave(user)) {
+ this.scheduledSaves.remove(user.getId());
+ }
+ this.plugin.runTaskAsync(task -> this.save(user));
+ //this.scheduleSave(user);
this.cacheTemporary(user);
}
diff --git a/src/main/java/su/nightexpress/nightcore/database/DataUser.java b/src/main/java/su/nightexpress/nightcore/database/DataUser.java
index 7746586..527831f 100644
--- a/src/main/java/su/nightexpress/nightcore/database/DataUser.java
+++ b/src/main/java/su/nightexpress/nightcore/database/DataUser.java
@@ -31,7 +31,7 @@ public interface DataUser {
void setCachedUntil(long cachedUntil);
- void setAutoSaveIn(int seconds);
+ void setAutoSaveIn(double seconds);
void setNextSyncIn(int seconds);
diff --git a/src/main/java/su/nightexpress/nightcore/database/UserdataConfig.java b/src/main/java/su/nightexpress/nightcore/database/UserdataConfig.java
index 0de55b2..5e6c27d 100644
--- a/src/main/java/su/nightexpress/nightcore/database/UserdataConfig.java
+++ b/src/main/java/su/nightexpress/nightcore/database/UserdataConfig.java
@@ -8,10 +8,10 @@ import su.nightexpress.nightcore.config.FileConfig;
public class UserdataConfig {
private final long scheduledSaveInterval;
- private final int scheduledSaveDelay;
+ private final double scheduledSaveDelay;
private final int scheduledSaveSyncPause;
- public UserdataConfig(long scheduledSaveInterval, int scheduledSaveDelay, int scheduledSaveSyncPause) {
+ public UserdataConfig(long scheduledSaveInterval, double scheduledSaveDelay, int scheduledSaveSyncPause) {
this.scheduledSaveInterval = scheduledSaveInterval;
this.scheduledSaveDelay = scheduledSaveDelay;
this.scheduledSaveSyncPause = scheduledSaveSyncPause;
@@ -30,8 +30,8 @@ public class UserdataConfig {
"[Default is 20]"
).read(config);
- int scheduledSaveDelay = ConfigValue.create("Database.UserData.Scheduled_Save_Delay",
- 1,
+ double scheduledSaveDelay = ConfigValue.create("Database.UserData.Scheduled_Save_Delay",
+ 1D,
"Sets scheduled save delay (in seconds) for a user when marked to be saved.",
"This means that a user will be saved X seconds later after being marked.",
"Generally, you should keep this value less than 'Scheduled_Save_Interval' for best results,",
@@ -42,6 +42,7 @@ public class UserdataConfig {
"",
"Users marked for save when their data has been changed/affected in some way.",
"However this is higly depends on the plugin.",
+ "[Decimals allowed]",
"[Default is 1]"
).read(config);
@@ -61,7 +62,7 @@ public class UserdataConfig {
return scheduledSaveInterval;
}
- public int getScheduledSaveDelay() {
+ public double getScheduledSaveDelay() {
return scheduledSaveDelay;
}
diff --git a/src/main/java/su/nightexpress/nightcore/dialog/Dialog.java b/src/main/java/su/nightexpress/nightcore/dialog/Dialog.java
index 5dc08ef..acecfa1 100644
--- a/src/main/java/su/nightexpress/nightcore/dialog/Dialog.java
+++ b/src/main/java/su/nightexpress/nightcore/dialog/Dialog.java
@@ -109,7 +109,7 @@ public class Dialog {
String hoverHint = GRAY.enclose("Click me to select " + CYAN.enclose(element) + ".");
String clickCommand = element.charAt(0) == '/' ? element : '/' + element;
- builder.append(DARK_GRAY.enclose("> ")).append(GREEN.enclose(HOVER.encloseHint(CLICK.encloseRun(element, clickCommand), hoverHint)));
+ builder.append(DARK_GRAY.enclose("> ")).append(GREEN.enclose(HOVER.encloseHint(CLICK.enclose(element, action, clickCommand), hoverHint)));
builder.append(Placeholders.TAG_LINE_BREAK);
});
diff --git a/src/main/java/su/nightexpress/nightcore/language/LangAssets.java b/src/main/java/su/nightexpress/nightcore/language/LangAssets.java
index d637555..b49b7b0 100644
--- a/src/main/java/su/nightexpress/nightcore/language/LangAssets.java
+++ b/src/main/java/su/nightexpress/nightcore/language/LangAssets.java
@@ -2,7 +2,9 @@ package su.nightexpress.nightcore.language;
import org.bukkit.Keyed;
import org.bukkit.Material;
+import org.bukkit.Registry;
import org.bukkit.World;
+import org.bukkit.damage.DamageType;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.potion.PotionEffectType;
@@ -28,6 +30,18 @@ public class LangAssets {
String assetsCode = downloadAssets(core, langCode);
config = FileConfig.loadOrExtract(core, LangManager.DIR_LANG, getFileName(assetsCode));
+
+ loadDamageTypes();
+ }
+
+ public static void shutdown() {
+ config.saveChanges();
+ config = null;
+ }
+
+ @SuppressWarnings("UnstableApiUsage")
+ private static void loadDamageTypes() {
+ BukkitThing.allFromRegistry(Registry.DAMAGE_TYPE).forEach(damageType -> getOrCreate("DamageType", damageType));
}
@NotNull
@@ -90,6 +104,12 @@ public class LangAssets {
return getOrCreate("Enchantment", enchantment);
}
+ @SuppressWarnings("UnstableApiUsage")
+ @NotNull
+ public static String get(@NotNull DamageType damageType) {
+ return getOrCreate("DamageType", damageType);
+ }
+
@NotNull
public static String getAsset(@NotNull String path, @NotNull Keyed keyed) {
return getAsset(path, BukkitThing.toString(keyed));
@@ -113,7 +133,7 @@ public class LangAssets {
@NotNull
public static String getOrCreate(@NotNull String path, @NotNull String nameRaw) {
config.addMissing(path + "." + nameRaw, StringUtil.capitalizeUnderscored(nameRaw));
- config.saveChanges();
+ //config.saveChanges();
return getAsset(path, nameRaw);
}
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 6466217..ce045a4 100644
--- a/src/main/java/su/nightexpress/nightcore/menu/impl/EditorMenu.java
+++ b/src/main/java/su/nightexpress/nightcore/menu/impl/EditorMenu.java
@@ -59,16 +59,18 @@ public abstract class EditorMenu
extends AbstractM
@NotNull
@Deprecated
protected MenuItem addReturn(int... slots) {
- ItemStack item = new ItemStack(Material.PLAYER_HEAD);
- ItemUtil.setSkullTexture(item, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM4NTJiZjYxNmYzMWVkNjdjMzdkZTRiMGJhYTJjNWY4ZDhmY2E4MmU3MmRiY2FmY2JhNjY5NTZhODFjNCJ9fX0=");
+ ItemStack item = ItemUtil.getSkinHead("be9ae7a4be65fcbaee65181389a2f7d47e2e326db59ea3eb789a92c85ea46");
+ //ItemStack item = new ItemStack(Material.PLAYER_HEAD);
+ //ItemUtil.setSkullTexture(item, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM4NTJiZjYxNmYzMWVkNjdjMzdkZTRiMGJhYTJjNWY4ZDhmY2E4MmU3MmRiY2FmY2JhNjY5NTZhODFjNCJ9fX0=");
return this.addItem(item, CoreLang.EDITOR_ITEM_RETURN, slots);
}
@NotNull
@Deprecated
protected MenuItem addCreation(@NotNull LangItem locale, int... slots) {
- ItemStack item = new ItemStack(Material.PLAYER_HEAD);
- ItemUtil.setSkullTexture(item, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWZmMzE0MzFkNjQ1ODdmZjZlZjk4YzA2NzU4MTA2ODFmOGMxM2JmOTZmNTFkOWNiMDdlZDc4NTJiMmZmZDEifX19");
+ ItemStack item = ItemUtil.getSkinHead("5ff31431d64587ff6ef98c0675810681f8c13bf96f51d9cb07ed7852b2ffd1");
+ //ItemStack item = new ItemStack(Material.PLAYER_HEAD);
+ //ItemUtil.setSkullTexture(item, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWZmMzE0MzFkNjQ1ODdmZjZlZjk4YzA2NzU4MTA2ODFmOGMxM2JmOTZmNTFkOWNiMDdlZDc4NTJiMmZmZDEifX19");
return this.addItem(item, locale, slots);
}
diff --git a/src/main/java/su/nightexpress/nightcore/util/ItemReplacer.java b/src/main/java/su/nightexpress/nightcore/util/ItemReplacer.java
index a61cf82..3321e66 100644
--- a/src/main/java/su/nightexpress/nightcore/util/ItemReplacer.java
+++ b/src/main/java/su/nightexpress/nightcore/util/ItemReplacer.java
@@ -3,16 +3,17 @@ package su.nightexpress.nightcore.util;
import com.google.common.base.Splitter;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.language.entry.LangItem;
+import su.nightexpress.nightcore.util.placeholder.Placeholder;
import su.nightexpress.nightcore.util.placeholder.PlaceholderMap;
import su.nightexpress.nightcore.util.text.NightMessage;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
@@ -26,11 +27,11 @@ public class ItemReplacer {
private final List> operatorCache;
private String displayName;
- private String lore;
+ private List lore;
private boolean trimLore;
private boolean hideFlags;
- private Player papi;
+ //private Player papi;
public ItemReplacer(@NotNull ItemStack item) {
this(item, item.getItemMeta());
@@ -82,21 +83,19 @@ public class ItemReplacer {
operators.add(this.placeholderCache.replacer());
boolean hasDisplayName = this.displayName != null;
- boolean hasLore = this.lore != null;
+ //boolean hasLore = this.lore != null;
operators.forEach(operator -> {
if (hasDisplayName) this.setDisplayName(operator.apply(this.displayName));
- if (hasLore) this.setLore(operator.apply(this.lore));
+ this.replaceLore(operator);
+ //if (hasLore) this.setLore(operator.apply(this.lore));
});
- //this.replace(this.placeholderCache.replacer());
-// this.injectPlaceholderAPI(this.papi);
-
this.meta.setDisplayName(this.getDisplayName() == null ? null : NightMessage.asLegacy(this.getDisplayName()));
this.meta.setLore(this.packTrimmedLore());
if (this.isHideFlags()) {
- this.meta.addItemFlags(ItemFlag.values());
+ ItemUtil.hideAttributes(this.meta, this.item.getType());
}
if (this.hasItem()) {
@@ -211,23 +210,11 @@ public class ItemReplacer {
@NotNull
public ItemReplacer replace(@NotNull UnaryOperator replacer) {
-// this.operatorCache.add(replacer);
-//
-// if (this.getDisplayName() != null) {
-// this.setDisplayName(replacer.apply(this.getDisplayName()));
-// }
-//
-// if (this.getLore() != null) {
-// this.setLore(replacer.apply(this.getLore()));
-// }
return cacheOperator(replacer);
}
@NotNull
public ItemReplacer replacePlaceholderAPI(@NotNull Player player) {
-// if (Plugins.hasPlaceholderAPI()) {
-// this.papi = player;
-// }
if (Plugins.hasPlaceholderAPI()) {
this.cacheOperator(str -> PlaceholderAPI.setPlaceholders(player, str));
}
@@ -237,39 +224,24 @@ public class ItemReplacer {
@NotNull
@Deprecated
public ItemReplacer replaceLoreExact(@NotNull String placeholder, @NotNull List replacer) {
-// this.replace(placeholder, () -> String.join(Tags.LINE_BREAK.getBracketsName(), replacer));
-// return this;
return this.replace(placeholder, replacer);
}
@NotNull
@Deprecated
public ItemReplacer replaceLore(@NotNull String placeholder, @NotNull Supplier> replacer) {
-// this.replace(placeholder, () -> String.join(Tags.LINE_BREAK.getBracketsName(), replacer.get()));
-// return this;
return this.replace(placeholder, replacer.get());
}
@NotNull
@Deprecated
public ItemReplacer injectLore(@NotNull String placeholder, @NotNull List replacer) {
-// this.injectLoreCache.put(placeholder, replacer);
-// if (this.getLore() == null) return this;
-//
-// this.setLore(Lists.replace(this.packLore(), placeholder, replacer));
-// return this;
return this.replace(placeholder, replacer);
}
-
-
@NotNull
@Deprecated
public ItemReplacer injectPlaceholderAPI(@NotNull Player player) {
-//// if (player != null) {
-// this.replace(str -> PlaceholderAPI.setPlaceholders(player, str));
-//// }
-// return this;
return this.replacePlaceholderAPI(player);
}
@@ -294,9 +266,26 @@ public class ItemReplacer {
@NotNull
public List packLore() {
- if (this.lore == null) return new ArrayList<>();
+// if (this.lore == null) return new ArrayList<>();
+//
+// return Splitter.on("\n").splitToList(this.lore);
+ return this.lore == null ? new ArrayList<>() : this.lore;
+ }
- return Splitter.on("\n").splitToList(this.lore);
+ private void replaceLore(@NotNull UnaryOperator operator) {
+ if (this.lore == null) return;
+
+ List replaced = new ArrayList<>();
+ for (String line : this.lore) {
+ if (!line.isBlank()) {
+ line = operator.apply(line);
+ if (line.isBlank()) continue;
+
+ replaced.addAll(Arrays.asList(line.split("\n")));
+ }
+ else replaced.add(line);
+ }
+ this.setLore(replaced);
}
@NotNull
@@ -305,7 +294,39 @@ public class ItemReplacer {
if (this.isTrimLore()) {
lore = Lists.stripEmpty(lore);
}
- return NightMessage.asLegacy(lore);
+
+ List fixed = fixLore(lore);
+
+ return NightMessage.asLegacy(fixed);
+ }
+
+ @NotNull
+ private List fixLore(@NotNull List lore) {
+ for (int index = 0; index < lore.size(); index++) {
+ String line = lore.get(index);
+ if (line.equalsIgnoreCase(Placeholders.EMPTY_IF_ABOVE)) {
+ if (index == 0 || !this.isNotEmpty(lore.get(index - 1))) {
+ lore.remove(index);
+ }
+ else lore.set(index, "");
+
+ return fixLore(lore);
+ }
+ else if (line.equalsIgnoreCase(Placeholders.EMPTY_IF_BELOW)) {
+ if (index == lore.size() - 1 || !this.isNotEmpty(lore.get(index + 1))) {
+ lore.remove(index);
+ }
+ else lore.set(index, "");
+
+ return fixLore(lore);
+ }
+ }
+
+ return lore;
+ }
+
+ private boolean isNotEmpty(@NotNull String line) {
+ return !line.isBlank() && !line.equalsIgnoreCase(Placeholders.EMPTY_IF_ABOVE) && !line.equalsIgnoreCase(Placeholders.EMPTY_IF_BELOW);
}
@Nullable
@@ -320,18 +341,21 @@ public class ItemReplacer {
}
@Nullable
- public String getLore() {
+ public List getLore() {
return this.lore;
}
@NotNull
public ItemReplacer setLore(@Nullable List lore) {
- return this.setLore(lore == null ? null : String.join("\n", lore));
+ this.lore = lore;
+ return this;
+ //return this.setLore(lore == null ? null : String.join("\n", lore));
}
@NotNull
public ItemReplacer setLore(@Nullable String lore) {
- this.lore = lore;
+ this.lore = lore == null ? null : Lists.newList(lore.split("\n"));
+ //this.lore = lore;
return this;
}
}
diff --git a/src/main/java/su/nightexpress/nightcore/util/ItemUtil.java b/src/main/java/su/nightexpress/nightcore/util/ItemUtil.java
index c7daec7..02836c3 100644
--- a/src/main/java/su/nightexpress/nightcore/util/ItemUtil.java
+++ b/src/main/java/su/nightexpress/nightcore/util/ItemUtil.java
@@ -1,11 +1,14 @@
package su.nightexpress.nightcore.util;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
@@ -15,8 +18,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.language.LangAssets;
-import java.lang.reflect.Method;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.Consumer;
@@ -38,6 +41,20 @@ public class ItemUtil {
item.setItemMeta(meta);
}
+ public static void hideAttributes(@NotNull ItemStack itemStack) {
+ editMeta(itemStack, meta -> hideAttributes(meta, itemStack.getType()));
+ }
+
+ public static void hideAttributes(@NotNull ItemMeta meta, @NotNull Material material) {
+ if (Version.isAtLeast(Version.MC_1_20_6)) {
+ EquipmentSlot slot = material.getEquipmentSlot();
+ material.getDefaultAttributeModifiers(slot).forEach((meta::addAttributeModifier));
+ //meta.addAttributeModifier(Attribute.GENERIC_MAX_HEALTH, new AttributeModifier("veryNiceItemChanges", 1, AttributeModifier.Operation.ADD_NUMBER));
+ }
+
+ meta.addItemFlags(ItemFlag.values());
+ }
+
@NotNull
public static List getLore(@NotNull ItemStack item) {
ItemMeta meta = item.getItemMeta();
@@ -106,21 +123,35 @@ public class ItemUtil {
@Deprecated
public static void setSkullTexture(@NotNull ItemStack item, @NotNull String value) {
if (item.getType() != Material.PLAYER_HEAD) return;
- if (!(item.getItemMeta() instanceof SkullMeta meta)) return;
+ //if (!(item.getItemMeta() instanceof SkullMeta meta)) return;
- UUID uuid = UUID.nameUUIDFromBytes(value.getBytes());
- GameProfile profile = new GameProfile(uuid, "null");
- profile.getProperties().put("textures", new Property("textures", value));
+ try {
+ byte[] decoded = Base64.getDecoder().decode(value);
+ String decodedStr = new String(decoded, StandardCharsets.UTF_8);
+ JsonElement element = JsonParser.parseString(decodedStr);
- Method method = Reflex.getMethod(meta.getClass(), "setProfile", GameProfile.class);
- if (method != null) {
- Reflex.invokeMethod(method, meta, profile);
+ String url = element.getAsJsonObject().getAsJsonObject("textures").getAsJsonObject("SKIN").get("url").getAsString();
+ url = url.substring(ItemUtil.TEXTURES_HOST.length());
+
+ setHeadSkin(item, url);
}
- else {
- Reflex.setFieldValue(meta, "profile", profile);
+ catch (Exception exception) {
+ exception.printStackTrace();
}
- item.setItemMeta(meta);
+// UUID uuid = UUID.nameUUIDFromBytes(value.getBytes());
+// GameProfile profile = new GameProfile(uuid, "null");
+// profile.getProperties().put("textures", new Property("textures", value));
+//
+// Method method = Reflex.getMethod(meta.getClass(), "setProfile", GameProfile.class);
+// if (method != null) {
+// Reflex.invokeMethod(method, meta, profile);
+// }
+// else {
+// Reflex.setFieldValue(meta, "profile", profile);
+// }
+//
+// item.setItemMeta(meta);
}
@Nullable
diff --git a/src/main/java/su/nightexpress/nightcore/util/Lists.java b/src/main/java/su/nightexpress/nightcore/util/Lists.java
index e9f6579..bbcd5a6 100644
--- a/src/main/java/su/nightexpress/nightcore/util/Lists.java
+++ b/src/main/java/su/nightexpress/nightcore/util/Lists.java
@@ -126,16 +126,16 @@ public class Lists {
public static List getSequentialMatches(@NotNull List results, @NotNull String input) {
if (input.isBlank()) return results;
- char[] chars = input.toCharArray();
+ char[] inputChars = input.toCharArray();
List goods = new ArrayList<>();
Result:
- for (String item : results) {
- int itemLength = item.length();
+ for (String resultItem : results) {
+ int itemLength = resultItem.length();
if (input.length() > itemLength) continue;
int lastIndex = -1;
- for (char letter : chars) {
+ for (char letter : inputChars) {
int nextIndex = lastIndex;
if (nextIndex < 0) {
@@ -145,14 +145,15 @@ public class Lists {
nextIndex++; // This fixes an issue, where method fails for similar characters in a row, like 'oo'.
}
- int index = item.indexOf(letter, nextIndex);
+ letter = Character.toLowerCase(letter);
+ int index = resultItem.toLowerCase().indexOf(letter, nextIndex);
if (index <= lastIndex) {
continue Result;
}
lastIndex = index;
}
- goods.add(item);
+ goods.add(resultItem);
}
return goods;
}
diff --git a/src/main/java/su/nightexpress/nightcore/util/Placeholders.java b/src/main/java/su/nightexpress/nightcore/util/Placeholders.java
index 936047d..99ee700 100644
--- a/src/main/java/su/nightexpress/nightcore/util/Placeholders.java
+++ b/src/main/java/su/nightexpress/nightcore/util/Placeholders.java
@@ -47,6 +47,10 @@ public class Placeholders {
public static final String SKIN_ARROW_RIGHT = "f32ca66056b72863e98f7f32bd7d94c7a0d796af691c9ac3a9136331352288f9";
public static final String SKIN_ARROW_DOWN = "be9ae7a4be65fcbaee65181389a2f7d47e2e326db59ea3eb789a92c85ea46";
+ public static final String EMPTY_IF_ABOVE = "%empty-if-above%";
+ public static final String EMPTY_IF_BELOW = "%empty-if-below%";
+ public static final String EMPTY_IF_BOTH = "%empty-if-both%";
+
public static final String COMMAND_USAGE = "%command_usage%";
public static final String COMMAND_DESCRIPTION = "%command_description%";
public static final String COMMAND_LABEL = "%command_label%";
diff --git a/src/main/java/su/nightexpress/nightcore/util/Version.java b/src/main/java/su/nightexpress/nightcore/util/Version.java
index 4e6b598..05b9260 100644
--- a/src/main/java/su/nightexpress/nightcore/util/Version.java
+++ b/src/main/java/su/nightexpress/nightcore/util/Version.java
@@ -8,13 +8,14 @@ import java.util.stream.Stream;
public enum Version {
- V1_18_R2("1.18.2", true),
+ V1_18_R2("1.18.2", Status.DROPPED),
V1_19_R3("1.19.4"),
- V1_20_R1("1.20.1", true),
- V1_20_R2("1.20.2", true),
+ V1_20_R1("1.20.1", Status.OUTDATED),
+ V1_20_R2("1.20.2", Status.OUTDATED),
V1_20_R3("1.20.4"),
- MC_1_20_6("1.20.6"),
- MC_1_21("1.21"),
+ MC_1_20_6("1.20.6", Status.DROPPED),
+ MC_1_21_0("1.21", Status.OUTDATED),
+ MC_1_21("1.21.1"),
UNKNOWN("Unknown"),
;
@@ -22,16 +23,16 @@ public enum Version {
private static Version current;
- private final boolean deprecated;
+ private final Status status;
private final String localized;
Version(@NotNull String localized) {
- this(localized, false);
+ this(localized, Status.SUPPORTED);
}
- Version(@NotNull String localized, boolean deprecated) {
+ Version(@NotNull String localized, @NotNull Status status) {
this.localized = localized;
- this.deprecated = deprecated;
+ this.status = status;
}
@NotNull
@@ -40,17 +41,38 @@ public enum Version {
return Bukkit.getServer().getBukkitVersion();
}
+ public enum Status {
+ SUPPORTED,
+ OUTDATED,
+ DROPPED
+ }
+
@NotNull
public static Version getCurrent() {
if (current == null) {
String protocol = Bukkit.getServer().getBukkitVersion();
- current = Stream.of(values()).sorted(Comparator.reverseOrder()).filter(version -> protocol.startsWith(version.getLocalized())).findFirst().orElse(UNKNOWN);
+ String exact = protocol.split("-")[0];
+
+ current = Stream.of(values()).sorted(Comparator.reverseOrder()).filter(version -> exact.equalsIgnoreCase(version.getLocalized())).findFirst().orElse(UNKNOWN);
}
return current;
}
public boolean isDeprecated() {
- return deprecated;
+ return this.status == Status.OUTDATED;
+ }
+
+ public boolean isDropped() {
+ return this.status == Status.DROPPED;
+ }
+
+ public boolean isSupported() {
+ return this.status == Status.SUPPORTED;
+ }
+
+ @NotNull
+ public Status getStatus() {
+ return status;
}
@NotNull
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 afd7d79..8553f46 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
@@ -43,7 +43,7 @@ public class Tags {
public static final ColorTag DARK_GRAY = new ColorTag("dgray", new String[]{"dark_gray"}, "#6c6c62");
public static final ColorTag LIGHT_GRAY = new ColorTag("lgray", new String[]{"light_gray"}, "#d4d9d8");
- public static final ColorTag LIGHT_GREEN = new ColorTag("lgreen", new String[]{"light_green"}, "#aefd5e");
+ public static final ColorTag LIGHT_GREEN = new ColorTag("lgreen", new String[]{"light_green"}, "#91f251");
public static final ColorTag LIGHT_YELLOW = new ColorTag("lyellow", new String[]{"light_yellow"}, "#ffeea2");
public static final ColorTag LIGHT_ORANGE = new ColorTag("lorange", new String[]{"light_orange"}, "#fdba5e");
public static final ColorTag LIGHT_RED = new ColorTag("lred", new String[]{"light_red"}, "#fd5e5e");
diff --git a/src/main/java/su/nightexpress/nightcore/util/wrapper/UniFormatter.java b/src/main/java/su/nightexpress/nightcore/util/wrapper/UniFormatter.java
index 3ae89c9..972ac5a 100644
--- a/src/main/java/su/nightexpress/nightcore/util/wrapper/UniFormatter.java
+++ b/src/main/java/su/nightexpress/nightcore/util/wrapper/UniFormatter.java
@@ -1,6 +1,7 @@
package su.nightexpress.nightcore.util.wrapper;
import org.jetbrains.annotations.NotNull;
+import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig;
import java.math.RoundingMode;
@@ -15,7 +16,7 @@ public class UniFormatter {
private final String format;
private final RoundingMode rounding;
- private UniFormatter(String format, RoundingMode rounding) {
+ private UniFormatter(@NotNull String format, @NotNull RoundingMode rounding) {
this.format = format;
this.rounding = rounding;
this.formatter = new DecimalFormat(format, new DecimalFormatSymbols(Locale.US));
@@ -23,20 +24,21 @@ public class UniFormatter {
}
@NotNull
- public static UniFormatter of(String format, RoundingMode rounding) {
+ public static UniFormatter of(@NotNull String format, @NotNull RoundingMode rounding) {
return new UniFormatter(format, rounding);
}
@NotNull
- public static UniFormatter read(@NotNull FileConfig cfg, @NotNull String path) {
- String format = cfg.getString(path + ".Format_Pattern", "#,###.##");
- RoundingMode rounding = RoundingMode.valueOf(cfg.getString(path + ".Rounding_Mode", "half_even").toUpperCase());
+ public static UniFormatter read(@NotNull FileConfig config, @NotNull String path) {
+ String format = ConfigValue.create(path + ".Format", "#,###.##").read(config);
+ RoundingMode rounding = ConfigValue.create(path + ".Rounding", RoundingMode.class, RoundingMode.HALF_EVEN).read(config);
+
return of(format, rounding);
}
- public void write(@NotNull FileConfig cfg, @NotNull String path) {
- cfg.set(path + ".Format", this.getFormat());
- cfg.set(path + ".Rounding", this.getRounding().name().toLowerCase());
+ public void write(@NotNull FileConfig config, @NotNull String path) {
+ config.set(path + ".Format", this.getFormat());
+ config.set(path + ".Rounding", this.getRounding().name().toLowerCase());
}
public String getFormat() {
diff --git a/src/main/resources/lang/messages_tw.yml b/src/main/resources/lang/messages_tw.yml
new file mode 100644
index 0000000..161e518
--- /dev/null
+++ b/src/main/resources/lang/messages_tw.yml
@@ -0,0 +1,111 @@
+Command:
+ Help:
+ List:
+ -
+ - ' %name% - 指令:'
+ - ' '
+ - <> - 必填, [] - 選填。
+ - ' '
+ - '%entry%'
+ - ' '
+ Entry: ' /%command_label% %command_usage% - %command_description%'
+ Desc: 顯示幫助頁面。
+ CheckPerm:
+ Desc: 顯示玩家權限資訊。
+ Usage:
+ Reload:
+ Desc: 重新加載插件。
+ Done: 插件 已重新加載!
+ Argument:
+ Type:
+ Required: <%name%>
+ Optional: [%name%]
+ Name:
+ Generic: 數值
+ Type: 類型
+ Name: 名稱
+ Player: 玩家
+ World: 世界
+ Amount: 數量
+ Material: 材料
+ ItemMaterial: 物品類型
+ BlockMaterial: 方塊類型
+ Enchantment: 附魔
+ Flag:
+ Format: [%name%]
+Time:
+ Day: '%amount%天.'
+ Hour: '%amount%小時.'
+ Min: '%amount%分鐘.'
+ Sec: '%amount%秒.'
+ Delimiter: ' '
+Other:
+ 'Yes': 是
+ 'No': 否
+ Enabled: 啟用
+ Disabled: 停用
+ Any: 任意
+ None: 無
+ Never: 從不
+ OneTimed: 單次
+ Unlimited: 無限
+ Infinity: ∞
+Error:
+ Invalid_Player: 找不到玩家。
+ Invalid_World: 無效的世界。
+ Invalid_Number: %value% 不是有效的數字。
+ NoPermission: 您沒有權限執行此操作!
+ Command:
+ NotYourself: 此命令無法用於自己。
+ PlayerOnly: 此命令僅適用於玩家。
+ Usage:
+ -
+ - '錯誤: 參數錯誤!'
+ - '用法: /%command_label% %command_usage%'
+ - ' '
+ ParseFlag: 無效的值 %value% 用於 %name% 標誌。
+ ParseArgument: 無效的值 %value% 用於 %name% 參數。
+ Argument:
+ InvalidPlayer: 找不到玩家 %value%!
+ InvalidWorld: 找不到世界 %value%!
+ InvalidNumber: %value% 不是有效的數字!
+ InvalidMaterial: %value% 不是有效的材料!
+ InvalidEnchantment: %value% 不是有效的附魔!
+ InvalidMaterial: 無效的材料!
+ InvalidEnchantment: 無效的附魔!
+Editor:
+ Action:
+ Exit:
+ -
+ - 點擊 點擊以取消'>[此處] 退出輸入模式。
+ - ' '
+ Input:
+ Header:
+ Main: 輸入模式
+ Error: 錯誤
+ Error:
+ NotInteger: 預期的 整數!
+ Generic: 無效的值!
+ Generic:
+ Close:
+ Name: (✕) 退出
+ Lore: []
+ Return:
+ Name: () 返回
+ Lore: []
+ NextPage:
+ Name: 下一頁 (→)
+ Lore: []
+ PreviousPage:
+ Name: (←) 上一頁
+ Lore: []
+Number:
+ Thousand: 千
+ Million: 百萬
+ Billion: 十億
+ Trillion: 兆
+ Quadrillion: 千兆
+Entry:
+ Good: ✔ %entry%
+ Bad: ✘ %entry%
+ Warn: [❗] %entry%
\ No newline at end of file