add a few additional options

This commit is contained in:
2023-08-01 18:36:09 +02:00
parent 7f05194461
commit 48284dc0b5
5 changed files with 29 additions and 7 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ plugins {
}
group = "me.youhavetrouble"
version = "1.1.0"
version = "1.2.0"
description = "Nameplates using display entities"
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);
@@ -10,7 +10,7 @@ import java.util.List;
public class DisplayContent {
private final List<DisplayFrame> 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);
}
@@ -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) {
}
@@ -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