mirror of
https://github.com/darksaid98/nightcore-spigot.git
synced 2026-12-01 14:38:47 +00:00
v2.7.5.1
- Fixed plugin not loading on versions < 1.21 - Fixed empty lines on some items in some GUIs.
This commit is contained in:
1 parent
8562f69011
commit
b7495ac492
5 files changed
+44
-13
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>su.nightexpress.nightcore</groupId>
|
||||
<artifactId>nightcore</artifactId>
|
||||
<version>2.7.5</version>
|
||||
<version>2.7.5.1</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
|
||||
@@ -27,12 +27,13 @@ public class LangUIButton implements LangElement {
|
||||
return new Builder(path, name);
|
||||
}
|
||||
|
||||
protected record Details(String name, List<String> description, Map<String, String> currentInfo, Map<ClickKey, String> clickActions){}
|
||||
protected record Details(String name, List<String> description, boolean formatted, Map<String, String> currentInfo, Map<ClickKey, String> clickActions){}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull FileConfig config) {
|
||||
config.set(this.path + ".Name", this.defaults.name);
|
||||
config.set(this.path + ".Description", this.defaults.description);
|
||||
config.set(this.path + ".Formatted", this.defaults.formatted);
|
||||
|
||||
config.remove(this.path + ".CurrentInfo");
|
||||
this.defaults.currentInfo.forEach((name, value) -> config.set(this.path + ".CurrentInfo." + name, value));
|
||||
@@ -45,12 +46,13 @@ public class LangUIButton implements LangElement {
|
||||
public void load(@NotNull NightCorePlugin plugin) {
|
||||
FileConfig config = plugin.getLang();
|
||||
|
||||
if (!config.contains(this.path) || !config.contains(this.path + ".ClickActions")) {
|
||||
if (!config.contains(this.path) || (!config.contains(this.path + ".ClickActions") && !this.defaults.clickActions.isEmpty())) {
|
||||
this.write(config);
|
||||
}
|
||||
|
||||
String name = ConfigValue.create(this.path + ".Name", this.defaults.name).read(config);
|
||||
List<String> description = ConfigValue.create(this.path + ".Description", this.defaults.description).read(config);
|
||||
boolean formatted = ConfigValue.create(this.path + ".Formatted", this.defaults.formatted).read(config);
|
||||
|
||||
Map<String, String> currentInfo = new LinkedHashMap<>();
|
||||
config.getSection(this.path + ".CurrentInfo").forEach(sId -> {
|
||||
@@ -71,7 +73,7 @@ public class LangUIButton implements LangElement {
|
||||
clickActions.put(key, action);
|
||||
});
|
||||
|
||||
this.details = new Details(name, description, currentInfo, clickActions);
|
||||
this.details = new Details(name, description, formatted, currentInfo, clickActions);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -84,6 +86,10 @@ public class LangUIButton implements LangElement {
|
||||
return this.details.description;
|
||||
}
|
||||
|
||||
public boolean isFormatted() {
|
||||
return this.details.formatted;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, String> getCurrentInfo() {
|
||||
return this.details.currentInfo;
|
||||
@@ -103,10 +109,12 @@ public class LangUIButton implements LangElement {
|
||||
private final Map<ClickKey, String> clickActions;
|
||||
|
||||
private String name;
|
||||
private boolean formatted;
|
||||
|
||||
public Builder(@NotNull String path, @NotNull String name) {
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.formatted = true;
|
||||
this.description = new ArrayList<>();
|
||||
this.currentInfo = new LinkedHashMap<>();
|
||||
this.clickActions = new LinkedHashMap<>();
|
||||
@@ -114,7 +122,7 @@ public class LangUIButton implements LangElement {
|
||||
|
||||
@NotNull
|
||||
public LangUIButton build() {
|
||||
return new LangUIButton(this.path, new Details(this.name, new ArrayList<>(this.description), this.currentInfo, new HashMap<>(this.clickActions)));
|
||||
return new LangUIButton(this.path, new Details(this.name, new ArrayList<>(this.description), this.formatted, this.currentInfo, new HashMap<>(this.clickActions)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -129,6 +137,12 @@ public class LangUIButton implements LangElement {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Builder formatted(boolean formatted) {
|
||||
this.formatted = formatted;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Builder current(@NotNull String value) {
|
||||
return this.current(CoreLang.EDITOR_BUTTON_CURRENT_DEFAULT_NAME.getString(), value);
|
||||
|
||||
@@ -5,21 +5,31 @@ import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.nightcore.NightCore;
|
||||
import su.nightexpress.nightcore.ui.menu.confirmation.ConfirmMenu;
|
||||
import su.nightexpress.nightcore.ui.menu.confirmation.Confirmation;
|
||||
import su.nightexpress.nightcore.util.Plugins;
|
||||
import su.nightexpress.nightcore.util.Version;
|
||||
|
||||
public class UIUtils {
|
||||
|
||||
private static ConfirmMenu confirmMenu;
|
||||
|
||||
public static void load(@NotNull NightCore plugin) {
|
||||
confirmMenu = new ConfirmMenu(plugin);
|
||||
if (Version.isAtLeast(Version.MC_1_21)) {
|
||||
confirmMenu = new ConfirmMenu(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
confirmMenu.clear();
|
||||
confirmMenu = null;
|
||||
if (confirmMenu != null) {
|
||||
confirmMenu.clear();
|
||||
confirmMenu = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void openConfirmation(@NotNull Player player, @NotNull Confirmation confirmation) {
|
||||
if (confirmMenu == null) {
|
||||
Plugins.getCore().error("[UIUtils] Unsupported server version.");
|
||||
return;
|
||||
}
|
||||
confirmMenu.open(player, confirmation);
|
||||
}
|
||||
}
|
||||
@@ -353,7 +353,9 @@ public class NightMeta implements Writeable {
|
||||
|
||||
@NotNull
|
||||
public NightMeta localized(@NotNull LangUIButton locale) {
|
||||
String name = CoreLang.EDITOR_BUTTON_NAME.getString().replace(Placeholders.GENERIC_NAME, locale.getName());
|
||||
boolean formatted = locale.isFormatted();
|
||||
|
||||
String name = formatted ? CoreLang.EDITOR_BUTTON_NAME.getString().replace(Placeholders.GENERIC_NAME, locale.getName()) : locale.getName();
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
locale.getCurrentInfo().forEach((title, value) -> {
|
||||
@@ -364,9 +366,9 @@ public class NightMeta implements Writeable {
|
||||
lore.add(Placeholders.EMPTY_IF_ABOVE);
|
||||
|
||||
for (String entry : locale.getDescription()) {
|
||||
lore.add(CoreLang.EDITOR_BUTTON_DESCRIPTION.getString().replace(Placeholders.GENERIC_ENTRY, entry));
|
||||
lore.add(formatted ? CoreLang.EDITOR_BUTTON_DESCRIPTION.getString().replace(Placeholders.GENERIC_ENTRY, entry) : entry);
|
||||
}
|
||||
lore.add(Placeholders.EMPTY_IF_ABOVE);
|
||||
lore.add(Placeholders.EMPTY_IF_BELOW);
|
||||
|
||||
locale.getClickActions().forEach((key, action) -> {
|
||||
lore.add(CoreLang.EDITOR_BUTTON_CLICK_KEY.getString()
|
||||
|
||||
@@ -47,12 +47,17 @@ public class HoverTag extends Tag implements ContentTag {
|
||||
|
||||
@NotNull
|
||||
public String wrapShowText(@NotNull String string, @NotNull String text) {
|
||||
return this.enclose(string, HoverEventType.SHOW_TEXT, text);
|
||||
return this.wrap(string, HoverEventType.SHOW_TEXT, text);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String wrapShowItem(@NotNull String string, @NotNull ItemStack itemStack) {
|
||||
return this.enclose(string, HoverEventType.SHOW_ITEM, String.valueOf(ItemNbt.compress(itemStack)));
|
||||
return this.wrapShowItem(string, String.valueOf(ItemNbt.compress(itemStack)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String wrapShowItem(@NotNull String string, @NotNull String compressed) {
|
||||
return this.wrap(string, HoverEventType.SHOW_ITEM, compressed);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in new issue
Block a user