mirror of
https://github.com/darksaid98/nightcore-spigot.git
synced 2026-12-03 22:16:57 +00:00
Added missing colors
This commit is contained in:
1 parent
e7cac430bb
commit
f90a4fd435
6 files changed
+52
-6
No files matched your search
@@ -4,6 +4,9 @@ import org.bukkit.Bukkit;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import su.nightexpress.nightcore.NightCore;
|
import su.nightexpress.nightcore.NightCore;
|
||||||
import su.nightexpress.nightcore.NightCorePlugin;
|
import su.nightexpress.nightcore.NightCorePlugin;
|
||||||
|
import su.nightexpress.nightcore.util.bridge.PaperBridge;
|
||||||
|
import su.nightexpress.nightcore.util.bridge.Software;
|
||||||
|
import su.nightexpress.nightcore.util.bridge.SpigotBridge;
|
||||||
import su.nightexpress.nightcore.util.version.VersionComponent;
|
import su.nightexpress.nightcore.util.version.VersionComponent;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -30,7 +33,8 @@ public enum Version {
|
|||||||
private static final Set<VersionComponent> LOADED_COMPONENTS = new HashSet<>();
|
private static final Set<VersionComponent> LOADED_COMPONENTS = new HashSet<>();
|
||||||
|
|
||||||
private static Version current;
|
private static Version current;
|
||||||
private static boolean spigot;
|
//private static boolean spigot;
|
||||||
|
private static Software software;
|
||||||
|
|
||||||
private final Status status;
|
private final Status status;
|
||||||
private final String localized;
|
private final String localized;
|
||||||
@@ -60,9 +64,11 @@ public enum Version {
|
|||||||
String bukkitVersion = core.getServer().getBukkitVersion();
|
String bukkitVersion = core.getServer().getBukkitVersion();
|
||||||
String bukkitName = core.getServer().getName();
|
String bukkitName = core.getServer().getName();
|
||||||
String exact = bukkitVersion.split("-")[0];
|
String exact = bukkitVersion.split("-")[0];
|
||||||
|
boolean isSpigot = bukkitName.equalsIgnoreCase("Spigot");
|
||||||
|
|
||||||
current = Stream.of(values()).sorted(Comparator.reverseOrder()).filter(version -> exact.equalsIgnoreCase(version.getLocalized())).findFirst().orElse(UNKNOWN);
|
current = Stream.of(values()).sorted(Comparator.reverseOrder()).filter(version -> exact.equalsIgnoreCase(version.getLocalized())).findFirst().orElse(UNKNOWN);
|
||||||
spigot = bukkitName.equalsIgnoreCase("Spigot");
|
software = isSpigot ? new SpigotBridge() : new PaperBridge();
|
||||||
|
//spigot = bukkitName.equalsIgnoreCase("Spigot");
|
||||||
core.info("Server version detected as " + bukkitName + " " + current.getLocalized() + ".");
|
core.info("Server version detected as " + bukkitName + " " + current.getLocalized() + ".");
|
||||||
|
|
||||||
loadComponents(core);
|
loadComponents(core);
|
||||||
@@ -111,13 +117,18 @@ public enum Version {
|
|||||||
plugin.warn("=".repeat(35));
|
plugin.warn("=".repeat(35));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static Software software() {
|
||||||
|
return software;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Version getCurrent() {
|
public static Version getCurrent() {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSpigot() {
|
public static boolean isSpigot() {
|
||||||
return spigot;
|
return software.isSpigot();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasComponent(@NotNull VersionComponent component) {
|
public static boolean hasComponent(@NotNull VersionComponent component) {
|
||||||
|
|||||||
@@ -9,7 +9,17 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
public class PaperBridge {
|
public class PaperBridge implements Software {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpigot() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPaper() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static InventoryView create(@NotNull InventoryViewBuilder<?> builder, @NotNull String title, @NotNull Player player) {
|
public static InventoryView create(@NotNull InventoryViewBuilder<?> builder, @NotNull String title, @NotNull Player player) {
|
||||||
Component component = JSONComponentSerializer.json().deserialize(NightMessage.asJson(title)); // TODO Direct NightMessage to component
|
Component component = JSONComponentSerializer.json().deserialize(NightMessage.asJson(title)); // TODO Direct NightMessage to component
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package su.nightexpress.nightcore.util.bridge;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
import org.bukkit.inventory.MenuType;
|
|
||||||
import org.bukkit.inventory.view.builder.InventoryViewBuilder;
|
import org.bukkit.inventory.view.builder.InventoryViewBuilder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import su.nightexpress.nightcore.util.Version;
|
import su.nightexpress.nightcore.util.Version;
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package su.nightexpress.nightcore.util.bridge;
|
||||||
|
|
||||||
|
public interface Software {
|
||||||
|
|
||||||
|
boolean isSpigot();
|
||||||
|
|
||||||
|
boolean isPaper();
|
||||||
|
}
|
||||||
@@ -8,7 +8,17 @@ import su.nightexpress.nightcore.util.Reflex;
|
|||||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
public class SpigotBridge {
|
public class SpigotBridge implements Software {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpigot() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPaper() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static InventoryView create(@NotNull InventoryViewBuilder<?> builder, @NotNull String title, @NotNull Player player) {
|
public static InventoryView create(@NotNull InventoryViewBuilder<?> builder, @NotNull String title, @NotNull Player player) {
|
||||||
Reflex.setFieldValue(builder, "title", NightMessage.asLegacy(title));
|
Reflex.setFieldValue(builder, "title", NightMessage.asLegacy(title));
|
||||||
|
|||||||
@@ -82,6 +82,14 @@ public class Tags {
|
|||||||
|
|
||||||
registerTags(Tags.GRADIENT, Tags.LINE_BREAK, Tags.FONT, Tags.HOVER, Tags.CLICK,
|
registerTags(Tags.GRADIENT, Tags.LINE_BREAK, Tags.FONT, Tags.HOVER, Tags.CLICK,
|
||||||
Tags.RESET, Tags.HEX_COLOR, Tags.HEX_COLOR_SHORT, Tags.TRANSLATE);
|
Tags.RESET, Tags.HEX_COLOR, Tags.HEX_COLOR_SHORT, Tags.TRANSLATE);
|
||||||
|
|
||||||
|
registerTag(new ColorTag("dark_blue", "#0000AA"));
|
||||||
|
registerTag(new ColorTag("dark_green", "#00AA00"));
|
||||||
|
registerTag(new ColorTag("dark_aqua", "#00AAAA"));
|
||||||
|
registerTag(new ColorTag("dark_red", "#AA0000"));
|
||||||
|
registerTag(new ColorTag("dark_purple", "#AA00AA"));
|
||||||
|
registerTag(new ColorTag("gold", "#FFAA00"));
|
||||||
|
registerTag(new ColorTag("aqua", "#55FFFF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadColorsFromFile(@NotNull NightCore core) {
|
public static void loadColorsFromFile(@NotNull NightCore core) {
|
||||||
|
|||||||
Reference in new issue
Block a user