diff --git a/build.gradle.kts b/build.gradle.kts index 359d3d3..559ce2d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "me.youhavetrouble" -version = "1.5.0" +version = "1.6.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 e996805..4438c5d 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/NJNConfig.java @@ -9,6 +9,7 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Display; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; +import org.joml.Vector3f; import javax.annotation.Nullable; import java.util.HashMap; @@ -102,14 +103,16 @@ 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); + float offsetX = (float) frameSection.getDouble("offset-x", 0); + float offsetY = (float) frameSection.getDouble("offset-y", 0); + float offsetZ = (float) frameSection.getDouble("offset-z", 0); boolean shadowed = frameSection.getBoolean("shadowed", false); - byte textOpacity = (byte) Math.min(Math.max(frameSection.getInt("text-opacity", 255), 0), 255) ; + byte textOpacity = (byte) Math.min(Math.max(frameSection.getInt("text-opacity", 255), 0), 255); displayContent.addFrame(new DisplayFrame( text, colorFromHex(backgroundColor), - scaleX, - scaleY, - scaleZ, + new Vector3f(scaleX, scaleY, scaleZ), + new Vector3f(offsetX, offsetY, offsetZ), shadowed, textOpacity )); diff --git a/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java b/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java index 617bde0..d41d7de 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/displays/DisplayFrame.java @@ -1,6 +1,14 @@ package me.youhavetrouble.notjustnameplates.displays; import org.bukkit.Color; +import org.joml.Vector3f; -public record DisplayFrame(String text, Color backgroundColor, float scaleX, float scaleY, float scaleZ, boolean shadowed, byte textOpacity) { +public record DisplayFrame( + String text, + Color backgroundColor, + Vector3f scale, + Vector3f offset, + 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 9a8e5fd..76d3e62 100644 --- a/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java +++ b/src/main/java/me/youhavetrouble/notjustnameplates/nameplates/Nameplate.java @@ -19,9 +19,7 @@ import org.bukkit.util.Transformation; import org.jetbrains.annotations.NotNull; import org.joml.AxisAngle4f; import org.joml.Vector3f; -import org.kitteh.vanish.VanishCheck; import org.kitteh.vanish.VanishPlugin; -import org.kitteh.vanish.staticaccess.VanishNoPacket; import java.util.UUID; @@ -32,7 +30,6 @@ public class Nameplate { protected boolean forceHide = false; private DisplayContent content; private final UUID playerUuid; - private final float heightOffset = 0.7f; private TextDisplay.TextAlignment alignment = TextDisplay.TextAlignment.CENTER; private boolean visibleForOwner = false; @@ -78,13 +75,9 @@ public class Nameplate { textDisplay.text(parseText(this.content.getCurrentFrame().text(), player)); textDisplay.setTransformation(new Transformation( - new Vector3f(0, heightOffset, 0), // offset + content.getCurrentFrame().offset(), new AxisAngle4f(0, 0, 0, 0), // left rotation - new Vector3f( - content.getCurrentFrame().scaleX(), - content.getCurrentFrame().scaleY(), - content.getCurrentFrame().scaleZ() - ), // scale + content.getCurrentFrame().scale(), new AxisAngle4f(0, 0, 0, 0) // right rotation )); }); @@ -176,15 +169,10 @@ public class Nameplate { 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 + content.getCurrentFrame().offset(), new AxisAngle4f(0, 0, 0, 0), // left rotation - new Vector3f( - content.getCurrentFrame().scaleX(), - content.getCurrentFrame().scaleY(), - content.getCurrentFrame().scaleZ() - ), // scale + content.getCurrentFrame().scale(), new AxisAngle4f(0, 0, 0, 0) // right rotation )); @@ -195,9 +183,6 @@ public class Nameplate { textDisplay.setBackgroundColor(backgroundColor); } - textDisplay.setInterpolationDuration(content.getInterpolationDuration()); - textDisplay.setInterpolationDelay(content.getInterpolationDelay()); - setVisibleForOwner(this.visibleForOwner || player.hasPermission("notjustnameplates.seeown")); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4aa1618..0022cf8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,10 +3,11 @@ nameplates: default: refresh-rate: 10 - billboard: "vertical" + billboard: "center" frames: 1: text: "" + offset-y: 0.2 messages: config-reloaded: "NJN Config reloaded."