From 9c696a9578a894a1aefc6ff75a5ef6d68984bb28 Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Sun, 7 Aug 2022 23:08:23 +0800 Subject: [PATCH] 1.8.4 --- build.gradle | 4 +- .../customnameplates/ConfigManager.java | 13 +++ .../customnameplates/CustomNameplates.java | 33 +++++-- .../bossbar/adventure/BossBarSenderA.java | 1 - .../bossbar/protocollib/BossBarSenderP.java | 2 +- .../customnameplates/commands/Execute.java | 27 ++--- .../commands/TabComplete.java | 12 +-- .../customnameplates/font/FontWidth.java | 17 +++- .../customnameplates/font/FontWidthThin.java | 17 +++- .../hook/{ParsePapi.java => PapiHook.java} | 6 +- .../listener/PacketsListener.java | 81 --------------- .../listener/PlayerListener.java | 92 +++++++++++++----- .../resource/ResourceManager.java | 16 +-- .../scoreboard/NameplatesTeam.java | 29 ++---- .../scoreboard/ScoreBoardManager.java | 15 +-- src/main/resources/backgrounds/b0.png | Bin 1410 -> 1615 bytes src/main/resources/backgrounds/b1.png | Bin 1404 -> 1609 bytes src/main/resources/backgrounds/b128.png | Bin 1415 -> 1621 bytes src/main/resources/backgrounds/b16.png | Bin 1409 -> 1614 bytes src/main/resources/backgrounds/b2.png | Bin 1406 -> 1611 bytes src/main/resources/backgrounds/b32.png | Bin 1389 -> 1595 bytes src/main/resources/backgrounds/b4.png | Bin 1410 -> 1615 bytes src/main/resources/backgrounds/b64.png | Bin 1408 -> 1614 bytes src/main/resources/backgrounds/b8.png | Bin 1407 -> 1612 bytes src/main/resources/bossbar.yml | 22 ++++- src/main/resources/char-width.yml | 6 ++ src/main/resources/config.yml | 5 +- src/main/resources/custom-papi.yml | 3 + src/main/resources/plugin.yml | 36 ++++++- 29 files changed, 237 insertions(+), 200 deletions(-) rename src/main/java/net/momirealms/customnameplates/hook/{ParsePapi.java => PapiHook.java} (76%) delete mode 100644 src/main/java/net/momirealms/customnameplates/listener/PacketsListener.java create mode 100644 src/main/resources/char-width.yml diff --git a/build.gradle b/build.gradle index 88447dd..622e9db 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '1.8.1' +version = '1.8.4' repositories { mavenCentral() @@ -44,7 +44,7 @@ dependencies { implementation('net.kyori:adventure-api:4.11.0') implementation('net.kyori:adventure-platform-bukkit:4.1.1') implementation('net.kyori:adventure-text-minimessage:4.11.0') - implementation("net.kyori:adventure-text-serializer-gson:4.11.0") + implementation('net.kyori:adventure-text-serializer-gson:4.11.0') } def targetJavaVersion = 16 diff --git a/src/main/java/net/momirealms/customnameplates/ConfigManager.java b/src/main/java/net/momirealms/customnameplates/ConfigManager.java index f020492..97b6e02 100644 --- a/src/main/java/net/momirealms/customnameplates/ConfigManager.java +++ b/src/main/java/net/momirealms/customnameplates/ConfigManager.java @@ -41,6 +41,7 @@ public class ConfigManager { public static TreeMap bossbarsP = new TreeMap<>(); public static HashMap papiBG = new HashMap<>(); public static HashMap papiNP = new HashMap<>(); + public static HashMap fontWidth = new HashMap<>(); public static YamlConfiguration getConfig(String configName) { File file = new File(CustomNameplates.instance.getDataFolder(), configName); @@ -65,6 +66,18 @@ public class ConfigManager { useAdventure = bossbarmode.getString("mode").equalsIgnoreCase("Adventure"); } + + public static void loadWidth(){ + + fontWidth.clear(); + + YamlConfiguration config = getConfig("char-width.yml"); + config.getConfigurationSection("").getKeys(false).forEach(key -> { + fontWidth.put(key.charAt(0), config.getInt(key)); + }); + AdventureManager.consoleMessage("[CustomNameplates] Loaded " + fontWidth.size() + " custom char width"); + } + public static class MainConfig{ public static String namespace; public static String fontName; diff --git a/src/main/java/net/momirealms/customnameplates/CustomNameplates.java b/src/main/java/net/momirealms/customnameplates/CustomNameplates.java index 887d402..c254da1 100644 --- a/src/main/java/net/momirealms/customnameplates/CustomNameplates.java +++ b/src/main/java/net/momirealms/customnameplates/CustomNameplates.java @@ -30,7 +30,6 @@ import net.momirealms.customnameplates.data.SqlHandler; import net.momirealms.customnameplates.helper.LibraryLoader; import net.momirealms.customnameplates.hook.Placeholders; import net.momirealms.customnameplates.listener.PlayerListener; -import net.momirealms.customnameplates.listener.PacketsListener; import net.momirealms.customnameplates.resource.ResourceManager; import net.momirealms.customnameplates.scoreboard.ScoreBoardManager; import org.bukkit.Bukkit; @@ -48,11 +47,10 @@ public final class CustomNameplates extends JavaPlugin { private ResourceManager resourceManager; private DataManager dataManager; private ScoreBoardManager scoreBoardManager; + private Placeholders placeholders; private Timer timer; - public ResourceManager getResourceManager() { - return this.resourceManager; - } + public ResourceManager getResourceManager() {return this.resourceManager;} public DataManager getDataManager() { return this.dataManager; } public ScoreBoardManager getScoreBoardManager() { return this.scoreBoardManager; } @@ -71,6 +69,7 @@ public final class CustomNameplates extends JavaPlugin { ConfigManager.loadModule(); ConfigManager.MainConfig.ReloadConfig(); ConfigManager.Message.ReloadConfig(); + ConfigManager.loadWidth(); if (ConfigManager.bossbar){ ConfigManager.loadBossBar(); if (ConfigManager.useAdventure){ @@ -89,17 +88,17 @@ public final class CustomNameplates extends JavaPlugin { if (ConfigManager.nameplate){ ConfigManager.DatabaseConfig.LoadConfig(); Bukkit.getPluginManager().registerEvents(new PlayerListener(this),this); - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketsListener(this)); } if (ConfigManager.MainConfig.placeholderAPI){ - new Placeholders().register(); + placeholders = new Placeholders(); + placeholders.register(); AdventureManager.consoleMessage("[CustomNameplates] PlaceholderAPI Hooked!"); } if (ConfigManager.MainConfig.tab){ AdventureManager.consoleMessage("[CustomNameplates] TAB Hooked!"); } Objects.requireNonNull(Bukkit.getPluginCommand("customnameplates")).setExecutor(new Execute(this)); - Objects.requireNonNull(Bukkit.getPluginCommand("customnameplates")).setTabCompleter(new TabComplete(this)); + Objects.requireNonNull(Bukkit.getPluginCommand("customnameplates")).setTabCompleter(new TabComplete()); this.resourceManager = new ResourceManager(this); this.dataManager = new DataManager(this); this.scoreBoardManager = new ScoreBoardManager(this); @@ -122,9 +121,27 @@ public final class CustomNameplates extends JavaPlugin { if (timer != null){ timer.stopTimer(timer.getTaskID()); } - if(adventure != null) { + if (adventure != null) { adventure.close(); adventure = null; } + if (protocolManager != null){ + protocolManager = null; + } + if (placeholders != null){ + placeholders.unregister(); + } + if (resourceManager != null){ + resourceManager = null; + } + if (scoreBoardManager != null){ + scoreBoardManager = null; + } + if (dataManager != null){ + dataManager = null; + } + if (instance != null){ + instance = null; + } } } diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/adventure/BossBarSenderA.java b/src/main/java/net/momirealms/customnameplates/bossbar/adventure/BossBarSenderA.java index a7c9bbf..c4162c1 100644 --- a/src/main/java/net/momirealms/customnameplates/bossbar/adventure/BossBarSenderA.java +++ b/src/main/java/net/momirealms/customnameplates/bossbar/adventure/BossBarSenderA.java @@ -21,7 +21,6 @@ import me.clip.placeholderapi.PlaceholderAPI; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.minimessage.MiniMessage; import net.momirealms.customnameplates.ConfigManager; import net.momirealms.customnameplates.CustomNameplates; diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/protocollib/BossBarSenderP.java b/src/main/java/net/momirealms/customnameplates/bossbar/protocollib/BossBarSenderP.java index 6950f57..561ee64 100644 --- a/src/main/java/net/momirealms/customnameplates/bossbar/protocollib/BossBarSenderP.java +++ b/src/main/java/net/momirealms/customnameplates/bossbar/protocollib/BossBarSenderP.java @@ -37,9 +37,9 @@ public class BossBarSenderP extends BukkitRunnable { public void showBossbar(){ this.packet = new PacketContainer(PacketType.Play.Server.BOSS); - packet.setMeta("id", UUID.randomUUID()); this.overlay = bossbarConfig.getOverlay(); this.barColor = bossbarConfig.getColor(); + packet.getModifier().write(0, UUID.randomUUID()); InternalStructure internalStructure = packet.getStructures().read(1); if (ConfigManager.MainConfig.placeholderAPI){ this.text = PlaceholderAPI.setPlaceholders(player, bossbarConfig.getText()); diff --git a/src/main/java/net/momirealms/customnameplates/commands/Execute.java b/src/main/java/net/momirealms/customnameplates/commands/Execute.java index 9e6554f..0814023 100644 --- a/src/main/java/net/momirealms/customnameplates/commands/Execute.java +++ b/src/main/java/net/momirealms/customnameplates/commands/Execute.java @@ -31,10 +31,11 @@ import net.momirealms.customnameplates.AdventureManager; import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.data.DataManager; import net.momirealms.customnameplates.font.FontCache; -import net.momirealms.customnameplates.hook.ParsePapi; +import net.momirealms.customnameplates.hook.PapiHook; import net.momirealms.customnameplates.hook.TABHook; import net.momirealms.customnameplates.nameplates.NameplateUtil; import net.momirealms.customnameplates.scoreboard.NameplatesTeam; +import net.momirealms.customnameplates.scoreboard.ScoreBoardManager; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -80,6 +81,7 @@ public class Execute implements CommandExecutor { if (sender.hasPermission("customnameplates.reload") || sender.isOp()) { ConfigManager.MainConfig.ReloadConfig(); ConfigManager.Message.ReloadConfig(); + ConfigManager.loadWidth(); if (ConfigManager.actionbar){ ConfigManager.ActionbarConfig.LoadConfig(); } @@ -123,9 +125,9 @@ public class Execute implements CommandExecutor { } DataManager.cache.get(player.getUniqueId()).equipNameplate(args[1]); if (ConfigManager.MainConfig.tab){ - this.plugin.getScoreBoardManager().getTeam(TABHook.getTABTeam(player.getName())).updateNameplates(); + ScoreBoardManager.teams.get(TABHook.getTABTeam(player.getName())).updateNameplates(); }else { - this.plugin.getScoreBoardManager().getTeam(player.getName()).updateNameplates(); + ScoreBoardManager.teams.get(player.getName()).updateNameplates(); } this.plugin.getDataManager().savePlayer(player.getUniqueId()); AdventureManager.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.equip.replace("{Nameplate}", plugin.getResourceManager().getNameplateInfo(args[1]).getConfig().getName())); @@ -160,9 +162,9 @@ public class Execute implements CommandExecutor { } DataManager.cache.get(player.getUniqueId()).equipNameplate(args[2]); if (ConfigManager.MainConfig.tab){ - this.plugin.getScoreBoardManager().getTeam(TABHook.getTABTeam(args[1])).updateNameplates(); + ScoreBoardManager.teams.get(TABHook.getTABTeam(args[1])).updateNameplates(); }else { - this.plugin.getScoreBoardManager().getTeam(args[1]).updateNameplates(); + ScoreBoardManager.teams.get(args[1]).updateNameplates(); } this.plugin.getDataManager().savePlayer(player.getUniqueId()); if (sender instanceof Player){ @@ -187,9 +189,9 @@ public class Execute implements CommandExecutor { if (sender instanceof Player player){ DataManager.cache.get(player.getUniqueId()).equipNameplate("none"); if (ConfigManager.MainConfig.tab){ - this.plugin.getScoreBoardManager().getTeam(TABHook.getTABTeam(player.getName())).updateNameplates(); + ScoreBoardManager.teams.get(TABHook.getTABTeam(player.getName())).updateNameplates(); }else { - this.plugin.getScoreBoardManager().getTeam(player.getName()).updateNameplates(); + ScoreBoardManager.teams.get(player.getName()).updateNameplates(); } this.plugin.getDataManager().savePlayer(player.getUniqueId()); AdventureManager.playerMessage(player, ConfigManager.Message.prefix + ConfigManager.Message.unequip); @@ -212,9 +214,9 @@ public class Execute implements CommandExecutor { Player player = Bukkit.getPlayer(args[1]); DataManager.cache.get(player.getUniqueId()).equipNameplate("none"); if (ConfigManager.MainConfig.tab){ - this.plugin.getScoreBoardManager().getTeam(TABHook.getTABTeam(args[1])).updateNameplates(); + ScoreBoardManager.teams.get(TABHook.getTABTeam(args[1])).updateNameplates(); }else { - this.plugin.getScoreBoardManager().getTeam(args[1]).updateNameplates(); + ScoreBoardManager.teams.get(args[1]).updateNameplates(); } this.plugin.getDataManager().savePlayer(player.getUniqueId()); if (sender instanceof Player){ @@ -293,8 +295,8 @@ public class Execute implements CommandExecutor { String playerPrefix; String playerSuffix; if (ConfigManager.MainConfig.placeholderAPI) { - playerPrefix = ParsePapi.parsePlaceholders(player, ConfigManager.MainConfig.player_prefix); - playerSuffix = ParsePapi.parsePlaceholders(player, ConfigManager.MainConfig.player_suffix); + playerPrefix = PapiHook.parsePlaceholders(player, ConfigManager.MainConfig.player_prefix); + playerSuffix = PapiHook.parsePlaceholders(player, ConfigManager.MainConfig.player_suffix); }else { playerPrefix = ConfigManager.MainConfig.player_prefix; playerSuffix = ConfigManager.MainConfig.player_suffix; @@ -345,6 +347,7 @@ public class Execute implements CommandExecutor { AdventureManager.playerMessage(player,"/nameplates preview - preview your nameplate"); AdventureManager.playerMessage(player,"/nameplates forcepreview - force a player to preview a nameplate"); AdventureManager.playerMessage(player,"/nameplates list - list your available nameplates"); + AdventureManager.playerMessage(player,"/nameplates generate - generate the RP"); } }else { AdventureManager.consoleMessage("/nameplates help - show the command list"); @@ -356,6 +359,7 @@ public class Execute implements CommandExecutor { AdventureManager.consoleMessage("/nameplates preview - preview your nameplate"); AdventureManager.consoleMessage("/nameplates forcepreview - force a player to preview a nameplate"); AdventureManager.consoleMessage("/nameplates list - list your available nameplates"); + AdventureManager.consoleMessage("/nameplates generate - generate the RP"); } return true; } @@ -364,6 +368,7 @@ public class Execute implements CommandExecutor { } private void showNameplate(Player player, Component component) { + ArmorStand entity = player.getWorld().spawn(player.getLocation().add(0,0.8,0), ArmorStand.class, a -> { a.setInvisible(true); a.setCollidable(false); diff --git a/src/main/java/net/momirealms/customnameplates/commands/TabComplete.java b/src/main/java/net/momirealms/customnameplates/commands/TabComplete.java index fe4368d..27bd2b1 100644 --- a/src/main/java/net/momirealms/customnameplates/commands/TabComplete.java +++ b/src/main/java/net/momirealms/customnameplates/commands/TabComplete.java @@ -17,7 +17,7 @@ package net.momirealms.customnameplates.commands; -import net.momirealms.customnameplates.CustomNameplates; +import net.momirealms.customnameplates.resource.ResourceManager; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -33,12 +33,6 @@ import java.util.List; public class TabComplete implements TabCompleter { - private final CustomNameplates plugin; - - public TabComplete(CustomNameplates plugin){ - this.plugin = plugin; - } - @Override @ParametersAreNonnullByDefault public @Nullable List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { @@ -95,7 +89,7 @@ public class TabComplete implements TabCompleter { String permission = info.getPermission().toLowerCase(); if (permission.startsWith("customnameplates.equip.")) { permission = StringUtils.replace(permission, "customnameplates.equip.", ""); - if (this.plugin.getResourceManager().caches.get(permission) != null){ + if (ResourceManager.caches.get(permission) != null){ availableNameplates.add(permission); } } @@ -105,6 +99,6 @@ public class TabComplete implements TabCompleter { } private List nameplates(){ - return new ArrayList<>(this.plugin.getResourceManager().caches.keySet()); + return new ArrayList<>(ResourceManager.caches.keySet()); } } diff --git a/src/main/java/net/momirealms/customnameplates/font/FontWidth.java b/src/main/java/net/momirealms/customnameplates/font/FontWidth.java index 12b6b5a..94ebdd1 100644 --- a/src/main/java/net/momirealms/customnameplates/font/FontWidth.java +++ b/src/main/java/net/momirealms/customnameplates/font/FontWidth.java @@ -17,6 +17,8 @@ package net.momirealms.customnameplates.font; +import net.momirealms.customnameplates.ConfigManager; + public enum FontWidth { A('A', 5), a('a', 5), B('B', 5), b('b', 5), @@ -72,13 +74,18 @@ public enum FontWidth { /* 获取每个字符的像素宽度 */ - public static FontWidth getInfo(char c) { + public static int getInfo(char c) { for (FontWidth minecraftFontWidth : values()) { if (minecraftFontWidth.getCharacter() == c) { - return minecraftFontWidth; + return minecraftFontWidth.length; } } - return FontWidth.DEFAULT; + int custom = ConfigManager.fontWidth.get(c); + if (custom != 0){ + return custom; + }else { + return 8; + } } /* @@ -88,8 +95,8 @@ public enum FontWidth { int length = s.length(); int n = 0; for (int i = 0; i < length; i++) { - n += getInfo(s.charAt(i)).getLength(); + n += getInfo(s.charAt(i)); } - return n + FontWidth.IN_BETWEEN.getLength() * (length - 1); //总长还需加上字符间距 + return n + length - 1; //总长还需加上字符间距 } } diff --git a/src/main/java/net/momirealms/customnameplates/font/FontWidthThin.java b/src/main/java/net/momirealms/customnameplates/font/FontWidthThin.java index 11c7801..97a1020 100644 --- a/src/main/java/net/momirealms/customnameplates/font/FontWidthThin.java +++ b/src/main/java/net/momirealms/customnameplates/font/FontWidthThin.java @@ -17,6 +17,8 @@ package net.momirealms.customnameplates.font; +import net.momirealms.customnameplates.ConfigManager; + public enum FontWidthThin { A('A', 3), a('a', 3), B('B', 3), b('b', 3), @@ -72,13 +74,18 @@ public enum FontWidthThin { /* 获取每个字符的像素宽度 */ - public static FontWidthThin getInfo(char c) { + public static int getInfo(char c) { for (FontWidthThin minecraftFontWidth : values()) { if (minecraftFontWidth.getCharacter() == c) { - return minecraftFontWidth; + return minecraftFontWidth.length; } } - return FontWidthThin.DEFAULT; + int custom = ConfigManager.fontWidth.get(c); + if (custom != 0){ + return custom; + }else { + return 8; + } } /* @@ -88,8 +95,8 @@ public enum FontWidthThin { int length = s.length(); int n = 0; for (int i = 0; i < length; i++) { - n += getInfo(s.charAt(i)).getLength(); + n += getInfo(s.charAt(i)); } - return n + FontWidthThin.IN_BETWEEN.getLength() * (length - 1); //总长还需加上字符间距 + return n + length - 1; //总长还需加上字符间距 } } diff --git a/src/main/java/net/momirealms/customnameplates/hook/ParsePapi.java b/src/main/java/net/momirealms/customnameplates/hook/PapiHook.java similarity index 76% rename from src/main/java/net/momirealms/customnameplates/hook/ParsePapi.java rename to src/main/java/net/momirealms/customnameplates/hook/PapiHook.java index 831c41a..a83060b 100644 --- a/src/main/java/net/momirealms/customnameplates/hook/ParsePapi.java +++ b/src/main/java/net/momirealms/customnameplates/hook/PapiHook.java @@ -18,13 +18,11 @@ package net.momirealms.customnameplates.hook; import me.clip.placeholderapi.PlaceholderAPI; -import org.apache.commons.lang.StringUtils; import org.bukkit.entity.Player; -public class ParsePapi { +public class PapiHook { public static String parsePlaceholders(Player player, String papi) { - String s = StringUtils.replace(StringUtils.replace(papi, "%player_name%", player.getName()), "%player_displayname%", player.getDisplayName()); - return PlaceholderAPI.setPlaceholders(player, s); + return PlaceholderAPI.setPlaceholders(player, papi); } } diff --git a/src/main/java/net/momirealms/customnameplates/listener/PacketsListener.java b/src/main/java/net/momirealms/customnameplates/listener/PacketsListener.java deleted file mode 100644 index bd87a96..0000000 --- a/src/main/java/net/momirealms/customnameplates/listener/PacketsListener.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) <2022> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.momirealms.customnameplates.listener; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.InternalStructure; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.utility.MinecraftReflection; -import com.comphenix.protocol.wrappers.WrappedChatComponent; -import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import net.momirealms.customnameplates.ConfigManager; -import net.momirealms.customnameplates.CustomNameplates; -import net.momirealms.customnameplates.data.DataManager; -import net.momirealms.customnameplates.scoreboard.NameplatesTeam; -import org.bukkit.ChatColor; - -import java.util.Optional; - -public class PacketsListener extends PacketAdapter { - - private final CustomNameplates plugin; - - public PacketsListener(CustomNameplates plugin) { - super(plugin, ListenerPriority.HIGHEST, PacketType.Play.Server.SCOREBOARD_TEAM); - this.plugin = plugin; - } - - public void onPacketSending(PacketEvent event) { - Integer n = event.getPacket().getIntegers().read(0); - if (n != 2) { - return; - } - //if (n == 0) System.out.println("对玩家" + event.getPlayer().getName() + "发送team创建包"); - //if (n == 2) System.out.println("对玩家"+ event.getPlayer().getName() + "发送team更新包"); - Optional optional = event.getPacket().getOptionalStructures().read(0); - if (optional.isEmpty()) { - return; - } - InternalStructure internalStructure = optional.get(); - String teamName = event.getPacket().getStrings().read(0); - //System.out.println("本次创建/更新的队伍名是" + teamName); - NameplatesTeam team = this.plugin.getScoreBoardManager().getTeam(teamName); - if (team == null) { - //System.out.println("但是这个队伍不存在于缓存中哦,说明那个玩家还没上线"); - return; - } - //System.out.println("这个队伍确实存在于缓存中呢!"); - if (ConfigManager.MainConfig.show_after && (DataManager.cache.get(event.getPlayer().getUniqueId()) == null || DataManager.cache.get(event.getPlayer().getUniqueId()).getAccepted() == 0)) { - //System.out.println("玩家" +event.getPlayer().getName() +"因为没有接受资源包所以没有被显示铭牌"); - internalStructure.getChatComponents().write(1, WrappedChatComponent.fromJson("{\"text\":\"\"}")); - internalStructure.getChatComponents().write(2, WrappedChatComponent.fromJson("{\"text\":\"\"}")); - internalStructure.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0,ChatColor.WHITE); - return; - } - //System.out.println("玩家" +event.getPlayer().getName() +"可以看见队伍" + teamName + "的铭牌"); - if (team.getPrefix() != null) { - internalStructure.getChatComponents().write(1, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(team.getPrefix()))); - } - if (team.getSuffix() != null) { - internalStructure.getChatComponents().write(2, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(team.getSuffix()))); - } - internalStructure.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0,team.getColor()); - } -} diff --git a/src/main/java/net/momirealms/customnameplates/listener/PlayerListener.java b/src/main/java/net/momirealms/customnameplates/listener/PlayerListener.java index 0e17b62..24a39ec 100644 --- a/src/main/java/net/momirealms/customnameplates/listener/PlayerListener.java +++ b/src/main/java/net/momirealms/customnameplates/listener/PlayerListener.java @@ -17,20 +17,31 @@ package net.momirealms.customnameplates.listener; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.InternalStructure; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.utility.MinecraftReflection; +import com.comphenix.protocol.wrappers.WrappedChatComponent; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customnameplates.ConfigManager; import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.data.DataManager; import net.momirealms.customnameplates.data.PlayerData; import net.momirealms.customnameplates.hook.TABHook; +import net.momirealms.customnameplates.scoreboard.NameplatesTeam; import net.momirealms.customnameplates.scoreboard.ScoreBoardManager; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerResourcePackStatusEvent; -import org.bukkit.scoreboard.Scoreboard; -import org.bukkit.scoreboard.Team; + +import java.lang.reflect.InvocationTargetException; +import java.util.Collections; +import java.util.Optional; public record PlayerListener(CustomNameplates plugin) implements Listener { @@ -38,30 +49,20 @@ public record PlayerListener(CustomNameplates plugin) implements Listener { public void onJoin(PlayerJoinEvent event) { this.plugin.getDataManager().loadData(event.getPlayer()); Bukkit.getScheduler().runTaskLaterAsynchronously(CustomNameplates.instance, ()-> { - if (ConfigManager.MainConfig.tab){ - Bukkit.getOnlinePlayers().forEach(player -> this.plugin.getScoreBoardManager().getTeam(TABHook.getTABTeam(player.getName())).updateNameplates()); - }else { - Bukkit.getOnlinePlayers().forEach(player -> this.plugin.getScoreBoardManager().getTeam(player.getName()).updateNameplates()); - } - }, 50); + sendPacketsToPlayer(event.getPlayer()); + }, 40); } @EventHandler public void onQuit(PlayerQuitEvent event) { this.plugin.getDataManager().unloadPlayer(event.getPlayer().getUniqueId()); - Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); - Team team; String teamName; if (ConfigManager.MainConfig.tab){ teamName = TABHook.getTABTeam(event.getPlayer().getName()); }else { teamName = event.getPlayer().getName(); } - team = scoreboard.getTeam(teamName); ScoreBoardManager.teams.remove(teamName); - if (team != null){ - team.unregister(); - } } @EventHandler @@ -73,19 +74,58 @@ public record PlayerListener(CustomNameplates plugin) implements Listener { } if (event.getStatus() == PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED) { playerData.setAccepted(1); - if (ConfigManager.MainConfig.tab){ - Bukkit.getOnlinePlayers().forEach(player -> this.plugin.getScoreBoardManager().getTeam(TABHook.getTABTeam(player.getName())).updateNameplates()); - }else { - Bukkit.getOnlinePlayers().forEach(player -> this.plugin.getScoreBoardManager().getTeam(player.getName()).updateNameplates()); - } - } else if(event.getStatus() == PlayerResourcePackStatusEvent.Status.DECLINED || event.getStatus() == PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD) { - playerData.setAccepted(0); - if (ConfigManager.MainConfig.tab){ - Bukkit.getOnlinePlayers().forEach(player -> this.plugin.getScoreBoardManager().getTeam(TABHook.getTABTeam(player.getName())).updateNameplates()); - }else { - Bukkit.getOnlinePlayers().forEach(player -> this.plugin.getScoreBoardManager().getTeam(player.getName()).updateNameplates()); - } } + else if(event.getStatus() == PlayerResourcePackStatusEvent.Status.DECLINED || event.getStatus() == PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD) { + playerData.setAccepted(0); + } + sendPacketsToPlayer(event.getPlayer()); }, 20); } + + private void sendPacketsToPlayer(Player player){ + + if (ConfigManager.MainConfig.show_after && DataManager.cache.get(player.getUniqueId()).getAccepted() != 1) return; + + Bukkit.getOnlinePlayers().forEach(onlinePlayer -> { + + String teamName; + + if (ConfigManager.MainConfig.tab){ + teamName = TABHook.getTABTeam(onlinePlayer.getName()); + }else { + teamName = onlinePlayer.getName(); + } + + NameplatesTeam team = ScoreBoardManager.teams.get(teamName); + + if (team == null) return; + + PacketContainer packetContainer = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM); + packetContainer.getStrings().write(0, teamName); + + Optional optional = packetContainer.getOptionalStructures().read(0); + if (optional.isEmpty()) { + return; + } + InternalStructure internalStructure1 = optional.get(); + internalStructure1.getChatComponents().write(0, WrappedChatComponent.fromJson("{\"text\":\" "+ onlinePlayer.getName() +" \"}")); + + if (team.getPrefix() != null){ + internalStructure1.getChatComponents().write(1, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(team.getPrefix()))); + } + + if (team.getSuffix() != null){ + internalStructure1.getChatComponents().write(2, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(team.getSuffix()))); + } + + internalStructure1.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0,team.getColor()); + packetContainer.getModifier().write(2, Collections.singletonList(onlinePlayer.getName())); + + try { + CustomNameplates.protocolManager.sendServerPacket(player, packetContainer); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + }); + } } diff --git a/src/main/java/net/momirealms/customnameplates/resource/ResourceManager.java b/src/main/java/net/momirealms/customnameplates/resource/ResourceManager.java index 7db6835..443aa29 100644 --- a/src/main/java/net/momirealms/customnameplates/resource/ResourceManager.java +++ b/src/main/java/net/momirealms/customnameplates/resource/ResourceManager.java @@ -96,6 +96,14 @@ public class ResourceManager { if (ConfigManager.MainConfig.anotherFont){ + JsonObject jsonObject_3 = new JsonObject(); + jsonObject_3.add("type", new JsonPrimitive("space")); + JsonObject jsonObject_4 = new JsonObject(); + jsonObject_4.add(" ", new JsonPrimitive(4)); + jsonObject_4.add("\\u200c", new JsonPrimitive(0)); + jsonObject_3.add("advances", jsonObject_4); + jsonArray_1.add(jsonObject_3); + JsonObject jsonObject_2 = new JsonObject(); jsonObject_2.add("type", new JsonPrimitive("bitmap")); jsonObject_2.add("file", new JsonPrimitive("minecraft:font/ascii.png")); @@ -120,14 +128,6 @@ public class ResourceManager { jsonArray_2.add("\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"); jsonObject_2.add("chars", jsonArray_2); jsonArray_1.add(jsonObject_2); - - JsonObject jsonObject_3 = new JsonObject(); - jsonObject_3.add("type", new JsonPrimitive("space")); - JsonObject jsonObject_4 = new JsonObject(); - jsonObject_4.add(" ", new JsonPrimitive(4)); - jsonObject_4.add("", new JsonPrimitive(0)); - jsonObject_3.add("advances", jsonObject_4); - jsonArray_1.add(jsonObject_3); } if (ConfigManager.nameplate){ diff --git a/src/main/java/net/momirealms/customnameplates/scoreboard/NameplatesTeam.java b/src/main/java/net/momirealms/customnameplates/scoreboard/NameplatesTeam.java index fa031c9..1b9d9c3 100644 --- a/src/main/java/net/momirealms/customnameplates/scoreboard/NameplatesTeam.java +++ b/src/main/java/net/momirealms/customnameplates/scoreboard/NameplatesTeam.java @@ -24,14 +24,11 @@ import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.data.DataManager; import net.momirealms.customnameplates.data.PlayerData; import net.momirealms.customnameplates.font.FontCache; -import net.momirealms.customnameplates.hook.ParsePapi; +import net.momirealms.customnameplates.hook.PapiHook; import net.momirealms.customnameplates.hook.TABHook; import net.momirealms.customnameplates.nameplates.NameplateUtil; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import org.bukkit.scoreboard.Scoreboard; -import org.bukkit.scoreboard.Team; import java.util.Optional; @@ -39,7 +36,6 @@ public class NameplatesTeam { private final CustomNameplates plugin; private final Player player; - private final Team team; private Component prefix; private Component suffix; private String prefixText; @@ -58,16 +54,11 @@ public class NameplatesTeam { this.color = ChatColor.WHITE; this.plugin = plugin; this.player = player; - Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); String name = player.getName(); if (ConfigManager.MainConfig.tab){ this.teamName = TABHook.getTABTeam(name); - this.team = Optional.ofNullable(Bukkit.getScoreboardManager().getMainScoreboard().getTeam(teamName)).orElseGet(() -> scoreboard.registerNewTeam(teamName)); - team.addEntry(player.getName()); }else { this.teamName = name; - this.team = Optional.ofNullable(Bukkit.getScoreboardManager().getMainScoreboard().getTeam(name)).orElseGet(() -> scoreboard.registerNewTeam(name)); - team.addEntry(player.getName()); } } @@ -81,8 +72,8 @@ public class NameplatesTeam { } if (nameplate.equals("none")) { if (ConfigManager.MainConfig.placeholderAPI) { - this.prefix = MiniMessage.miniMessage().deserialize(ParsePapi.parsePlaceholders(this.player, ConfigManager.MainConfig.player_prefix)); - this.suffix = MiniMessage.miniMessage().deserialize(ParsePapi.parsePlaceholders(this.player, ConfigManager.MainConfig.player_suffix)); + this.prefix = MiniMessage.miniMessage().deserialize(PapiHook.parsePlaceholders(this.player, ConfigManager.MainConfig.player_prefix)); + this.suffix = MiniMessage.miniMessage().deserialize(PapiHook.parsePlaceholders(this.player, ConfigManager.MainConfig.player_suffix)); this.prefixText = ""; this.suffixText = ""; } else { @@ -92,7 +83,6 @@ public class NameplatesTeam { this.suffixText = ""; } this.color = ChatColor.WHITE; - this.team.setPrefix(""); return; } FontCache fontCache = this.plugin.getResourceManager().getNameplateInfo(nameplate); @@ -100,7 +90,6 @@ public class NameplatesTeam { this.prefix = Component.text(""); this.suffix = Component.text(""); this.color = ChatColor.WHITE; - this.team.setPrefix(""); DataManager.cache.get(player.getUniqueId()).equipNameplate("none"); return; } @@ -110,16 +99,17 @@ public class NameplatesTeam { String playerSuffix; if (ConfigManager.MainConfig.placeholderAPI) { if (!ConfigManager.MainConfig.hidePrefix){ - playerPrefix = ParsePapi.parsePlaceholders(this.player, ConfigManager.MainConfig.player_prefix); + playerPrefix = PapiHook.parsePlaceholders(this.player, ConfigManager.MainConfig.player_prefix); }else { playerPrefix = ""; } if (!ConfigManager.MainConfig.hideSuffix){ - playerSuffix = ParsePapi.parsePlaceholders(this.player, ConfigManager.MainConfig.player_suffix); + playerSuffix = PapiHook.parsePlaceholders(this.player, ConfigManager.MainConfig.player_suffix); }else { playerSuffix = ""; } - }else { + } + else { if (!ConfigManager.MainConfig.hidePrefix){ playerPrefix = ConfigManager.MainConfig.player_prefix; }else { @@ -135,11 +125,6 @@ public class NameplatesTeam { this.suffixText = nameplateUtil.getSuffixLength(MiniMessage.miniMessage().stripTags(playerPrefix) + name + MiniMessage.miniMessage().stripTags(playerSuffix)); this.prefix = Component.text(nameplateUtil.makeCustomNameplate(MiniMessage.miniMessage().stripTags(playerPrefix), name, MiniMessage.miniMessage().stripTags(playerSuffix))).font(ConfigManager.MainConfig.key).append(MiniMessage.miniMessage().deserialize(playerPrefix)); this.suffix = MiniMessage.miniMessage().deserialize(playerSuffix).append(Component.text(nameplateUtil.getSuffixLength(MiniMessage.miniMessage().stripTags(playerPrefix) + name + MiniMessage.miniMessage().stripTags(playerSuffix))).font(ConfigManager.MainConfig.key)); -// this.prefixText = nameplateUtil.makeCustomNameplate(playerPrefix, name, playerSuffix) + playerPrefix; -// this.suffixText = playerSuffix + nameplateUtil.getSuffixLength(playerPrefix + name + playerSuffix); -// this.prefix = Component.text(nameplateUtil.makeCustomNameplate(playerPrefix, name, playerSuffix)).font(ConfigManager.MainConfig.key).append(Component.text(playerPrefix).font(Key.key("default"))); -// this.suffix = Component.text(playerSuffix).append(Component.text(nameplateUtil.getSuffixLength(playerPrefix + name + playerSuffix)).font(ConfigManager.MainConfig.key)); this.color = nameplateUtil.getColor(); - this.team.setPrefix(""); } } \ No newline at end of file diff --git a/src/main/java/net/momirealms/customnameplates/scoreboard/ScoreBoardManager.java b/src/main/java/net/momirealms/customnameplates/scoreboard/ScoreBoardManager.java index efaa37c..05fbe8e 100644 --- a/src/main/java/net/momirealms/customnameplates/scoreboard/ScoreBoardManager.java +++ b/src/main/java/net/momirealms/customnameplates/scoreboard/ScoreBoardManager.java @@ -35,22 +35,15 @@ public record ScoreBoardManager(CustomNameplates plugin) { if (!teams.containsKey(tabTeamName)) { teams.put(tabTeamName, new NameplatesTeam(this.plugin, player)); } - this.getTeam(tabTeamName).updateNameplates(); + teams.get(tabTeamName).updateNameplates(); return teams.get(tabTeamName); - } else { + } + else { if (!teams.containsKey(player.getName())) { teams.put(player.getName(), new NameplatesTeam(this.plugin, player)); } - this.getTeam(player.getName()).updateNameplates(); + teams.get(player.getName()).updateNameplates(); return teams.get(player.getName()); } } - - public void removeTeam(String teamName) { - teams.remove(teamName); - } - - public NameplatesTeam getTeam(String teamName) { - return teams.get(teamName); - } } diff --git a/src/main/resources/backgrounds/b0.png b/src/main/resources/backgrounds/b0.png index 45cb1739c27b1a8673c350afad01ccaa317efee4..1130ab394164edce32b2ecefaf5ff31d314b60fe 100644 GIT binary patch delta 291 zcmZqTKF>43lJWjVt1c#PV}lSQV=DtoD-+Yn=b4mH_u%oBBu z4NQ`BEiH{xbd3`&k_^oajFVF=%{NbBPG+nxN=dWI$y6vVaV;ycN=z=v%+Iq`Do!j* zO;LghX66-_B<3Zjdb-#uRpb`vWoD*W5o10~e|bhK&`2W#BO_e{bD&$`F4s1&u$sJ^ z#X=BjQF2CNUV3VZt&;xaPb_gpN7>dsXJB9u^K@|x;h35H(O4C!K-8 XjF%~Ns;~b$pb7?0S3j3^P6xzD@`iuX85rz+nWmnXd3O}3g2B_(&t;ucLK6Tp CP$Z`S diff --git a/src/main/resources/backgrounds/b1.png b/src/main/resources/backgrounds/b1.png index 86ff93d9e7d5cedea83dc8d47732b583a6402934..ae76d6ab6bf79e8aa309674fbf1b223aa6522dc5 100644 GIT binary patch delta 285 zcmeyvb&_X-CFA{#R$WZo#s(oq##RQFRwjm%&oe2Z@c%HCsH7TNCYdLjr0Av^rKIVa zCz)94S{N9o=_VywSXvsG7?~RzCT*U=oXl8Xl#*tZlc`W#;#yW>m6%+TnV)B?RGe6r znxX_1%*-n;Nz6-5^>ndSs>m(S%gju%BF21}{_>1eppixfMn<{@=DJ8O*EX=Qn!KCE zLJ(?EazTBqSv$urV_5_%KAzV6d15 PlwbP0l+XkKBZX6- delta 102 zcmX@f^M`AKC8N+rt1c#PBl8eLV=F^5D#XV)z4*}Q$iB}FO(lH diff --git a/src/main/resources/backgrounds/b128.png b/src/main/resources/backgrounds/b128.png index 9a1e9715312bf151b7ae40fdfebb4ba104061376..7a4c1ada619047c51b69f88202500e0a0257c84c 100644 GIT binary patch delta 302 zcmZqYzREMff{AtaMyoC+ZexQGBV#KAODhB8$>*7rQ22kC0#p){%uG@f4b5~D&6Cq~ zEiFt^buBCnlXO!J5>3rajV;p5QcX4&Fefug6s4qD= kkgdbmVGiRXxX?T1<);{8W^2e!1DeI)>FVdQ&MBb@0KC^-Q2+n{ delta 150 zcmcc0)6PA?f{EqbMyoC+ZX@#$Lt`sLQ!4|*$>*7rQ22kC0w(*hsBJD{PGp?CfHg8Y zc&=<90|SG-r;B4qMC;p2hKvjfJO?&37A;Xub{A%~tx9{w8(D7M5X;tK>@bJ%5syH6 lg9Y;uNriI^g>a$ojH@;?%=vnYYa`Go22WQ%mvv4FO#qF{FZ}=j diff --git a/src/main/resources/backgrounds/b16.png b/src/main/resources/backgrounds/b16.png index 009ec0e17b3a54002ce819acdc1cf38332bc5cf8..83d0f34e7b65cc65f93ffc8d4fc670af5ad69b79 100644 GIT binary patch delta 290 zcmZqVKF2e`lJWjVt1c#PV}lSQV=DtoD&5*Xs-z7#Ku7T^vIsrY5HpBpl$L@xi-aOTveXp-+e* U#=Go|D^LN0r>mdKI;Vst03?rBEdT%j delta 107 zcmX@d)5tx+l2K@*RTmStk$H%rv6Z2zm66%x^Gr%8{69=3lZ#l?Hcw+tWSo42HPZ0O z8VxlD1_n`27sn8ZsmUoB2?w}meDLnqlJMbTU{qw7v&n^Z6Hozzr>mdKI;Vst0EurO AR{#J2 diff --git a/src/main/resources/backgrounds/b2.png b/src/main/resources/backgrounds/b2.png index 4469ef4c8ba2e90fd29ffc4b7346450394de3cb3..9daf46c4ef929e06ef48870b0d627fde8983f896 100644 GIT binary patch delta 287 zcmeyzb(&{_CFA{#R$WZo#s(oq##RQFR>tO&&oe2Z@c%HCs2C(ACK;I+80)4P8KvnO znwli(CZ(ks>Y5uR8z-iiq#37Lq->tToXl8Xl#*tZlc`W#;#yW>m6%+TnV)B?RGe6r znxX_1%*-n;Nz6-5^>ndSs>m(S%gju%BF21}{_>1eppixfMn<{@=DJ8O*EX=Qn!KCE zLJ(?Eaz_V$S114g delta 104 zcmX@j^N(wSC8N+rt1c#PBl8eLV=F^5D?@|H=b4mH_f3u diff --git a/src/main/resources/backgrounds/b32.png b/src/main/resources/backgrounds/b32.png index ca23db57c60b0144bed59f80990e0af7022526e8..31ce74f3f69fc0debf4f9ad90c6f58b9b1f59582 100644 GIT binary patch delta 279 zcmaFMwVP*x1rzJ;jaFSu+{OkWM#feKmR5#llg~3Lq457O1*oK1rkSKBnHuXRnVYBS zrWu=9=q6ewTIw36CYhNVnkJ?gn5JzmU`}R~C`w7Q%E?qHE^#d@u}VxX$;{8QRVq#_ zn{2=$=Sqw*N>IJ!8L2>>Mg~Skx(4RD$PS#$Vj~Dul$?>6m!6tptE4~q97~+jsl$Hl z3=9lvo-U3d7QM+S2?+%W5)KDUCQR$MO1Q$fm`|egzzSwJ*#khpz@SsW5aae{jxbOM NgQu&X%Q~loCIB08RdxUX delta 124 zcmdnZ^OkFZ1ry7=jaFSu+(zahhQ?Ng=2pfAlg~3Lq457O1x)s1QQKU^oX9wN0c)fq z*H5NZ3=9mao-U3d7QJuJ88R{$@HA}La!S3{=vM=yQ3c=a)0GVjj7%&X4D#>(Gt8MN S+#Ckfz~JfX=d#Wzp$Pz4xhD1i diff --git a/src/main/resources/backgrounds/b4.png b/src/main/resources/backgrounds/b4.png index f1bdd4391e1ba5a417dda6ec74baf89746d29598..0532849a5a21ae128a90a7643944ea03c19c018a 100644 GIT binary patch delta 289 zcmZqTKF>43lJWjVt1c!kV}lSQV=DtoE91%Mn3R#ZznMx^%uP)VjFM7Jb3@y@9H&0_1H%Y3=CqPE{-7_Gm}#a5+EQcVSzm}gIW?pjNX@w QUZ4sFPgg&ebxsLQ0Cz-JtN;K2 delta 106 zcmX@l)5JZ&l2K@*RTmSNk$H%rv6Z2zmFeVjOv=dI-%O>Gi&)e)Ph(DGoP2~e(kMt{ w=`{uh1~E?;#}JO0$tf8L5RjCxz@C}GHHl%)(vJ*BfGQX~UHx3vIVCg!0EjvuPXGV_ diff --git a/src/main/resources/backgrounds/b64.png b/src/main/resources/backgrounds/b64.png index 217322e7ba31a77dae25dcf8bf1195ad717f1727..9188308f16352b93966a6dee8e88d42beb37efdc 100644 GIT binary patch delta 298 zcmZqRKF2e`f{AtaMyoC+ZexQGBV#KAODjXe$>*7rQ22kC0#q!`Q%%znQ!RBZQd3iP zEsac!buAN(Qgu_4&5TnMjgt*iQxi8AFefug6s4qDPh&Z`<82E4#qdfjxuw0%H_&Ny9Y; bIQJHRXdgq2p5#P7pdk#Nu6{1-oD!Mopk`!yH}*-+Z7M44$rjF6*2UngFW{GT#6I diff --git a/src/main/resources/backgrounds/b8.png b/src/main/resources/backgrounds/b8.png index 496b4b57863f1ba4713c08b5ec2b8f65b813961e..87d0de7057c4e24b7e088c945f51ab455fd99cc6 100644 GIT binary patch delta 288 zcmey*b%tkxCFA{#R$WZo#s(oq##RQFRz{YS&oe2Z@c%HCsFi?d z8k!jCCYc+X>82Q(TNoN98m6UKns1)MoXl8Xl#*tZlc`W#;#yW>m6%+TnV)B?RGe6r znxX_1%*-n;Nz6-5^>ndSs>m(S%gju%BF21}{_>1eppixfMn<{@=DJ8O*EX=Qn!KCE zLJ(?Eaz%nameplates_bg_player%Hello! %player_name% %nameplates_bg_pos%You are now at: %player_x%, %player_y%, %player_z%' refresh-rate: 5 # PINK @@ -25,4 +24,21 @@ bossbar: # NOTCHED_10 # NOTCHED_12 # NOTCHED_20 - overlay: PROGRESS \ No newline at end of file + overlay: PROGRESS + example_2: + text: 'Another BossBar' + refresh-rate: 5 + # PINK + # YELLOW + # WHITE + # RED + # PURPLE + # GREEN + # BLUE + color: RED + # PROGRESS + # NOTCHED_6 + # NOTCHED_10 + # NOTCHED_12 + # NOTCHED_20 + overlay: NOTCHED_10 \ No newline at end of file diff --git a/src/main/resources/char-width.yml b/src/main/resources/char-width.yml new file mode 100644 index 0000000..d3b1c9e --- /dev/null +++ b/src/main/resources/char-width.yml @@ -0,0 +1,6 @@ +# Font is processed by client +# Server side doesn't know the width of you custom font +# So you can tell the plugin each character's width here +小: 8 +默: 8 +米: 8 \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c93b844..2315d04 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -56,7 +56,10 @@ config: # Placeholder based prefix and suffix system. When enabled, it is recommended # to use PlaceholderAPI to be able to use this feature to the fullest extent. # keep it empty if you don't want to enable this feature. - prefix: 'Hello! ' + # You should make sure the papi doesn't contain "&" (legacy color code) + # Nameplates work on the custom font system where legacy color code is not supported! + # Please use minimessage format: https://docs.adventure.kyori.net/minimessage/format.html + prefix: 'Hello! ' suffix: '' # should prefix/suffix be hidden when player is equipping a nameplate diff --git a/src/main/resources/custom-papi.yml b/src/main/resources/custom-papi.yml index 98fb949..7a51108 100644 --- a/src/main/resources/custom-papi.yml +++ b/src/main/resources/custom-papi.yml @@ -13,6 +13,9 @@ papi: pos: text: 'You are now at: %player_x%, %player_y%, %player_z%' background: bedrock_1 + text: + text: 'Thanks for your purchase!' + background: bedrock_2 #This papi will not return text with nameplate #It will only return the nameplate diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9a702e5..63637ef 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -12,6 +12,38 @@ softdepend: - Oraxen commands: customnameplates: - usage: /customnameplates help + usage: /customnameplates aliases: - - nameplates \ No newline at end of file + - nameplates + +permissions: + nameplates.*: + description: Gives access to all nameplates commands + children: + nameplates.generate: true + nameplates.reload: true + nameplates.forceequip: true + nameplates.forceunequip: true + nameplates.help: true + nameplates.unequip: true + nameplates.preview: true + nameplates.list: true + + nameplates.generate: + default: op + nameplates.reload: + default: op + nameplates.forceequip: + default: op + nameplates.forceunequip: + default: op + nameplates.help: + default: op + nameplates.unequip: + default: true + nameplates.preview: + default: true + nameplates.list: + default: true + nameplates.equip: + default: true \ No newline at end of file