mirror of
https://github.com/YouHaveTrouble/NotJustNameplates.git
synced 2026-05-12 06:26:58 +00:00
respawn the entity if display content changes
This commit is contained in:
@@ -6,6 +6,8 @@ import org.bukkit.Color;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
@@ -20,6 +22,13 @@ public class NJNConfig {
|
||||
|
||||
protected NJNConfig(NotJustNameplates plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getServer().getPluginManager().getPermissions().forEach(permission -> {
|
||||
if (permission.getName().startsWith("notjustnameplates.display.")) {
|
||||
plugin.getServer().getPluginManager().removePermission(permission);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.saveDefaultConfig();
|
||||
plugin.reloadConfig();
|
||||
|
||||
@@ -86,6 +95,8 @@ public class NJNConfig {
|
||||
String backgroundColor = frameSection.getString("background");
|
||||
displayContent.addFrame(new DisplayFrame(text, colorFromHex(backgroundColor)));
|
||||
});
|
||||
Permission permission = new Permission("notjustnameplates.display." + displayContentSection.getName(), "Allows player to use " + displayContentSection.getName() + " nameplate", PermissionDefault.FALSE);
|
||||
plugin.getServer().getPluginManager().addPermission(permission);
|
||||
return displayContent;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,17 @@ public final class NotJustNameplates extends JavaPlugin {
|
||||
});
|
||||
|
||||
if (time % 20 != 0) return;
|
||||
updateNameplatesBasedOnPermission();
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
public void reloadPluginConfig() {
|
||||
config = new NJNConfig(this);
|
||||
nameplateManager.reloadNameplates();
|
||||
updateNameplatesBasedOnPermission();
|
||||
}
|
||||
|
||||
private void updateNameplatesBasedOnPermission() {
|
||||
nameplateManager.getNameplates().forEach(((uuid, nameplate) -> {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null || !player.isOnline()) return;
|
||||
@@ -59,13 +70,6 @@ public final class NotJustNameplates extends JavaPlugin {
|
||||
}
|
||||
nameplate.setContent(config.getDisplayContent("default"));
|
||||
}));
|
||||
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
public void reloadPluginConfig() {
|
||||
config = new NJNConfig(this);
|
||||
nameplateManager.reloadNameplates();
|
||||
}
|
||||
|
||||
public TeamManager getTeamManager() {
|
||||
|
||||
@@ -81,7 +81,9 @@ public class Nameplate {
|
||||
}
|
||||
|
||||
public void setContent(@NotNull DisplayContent content) {
|
||||
if (this.content == content) return;
|
||||
this.content = content;
|
||||
Bukkit.getScheduler().runTask(NotJustNameplates.getInstance(), this::remove);
|
||||
}
|
||||
|
||||
public void setAlignment(@NotNull TextDisplay.TextAlignment alignment) {
|
||||
|
||||
Reference in New Issue
Block a user