diff --git a/build.gradle.kts b/build.gradle.kts index b7383b4..dcd3361 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "me.youhavetrouble" -version = "1.1.0" +version = "1.2.0" description = "Nameplates using display entities" java { diff --git a/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java b/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java index 2567032..e996805 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java @@ -2,6 +2,7 @@ package me.youhavetrouble.notjustnameplates; import me.youhavetrouble.notjustnameplates.displays.DisplayContent; import me.youhavetrouble.notjustnameplates.displays.DisplayFrame; +import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; @@ -83,6 +84,7 @@ public class NJNConfig { displayContent.setSeeThrough(displayContentSection.getBoolean("see-through", false)); displayContent.setInterpolationDelay(displayContentSection.getInt("interpolation-delay", displayContent.getRefreshRate())); displayContent.setInterpolationDuration(displayContentSection.getInt("interpolation-duration", displayContent.getRefreshRate())); + displayContent.setViewRange(displayContentSection.getInt("view-range", Bukkit.spigot().getSpigotConfig().getInt("world-settings.default.entity-tracking-range.players", 48))); Display.Billboard billboard = Display.Billboard.HORIZONTAL; try { @@ -100,7 +102,17 @@ public class NJNConfig { float scaleX = (float) frameSection.getDouble("scale-x", 1); float scaleY = (float) frameSection.getDouble("scale-y", 1); float scaleZ = (float) frameSection.getDouble("scale-z", 1); - displayContent.addFrame(new DisplayFrame(text, colorFromHex(backgroundColor), scaleX, scaleY, scaleZ)); + boolean shadowed = frameSection.getBoolean("shadowed", false); + byte textOpacity = (byte) Math.min(Math.max(frameSection.getInt("text-opacity", 255), 0), 255) ; + displayContent.addFrame(new DisplayFrame( + text, + colorFromHex(backgroundColor), + scaleX, + scaleY, + scaleZ, + shadowed, + textOpacity + )); }); Permission permission = new Permission("notjustnameplates.display." + displayContentSection.getName(), "Allows player to use " + displayContentSection.getName() + " nameplate", PermissionDefault.FALSE); plugin.getServer().getPluginManager().addPermission(permission); diff --git a/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayContent.java b/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayContent.java index f672fe3..7fb5824 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayContent.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayContent.java @@ -10,7 +10,7 @@ import java.util.List; public class DisplayContent { private final List frames = new ArrayList<>(); - private int refreshRate, interpolationDuration, interpolationDelay, currentFrame; + private int refreshRate, interpolationDuration, interpolationDelay, currentFrame, viewRange; private Display.Billboard billboard = Display.Billboard.HORIZONTAL; private boolean seeThrough = false; @@ -60,6 +60,14 @@ public class DisplayContent { return interpolationDuration; } + public void setViewRange(int viewRange) { + this.viewRange = viewRange; + } + + public int getViewRange() { + return viewRange; + } + public void addFrame(DisplayFrame frame) { frames.add(frame); } diff --git a/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java b/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java index 5aebef1..617bde0 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java @@ -2,5 +2,5 @@ package me.youhavetrouble.notjustnameplates.displays; import org.bukkit.Color; -public record DisplayFrame(String text, Color backgroundColor, float scaleX, float scaleY, float scaleZ) { +public record DisplayFrame(String text, Color backgroundColor, float scaleX, float scaleY, float scaleZ, boolean shadowed, byte textOpacity) { } diff --git a/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java b/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java index fd501b2..d917b91 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java @@ -4,9 +4,6 @@ import me.youhavetrouble.notjustnameplates.NotJustNameplates; import me.youhavetrouble.notjustnameplates.displays.DisplayContent; import me.youhavetrouble.notjustnameplates.text.TextParser; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.minimessage.MiniMessage; -import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; -import net.kyori.adventure.text.minimessage.tag.standard.StandardTags; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.GameMode; @@ -63,9 +60,12 @@ public class Nameplate { textDisplay.setAlignment(alignment); textDisplay.setBillboard(this.content.getBillboard()); textDisplay.setSeeThrough(this.content.getSeeThrough()); + textDisplay.setViewRange(content.getViewRange()); textDisplay.setShadowRadius(0); textDisplay.setInterpolationDuration(content.getInterpolationDuration()); textDisplay.setInterpolationDelay(content.getInterpolationDelay()); + textDisplay.setShadowed(content.getCurrentFrame().shadowed()); + textDisplay.setTextOpacity(content.getCurrentFrame().textOpacity()); Color backgroundColor = this.content.getCurrentFrame().backgroundColor(); if (backgroundColor != null) textDisplay.setBackgroundColor(backgroundColor); @@ -152,6 +152,8 @@ public class Nameplate { textDisplay.text(parseText(this.content.getCurrentFrame().text(), player)); textDisplay.setBillboard(this.content.getBillboard()); + textDisplay.setShadowed(content.getCurrentFrame().shadowed()); + textDisplay.setTextOpacity(content.getCurrentFrame().textOpacity()); textDisplay.setTransformation(new Transformation( new Vector3f(0, heightOffset, 0), // offset