Implement display offset, refactor scaling and upgrade version

The main change introduced is the implementation of display offset within nameplates. Previously applied scaling calculations have been refactored and simplified by using the Vector3f class. The software version has also been upgraded from 1.5.0 to 1.6.0 in preparation for release. Other minor adjustments include changing the default 'billboard' setting from 'vertical' to 'center'.
This commit is contained in:
2024-02-28 22:41:57 +01:00
parent 061d7ecfef
commit 9ff6223829
5 changed files with 23 additions and 26 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ plugins {
}
group = "me.youhavetrouble"
version = "1.5.0"
version = "1.6.0"
description = "Nameplates using display entities"
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
));
@@ -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
) {
}
@@ -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"));
}
+2 -1
View File
@@ -3,10 +3,11 @@
nameplates:
default:
refresh-rate: 10
billboard: "vertical"
billboard: "center"
frames:
1:
text: "<placeholder:displayname>"
offset-y: 0.2
messages:
config-reloaded: "<aqua>NJN Config reloaded."