diff --git a/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java b/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java index 6dc0bd3..8ca5ca6 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java @@ -80,6 +80,9 @@ public class NJNConfig { DisplayContent displayContent = new DisplayContent(); displayContent.setRefreshRate(displayContentSection.getInt("refresh-rate", 0)); + displayContent.setSeeThrough(displayContentSection.getBoolean("see-through", false)); + displayContent.setInterpolationDelay(displayContentSection.getInt("interpolation-delay", displayContent.getRefreshRate())); + displayContent.setInterpolationDuration(displayContentSection.getInt("interpolation-duration", displayContent.getRefreshRate())); Display.Billboard billboard = Display.Billboard.HORIZONTAL; try { @@ -94,7 +97,10 @@ public class NJNConfig { if (frameSection == null) return; String text = frameSection.getString("text", null); String backgroundColor = frameSection.getString("background"); - displayContent.addFrame(new DisplayFrame(text, colorFromHex(backgroundColor))); + float scaleX = (float) frameSection.getDouble("scale-x", 1); + float scaleY = (float) frameSection.getDouble("scale-y", 1); + float scaleZ = (float) frameSection.getDouble("offset-z", 1); + displayContent.addFrame(new DisplayFrame(text, colorFromHex(backgroundColor), scaleX, scaleY, scaleZ)); }); 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 57c334f..f672fe3 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayContent.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayContent.java @@ -10,12 +10,12 @@ import java.util.List; public class DisplayContent { private final List frames = new ArrayList<>(); - private int refreshRate = 0; - private int currentFrame = 0; - + private int refreshRate, interpolationDuration, interpolationDelay, currentFrame; private Display.Billboard billboard = Display.Billboard.HORIZONTAL; + private boolean seeThrough = false; - public DisplayContent() {} + public DisplayContent() { + } /** * Set the refresh rate of the display in ticks. 0 means no refresh rate. @@ -36,6 +36,30 @@ public class DisplayContent { return billboard; } + public void setSeeThrough(boolean seeThrough) { + this.seeThrough = seeThrough; + } + + public boolean getSeeThrough() { + return seeThrough; + } + + public void setInterpolationDelay(int interpolationDelay) { + this.interpolationDelay = interpolationDelay; + } + + public void setInterpolationDuration(int interpolationDuration) { + this.interpolationDuration = interpolationDuration; + } + + public int getInterpolationDelay() { + return interpolationDelay; + } + + public int getInterpolationDuration() { + return interpolationDuration; + } + 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 dd9779e..5aebef1 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java @@ -1,13 +1,6 @@ package me.youhavetrouble.notjustnameplates.displays; import org.bukkit.Color; -import org.jetbrains.annotations.Nullable; - -public record DisplayFrame(String text, Color backgroundColor) { - - public DisplayFrame(@Nullable String text, @Nullable Color backgroundColor) { - this.text = text; - this.backgroundColor = backgroundColor; - } +public record DisplayFrame(String text, Color backgroundColor, float scaleX, float scaleY, float scaleZ) { } diff --git a/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java b/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java index 3315796..4ee91b5 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java @@ -60,20 +60,26 @@ public class Nameplate { textDisplay.setPersistent(false); textDisplay.setAlignment(alignment); textDisplay.setBillboard(this.content.getBillboard()); + textDisplay.setSeeThrough(this.content.getSeeThrough()); textDisplay.setShadowRadius(0); + textDisplay.setInterpolationDuration(content.getInterpolationDuration()); + textDisplay.setInterpolationDelay(content.getInterpolationDelay()); Color backgroundColor = this.content.getCurrentFrame().backgroundColor(); if (backgroundColor != null) textDisplay.setBackgroundColor(backgroundColor); textDisplay.text(parseText(this.content.getCurrentFrame().text(), player)); - textDisplay.setTransformation( - new Transformation( - new Vector3f(0, heightOffset, 0), // offset - new AxisAngle4f(0, 0, 0, 0), // left rotation - new Vector3f(1, 1, 1), // scale - new AxisAngle4f(0, 0, 0, 0) // right rotation - )); + textDisplay.setTransformation(new Transformation( + new Vector3f(0, heightOffset, 0), // offset + new AxisAngle4f(0, 0, 0, 0), // left rotation + new Vector3f( + content.getCurrentFrame().scaleX(), + content.getCurrentFrame().scaleY(), + content.getCurrentFrame().scaleZ() + ), // scale + new AxisAngle4f(0, 0, 0, 0) // right rotation + )); }); if (!this.visibleForOwner) { player.hideEntity(NotJustNameplates.getInstance(), textDisplay); @@ -144,7 +150,17 @@ public class Nameplate { textDisplay.text(parseText(this.content.getCurrentFrame().text(), player)); textDisplay.setBillboard(this.content.getBillboard()); - textDisplay.setInterpolationDuration(content.getRefreshRate()); + + textDisplay.setTransformation(new Transformation( + new Vector3f(0, heightOffset, 0), // offset + new AxisAngle4f(0, 0, 0, 0), // left rotation + new Vector3f( + content.getCurrentFrame().scaleX(), + content.getCurrentFrame().scaleY(), + content.getCurrentFrame().scaleZ() + ), // scale + new AxisAngle4f(0, 0, 0, 0) // right rotation + )); Color backgroundColor = this.content.getCurrentFrame().backgroundColor(); if (backgroundColor == null) { @@ -153,6 +169,9 @@ public class Nameplate { textDisplay.setBackgroundColor(backgroundColor); } + textDisplay.setInterpolationDuration(content.getInterpolationDuration()); + textDisplay.setInterpolationDelay(content.getInterpolationDelay()); + setVisibleForOwner(this.visibleForOwner || player.hasPermission("notjustnameplates.seeown")); }