9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-31 04:36:29 +00:00

2.0-PRE-9

This commit is contained in:
Xiao-MoMi
2022-09-16 13:58:58 +08:00
parent 6db759b876
commit 9d93183550
88 changed files with 984 additions and 662 deletions

View File

@@ -22,7 +22,6 @@ import net.momirealms.customnameplates.bossbar.BossBarConfig;
import net.momirealms.customnameplates.bossbar.Overlay;
import net.momirealms.customnameplates.data.SqlHandler;
import net.momirealms.customnameplates.font.FontOffset;
import net.momirealms.customnameplates.objects.BackGround;
import net.momirealms.customnameplates.font.FontWidthNormal;
import net.momirealms.customnameplates.font.FontWidthThin;
import net.momirealms.customnameplates.utils.AdventureUtil;
@@ -44,7 +43,6 @@ import java.util.TreeMap;
public class ConfigManager {
public static TreeMap<String, BackGround> backgrounds = new TreeMap<>();
public static TreeMap<String, BossBarConfig> bossBars = new TreeMap<>();
public static HashMap<String, BackGroundText> papiBG = new HashMap<>();
public static HashMap<String, NameplateText> papiNP = new HashMap<>();
@@ -102,9 +100,10 @@ public class ConfigManager {
public static String lang;
public static String version;
public static String folder_path;
public static String np_folder_path;
public static String bg_folder_path;
public static String ss_folder_path;
public static String bb_folder_path;
public static String font;
public static boolean itemsAdder;
@@ -131,7 +130,8 @@ public class ConfigManager {
fontName = namespace + ":" + font;
start_char = config.getString("config.start-char");
start = start_char.charAt(0);
folder_path = config.getString("config.nameplate-folder-path","font\\nameplates\\");
np_folder_path = config.getString("config.nameplate-folder-path","font\\nameplates\\");
bb_folder_path = config.getString("config.bubble-folder-path","font\\bubbles\\");
bg_folder_path = config.getString("config.background-folder-path","font\\backgrounds\\");
ss_folder_path = config.getString("config.space-split-folder-path","font\\");
key = Key.key(fontName);
@@ -203,12 +203,12 @@ public class ConfigManager {
for (String text : texts) {
textMap.put(text, -0.1);
}
smallSize = config.getBoolean("nameplate.riding.small-size", true);
smallSize = config.getBoolean("nameplate.riding.small-height", true);
removeTag = config.getBoolean("nameplate.riding.remove-nametag");
}
else if (mode.equalsIgnoreCase("teleporting")) {
removeTag = config.getBoolean("nameplate.teleporting.remove-nametag");
smallSize = config.getBoolean("nameplate.teleporting.small-size", true);
smallSize = config.getBoolean("nameplate.teleporting.small-height", true);
textMap.clear();
config.getConfigurationSection("nameplate.teleporting.text").getKeys(false).forEach(key -> {
textMap.put(config.getString("nameplate.teleporting.text." + key + ".content"), config.getDouble("nameplate.teleporting.text." + key + ".offset"));
@@ -288,19 +288,6 @@ public class ConfigManager {
}
}
/*
载入背景配置
*/
public static void loadBGConfig(){
backgrounds.clear();
YamlConfiguration bgConfig = getConfig("background.yml");
bgConfig.getConfigurationSection("background").getKeys(false).forEach(key -> backgrounds.put(key, new BackGround(key, bgConfig.getString("background." + key + ".start"),bgConfig.getString("background." + key + ".offset_1"),
bgConfig.getString("background." + key + ".offset_2"),bgConfig.getString("background." + key + ".offset_4"),bgConfig.getString("background." + key + ".offset_8"),
bgConfig.getString("background." + key + ".offset_16"),bgConfig.getString("background." + key + ".offset_32"),bgConfig.getString("background." + key + ".offset_64"),
bgConfig.getString("background." + key + ".offset_128"),bgConfig.getString("background." + key + ".end"),bgConfig.getInt("background." + key + ".y-offset",0),bgConfig.getInt("background." + key + ".start-offset", 1), bgConfig.getInt("background." + key + ".end-offset", 1),bgConfig.getInt("background." + key + ".size",14)
)));
}
/**
* 载入BossBar配置
*/
@@ -446,7 +433,7 @@ public class ConfigManager {
enable_pool = databaseConfig.getBoolean("settings.use-pool");
if(enable_pool){
maximum_pool_size = databaseConfig.getInt("Pool-Settings.maximum-pool-size");
maximum_pool_size = databaseConfig.getInt("Pool-Settings.maximum-pool-height");
minimum_idle = databaseConfig.getInt("Pool-Settings.minimum-idle");
maximum_lifetime = databaseConfig.getInt("Pool-Settings.maximum-lifetime");
idle_timeout = databaseConfig.getInt("Pool-Settings.idle-timeout");

View File

@@ -46,6 +46,7 @@ import net.momirealms.customnameplates.utils.AdventureUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.Team;
import java.util.Objects;
@@ -100,22 +101,35 @@ public final class CustomNameplates extends JavaPlugin {
if (ConfigManager.Module.nameplate){
SqlHandler.saveAll();
SqlHandler.close();
if (!ConfigManager.Nameplate.fakeTeam && !ConfigManager.Main.tab && !ConfigManager.Main.tab_bc) {
for (Team team : Bukkit.getScoreboardManager().getMainScoreboard().getTeams()) {
team.unregister();
}
}
}
if (actionBarManager != null){
if (actionBarManager != null) {
actionBarManager.unload();
}
if (nameplateManager != null) {
nameplateManager.unload();
}
if (bossBarManager != null) {
bossBarManager.unload();
}
if (placeholderManager != null) {
placeholderManager.unload();
}
if (chatBubblesManager != null) {
chatBubblesManager.unload();
}
if (adventure != null) {
adventure.close();
}
if (resourceManager != null){
resourceManager = null;
}
if (teamManager != null){
teamManager = null;
}
if (dataManager != null){
dataManager = null;
if (proxyDataListener != null) {
this.getServer().getMessenger().unregisterIncomingPluginChannel(this, "customnameplates:cnp");
this.getServer().getMessenger().unregisterOutgoingPluginChannel(this, "customnameplates:cnp");
}
}
public void loadConfig() {
@@ -172,11 +186,6 @@ public final class CustomNameplates extends JavaPlugin {
this.actionBarManager.unload();
this.actionBarManager = null;
}
if (ConfigManager.Module.background){
ConfigManager.loadBGConfig();
}
if (ConfigManager.Module.nameplate){
ConfigManager.Nameplate.reload();
ConfigManager.DatabaseConfig.reload();

View File

@@ -1,6 +1,5 @@
package net.momirealms.customnameplates.bungeecord;
import com.comphenix.protocol.events.PacketListener;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
@@ -8,7 +7,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.protocol.packet.Team;
import net.momirealms.customnameplates.hook.TABTeamHook;
import java.util.Objects;

View File

@@ -36,14 +36,13 @@ public class ExecuteB implements CommandExecutor {
return true;
}
if (sender.hasPermission("bubbles.equip." + args[1]) || sender.isOp()) {
if (CustomNameplates.instance.getResourceManager().getNameplateInstance(args[1]) == null) {
if (CustomNameplates.instance.getResourceManager().getBubbleConfig(args[1]) == null) {
AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.bb_not_exist);
return true;
}
CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId()).setBubbles(args[1]);
CustomNameplates.instance.getDataManager().savePlayer(player.getUniqueId());
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.bb_equip.replace("{Bubble}", CustomNameplates.instance.getResourceManager().getNameplateInstance(args[1]).getConfig().getName()));
AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.bb_equip.replace("{Bubble}", CustomNameplates.instance.getResourceManager().getBubbleConfig(args[1]).name()));
}
else AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.bb_notAvailable);
}
@@ -56,19 +55,20 @@ public class ExecuteB implements CommandExecutor {
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.lackArgs);
return true;
}
if (sender.hasPermission("bubbles.forceequip") || sender.isOp()){
if (sender.hasPermission("bubbles.forceequip") || sender.isOp()) {
Player player = Bukkit.getPlayer(args[1]);
if (player != null){
if (CustomNameplates.instance.getResourceManager().getNameplateInstance(args[2]) == null){
if (CustomNameplates.instance.getResourceManager().getBubbleConfig(args[2]) == null){
if(sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.bb_not_exist);
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.bb_not_exist);
return true;
}
CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId()).setBubbles(args[2]);
CustomNameplates.instance.getDataManager().savePlayer(player.getUniqueId());
if (sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.bb_force_equip.replace("{Bubble}", CustomNameplates.instance.getResourceManager().getNameplateInstance(args[2]).getConfig().getName()).replace("{Player}", args[1]));
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.bb_force_equip.replace("{Bubble}", CustomNameplates.instance.getResourceManager().getNameplateInstance(args[2]).getConfig().getName()).replace("{Player}", args[1]));
}else {
if (sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.bb_force_equip.replace("{Bubble}", CustomNameplates.instance.getResourceManager().getBubbleConfig(args[2]).name()).replace("{Player}", args[1]));
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.bb_force_equip.replace("{Bubble}", CustomNameplates.instance.getResourceManager().getBubbleConfig(args[2]).name()).replace("{Player}", args[1]));
}
else {
if (sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.not_online.replace("{Player}",args[1]));
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.not_online.replace("{Player}",args[1]));
}
@@ -109,7 +109,7 @@ public class ExecuteB implements CommandExecutor {
if (sender instanceof Player player) {
if (player.isOp()) {
StringBuilder stringBuilder = new StringBuilder();
ResourceManager.NAMEPLATES.keySet().forEach(key -> {
ResourceManager.BUBBLES.keySet().forEach(key -> {
if (key.equalsIgnoreCase("none")) return;
stringBuilder.append(key).append(" ");
});
@@ -121,7 +121,7 @@ public class ExecuteB implements CommandExecutor {
String permission = info.getPermission().toLowerCase();
if (permission.startsWith("bubbles.equip.")) {
permission = StringUtils.replace(permission, "bubbles.equip.", "");
if (ResourceManager.NAMEPLATES.get(permission) != null) {
if (ResourceManager.BUBBLES.get(permission) != null) {
availableBubbles.add(permission);
}
}
@@ -144,7 +144,7 @@ public class ExecuteB implements CommandExecutor {
}
default -> {
if (sender instanceof Player player){
if (player.hasPermission("nameplates.help")){
if (player.hasPermission("bubbles.help")){
AdventureUtil.playerMessage(player,"<color:#87CEFA>/bubbles help - <color:#7FFFAA>show the command list");
AdventureUtil.playerMessage(player,"<color:#87CEFA>/bubbles equip <nameplate> - <color:#7FFFAA>equip a specified bubble");
AdventureUtil.playerMessage(player,"<color:#87CEFA>/bubbles forceequip <player> <nameplate> - <color:#7FFFAA>force a player to equip a specified bubble");

View File

@@ -87,7 +87,7 @@ public class TabCompleteB implements TabCompleter {
String permission = info.getPermission().toLowerCase();
if (permission.startsWith("bubbles.equip.")) {
permission = StringUtils.replace(permission, "bubbles.equip.", "");
if (ResourceManager.NAMEPLATES.get(permission) != null){
if (ResourceManager.BUBBLES.get(permission) != null){
availableBubbles.add(permission);
}
}
@@ -97,6 +97,6 @@ public class TabCompleteB implements TabCompleter {
}
private List<String> bubbles(){
return new ArrayList<>(ResourceManager.NAMEPLATES.keySet());
return new ArrayList<>(ResourceManager.BUBBLES.keySet());
}
}

View File

@@ -88,15 +88,15 @@ public class ExecuteN implements CommandExecutor {
if (sender.hasPermission("nameplates.equip." + args[1]) || sender.isOp()) {
if (CustomNameplates.instance.getResourceManager().getNameplateInstance(args[1]) == null) {
if (CustomNameplates.instance.getResourceManager().getNameplateConfig(args[1]) == null) {
AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_not_exist);
return true;
}
CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId()).equipNameplate(args[1]);
CustomNameplates.instance.getDataManager().savePlayer(player.getUniqueId());
CustomNameplates.instance.getTeamManager().getTeams().get(TeamManager.getTeamName(player)).updateNameplates();
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_equip.replace("{Nameplate}", CustomNameplates.instance.getResourceManager().getNameplateInstance(args[1]).getConfig().getName()));
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player, true);
AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_equip.replace("{Nameplate}", CustomNameplates.instance.getResourceManager().getNameplateConfig(args[1]).name()));
}
else AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_notAvailable);
@@ -117,7 +117,7 @@ public class ExecuteN implements CommandExecutor {
if (sender.hasPermission("nameplates.forceequip") || sender.isOp()){
Player player = Bukkit.getPlayer(args[1]);
if (player != null){
if (CustomNameplates.instance.getResourceManager().getNameplateInstance(args[2]) == null){
if (CustomNameplates.instance.getResourceManager().getNameplateConfig(args[2]) == null){
if(sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_not_exist);
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.np_not_exist);
return true;
@@ -125,9 +125,9 @@ public class ExecuteN implements CommandExecutor {
CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId()).equipNameplate(args[2]);
CustomNameplates.instance.getDataManager().savePlayer(player.getUniqueId());
CustomNameplates.instance.getTeamManager().getTeams().get(TeamManager.getTeamName(player)).updateNameplates();
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
if (sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_force_equip.replace("{Nameplate}", CustomNameplates.instance.getResourceManager().getNameplateInstance(args[2]).getConfig().getName()).replace("{Player}", args[1]));
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.np_force_equip.replace("{Nameplate}", CustomNameplates.instance.getResourceManager().getNameplateInstance(args[2]).getConfig().getName()).replace("{Player}", args[1]));
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player, true);
if (sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_force_equip.replace("{Nameplate}", CustomNameplates.instance.getResourceManager().getNameplateConfig(args[2]).name()).replace("{Player}", args[1]));
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.np_force_equip.replace("{Nameplate}", CustomNameplates.instance.getResourceManager().getNameplateConfig(args[2]).name()).replace("{Player}", args[1]));
}else {
if (sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.not_online.replace("{Player}",args[1]));
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.not_online.replace("{Player}",args[1]));
@@ -144,7 +144,7 @@ public class ExecuteN implements CommandExecutor {
CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId()).equipNameplate("none");
CustomNameplates.instance.getDataManager().savePlayer(player.getUniqueId());
CustomNameplates.instance.getTeamManager().getTeams().get(TeamManager.getTeamName(player)).updateNameplates();
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player, true);
AdventureUtil.playerMessage(player, ConfigManager.Message.prefix + ConfigManager.Message.np_unEquip);
}
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.no_console);
@@ -167,7 +167,7 @@ public class ExecuteN implements CommandExecutor {
CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId()).equipNameplate("none");
CustomNameplates.instance.getDataManager().savePlayer(player.getUniqueId());
CustomNameplates.instance.getTeamManager().getTeams().get(TeamManager.getTeamName(player)).updateNameplates();
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player, true);
if (sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_force_unEquip.replace("{Player}", args[1]));
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.np_force_unEquip.replace("{Player}", args[1]));
}else {
@@ -236,8 +236,8 @@ public class ExecuteN implements CommandExecutor {
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.not_online);
return true;
}
NameplateInstance nameplateInstance = CustomNameplates.instance.getResourceManager().getNameplateInstance(args[2]);
if (nameplateInstance == null){
NameplateConfig nameplateConfig = CustomNameplates.instance.getResourceManager().getNameplateConfig(args[2]);
if (nameplateConfig == null){
if (sender instanceof Player) AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.np_not_exist);
else AdventureUtil.consoleMessage(ConfigManager.Message.prefix + ConfigManager.Message.np_not_exist);
return true;
@@ -251,9 +251,9 @@ public class ExecuteN implements CommandExecutor {
if (ConfigManager.Nameplate.mode.equalsIgnoreCase("team")) {
String playerPrefix = ConfigManager.Nameplate.hidePrefix ? "" : ConfigManager.Main.placeholderAPI ? CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(player, ConfigManager.Nameplate.player_prefix) : ConfigManager.Nameplate.player_prefix;
String playerSuffix = ConfigManager.Nameplate.hideSuffix ? "" : ConfigManager.Main.placeholderAPI ? CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(player, ConfigManager.Nameplate.player_suffix) : ConfigManager.Nameplate.player_suffix;
Component prefix = Component.text(NameplateUtil.makeCustomNameplate(MiniMessage.miniMessage().stripTags(playerPrefix), args[1], MiniMessage.miniMessage().stripTags(playerSuffix), nameplateInstance)).font(ConfigManager.Main.key).append(MiniMessage.miniMessage().deserialize(playerPrefix));
Component prefix = Component.text(NameplateUtil.makeCustomNameplate(MiniMessage.miniMessage().stripTags(playerPrefix), args[1], MiniMessage.miniMessage().stripTags(playerSuffix), nameplateConfig)).font(ConfigManager.Main.key).append(MiniMessage.miniMessage().deserialize(playerPrefix));
Component suffix = MiniMessage.miniMessage().deserialize(playerSuffix).append(Component.text(NameplateUtil.getSuffixChar(MiniMessage.miniMessage().stripTags(playerPrefix) + args[1] + MiniMessage.miniMessage().stripTags(playerSuffix))).font(ConfigManager.Main.key));
Component full = prefix.append(Component.text(player.getName()).color(TextColor.color(color2decimal(nameplateInstance.getConfig().getColor()))).font(Key.key("default")).append(suffix));
Component full = prefix.append(Component.text(player.getName()).color(TextColor.color(color2decimal(nameplateConfig.color()))).font(Key.key("default")).append(suffix));
HoloUtil.showHolo(full, player, (int) ConfigManager.Nameplate.preview);
}
else {
@@ -270,7 +270,6 @@ public class ExecuteN implements CommandExecutor {
},ConfigManager.Nameplate.preview * 20);
}
}
return true;
}
//显示可用铭牌

View File

@@ -21,14 +21,11 @@ import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customnameplates.ConfigManager;
import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.nameplates.*;
import net.momirealms.customnameplates.objects.BackGround;
import net.momirealms.customnameplates.data.PlayerData;
import net.momirealms.customnameplates.nameplates.NameplateInstance;
import net.momirealms.customnameplates.font.FontUtil;
import net.momirealms.customnameplates.nameplates.NameplateUtil;
import net.momirealms.customnameplates.resource.ResourceManager;
import net.momirealms.customnameplates.nameplates.NameplatesTeam;
import net.momirealms.customnameplates.nameplates.TeamManager;
import net.momirealms.customnameplates.objects.BackGroundText;
import net.momirealms.customnameplates.objects.NameplateText;
import org.bukkit.OfflinePlayer;
@@ -51,14 +48,14 @@ public class NameplatePlaceholders extends PlaceholderExpansion {
@Override
public @NotNull String getVersion() {
return "1.0";
return "1.1";
}
@Override
public String onRequest(OfflinePlayer player, String params) {
if (params.equals("equipped")){
String nameplate = Optional.ofNullable(CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId())).orElse(PlayerData.EMPTY).getEquippedNameplate();
if (!nameplate.equals("none")) return ResourceManager.NAMEPLATES.get(nameplate).getName();
if (!nameplate.equals("none")) return ResourceManager.NAMEPLATES.get(nameplate).name();
else return ConfigManager.Message.noNameplate;
}
if (params.equals("prefix")){
@@ -75,28 +72,26 @@ public class NameplatePlaceholders extends PlaceholderExpansion {
String bg = params.substring(3);
BackGroundText backGroundText = ConfigManager.papiBG.get(bg);
if (backGroundText == null) return "";
BackGround backGround = ConfigManager.backgrounds.get(backGroundText.getBackground());
BackGround backGround = ResourceManager.BACKGROUNDS.get(backGroundText.getBackground());
if (backGround == null) return "";
String text = backGroundText.getText();
if (ConfigManager.Main.placeholderAPI) text = PlaceholderAPI.setPlaceholders(player, text);
String text = PlaceholderAPI.setPlaceholders(player, backGroundText.getText());
return backGround.getBackGround(FontUtil.getTotalWidth(text));
}
if (params.startsWith("npp_")){
String np = params.substring(4);
NameplateText nameplateText = ConfigManager.papiNP.get(np);
if (nameplateText == null) return "";
NameplateInstance nameplateInstance = ResourceManager.NAMEPLATES.get(nameplateText.getNameplate());
if (nameplateInstance == null) return "";
String text = nameplateText.getText();
if (ConfigManager.Main.placeholderAPI) text = PlaceholderAPI.setPlaceholders(player, text);
return NameplateUtil.makeCustomNameplate("", text,"", nameplateInstance);
NameplateConfig nameplateConfig = ResourceManager.NAMEPLATES.get(nameplateText.getNameplate());
if (nameplateConfig == null) return "";
String text = PlaceholderAPI.setPlaceholders(player, nameplateText.getText());
return NameplateUtil.makeCustomNameplate("", text,"", nameplateConfig);
}
if (params.startsWith("nps_")){
String np = params.substring(4);
NameplateText nameplateText = ConfigManager.papiNP.get(np);
if (nameplateText == null) return "";
NameplateInstance nameplateInstance = ResourceManager.NAMEPLATES.get(nameplateText.getNameplate());
if (nameplateInstance == null) return "";
NameplateConfig nameplateConfig = ResourceManager.NAMEPLATES.get(nameplateText.getNameplate());
if (nameplateConfig == null) return "";
String text = nameplateText.getText();
if (ConfigManager.Main.placeholderAPI) text = PlaceholderAPI.setPlaceholders(player, text);
return NameplateUtil.getSuffixChar(text);

View File

@@ -0,0 +1,40 @@
package net.momirealms.customnameplates.nameplates;
import net.momirealms.customnameplates.objects.SimpleChar;
public record BubbleConfig(String format, String name,
SimpleChar left,
SimpleChar middle,
SimpleChar right,
SimpleChar tail) {
@Override
public String format() {
return format;
}
@Override
public String name() {
return name;
}
@Override
public SimpleChar tail() {
return tail;
}
@Override
public SimpleChar left() {
return left;
}
@Override
public SimpleChar middle() {
return middle;
}
@Override
public SimpleChar right() {
return right;
}
}

View File

@@ -17,44 +17,35 @@
package net.momirealms.customnameplates.nameplates;
import net.momirealms.customnameplates.objects.SimpleChar;
import org.bukkit.ChatColor;
import java.util.Objects;
public record NameplateConfig(ChatColor color, String name, SimpleChar left, SimpleChar middle, SimpleChar right) {
public record NameplateConfig(ChatColor color, int height, String name, int yoffset, String bubbleColor) {
public static NameplateConfig EMPTY = new NameplateConfig(ChatColor.WHITE, "none", SimpleChar.none, SimpleChar.none, SimpleChar.none);
public static NameplateConfig EMPTY = new NameplateConfig(ChatColor.WHITE, 16, "none", 12, "<white>");
public ChatColor getColor() {
return this.color;
}
public int getHeight() {
return this.height;
}
public String getName() {
return this.name;
}
public int getYOffset() {
return this.yoffset;
}
public String bubbleColor() {
return bubbleColor;
@Override
public ChatColor color() {
return color;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NameplateConfig that = (NameplateConfig) o;
return height == that.height && yoffset == that.yoffset && color == that.color && Objects.equals(name, that.name);
public String name() {
return name;
}
@Override
public int hashCode() {
return Objects.hash(color, height, name, yoffset);
public SimpleChar left() {
return left;
}
@Override
public SimpleChar middle() {
return middle;
}
@Override
public SimpleChar right() {
return right;
}
}

View File

@@ -1,66 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.nameplates;
import net.momirealms.customnameplates.font.FontChar;
import java.util.Objects;
public record NameplateInstance(String name, FontChar fontChar, NameplateConfig config) {
public static NameplateInstance EMPTY = new NameplateInstance("none", new FontChar('小', '默', '米'), NameplateConfig.EMPTY);
public String getName() {
return this.name;
}
public FontChar getChar() {
return this.fontChar;
}
public NameplateConfig getConfig() {
return this.config;
}
@Override
public boolean equals(final Object o) {
if (o == this) return true;
if (!(o instanceof NameplateInstance nameplateInstance)) return false;
return Objects.equals(nameplateInstance.getName(), this.getName());
}
@Override
public int hashCode() {
int n = 1;
String name = this.getName();
int n2 = n * 59 + ((name == null) ? 43 : name.hashCode());
FontChar fontChar = this.getChar();
int n3 = n2 * 59 + ((fontChar == null) ? 43 : fontChar.hashCode());
NameplateConfig config = this.getConfig();
return n3 * 59 + ((config == null) ? 43 : config.hashCode());
}
@Override
public String toString() {
return "FontCache{" +
"name='" + name + '\'' +
", fontChar=" + fontChar +
", config=" + config +
'}';
}
}

View File

@@ -19,24 +19,34 @@ package net.momirealms.customnameplates.nameplates;
import net.momirealms.customnameplates.font.FontOffset;
import net.momirealms.customnameplates.font.FontUtil;
import net.momirealms.customnameplates.helper.Log;
import org.bukkit.ChatColor;
public class NameplateUtil {
public static String makeCustomNameplate(String prefix, String name, String suffix, NameplateInstance nameplate) {
public static String makeCustomNameplate(String prefix, String name, String suffix, NameplateConfig nameplate) {
int totalWidth = FontUtil.getTotalWidth(ChatColor.stripColor(prefix + name + suffix));
boolean isEven = totalWidth % 2 == 0;
char left = nameplate.getChar().getLeft();
char middle = nameplate.getChar().getMiddle();
char right = nameplate.getChar().getRight();
char left = nameplate.left().getChars();
char middle = nameplate.middle().getChars();
char right = nameplate.right().getChars();
char neg_1 = FontOffset.NEG_1.getCharacter();
int left_offset = totalWidth + 16 + 1;
int offset_2 = nameplate.right().getWidth() - nameplate.middle().getWidth();
int left_offset = totalWidth + (nameplate.left().getWidth() + nameplate.right().getWidth())/2 + 1;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(FontOffset.getShortestNegChars(isEven ? left_offset : left_offset + 1));
stringBuilder.append(FontOffset.getShortestNegChars(isEven ? left_offset : left_offset + 1 ));
stringBuilder.append(left).append(neg_1);
int mid_amount = (totalWidth + 1) / 16;
for (int i = 0; i < (mid_amount == 0 ? 1 : mid_amount); i++) stringBuilder.append(middle).append(neg_1);
stringBuilder.append(FontOffset.getShortestNegChars(16 - ((totalWidth + 1) % 16 + (isEven ? 0 : 1))));
int mid_amount = (totalWidth + 1 + offset_2) / (nameplate.middle().getWidth());
if (mid_amount == 0) {
stringBuilder.append(middle).append(neg_1);
}
else {
for (int i = 0; i < mid_amount; i++) {
stringBuilder.append(middle).append(neg_1);
}
}
stringBuilder.append(FontOffset.getShortestNegChars(nameplate.right().getWidth() - ((totalWidth + 1 + offset_2) % nameplate.middle().getWidth() + (isEven ? 0 : -1))));
// stringBuilder.append(FontOffset.getShortestNegChars(nameplate.right().getWidth() - ((totalWidth + 1) % nameplate.middle().getWidth() + (isEven ? 0 : -1))));
stringBuilder.append(middle).append(neg_1);
stringBuilder.append(right).append(neg_1);
stringBuilder.append(FontOffset.getShortestNegChars(left_offset - 1));
@@ -47,4 +57,38 @@ public class NameplateUtil {
int totalWidth = FontUtil.getTotalWidth(ChatColor.stripColor(name));
return FontOffset.getShortestNegChars(totalWidth + totalWidth % 2 + 1);
}
public static String makeCustomBubble(String prefix, String name, String suffix, BubbleConfig bubble) {
int totalWidth = FontUtil.getTotalWidth(ChatColor.stripColor(prefix + name + suffix));
boolean isEven = totalWidth % 2 == 0;
char left = bubble.left().getChars();
char middle = bubble.middle().getChars();
char right = bubble.right().getChars();
char tail = bubble.tail().getChars();
char neg_1 = FontOffset.NEG_1.getCharacter();
int offset = bubble.middle().getWidth() - bubble.tail().getWidth();
int left_offset = totalWidth + bubble.left().getWidth() + 1;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(FontOffset.getShortestNegChars(isEven ? left_offset - offset : left_offset + 1 - offset));
stringBuilder.append(left).append(neg_1);
int mid_amount = (totalWidth + 1 - bubble.tail().getWidth()) / (bubble.middle().getWidth());
if (mid_amount == 0) {
stringBuilder.append(tail).append(neg_1);
}
else {
for (int i = 0; i <= mid_amount; i++) {
if (i == mid_amount/2) {
stringBuilder.append(tail).append(neg_1);
}
else {
stringBuilder.append(middle).append(neg_1);
}
}
}
stringBuilder.append(FontOffset.getShortestNegChars(bubble.right().getWidth() - ((totalWidth + 1 + offset) % bubble.middle().getWidth() + (isEven ? 0 : -1))));
stringBuilder.append(middle).append(neg_1);
stringBuilder.append(right).append(neg_1);
stringBuilder.append(FontOffset.getShortestNegChars(left_offset - 1));
return stringBuilder.toString();
}
}

View File

@@ -39,12 +39,14 @@ public class NameplatesTeam {
private String prefixText;
private String suffixText;
private ChatColor color;
private String dynamic;
public Component getPrefix() {return this.prefix;}
public Component getSuffix() {return this.suffix;}
public ChatColor getColor() {return this.color;}
public String getPrefixText() {return prefixText;}
public String getSuffixText() {return suffixText;}
public String getDynamic() {return dynamic;}
public NameplatesTeam(Player player) {
@@ -98,9 +100,9 @@ public class NameplatesTeam {
return;
}
NameplateInstance nameplateInstance = CustomNameplates.instance.getResourceManager().getNameplateInstance(nameplate);
NameplateConfig nameplateConfig = CustomNameplates.instance.getResourceManager().getNameplateConfig(nameplate);
if (nameplateInstance == null){
if (nameplateConfig == null){
this.prefix = Component.text("");
this.suffix = Component.text("");
this.prefixText = "";
@@ -126,41 +128,31 @@ public class NameplatesTeam {
else playerSuffix = "";
}
this.dynamic = playerPrefix + playerSuffix;
String name = this.player.getName();
this.prefixText = NameplateUtil.makeCustomNameplate(
MiniMessage.miniMessage().stripTags(playerPrefix),
name,
MiniMessage.miniMessage().stripTags(playerSuffix),
nameplateInstance
) + playerPrefix;
nameplateConfig
);
this.suffixText = playerSuffix + NameplateUtil.getSuffixChar(
this.suffixText = NameplateUtil.getSuffixChar(
MiniMessage.miniMessage().stripTags(playerPrefix) +
name +
MiniMessage.miniMessage().stripTags(playerSuffix)
);
this.prefix = Component.text(
NameplateUtil.makeCustomNameplate(
MiniMessage.miniMessage().stripTags(playerPrefix),
name,
MiniMessage.miniMessage().stripTags(playerSuffix),
nameplateInstance
)
)
this.prefix = Component.text(this.prefixText)
.font(ConfigManager.Main.key)
.append(MiniMessage.miniMessage().deserialize(playerPrefix));
this.suffix = MiniMessage.miniMessage().deserialize(playerSuffix)
.append(Component.text(
NameplateUtil.getSuffixChar(
MiniMessage.miniMessage().stripTags(playerPrefix) +
name +
MiniMessage.miniMessage().stripTags(playerSuffix))
)
.append(Component.text(this.suffixText)
.font(ConfigManager.Main.key));
this.color = nameplateInstance.getConfig().getColor();
this.color = nameplateConfig.color();
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* 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 <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.nameplates;
import java.util.Objects;
public class TeamInfo {
private final String prefix;
private final String suffix;
public TeamInfo(String prefix, String suffix) {
this.prefix = prefix;
this.suffix = suffix;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TeamInfo teamInfo = (TeamInfo) o;
return Objects.equals(prefix, teamInfo.prefix) && Objects.equals(suffix, teamInfo.suffix);
}
@Override
public int hashCode() {
return Objects.hash(prefix, suffix);
}
}

View File

@@ -39,11 +39,11 @@ public class TeamManager {
String teamName = getTeamName(player);
if (teamName != null) {
if (!teams.containsKey(teamName)) teams.put(teamName, new NameplatesTeam(player));
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player, false);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToOne(player);
}
else {
if (!player.isOnline()) return;
if (player == null || !player.isOnline()) return;
Bukkit.getScheduler().runTaskLater(CustomNameplates.instance, () -> {
createTeam(player);
},20);

View File

@@ -22,6 +22,6 @@ import org.bukkit.entity.Player;
public interface TeamPacketManager {
void sendUpdateToOne(Player player);
void sendUpdateToAll(Player player);
void sendUpdateToAll(Player player, boolean force);
}

View File

@@ -20,7 +20,9 @@ package net.momirealms.customnameplates.nameplates.mode;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
public record EventListener(NameplateManager nameplateManager) implements Listener {
@@ -34,6 +36,7 @@ public record EventListener(NameplateManager nameplateManager) implements Listen
nameplateManager.onQuit(event.getPlayer());
}
// @EventHandler
// public void onAccept(PlayerResourcePackStatusEvent event) {
// nameplateManager.onRP(event.getPlayer(), event.getStatus());

View File

@@ -9,8 +9,8 @@ import net.momirealms.customnameplates.ConfigManager;
import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.data.PlayerData;
import net.momirealms.customnameplates.nameplates.ArmorStandManager;
import net.momirealms.customnameplates.nameplates.BubbleConfig;
import net.momirealms.customnameplates.nameplates.FakeArmorStand;
import net.momirealms.customnameplates.nameplates.NameplateInstance;
import net.momirealms.customnameplates.nameplates.NameplateUtil;
import net.momirealms.customnameplates.nameplates.mode.EntityTag;
import net.momirealms.customnameplates.resource.ResourceManager;
@@ -91,9 +91,9 @@ public class ChatBubblesManager extends EntityTag {
public void onChat(Player player, String text) {
PlayerData playerData = CustomNameplates.instance.getDataManager().getOrEmpty(player);
String bubbles = playerData.getBubbles();
NameplateInstance bubblesInstance = ResourceManager.NAMEPLATES.get(bubbles);
BubbleConfig bubbleConfig = ResourceManager.BUBBLES.get(bubbles);
WrappedChatComponent wrappedChatComponent;
if (bubblesInstance == null || bubbles.equals("none")) {
if (bubbleConfig == null || bubbles.equals("none")) {
text = ConfigManager.Main.placeholderAPI ?
CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(player, ConfigManager.Bubbles.prefix) + ConfigManager.Bubbles.defaultFormat + text + CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(player, ConfigManager.Bubbles.suffix)
:
@@ -102,15 +102,15 @@ public class ChatBubblesManager extends EntityTag {
}
else {
text = ConfigManager.Main.placeholderAPI ?
CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(player, ConfigManager.Bubbles.prefix) + bubblesInstance.getConfig().bubbleColor() + text + CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(player, ConfigManager.Bubbles.suffix)
CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(player, ConfigManager.Bubbles.prefix) + bubbleConfig.format() + text + CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(player, ConfigManager.Bubbles.suffix)
:
ConfigManager.Bubbles.prefix + text + ConfigManager.Bubbles.suffix;
String stripped = MiniMessage.miniMessage().stripTags(text);
String bubble = NameplateUtil.makeCustomNameplate("", stripped, "", bubblesInstance);
String bubble = NameplateUtil.makeCustomBubble("", stripped, "", bubbleConfig);
String suffix = NameplateUtil.getSuffixChar(stripped);
Component armorStand_Name = Component.text(bubble).font(ConfigManager.Main.key)
.append(MiniMessage.miniMessage().deserialize(text).font(Key.key("minecraft:default")))
.append(Component.text(suffix).font(ConfigManager.Main.key));
.append(MiniMessage.miniMessage().deserialize(text).font(Key.key("minecraft:default")))
.append(Component.text(suffix).font(ConfigManager.Main.key));
wrappedChatComponent = WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(armorStand_Name));
}
ArmorStandManager asm = getArmorStandManager(player);

View File

@@ -47,7 +47,7 @@ public class RidingTag extends EntityTag {
asm.addDefault();
armorStandManagerMap.put(all, asm);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToOne(all);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(all);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(all, true);
for (Player player : Bukkit.getOnlinePlayers())
ridingArmorStands(player, all);
}

View File

@@ -52,7 +52,7 @@ public class TeamTag extends NameplateManager {
Bukkit.getPluginManager().registerEvents(listener, CustomNameplates.instance);
for (Player player : Bukkit.getOnlinePlayers()) {
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player, true);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToOne(player);
}
@@ -64,7 +64,7 @@ public class TeamTag extends NameplateManager {
NameplatesTeam nameplatesTeam = teamManager.getTeams().get(teamName);
if (nameplatesTeam != null) {
nameplatesTeam.updateNameplates();
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player, false);
}
}
}, 20, ConfigManager.Nameplate.refresh);

View File

@@ -23,11 +23,8 @@ 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.hook.TABTeamHook;
import net.momirealms.customnameplates.nameplates.NameplatesTeam;
import net.momirealms.customnameplates.nameplates.TeamInfo;
import net.momirealms.customnameplates.nameplates.TeamManager;
import net.momirealms.customnameplates.nameplates.TeamPacketManager;
import org.bukkit.Bukkit;
@@ -40,7 +37,7 @@ import java.util.Optional;
public class TeamPacketA implements TeamPacketManager {
private final HashMap<Player, TeamInfo> teamInfoCache = new HashMap<>();
private final HashMap<Player, String> teamInfoCache = new HashMap<>();
private final TeamManager teamManager;
@@ -62,16 +59,9 @@ public class TeamPacketA implements TeamPacketManager {
if (optional.isEmpty()) return;
InternalStructure internalStructure = optional.get();
internalStructure.getStrings().write(0, "always");
// if (ConfigManager.Nameplate.show_after && !accepted) {
// 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);
// }
// else {
internalStructure.getChatComponents().write(1, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(nameplatesTeam.getPrefix())));
internalStructure.getChatComponents().write(2, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(nameplatesTeam.getSuffix())));
internalStructure.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0,nameplatesTeam.getColor());
// }
try {
CustomNameplates.protocolManager.sendServerPacket(player, packet);
}
@@ -81,12 +71,14 @@ public class TeamPacketA implements TeamPacketManager {
}
}
public void sendUpdateToAll(Player player) {
public void sendUpdateToAll(Player player, boolean force) {
String teamName = TeamManager.getTeamName(player);
NameplatesTeam nameplatesTeam = teamManager.getTeams().get(teamName);
TeamInfo newInfo = new TeamInfo(nameplatesTeam.getPrefixText(), nameplatesTeam.getSuffixText());
TeamInfo oldInfo = teamInfoCache.put(player, newInfo);
if (oldInfo != null && oldInfo.equals(newInfo)) return;
String newInfo = nameplatesTeam.getDynamic();
String oldInfo = teamInfoCache.get(player);
if (newInfo.equals(oldInfo) && !force) {
return;
}
teamInfoCache.put(player, newInfo);
for (Player otherPlayer : Bukkit.getOnlinePlayers()) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
@@ -96,24 +88,9 @@ public class TeamPacketA implements TeamPacketManager {
if (optional.isEmpty()) return;
InternalStructure internalStructure = optional.get();
internalStructure.getStrings().write(0, "always");
// if (ConfigManager.Nameplate.show_after) {
// PlayerData playerData = CustomNameplates.instance.getDataManager().getCache().get(otherPlayer.getUniqueId());
// if (playerData == null || !playerData.getAccepted()) {
// 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);
// }
// else {
// internalStructure.getChatComponents().write(1, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(nameplatesTeam.getPrefix())));
// internalStructure.getChatComponents().write(2, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(nameplatesTeam.getSuffix())));
// internalStructure.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0,nameplatesTeam.getColor());
// }
// }
// else {
internalStructure.getChatComponents().write(1, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(nameplatesTeam.getPrefix())));
internalStructure.getChatComponents().write(2, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(nameplatesTeam.getSuffix())));
internalStructure.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0,nameplatesTeam.getColor());
// }
try {
CustomNameplates.protocolManager.sendServerPacket(otherPlayer, packet);
} catch (InvocationTargetException e) {

View File

@@ -36,7 +36,6 @@ public class TeamPacketB implements TeamPacketManager {
@Override
public void sendUpdateToOne(Player player) {
// boolean accepted = CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId()).getAccepted();
for (Player otherPlayer : Bukkit.getOnlinePlayers()) {
if (player == otherPlayer) return;
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
@@ -46,15 +45,9 @@ public class TeamPacketB implements TeamPacketManager {
Optional<InternalStructure> optional = packet.getOptionalStructures().read(0);
if (optional.isEmpty()) return;
InternalStructure internalStructure = optional.get();
// if (ConfigManager.Nameplate.show_after && !accepted) {
// internalStructure.getStrings().write(0, "always");
// internalStructure.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0,ChatColor.WHITE);
// }
// else {
if (ConfigManager.Nameplate.removeTag) internalStructure.getStrings().write(0, "never");
else internalStructure.getStrings().write(0, "always");
internalStructure.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0,ChatColor.WHITE);
// }
try {
CustomNameplates.protocolManager.sendServerPacket(player, packet);
}
@@ -65,7 +58,7 @@ public class TeamPacketB implements TeamPacketManager {
}
@Override
public void sendUpdateToAll(Player player) {
public void sendUpdateToAll(Player player, boolean force) {
String teamName = TeamManager.getTeamName(player);
for (Player otherPlayer : Bukkit.getOnlinePlayers()) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
@@ -74,20 +67,8 @@ public class TeamPacketB implements TeamPacketManager {
Optional<InternalStructure> optional = packet.getOptionalStructures().read(0);
if (optional.isEmpty()) return;
InternalStructure internalStructure = optional.get();
// if (ConfigManager.Nameplate.show_after) {
// PlayerData playerData = CustomNameplates.instance.getDataManager().getCache().get(otherPlayer.getUniqueId());
// if (playerData == null || !playerData.getAccepted()) {
// internalStructure.getStrings().write(0, "always");
// }
// else {
// if (ConfigManager.Nameplate.removeTag) internalStructure.getStrings().write(0, "never");
// else internalStructure.getStrings().write(0, "always");
// }
// }
// else {
if (ConfigManager.Nameplate.removeTag) internalStructure.getStrings().write(0, "never");
else internalStructure.getStrings().write(0, "always");
// }
internalStructure.getEnumModifier(ChatColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, ChatColor.WHITE);
try {
CustomNameplates.protocolManager.sendServerPacket(otherPlayer, packet);

View File

@@ -21,6 +21,8 @@ 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.CustomNameplates;
import net.momirealms.customnameplates.nameplates.TeamManager;
import org.bukkit.Bukkit;
@@ -64,10 +66,13 @@ public class TeamPacketUtil {
PacketContainer packetToNew = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
packetToNew.getIntegers().write(0,0);
packetToNew.getStrings().write(0, all.getName());
packetToAll.getModifier().write(2, Collections.singletonList(all.getName()));
packetToNew.getModifier().write(2, Collections.singletonList(all.getName()));
try {
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomNameplates.instance, () -> {
CustomNameplates.instance.getTeamPacketManager().sendUpdateToOne(joinPlayer);
},100);
CustomNameplates.protocolManager.sendServerPacket(joinPlayer, packetToNew);
if (all != joinPlayer) CustomNameplates.protocolManager.sendServerPacket(all, packetToAll);
if (joinPlayer != all) CustomNameplates.protocolManager.sendServerPacket(all, packetToAll);
}
catch (InvocationTargetException e) {
e.printStackTrace();

View File

@@ -51,7 +51,7 @@ public class TeleportingTag extends EntityTag {
asm.addDefault();
armorStandManagerMap.put(all, asm);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToOne(all);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(all);
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(all, true);
for (Player player : Bukkit.getOnlinePlayers())
spawnArmorStands(player, all);
}

View File

@@ -22,110 +22,61 @@ import net.momirealms.customnameplates.resource.ResourceManager;
import java.util.HashMap;
public record BackGround(String key, String start, String offset_1,
String offset_2, String offset_4, String offset_8,
String offset_16, String offset_32, String offset_64,
String offset_128, String end, int offset_y, int start_width, int end_width, int size) {
public record BackGround(SimpleChar start, SimpleChar offset_1,
SimpleChar offset_2, SimpleChar offset_4,
SimpleChar offset_8, SimpleChar offset_16,
SimpleChar offset_32, SimpleChar offset_64,
SimpleChar offset_128, SimpleChar end,
int start_width, int end_width) {
public String getBackGround(int n) {
String offset = FontOffset.getShortestNegChars(n + end_width + 2);
n = n + start_width + end_width + 2;
StringBuilder stringBuilder = new StringBuilder();
HashMap<String, Character> chars = ResourceManager.BACKGROUNDS.get(key);
stringBuilder.append(chars.get(start));
stringBuilder.append(start.getChars());
while (n >= 128) {
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(offset_128));
stringBuilder.append(offset_128.getChars());
n -= 128;
}
if (n - 64 >= 0) {
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(offset_64));
stringBuilder.append(offset_64.getChars());
n -= 64;
}
if (n - 32 >= 0) {
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(offset_32));
stringBuilder.append(offset_32.getChars());
n -= 32;
}
if (n - 16 >= 0) {
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(offset_16));
stringBuilder.append(offset_16.getChars());
n -= 16;
}
if (n - 8 >= 0) {
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(offset_8));
stringBuilder.append(offset_8.getChars());
n -= 8;
}
if (n - 4 >= 0) {
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(offset_4));
stringBuilder.append(offset_4.getChars());
n -= 4;
}
if (n - 2 >= 0) {
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(offset_2));
stringBuilder.append(offset_2.getChars());
n -= 2;
}
if (n - 1 >= 0) {
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(offset_1));
stringBuilder.append(offset_1.getChars());
}
stringBuilder.append(FontOffset.NEG_1.getCharacter());
stringBuilder.append(chars.get(end)).append(offset);
stringBuilder.append(end.getChars()).append(offset);
return stringBuilder.toString();
}
public String getStart() {
return start;
}
public String getEnd() {
return end;
}
public int getOffset_y() {
return offset_y;
}
public String getOffset_1() {
return offset_1;
}
public String getOffset_2() {
return offset_2;
}
public String getOffset_4() {
return offset_4;
}
public String getOffset_8() {
return offset_8;
}
public String getOffset_16() {
return offset_16;
}
public String getOffset_32() {
return offset_32;
}
public String getOffset_64() {
return offset_64;
}
public String getOffset_128() {
return offset_128;
}
public String getKey() {
return key;
}
public int getSize() {
return size;
}
}

View File

@@ -0,0 +1,40 @@
package net.momirealms.customnameplates.objects;
public class SimpleChar {
public static SimpleChar none = new SimpleChar(16, 12, 16,'默', "none.png");
private final int height;
private final int ascent;
private final char chars;
private final String file;
private final int width;
public SimpleChar(int height, int ascent, int width, char chars, String path) {
this.height = height;
this.ascent = ascent;
this.chars = chars;
this.file = path;
this.width = width;
}
public int getHeight() {
return height;
}
public int getAscent() {
return ascent;
}
public char getChars() {
return chars;
}
public String getFile() {
return file;
}
public int getWidth() {
return width;
}
}

View File

@@ -22,10 +22,11 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import net.momirealms.customnameplates.ConfigManager;
import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.helper.Log;
import net.momirealms.customnameplates.nameplates.BubbleConfig;
import net.momirealms.customnameplates.objects.SimpleChar;
import net.momirealms.customnameplates.utils.AdventureUtil;
import net.momirealms.customnameplates.objects.BackGround;
import net.momirealms.customnameplates.nameplates.NameplateInstance;
import net.momirealms.customnameplates.font.FontChar;
import net.momirealms.customnameplates.font.FontOffset;
import net.momirealms.customnameplates.nameplates.NameplateConfig;
import org.apache.commons.io.FileUtils;
@@ -43,85 +44,368 @@ import static net.momirealms.customnameplates.ConfigManager.Main.start;
public class ResourceManager {
public static HashMap<String, NameplateInstance> NAMEPLATES = new HashMap<>();
public static HashMap<String, HashMap<String, Character>> BACKGROUNDS = new HashMap<>();
public static HashMap<String, NameplateConfig> NAMEPLATES;
public static HashMap<String, BubbleConfig> BUBBLES;
public static HashMap<String, BackGround> BACKGROUNDS;
//生成资源包并载入新的配置
public void generateResourcePack() {
File r_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "nameplates");
File b_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "backgrounds");
File g_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "ResourcePack");
//铭牌
File np_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "nameplates");
//背景
File bg_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "backgrounds");
//气泡
File bb_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "bubbles");
//生成的
File gd_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "ResourcePack");
if (!r_file.exists()) {
if (!r_file.mkdir()) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to create resources folder...</red>");
return;
}
saveDefaultResources();
}
//清除之前的旧文件
deleteDirectory(gd_file);
if (!b_file.exists()) {
if (!b_file.mkdir()) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to create resources folder...</red>");
return;
}
saveDefaultBGResources();
}
File font_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "ResourcePack" + File.separatorChar + ConfigManager.Main.namespace + File.separatorChar + "font");
File textures_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "ResourcePack" + File.separatorChar + ConfigManager.Main.namespace + File.separatorChar + "textures");
File[] pngFiles = r_file.listFiles(file -> file.getName().endsWith(".png"));
if (pngFiles == null) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! No png files detected in resource folder...</red>");
return;
}
Arrays.sort(pngFiles);
deleteDirectory(g_file);
File f_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "ResourcePack" + File.separatorChar + ConfigManager.Main.namespace + File.separatorChar + "font");
File t_file = new File(CustomNameplates.instance.getDataFolder() + File.separator + "ResourcePack" + File.separatorChar + ConfigManager.Main.namespace + File.separatorChar + "textures");
if (!f_file.mkdirs() || !t_file.mkdirs()) {
if (!font_file.mkdirs() || !textures_file.mkdirs()) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to generate resource pack folders...</red>");
return;
}
if (ConfigManager.Main.offsets != null){
ConfigManager.Main.offsets.forEach(offset -> {
//保存偏移字符图
saveSplit(textures_file.getPath());
//新建Json
JsonObject jsonObject_default = new JsonObject();
JsonArray jsonArray_default = new JsonArray();
jsonObject_default.add("providers", jsonArray_default);
//获取偏移字符
getOffsetFontEnums().forEach(jsonArray_default::add);
//铭牌模块
if (ConfigManager.Module.nameplate) {
//保存默认的文件
if (!np_file.exists()) {
if (!np_file.mkdir()) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to create resources folder...</red>");
return;
}
saveDefaultNameplates();
}
File[] np_config_files = np_file.listFiles(file -> file.getName().endsWith(".yml"));
//滚
if (np_config_files == null) return;
//排序
Arrays.sort(np_config_files);
if (ConfigManager.Module.nameplate){
NAMEPLATES = new HashMap<>();
NAMEPLATES.put("none", NameplateConfig.EMPTY);
for (File np_config_file : np_config_files) {
//初始化当前三个字符的unicode
char left = start;
char middle;
char right;
start = (char)((right = (char)((middle = (char)(start + '\u0001')) + '\u0001')) + '\u0001');
try {
String key = np_config_file.getName().substring(0, np_config_file.getName().length() - 4);
YamlConfiguration config = YamlConfiguration.loadConfiguration(np_config_file);
if (!config.contains("display-name")) config.set("display-name", key);
if (!config.contains("name-color")) config.set("name-color", "white");
if (!config.contains("left.image")) config.set("left.image", key + "_left");
if (!config.contains("left.height")) config.set("left.height", 16);
if (!config.contains("left.ascent")) config.set("left.ascent", 12);
if (!config.contains("left.width")) config.set("left.width", 16);
if (!config.contains("middle.image")) config.set("middle.image", key + "_middle");
if (!config.contains("middle.height")) config.set("middle.height", 16);
if (!config.contains("middle.ascent")) config.set("middle.ascent", 12);
if (!config.contains("middle.width")) config.set("middle.width", 16);
if (!config.contains("right.image")) config.set("right.image", key + "_right");
if (!config.contains("right.height")) config.set("right.height", 16);
if (!config.contains("right.ascent")) config.set("right.ascent", 12);
if (!config.contains("right.width")) config.set("right.width", 16);
SimpleChar leftChar = new SimpleChar(config.getInt("left.height"), config.getInt("left.ascent"), config.getInt("left.width"), left, config.getString("left.image") + ".png");
SimpleChar middleChar = new SimpleChar(config.getInt("middle.height"), config.getInt("middle.ascent"), config.getInt("middle.width"), middle, config.getString("middle.image") + ".png");
SimpleChar rightChar = new SimpleChar(config.getInt("right.height"), config.getInt("right.ascent"), config.getInt("right.width"), right, config.getString("right.image") + ".png");
ChatColor color = ChatColor.valueOf(Objects.requireNonNull(config.getString("color","WHITE")).toUpperCase());
config.save(np_config_file);
NameplateConfig nameplateConfig = new NameplateConfig(color, config.getString("display-name"), leftChar, middleChar, rightChar);
NAMEPLATES.put(key, nameplateConfig);
SimpleChar[] simpleChars = new SimpleChar[]{leftChar, middleChar, rightChar};
for (SimpleChar simpleChar : simpleChars) {
JsonObject jo_np = new JsonObject();
jo_np.add("type", new JsonPrimitive("bitmap"));
jo_np.add("file", new JsonPrimitive(ConfigManager.Main.namespace + ":" + ConfigManager.Main.np_folder_path.replaceAll("\\\\","/") + simpleChar.getFile()));
jo_np.add("ascent", new JsonPrimitive(simpleChar.getAscent()));
jo_np.add("height", new JsonPrimitive(simpleChar.getHeight()));
JsonArray ja_simple = new JsonArray();
ja_simple.add(native2ascii(simpleChar.getChars()));
jo_np.add("chars", ja_simple);
jsonArray_default.add(jo_np);
try {
FileUtils.copyFile(new File(np_config_file.getParent() + File.separator + simpleChar.getFile()), new File(textures_file.getPath() + File.separatorChar + StringUtils.replace(ConfigManager.Main.np_folder_path, "\\", File.separator) + simpleChar.getFile()));
}
catch (IOException e){
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy nameplate " + key + " png files to resource pack...</red>");
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}
//气泡模块
if (ConfigManager.Module.bubbles) {
if (!bb_file.exists()) {
if (!bb_file.mkdir()) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to create resources folder...</red>");
return;
}
saveDefaultBubbles();
}
BUBBLES = new HashMap<>();
File[] bb_config_files = bb_file.listFiles(file -> file.getName().endsWith(".yml"));
if (bb_config_files == null) return;
Arrays.sort(bb_config_files);
for (File bb_config_file : bb_config_files) {
char left = start;
char middle;
char right;
char tail;
start = (char) ((tail = (char)((right = (char)((middle = (char)(start + '\u0001')) + '\u0001')) + '\u0001')) + '\u0001');
try {
String key = bb_config_file.getName().substring(0, bb_config_file.getName().length() - 4);
YamlConfiguration config = YamlConfiguration.loadConfiguration(bb_config_file);
if (!config.contains("display-name")) config.set("display-name", key);
if (!config.contains("text-format")) config.set("text-format", "<white>");
if (!config.contains("left.image")) config.set("left.image", key + "_left");
if (!config.contains("left.height")) config.set("left.height", 16);
if (!config.contains("left.width")) config.set("left.width", 16);
if (!config.contains("left.ascent")) config.set("left.ascent", 12);
if (!config.contains("middle.image")) config.set("middle.image", key + "_middle");
if (!config.contains("middle.height")) config.set("middle.height", 16);
if (!config.contains("middle.width")) config.set("middle.width", 16);
if (!config.contains("middle.ascent")) config.set("middle.ascent", 12);
if (!config.contains("right.image")) config.set("right.image", key + "_right");
if (!config.contains("right.height")) config.set("right.height", 16);
if (!config.contains("right.width")) config.set("right.width", 16);
if (!config.contains("right.ascent")) config.set("right.ascent", 12);
if (!config.contains("tail.image")) config.set("tail.image", key + "_tail");
if (!config.contains("tail.height")) config.set("tail.height", 16);
if (!config.contains("tail.width")) config.set("tail.width", 16);
if (!config.contains("tail.ascent")) config.set("tail.ascent", 12);
SimpleChar leftChar = new SimpleChar(config.getInt("left.height"), config.getInt("left.ascent"), config.getInt("left.width"), left, config.getString("left.image") + ".png");
SimpleChar middleChar = new SimpleChar(config.getInt("middle.height"), config.getInt("middle.ascent"), config.getInt("middle.width"), middle, config.getString("middle.image") + ".png");
SimpleChar rightChar = new SimpleChar(config.getInt("right.height"), config.getInt("right.ascent"), config.getInt("right.width"), right, config.getString("right.image") + ".png");
SimpleChar tailChar = new SimpleChar(config.getInt("tail.height"), config.getInt("tail.ascent"), config.getInt("tail.width"), tail, config.getString("tail.image") + ".png");
config.save(bb_config_file);
BubbleConfig bubbleConfig = new BubbleConfig(config.getString("text-format"), config.getString("display-name"),
leftChar, middleChar,
rightChar, tailChar);
BUBBLES.put(key, bubbleConfig);
SimpleChar[] simpleChars = new SimpleChar[]{leftChar, middleChar, rightChar, tailChar};
for (SimpleChar simpleChar : simpleChars) {
JsonObject jo_bb = new JsonObject();
jo_bb.add("type", new JsonPrimitive("bitmap"));
jo_bb.add("file", new JsonPrimitive(ConfigManager.Main.namespace + ":" + ConfigManager.Main.bb_folder_path.replaceAll("\\\\","/") + simpleChar.getFile()));
jo_bb.add("ascent", new JsonPrimitive(simpleChar.getAscent()));
jo_bb.add("height", new JsonPrimitive(simpleChar.getHeight()));
JsonArray ja_simple = new JsonArray();
ja_simple.add(native2ascii(simpleChar.getChars()));
jo_bb.add("chars", ja_simple);
jsonArray_default.add(jo_bb);
try {
FileUtils.copyFile(new File(bb_config_file.getParent() + File.separator + simpleChar.getFile()), new File(textures_file.getPath() + File.separatorChar + StringUtils.replace(ConfigManager.Main.bb_folder_path, "\\", File.separator) + simpleChar.getFile()));
}
catch (IOException e){
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy bubble " + key + " png files to resource pack...</red>");
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
//背景模块
if (ConfigManager.Module.background) {
if (!bg_file.exists()) {
if (!bg_file.mkdir()) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to create resources folder...</red>");
return;
}
saveDefaultBackgrounds();
}
BACKGROUNDS = new HashMap<>();
File[] bg_config_files = bg_file.listFiles(file -> file.getName().endsWith(".yml"));
if (bg_config_files == null) return;
Arrays.sort(bg_config_files);
for (File bg_config_file : bg_config_files) {
try {
String key = bg_config_file.getName().substring(0, bg_config_file.getName().length() - 4);
YamlConfiguration config = YamlConfiguration.loadConfiguration(bg_config_file);
char oStart = start;
char o1 = (char) (oStart + '\u0001');
char o2 = (char) (o1 + '\u0001');
char o4 = (char) (o2 + '\u0001');
char o8 = (char) (o4 + '\u0001');
char o16 = (char) (o8 + '\u0001');
char o32 = (char) (o16 + '\u0001');
char o64 = (char) (o32 + '\u0001');
char o128 = (char) (o64 + '\u0001');
char oEnd = (char) (o128 + '\u0001');
start = (char) (oEnd + '\u0001');
int height = config.getInt("middle.height", 14);
int ascent = config.getInt("middle.ascent", 8);
SimpleChar startChar = new SimpleChar(config.getInt("left.height"), config.getInt("left.ascent"),1 ,oStart, config.getString("left.image") + ".png");
SimpleChar offset_1 = new SimpleChar(height, ascent,1, o1, config.getString("middle.1") + ".png");
SimpleChar offset_2 = new SimpleChar(height, ascent,1, o2, config.getString("middle.2") + ".png");
SimpleChar offset_4 = new SimpleChar(height, ascent,1, o4, config.getString("middle.4") + ".png");
SimpleChar offset_8 = new SimpleChar(height, ascent,1, o8, config.getString("middle.8") + ".png");
SimpleChar offset_16 = new SimpleChar(height, ascent,1, o16, config.getString("middle.16") + ".png");
SimpleChar offset_32 = new SimpleChar(height, ascent,1, o32, config.getString("middle.32") + ".png");
SimpleChar offset_64 = new SimpleChar(height, ascent,1, o64, config.getString("middle.64") + ".png");
SimpleChar offset_128 = new SimpleChar(height, ascent,1, o128, config.getString("middle.128") + ".png");
SimpleChar endChar = new SimpleChar(config.getInt("right.height"),config.getInt("right.ascent"),1, oEnd, config.getString("right.image") + ".png");
BackGround backGround = new BackGround(startChar, offset_1,
offset_2, offset_4,
offset_8, offset_16,
offset_32, offset_64,
offset_128, endChar,
config.getInt("start-width", 1), config.getInt("end-width", 1));
BACKGROUNDS.put(key, backGround);
SimpleChar[] simpleChars = new SimpleChar[]{startChar, offset_1,
offset_2, offset_4,
offset_8, offset_16,
offset_32, offset_64,
offset_128, endChar};
for (SimpleChar simpleChar : simpleChars) {
JsonObject jo_bg = new JsonObject();
jo_bg.add("type", new JsonPrimitive("bitmap"));
jo_bg.add("file", new JsonPrimitive(ConfigManager.Main.namespace + ":" + ConfigManager.Main.bg_folder_path.replaceAll("\\\\","/") + simpleChar.getFile()));
jo_bg.add("ascent", new JsonPrimitive(simpleChar.getAscent()));
jo_bg.add("height", new JsonPrimitive(simpleChar.getHeight()));
JsonArray ja_simple = new JsonArray();
ja_simple.add(native2ascii(simpleChar.getChars()));
jo_bg.add("chars", ja_simple);
jsonArray_default.add(jo_bg);
try {
FileUtils.copyFile(new File(bg_config_file.getParent() + File.separator + simpleChar.getFile()), new File(textures_file.getPath() + File.separatorChar + StringUtils.replace(ConfigManager.Main.bg_folder_path, "\\", File.separator) + simpleChar.getFile()));
}
catch (IOException e){
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy background " + key + " png files to resource pack...</red>");
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
//存储默认shader
if (ConfigManager.Main.extract) {
String path = "ResourcePack" + File.separator + "minecraft" + File.separator + "shaders" + File.separator + "core" + File.separator;
CustomNameplates.instance.saveResource(path + "rendertype_text.fsh", true);
CustomNameplates.instance.saveResource(path + "rendertype_text.json", true);
CustomNameplates.instance.saveResource(path + "rendertype_text.vsh", true);
CustomNameplates.instance.saveResource(path + "rendertype_text_see_through.fsh", true);
CustomNameplates.instance.saveResource(path + "rendertype_text_see_through.json", true);
CustomNameplates.instance.saveResource(path + "rendertype_text_see_through.vsh", true);
}
//载入多个偏移
if (ConfigManager.Main.offsets.size() != 0){
for (int offset : ConfigManager.Main.offsets) {
JsonObject jsonObject_offset = new JsonObject();
JsonArray jsonArray_offset = new JsonArray();
jsonObject_offset.add("providers", jsonArray_offset);
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_offset.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"));
jsonObject_2.add("ascent", new JsonPrimitive(offset));
jsonObject_2.add("height", new JsonPrimitive(8));
JsonArray jsonArray_2 = new JsonArray();
jsonArray_2.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000");
jsonArray_2.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000");
jsonArray_2.add("\\u0020\\u0021\\u0022\\u0023\\u0024\\u0025\\u0026\\u0027\\u0028\\u0029\\u002a\\u002b\\u002c\\u002d\\u002e\\u002f");
jsonArray_2.add("\\u0030\\u0031\\u0032\\u0033\\u0034\\u0035\\u0036\\u0037\\u0038\\u0039\\u003a\\u003b\\u003c\\u003d\\u003e\\u003f");
jsonArray_2.add("\\u0040\\u0041\\u0042\\u0043\\u0044\\u0045\\u0046\\u0047\\u0048\\u0049\\u004a\\u004b\\u004c\\u004d\\u004e\\u004f");
jsonArray_2.add("\\u0050\\u0051\\u0052\\u0053\\u0054\\u0055\\u0056\\u0057\\u0058\\u0059\\u005a\\u005b\\u005c\\u005d\\u005e\\u005f");
jsonArray_2.add("\\u0060\\u0061\\u0062\\u0063\\u0064\\u0065\\u0066\\u0067\\u0068\\u0069\\u006a\\u006b\\u006c\\u006d\\u006e\\u006f");
jsonArray_2.add("\\u0070\\u0071\\u0072\\u0073\\u0074\\u0075\\u0076\\u0077\\u0078\\u0079\\u007a\\u007b\\u007c\\u007d\\u007e\\u0000");
jsonArray_2.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000");
jsonArray_2.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u00a3\\u0000\\u0000\\u0192");
jsonArray_2.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u00aa\\u00ba\\u0000\\u0000\\u00ac\\u0000\\u0000\\u0000\\u00ab\\u00bb");
jsonArray_2.add("\\u2591\\u2592\\u2593\\u2502\\u2524\\u2561\\u2562\\u2556\\u2555\\u2563\\u2551\\u2557\\u255d\\u255c\\u255b\\u2510");
jsonArray_2.add("\\u2514\\u2534\\u252c\\u251c\\u2500\\u253c\\u255e\\u255f\\u255a\\u2554\\u2569\\u2566\\u2560\\u2550\\u256c\\u2567");
jsonArray_2.add("\\u2568\\u2564\\u2565\\u2559\\u2558\\u2552\\u2553\\u256b\\u256a\\u2518\\u250c\\u2588\\u2584\\u258c\\u2590\\u2580");
jsonArray_2.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u2205\\u2208\\u0000");
jsonArray_2.add("\\u2261\\u00b1\\u2265\\u2264\\u2320\\u2321\\u00f7\\u2248\\u00b0\\u2219\\u0000\\u221a\\u207f\\u00b2\\u25a0\\u0000");
jsonObject_2.add("chars", jsonArray_2);
jsonArray_offset.add(jsonObject_2);
JsonObject jo_providers = new JsonObject();
jo_providers.add("type", new JsonPrimitive("space"));
JsonObject jo_space = new JsonObject();
jo_space.add(" ", new JsonPrimitive(4));
jo_space.add("\\u200c", new JsonPrimitive(0));
jo_providers.add("advances", jo_space);
jsonArray_offset.add(jo_providers);
JsonObject jo_ascii = new JsonObject();
jo_ascii.add("type", new JsonPrimitive("bitmap"));
jo_ascii.add("file", new JsonPrimitive("minecraft:font/ascii.png"));
jo_ascii.add("ascent", new JsonPrimitive(offset));
jo_ascii.add("height", new JsonPrimitive(8));
JsonArray ja_ascii = new JsonArray();
ja_ascii.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000");
ja_ascii.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000");
ja_ascii.add("\\u0020\\u0021\\u0022\\u0023\\u0024\\u0025\\u0026\\u0027\\u0028\\u0029\\u002a\\u002b\\u002c\\u002d\\u002e\\u002f");
ja_ascii.add("\\u0030\\u0031\\u0032\\u0033\\u0034\\u0035\\u0036\\u0037\\u0038\\u0039\\u003a\\u003b\\u003c\\u003d\\u003e\\u003f");
ja_ascii.add("\\u0040\\u0041\\u0042\\u0043\\u0044\\u0045\\u0046\\u0047\\u0048\\u0049\\u004a\\u004b\\u004c\\u004d\\u004e\\u004f");
ja_ascii.add("\\u0050\\u0051\\u0052\\u0053\\u0054\\u0055\\u0056\\u0057\\u0058\\u0059\\u005a\\u005b\\u005c\\u005d\\u005e\\u005f");
ja_ascii.add("\\u0060\\u0061\\u0062\\u0063\\u0064\\u0065\\u0066\\u0067\\u0068\\u0069\\u006a\\u006b\\u006c\\u006d\\u006e\\u006f");
ja_ascii.add("\\u0070\\u0071\\u0072\\u0073\\u0074\\u0075\\u0076\\u0077\\u0078\\u0079\\u007a\\u007b\\u007c\\u007d\\u007e\\u0000");
ja_ascii.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000");
ja_ascii.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u00a3\\u0000\\u0000\\u0192");
ja_ascii.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u00aa\\u00ba\\u0000\\u0000\\u00ac\\u0000\\u0000\\u0000\\u00ab\\u00bb");
ja_ascii.add("\\u2591\\u2592\\u2593\\u2502\\u2524\\u2561\\u2562\\u2556\\u2555\\u2563\\u2551\\u2557\\u255d\\u255c\\u255b\\u2510");
ja_ascii.add("\\u2514\\u2534\\u252c\\u251c\\u2500\\u253c\\u255e\\u255f\\u255a\\u2554\\u2569\\u2566\\u2560\\u2550\\u256c\\u2567");
ja_ascii.add("\\u2568\\u2564\\u2565\\u2559\\u2558\\u2552\\u2553\\u256b\\u256a\\u2518\\u250c\\u2588\\u2584\\u258c\\u2590\\u2580");
ja_ascii.add("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u2205\\u2208\\u0000");
ja_ascii.add("\\u2261\\u00b1\\u2265\\u2264\\u2320\\u2321\\u00f7\\u2248\\u00b0\\u2219\\u0000\\u221a\\u207f\\u00b2\\u25a0\\u0000");
jo_ascii.add("chars", ja_ascii);
jsonArray_offset.add(jo_ascii);
try (FileWriter fileWriter = new FileWriter(
CustomNameplates.instance.getDataFolder() +
@@ -134,62 +418,7 @@ public class ResourceManager {
catch (IOException e) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to generate offset font json...</red>");
}
});
}
JsonObject jsonObject_1 = new JsonObject();
JsonArray jsonArray_1 = new JsonArray();
jsonObject_1.add("providers", jsonArray_1);
getNegativeFontEnums().forEach(jsonArray_1::add);
if (ConfigManager.Module.nameplate){
for (File png : pngFiles) {
JsonObject jsonObject_2 = new JsonObject();
char left = start;
char middle;
char right;
start = (char)((right = (char)((middle = (char)(start + '\u0001')) + '\u0001')) + '\u0001');
FontChar fontChar = new FontChar(left, middle, right);
String pngName = png.getName().substring(0, png.getName().length() - 4);
NameplateConfig config = this.getConfiguration(pngName);
NAMEPLATES.put(pngName, new NameplateInstance(pngName, fontChar, config));
jsonObject_2.add("type", new JsonPrimitive("bitmap"));
jsonObject_2.add("file", new JsonPrimitive(ConfigManager.Main.namespace + ":" + ConfigManager.Main.folder_path.replaceAll("\\\\","/") + png.getName().toLowerCase()));
jsonObject_2.add("ascent", new JsonPrimitive(config.getYOffset()));
jsonObject_2.add("height", new JsonPrimitive(config.getHeight()));
JsonArray jsonArray_2 = new JsonArray();
jsonArray_2.add(native2ascii(fontChar.getLeft()) + native2ascii(fontChar.getMiddle()) + native2ascii(fontChar.getRight()));
jsonObject_2.add("chars", jsonArray_2);
jsonArray_1.add(jsonObject_2);
try {
FileUtils.copyFile(png, new File(t_file.getPath() + File.separatorChar + StringUtils.replace(ConfigManager.Main.folder_path, "\\", String.valueOf(File.separatorChar)) + png.getName()));
}catch (IOException e){
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy png files to resource pack...</red>");
}
}
NAMEPLATES.put("none", NameplateInstance.EMPTY);
}
if (ConfigManager.Module.background){
ConfigManager.backgrounds.forEach((key, backGround) -> {
getBackgrounds(backGround).forEach(jsonArray_1::add);
});
}
if (ConfigManager.Main.extract) {
String path = "ResourcePack" + File.separator + "minecraft" + File.separator + "shaders" + File.separator + "core" + File.separator;
CustomNameplates.instance.saveResource(path + "rendertype_text.fsh", true);
CustomNameplates.instance.saveResource(path + "rendertype_text.json", true);
CustomNameplates.instance.saveResource(path + "rendertype_text.vsh", true);
CustomNameplates.instance.saveResource(path + "rendertype_text_see_through.fsh", true);
CustomNameplates.instance.saveResource(path + "rendertype_text_see_through.json", true);
CustomNameplates.instance.saveResource(path + "rendertype_text_see_through.vsh", true);
}
try{
CustomNameplates.instance.saveResource("space_split.png", false);
FileUtils.copyFile(new File(CustomNameplates.instance.getDataFolder(),"space_split.png"), new File(t_file.getPath() + File.separator + StringUtils.replace(ConfigManager.Main.ss_folder_path, "\\", String.valueOf(File.separatorChar)) + "space_split.png"));
new File(CustomNameplates.instance.getDataFolder(),"space_split.png").delete();
}catch (IOException e){
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy space_split.png to resource pack...</red>");
}
try (FileWriter fileWriter = new FileWriter(
@@ -199,93 +428,71 @@ public class ResourceManager {
File.separator + "font" +
File.separator + ConfigManager.Main.font + ".json"))
{
fileWriter.write(jsonObject_1.toString().replace("\\\\", "\\"));
} catch (IOException e) {
fileWriter.write(jsonObject_default.toString().replace("\\\\", "\\"));
}
catch (IOException e) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to generate font json...</red>");
}
if (NAMEPLATES.size() != 0) AdventureUtil.consoleMessage("[CustomNameplates] Loaded <green>" + (NAMEPLATES.size() -1) + " <gray>nameplates");
if (NAMEPLATES.size() != 1) AdventureUtil.consoleMessage("[CustomNameplates] Loaded <green>" + (NAMEPLATES.size() -1) + " <gray>nameplates");
if (BUBBLES.size() != 0) AdventureUtil.consoleMessage("[CustomNameplates] Loaded <green>" + BUBBLES.size() + " <gray>bubbles");
if (BACKGROUNDS.size() != 0) AdventureUtil.consoleMessage("[CustomNameplates] Loaded <green>" + BACKGROUNDS.size() + " <gray>backgrounds");
//复制到其他插件文件夹中
hookCopy(gd_file);
}
if (ConfigManager.Main.itemsAdder){
try{
FileUtils.copyDirectory(g_file, new File(Bukkit.getPluginManager().getPlugin("ItemsAdder").getDataFolder() + File.separator + "data"+ File.separator + "resource_pack" + File.separator + "assets") );
AdventureUtil.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>Detected <color:#90EE90>ItemsAdder!<color:#baffd1> Automatically sent rp to ItemsAdder folder!");
}catch (IOException e){
e.printStackTrace();
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy files to ItemsAdder...</red>");
}
}
if (ConfigManager.Main.oraxen){
try{
FileUtils.copyDirectory(g_file, new File(Bukkit.getPluginManager().getPlugin("Oraxen").getDataFolder() + File.separator + "pack"+ File.separator + "assets"));
AdventureUtil.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>Detected <color:#90EE90>Oraxen!<color:#baffd1> Automatically sent rp to Oraxen folder!");
}catch (IOException e){
e.printStackTrace();
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy files to Oraxen...</red>");
private void saveDefaultNameplates() {
String[] png_list = new String[]{"cat", "egg", "cheems", "wither", "xmas", "halloween", "hutao", "starsky", "trident", "rabbit"};
String[] part_list = new String[]{"_left.png", "_middle.png", "_right.png", ".yml"};
for (String name : png_list) {
for (String part : part_list) {
CustomNameplates.instance.saveResource("nameplates" + File.separatorChar + name + part, false);
}
}
}
private void saveDefaultResources() {
List<String> list = Arrays.asList("cat", "egg", "cheems", "wither", "xmas", "halloween","hutao","starsky","trident","rabbit");
list.forEach(name -> CustomNameplates.instance.saveResource("nameplates" + File.separatorChar + name + ".png", false));
private void saveDefaultBubbles() {
String[] png_list = new String[]{"chat"};
String[] part_list = new String[]{"_left.png", "_middle.png", "_right.png", "_tail.png", ".yml"};
for (String name : png_list) {
for (String part : part_list) {
CustomNameplates.instance.saveResource("bubbles" + File.separatorChar + name + part, false);
}
}
}
private void saveDefaultBGResources() {
List<String> list = Arrays.asList("b0", "b1", "b2", "b4", "b8", "b16","b32","b64","b128");
list.forEach(name -> CustomNameplates.instance.saveResource("backgrounds" + File.separatorChar + name + ".png", false));
private void saveDefaultBackgrounds() {
String[] bg_list = new String[]{"b0", "b1", "b2", "b4", "b8", "b16","b32","b64","b128"};
for (String bg : bg_list) {
CustomNameplates.instance.saveResource("backgrounds" + File.separatorChar + bg + ".png", false);
}
String[] config_list = new String[]{"bedrock_1", "bedrock_2", "bedrock_3"};
for (String config : config_list) {
CustomNameplates.instance.saveResource("backgrounds" + File.separatorChar + config + ".yml", false);
}
}
private void deleteDirectory(File file){
if(file.exists()){
try{
FileUtils.deleteDirectory(file);
}catch (IOException e){
}
catch (IOException e){
e.printStackTrace();
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to delete generated folder...</red>" );
}
}
}
private NameplateConfig getConfiguration(String nameplate) {
try {
File file = new File(CustomNameplates.instance.getDataFolder().getPath() + File.separator + "nameplates" + File.separator + nameplate + ".yml");
if (!file.exists()){
try {
file.createNewFile();
}
catch (IOException e) {
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error occurred when generating default nameplate config!");
}
}
YamlConfiguration config = new YamlConfiguration();
config.load(CustomNameplates.instance.getDataFolder().getPath() + File.separator + "nameplates" + File.separator + nameplate + ".yml");
if (!config.contains("name")) config.set("name", nameplate);
if (!config.contains("color")) config.set("color","WHITE");
if (!config.contains("size")) config.set("size", 16);
if (!config.contains("yoffset")) config.set("yoffset", 12);
if (!config.contains("bubble")) config.set("bubble", "<white>");
ChatColor color = ChatColor.valueOf(Objects.requireNonNull(config.getString("color","WHITE")).toUpperCase());
int size = config.getInt("size");
int yoffset = config.getInt("yoffset");
String name = config.getString("name");
String bubble = config.getString("bubble");
config.save(file);
return new NameplateConfig(color, size, name, yoffset, bubble);
}
catch (Exception e) {
return NameplateConfig.EMPTY;
}
}
private List<JsonObject> getNegativeFontEnums() {
private List<JsonObject> getOffsetFontEnums() {
ArrayList<JsonObject> list = new ArrayList<>();
for (FontOffset negativeFont : FontOffset.values()) {
list.add(this.getNegativeFontChar(negativeFont.getHeight(), negativeFont.getCharacter()));
for (FontOffset offsetFont : FontOffset.values()) {
list.add(this.getOffsetFontChar(offsetFont.getHeight(), offsetFont.getCharacter()));
}
return list;
}
private JsonObject getNegativeFontChar(int height, char character) {
private JsonObject getOffsetFontChar(int height, char character) {
JsonObject jsonObject = new JsonObject();
jsonObject.add("type", new JsonPrimitive("bitmap"));
jsonObject.add("file", new JsonPrimitive(ConfigManager.Main.namespace + ":" + ConfigManager.Main.ss_folder_path.replaceAll("\\\\","/") + "space_split.png"));
@@ -297,10 +504,6 @@ public class ResourceManager {
return jsonObject;
}
public NameplateInstance getNameplateInstance(String nameplate) {
return NAMEPLATES.get(nameplate);
}
private String native2ascii(char ch) {
if (ch > '\u007f') {
StringBuilder stringBuilder_1 = new StringBuilder("\\u");
@@ -313,45 +516,48 @@ public class ResourceManager {
return Character.toString(ch);
}
private List<JsonObject> getBackgrounds(BackGround backGround) {
ArrayList<JsonObject> list = new ArrayList<>();
int y_offset = backGround.getOffset_y();
int size = backGround.getSize();
String name = backGround.getKey();
HashMap<String, Character> chars = new HashMap<>();
list.add(setBackgrounds(backGround.getStart(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getOffset_1(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getOffset_2(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getOffset_4(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getOffset_8(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getOffset_16(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getOffset_32(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getOffset_64(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getOffset_128(),y_offset,size,chars));
list.add(setBackgrounds(backGround.getEnd(),y_offset,size,chars));
BACKGROUNDS.put(name, chars);
return list;
private void saveSplit(String path) {
try{
CustomNameplates.instance.saveResource("space_split.png", false);
FileUtils.copyFile(new File(CustomNameplates.instance.getDataFolder(),"space_split.png"), new File(path + File.separator + StringUtils.replace(ConfigManager.Main.ss_folder_path, "\\", File.separator) + "space_split.png"));
new File(CustomNameplates.instance.getDataFolder(),"space_split.png").delete();
}catch (IOException e){
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy space_split.png to resource pack...</red>");
}
}
private JsonObject setBackgrounds(String name, int y_offset, int size, HashMap<String, Character> chars){
JsonObject jsonObject_2 = new JsonObject();
jsonObject_2.add("type", new JsonPrimitive("bitmap"));
jsonObject_2.add("file", new JsonPrimitive(ConfigManager.Main.namespace + ":" + ConfigManager.Main.bg_folder_path.replaceAll("\\\\","/") + name.toLowerCase() + ".png"));
jsonObject_2.add("ascent", new JsonPrimitive(y_offset));
jsonObject_2.add("height", new JsonPrimitive(size));
JsonArray jsonArray_2 = new JsonArray();
char character = start;
jsonArray_2.add(native2ascii(character));
jsonObject_2.add("chars", jsonArray_2);
start = (char)(start + '\u0001');
chars.put(name, character);
try {
FileUtils.copyFile(new File(CustomNameplates.instance.getDataFolder() + File.separator + "backgrounds" + File.separator + name + ".png"), new File(CustomNameplates.instance.getDataFolder() + File.separator + "ResourcePack" + File.separator + ConfigManager.Main.namespace + File.separatorChar + "textures" + File.separatorChar + StringUtils.replace(ConfigManager.Main.bg_folder_path, "\\", String.valueOf(File.separatorChar)) + name + ".png"));
private void hookCopy(File generated) {
if (ConfigManager.Main.itemsAdder){
try {
FileUtils.copyDirectory(generated, new File(Bukkit.getPluginManager().getPlugin("ItemsAdder").getDataFolder() + File.separator + "data"+ File.separator + "resource_pack" + File.separator + "assets") );
AdventureUtil.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>Detected <color:#90EE90>ItemsAdder!<color:#baffd1> Automatically sent rp to ItemsAdder folder!");
}
catch (IOException e){
e.printStackTrace();
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy files to ItemsAdder...</red>");
}
}
catch (IOException e){
e.printStackTrace();
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy background png files to resource pack...</red>");
if (ConfigManager.Main.oraxen){
try {
FileUtils.copyDirectory(generated, new File(Bukkit.getPluginManager().getPlugin("Oraxen").getDataFolder() + File.separator + "pack"+ File.separator + "assets"));
AdventureUtil.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>Detected <color:#90EE90>Oraxen!<color:#baffd1> Automatically sent rp to Oraxen folder!");
}
catch (IOException e){
e.printStackTrace();
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to copy files to Oraxen...</red>");
}
}
return jsonObject_2;
}
public NameplateConfig getNameplateConfig(String nameplate) {
return NAMEPLATES.get(nameplate);
}
public BubbleConfig getBubbleConfig(String bubble) {
return BUBBLES.get(bubble);
}
public BackGround getBackground(String background) {
return BACKGROUNDS.get(background);
}
}

View File

@@ -1,51 +0,0 @@
background:
bedrock_1:
size: 14
# change the margin of the background
start-offset: 1
end-offset: 1
# y-offset is the vertical position of the background
y-offset: 7
start: b0
offset_1: b1
offset_2: b2
offset_4: b4
offset_8: b8
offset_16: b16
offset_32: b32
offset_64: b64
offset_128: b128
end: b0
bedrock_2:
size: 14
start-offset: 4
end-offset: 4
y-offset: 9
start: b0
offset_1: b1
offset_2: b2
offset_4: b4
offset_8: b8
offset_16: b16
offset_32: b32
offset_64: b64
offset_128: b128
end: b0
bedrock_3:
size: 14
start-offset: 1
end-offset: 1
y-offset: -7
start: b0
offset_1: b1
offset_2: b2
offset_4: b4
offset_8: b8
offset_16: b16
offset_32: b32
offset_64: b64
offset_128: b128
end: b0

View File

@@ -0,0 +1,24 @@
start-width: 1
end-width: 1
left:
image: b0
height: 14
ascent: 7
right:
image: b0
height: 14
ascent: 7
middle:
height: 14
ascent: 7
1: b1
2: b2
4: b4
8: b8
16: b16
32: b32
64: b64
128: b128

View File

@@ -0,0 +1,24 @@
start-width: 1
end-width: 1
left:
image: b0
height: 14
ascent: 9
right:
image: b0
height: 14
ascent: 9
middle:
height: 14
ascent: 9
1: b1
2: b2
4: b4
8: b8
16: b16
32: b32
64: b64
128: b128

View File

@@ -0,0 +1,24 @@
start-width: 1
end-width: 1
left:
image: b0
height: 14
ascent: -7
right:
image: b0
height: 14
ascent: -7
middle:
height: 14
ascent: -7
1: b1
2: b2
4: b4
8: b8
16: b16
32: b32
64: b64
128: b128

View File

@@ -0,0 +1,22 @@
text-format: <black>
display-name: Default Chat Bubbles
left:
image: chat_left
height: 13
ascent: 9
width: 3
middle:
image: chat_middle
height: 13
ascent: 9
width: 5
right:
image: chat_right
height: 13
ascent: 9
width: 5
tail:
image: chat_tail
height: 13
ascent: 9
width: 7

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

View File

@@ -1,5 +1,5 @@
# Do not change
config-version: '8'
config-version: '9'
config:
# Language
@@ -18,7 +18,7 @@ config:
# When enabled, the plugin will hook into TAB's team management
# require a restart to apply this
TAB: true
# When enabled, plugin will receive team data from TAB on proxy
# When enabled, plugin will receive team data from TAB on proxy server
# You need to install CustomNameplates on BungeeCord too, otherwise you might be kicked from the server if you enabled "create-fake-team" in nameplate.yml
TAB-BC: false
@@ -45,6 +45,7 @@ config:
# This is useful for those who want to keep their resource pack structure in order.
nameplate-folder-path: 'font\nameplates\'
background-folder-path: 'font\backgrounds\'
bubble-folder-path: 'font\bubbles\'
space-split-folder-path: 'font\'
# The initial character of all nameplates.

View File

@@ -14,7 +14,7 @@ nameplate:
# to provide additional tag lines for players
mode: Team
# When you meet problems of players getting kicked with proxy server you should enable this
# When you meet problems of players getting kicked with proxy server you should disable this
# Or installing BungeeTabListPlus / TAB on the proxy server would fix
create-fake-team: true
@@ -55,7 +55,7 @@ nameplate:
# Make player's original name-tag invisible
# If you have another plugin that is using team please disable team management in that plugin or make player's name invisible in that plugin
remove-nametag: true
# If armor stand is the normal size, more lines can be displayed but texts would go obviously abnormal when you look at it in a certain angle
# If armor stand is the normal height, more lines can be displayed but texts would go obviously abnormal when you look at it in a certain angle
small-size: true
# nameplates content
text:
@@ -68,7 +68,7 @@ nameplate:
# Make player's original name-tag invisible
# If you have another plugin that is using team please disable team management in that plugin or make player's name invisible in that plugin
remove-nametag: true
# Small size armor stand
# Small height armor stand
small-size: true
# nameplates content
text:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 812 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Sad Cat
left:
image: cat_left
height: 16
ascent: 12
width: 16
middle:
image: cat_middle
height: 16
ascent: 12
width: 16
right:
image: cat_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 820 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Thank you, Cheems
left:
image: cheems_left
height: 16
ascent: 12
width: 16
middle:
image: cheems_middle
height: 16
ascent: 12
width: 16
right:
image: cheems_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 769 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Happy Egg
left:
image: egg_left
height: 16
ascent: 12
width: 16
middle:
image: egg_middle
height: 16
ascent: 12
width: 16
right:
image: egg_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Halloween
left:
image: halloween_left
height: 16
ascent: 12
width: 16
middle:
image: halloween_middle
height: 16
ascent: 12
width: 16
right:
image: halloween_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 985 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Hu Tao
left:
image: hutao_left
height: 16
ascent: 12
width: 16
middle:
image: hutao_middle
height: 16
ascent: 12
width: 16
right:
image: hutao_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Little White Rabbit
left:
image: rabbit_left
height: 16
ascent: 12
width: 16
middle:
image: rabbit_middle
height: 16
ascent: 12
width: 16
right:
image: rabbit_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Star Sky
left:
image: starsky_left
height: 16
ascent: 12
width: 16
middle:
image: starsky_middle
height: 16
ascent: 12
width: 16
right:
image: starsky_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1010 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Trident
left:
image: trident_left
height: 16
ascent: 12
width: 16
middle:
image: trident_middle
height: 16
ascent: 12
width: 16
right:
image: trident_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 636 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Wither Rose
left:
image: wither_left
height: 16
ascent: 12
width: 16
middle:
image: wither_middle
height: 16
ascent: 12
width: 16
right:
image: wither_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 B

View File

@@ -0,0 +1,17 @@
name-color: WHITE
display-name: Merry Christmas
left:
image: xmas_left
height: 16
ascent: 12
width: 16
middle:
image: xmas_middle
height: 16
ascent: 12
width: 16
right:
image: xmas_right
height: 16
ascent: 12
width: 16

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB