mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-25 18:09:20 +00:00
2.0-PRE-6
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '2.0-PRE-4'
|
||||
version = '2.0-PRE-6'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.momirealms.customnameplates;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.momirealms.customnameplates.bossbar.BossBarConfig;
|
||||
import net.momirealms.customnameplates.bossbar.Overlay;
|
||||
import net.momirealms.customnameplates.font.FontOffset;
|
||||
import net.momirealms.customnameplates.objects.BackGround;
|
||||
import net.momirealms.customnameplates.font.FontWidthNormal;
|
||||
import net.momirealms.customnameplates.font.FontWidthThin;
|
||||
@@ -69,6 +70,7 @@ public class ConfigManager {
|
||||
public static boolean background;
|
||||
public static boolean bossBar;
|
||||
public static boolean actionbar;
|
||||
public static boolean bubbles;
|
||||
|
||||
public static void loadModule(){
|
||||
YamlConfiguration module = getConfig("MODULES.yml");
|
||||
@@ -76,6 +78,7 @@ public class ConfigManager {
|
||||
background = module.getBoolean("background", true);
|
||||
bossBar = module.getBoolean("bossbar", true);
|
||||
actionbar = module.getBoolean("actionbar", true);
|
||||
bubbles = module.getBoolean("bubbles", false);
|
||||
try {
|
||||
Reflection.load();
|
||||
ConfigUtil.update();
|
||||
@@ -265,7 +268,7 @@ public class ConfigManager {
|
||||
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 + ".x-offset"),bgConfig.getInt("background." + key + ".size",14)
|
||||
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)
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -324,6 +327,23 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载聊天气泡模块功能
|
||||
*/
|
||||
public static class Bubbles {
|
||||
public static String defaultBubble;
|
||||
public static double lineSpace;
|
||||
public static double yOffset;
|
||||
public static int stayTime;
|
||||
public static void load() {
|
||||
YamlConfiguration config = getConfig("bubble.yml");
|
||||
defaultBubble = config.getString("bubble.default-bubbles", "none");
|
||||
lineSpace = config.getDouble("bubble.line-spacing");
|
||||
yOffset = config.getDouble("bubble.bottom-line-Y-offset");
|
||||
stayTime = config.getInt("bubble.stay-time", 5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入自定义宽度配置
|
||||
*/
|
||||
@@ -338,6 +358,8 @@ public class ConfigManager {
|
||||
else
|
||||
for (int i = 0; i < FontWidthNormal.values().length; i++)
|
||||
fontWidth.put(FontWidthNormal.values()[i].getCharacter(), FontWidthNormal.values()[i].getLength());
|
||||
for (int i = 0; i < FontOffset.values().length; i++)
|
||||
fontWidth.put(FontOffset.values()[i].getCharacter(), FontOffset.values()[i].getSpace() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.momirealms.customnameplates.helper.LibraryLoader;
|
||||
import net.momirealms.customnameplates.hook.PlaceholderManager;
|
||||
import net.momirealms.customnameplates.nameplates.TeamManager;
|
||||
import net.momirealms.customnameplates.nameplates.TeamPacketManager;
|
||||
import net.momirealms.customnameplates.nameplates.bubbles.ChatBubblesManager;
|
||||
import net.momirealms.customnameplates.nameplates.mode.NameplateManager;
|
||||
import net.momirealms.customnameplates.nameplates.mode.rd.RidingTag;
|
||||
import net.momirealms.customnameplates.nameplates.mode.tm.TeamTag;
|
||||
@@ -39,7 +40,6 @@ import net.momirealms.customnameplates.nameplates.mode.tmpackets.TeamPacketC;
|
||||
import net.momirealms.customnameplates.nameplates.mode.tp.TeleportingTag;
|
||||
import net.momirealms.customnameplates.resource.ResourceManager;
|
||||
import net.momirealms.customnameplates.utils.AdventureUtil;
|
||||
import net.momirealms.customnameplates.utils.ConfigUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -60,6 +60,7 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
private ActionBarManager actionBarManager;
|
||||
private PlaceholderManager placeholderManager;
|
||||
private NameplateManager nameplateManager;
|
||||
private ChatBubblesManager chatBubblesManager;
|
||||
|
||||
@Override
|
||||
public void onLoad(){
|
||||
@@ -191,8 +192,8 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
this.nameplateManager = null;
|
||||
}
|
||||
if (ConfigManager.Nameplate.mode.equalsIgnoreCase("team")) {
|
||||
this.teamPacketManager = new TeamPacketA();
|
||||
this.nameplateManager = new TeamTag("TEAM");
|
||||
this.teamPacketManager = new TeamPacketA(teamManager);
|
||||
this.nameplateManager = new TeamTag("TEAM", teamManager);
|
||||
this.nameplateManager.load();
|
||||
}
|
||||
else {
|
||||
@@ -207,6 +208,14 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
AdventureUtil.consoleMessage("<red>[CustomNameplates] Unknown nameplate mode!");
|
||||
}
|
||||
}
|
||||
if (ConfigManager.Module.bubbles) {
|
||||
ConfigManager.Bubbles.load();
|
||||
this.chatBubblesManager = new ChatBubblesManager("BUBBLE");
|
||||
this.chatBubblesManager.load();
|
||||
}
|
||||
else if (this.chatBubblesManager != null) {
|
||||
this.chatBubblesManager.unload();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.nameplateManager != null) {
|
||||
|
||||
@@ -6,14 +6,21 @@ import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.google.gson.*;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.font.FontOffset;
|
||||
import net.momirealms.customnameplates.font.FontUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ActionBarPacketsListener extends PacketAdapter {
|
||||
|
||||
private ActionBarManager manager;
|
||||
private final ActionBarManager manager;
|
||||
|
||||
public ActionBarPacketsListener(ActionBarManager manager) {
|
||||
super(CustomNameplates.instance, ListenerPriority.HIGHEST, PacketType.Play.Server.SET_ACTION_BAR_TEXT);
|
||||
@@ -23,6 +30,16 @@ public class ActionBarPacketsListener extends PacketAdapter {
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
// PacketContainer packet = event.getPacket();
|
||||
// WrappedChatComponent chatComponent = packet.getChatComponents().read(0);
|
||||
// Component component = GsonComponentSerializer.gson().deserialize(chatComponent.getJson());
|
||||
// String json = chatComponent.getJson();
|
||||
// JsonElement jsonElement = new JsonParser().parse(json);
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// getJsonText(jsonElement, sb);
|
||||
// int width = FontUtil.getTotalWidth(sb + MiniMessage.miniMessage().stripTags(PlaceholderAPI.setPlaceholders(event.getPlayer(),ConfigManager.ActionbarConfig.text)));
|
||||
// String neg = FontOffset.getShortestNegChars(width/2);
|
||||
// Component raw = GsonComponentSerializer.gson().deserialize(json).append(Component.text(neg).font(ConfigManager.Main.key)).append(MiniMessage.miniMessage().deserialize(PlaceholderAPI.setPlaceholders(event.getPlayer(),ConfigManager.ActionbarConfig.text))).append(Component.text(neg).font(ConfigManager.Main.key));
|
||||
// WrappedChatComponent chatComponent1 = WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(raw));
|
||||
// packet.getChatComponents().write(0, chatComponent1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,16 +22,11 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.nameplates.mode.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.*;
|
||||
import net.momirealms.customnameplates.nameplates.mode.EntityTag;
|
||||
import net.momirealms.customnameplates.nameplates.mode.rd.RidingTag;
|
||||
import net.momirealms.customnameplates.resource.ResourceManager;
|
||||
import net.momirealms.customnameplates.utils.AdventureUtil;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.NameplateInstance;
|
||||
import net.momirealms.customnameplates.nameplates.NameplateUtil;
|
||||
import net.momirealms.customnameplates.nameplates.NameplatesTeam;
|
||||
import net.momirealms.customnameplates.nameplates.TeamManager;
|
||||
import net.momirealms.customnameplates.utils.HoloUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package net.momirealms.customnameplates.data;
|
||||
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
public static PlayerData EMPTY = new PlayerData("none");
|
||||
|
||||
@@ -1,114 +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.font;
|
||||
|
||||
public enum FontNegative {
|
||||
|
||||
/*
|
||||
实际向左移的距离是height(尺寸)-2
|
||||
*/
|
||||
NEG_1('\uf801', -1, -3),
|
||||
NEG_2('\uf802', -2, -4),
|
||||
NEG_3('\uf803', -3, -5),
|
||||
NEG_4('\uf804', -4, -6),
|
||||
NEG_5('\uf805', -5, -7),
|
||||
NEG_6('\uf806', -6, -8),
|
||||
NEG_7('\uf807', -7, -9),
|
||||
NEG_8('\uf808', -8, -10),
|
||||
NEG_16('\uf809', -16, -18),
|
||||
NEG_32('\uf80a', -32, -34),
|
||||
NEG_64('\uf80b', -64, -66),
|
||||
NEG_128('\uf80c', -128, -130);
|
||||
|
||||
private final char character;
|
||||
private final int space;
|
||||
private final int height;
|
||||
|
||||
FontNegative(char character, int space, int height) {
|
||||
this.character = character;
|
||||
this.space = space;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/*
|
||||
获取最短的负空格字符
|
||||
*/
|
||||
public static String getShortestNegChars(int n) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
while (n > 128) {
|
||||
stringBuilder.append(FontNegative.NEG_128.getCharacter());
|
||||
n -= 128;
|
||||
}
|
||||
if (n - 64 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_64.getCharacter());
|
||||
n -= 64;
|
||||
}
|
||||
if (n - 32 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_32.getCharacter());
|
||||
n -= 32;
|
||||
}
|
||||
if (n - 16 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_16.getCharacter());
|
||||
n -= 16;
|
||||
}
|
||||
if (n - 8 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_8.getCharacter());
|
||||
n -= 8;
|
||||
}
|
||||
if (n - 7 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_7.getCharacter());
|
||||
n -= 7;
|
||||
}
|
||||
if (n - 6 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_6.getCharacter());
|
||||
n -= 6;
|
||||
}
|
||||
if (n - 5 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_5.getCharacter());
|
||||
n -= 5;
|
||||
}
|
||||
if (n - 4 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_4.getCharacter());
|
||||
n -= 4;
|
||||
}
|
||||
if (n - 3 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_3.getCharacter());
|
||||
n -= 3;
|
||||
}
|
||||
if (n - 2 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_2.getCharacter());
|
||||
n -= 2;
|
||||
}
|
||||
if (n - 1 > 0) {
|
||||
stringBuilder.append(FontNegative.NEG_1.getCharacter());
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public char getCharacter() {
|
||||
return this.character;
|
||||
}
|
||||
|
||||
public int getSpace() {
|
||||
return this.space;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,6 @@ public class FontUtil {
|
||||
for (int i = 0; i < length; i++) {
|
||||
n += getInfo(s.charAt(i));
|
||||
}
|
||||
return n + length - 1; //总长还需加上字符间距
|
||||
return n + length; //总长还需加上字符间距
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.momirealms.customnameplates.nameplates.TeamManager;
|
||||
import net.momirealms.customnameplates.objects.BackGroundText;
|
||||
import net.momirealms.customnameplates.objects.NameplateText;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -1,105 +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.hook;
|
||||
|
||||
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.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;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class Placeholders extends PlaceholderExpansion {
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return "nameplates";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return "XiaoMoMi";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
@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();
|
||||
else return ConfigManager.Message.noNameplate;
|
||||
}
|
||||
if (params.equals("prefix")){
|
||||
NameplatesTeam nameplatesTeam = CustomNameplates.instance.getTeamManager().getTeams().get(TeamManager.getTeamName(player.getPlayer()));
|
||||
if (nameplatesTeam != null) return nameplatesTeam.getPrefixText();
|
||||
else return "";
|
||||
}
|
||||
if (params.equals("suffix")){
|
||||
NameplatesTeam nameplatesTeam = CustomNameplates.instance.getTeamManager().getTeams().get(TeamManager.getTeamName(player.getPlayer()));
|
||||
if (nameplatesTeam != null) return nameplatesTeam.getSuffixText();
|
||||
else return "";
|
||||
}
|
||||
if (params.startsWith("bg_")){
|
||||
String bg = params.substring(3);
|
||||
BackGroundText backGroundText = ConfigManager.papiBG.get(bg);
|
||||
if (backGroundText == null) return "";
|
||||
BackGround backGround = ConfigManager.backgrounds.get(backGroundText.getBackground());
|
||||
if (backGround == null) return "";
|
||||
String text = backGroundText.getText();
|
||||
if (ConfigManager.Main.placeholderAPI) text = PlaceholderAPI.setPlaceholders(player, text);
|
||||
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);
|
||||
}
|
||||
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 "";
|
||||
String text = nameplateText.getText();
|
||||
if (ConfigManager.Main.placeholderAPI) text = PlaceholderAPI.setPlaceholders(player, text);
|
||||
return NameplateUtil.getSuffixChar(text);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -15,34 +15,96 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode;
|
||||
package net.momirealms.customnameplates.nameplates;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStand;
|
||||
import net.momirealms.customnameplates.objects.TextCache;
|
||||
import net.momirealms.customnameplates.utils.AdventureUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ArmorStandManager {
|
||||
|
||||
private final Map<String, ArmorStand> armorStands = new LinkedHashMap<>();
|
||||
private final Map<String, ArmorStand> armorStands = new ConcurrentHashMap<>();
|
||||
private ArmorStand[] armorStandArray = new ArmorStand[0];
|
||||
private final List<Player> nearbyPlayers = new ArrayList<>();
|
||||
private Player[] nearbyPlayerArray = new Player[0];
|
||||
private final Player owner;
|
||||
|
||||
public ArmorStandManager(Player owner) {
|
||||
|
||||
public ArmorStandManager(Player owner, boolean isBubbles) {
|
||||
Set<Map.Entry<String, Double>> entries = ConfigManager.Nameplate.textMap.entrySet();
|
||||
this.owner = owner;
|
||||
entries.forEach(map -> {
|
||||
addArmorStand(map.getKey(), new FakeArmorStand(this, owner, new TextCache(owner, map.getKey()), map.getValue()));
|
||||
});
|
||||
if (!isBubbles) {
|
||||
entries.forEach(map -> {
|
||||
addArmorStand(map.getKey(), new FakeArmorStand(this, owner, new TextCache(owner, map.getKey()), map.getValue()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void addArmorStand(String name, ArmorStand as) {
|
||||
armorStands.put(name, as);
|
||||
armorStandArray = armorStands.values().toArray(new ArmorStand[0]);
|
||||
for (Player p : nearbyPlayerArray) as.spawn(p);
|
||||
}
|
||||
|
||||
public void mount(Player receiver) {
|
||||
try {
|
||||
CustomNameplates.protocolManager.sendServerPacket(receiver, getMountPacket(getArmorStandIDs()));
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
AdventureUtil.consoleMessage("<red>[CustomNameplates] Failed to mount player");
|
||||
}
|
||||
}
|
||||
|
||||
private PacketContainer getMountPacket(int[] passengers) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.MOUNT);
|
||||
packet.getIntegers().write(0, owner.getEntityId());
|
||||
packet.getIntegerArrays().write(0, passengers);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public Player[] getNearbyPlayers(){
|
||||
return nearbyPlayerArray;
|
||||
}
|
||||
|
||||
public boolean isNearby(Player viewer) {
|
||||
return nearbyPlayers.contains(viewer);
|
||||
}
|
||||
|
||||
public void spawn(Player viewer) {
|
||||
nearbyPlayers.add(viewer);
|
||||
nearbyPlayerArray = nearbyPlayers.toArray(new Player[0]);
|
||||
for (ArmorStand a : armorStandArray) a.spawn(viewer);
|
||||
}
|
||||
|
||||
public void refresh(boolean force) {
|
||||
for (ArmorStand as : armorStandArray) {
|
||||
if (as.getText().update() || force) {
|
||||
as.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ascent() {
|
||||
for (ArmorStand a : armorStandArray) {
|
||||
a.setOffset(a.getOffset() + ConfigManager.Bubbles.lineSpace);
|
||||
a.teleport();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
for (ArmorStand a : armorStandArray) a.destroy();
|
||||
nearbyPlayers.clear();
|
||||
nearbyPlayerArray = new Player[0];
|
||||
}
|
||||
|
||||
public void teleport(Player viewer) {
|
||||
@@ -53,19 +115,6 @@ public class ArmorStandManager {
|
||||
for (ArmorStand a : armorStandArray) a.teleport();
|
||||
}
|
||||
|
||||
public Player[] getNearbyPlayers(){
|
||||
return nearbyPlayerArray;
|
||||
}
|
||||
|
||||
public boolean hasArmorStandWithID(int entityId) {
|
||||
for (ArmorStand a : armorStandArray) {
|
||||
if (a.getEntityId() == entityId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setSneak(boolean sneaking, boolean respawn) {
|
||||
for (ArmorStand a : armorStandArray) a.setSneak(sneaking, respawn);
|
||||
}
|
||||
@@ -78,53 +127,13 @@ public class ArmorStandManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void spawn(Player viewer) {
|
||||
nearbyPlayers.add(viewer);
|
||||
nearbyPlayerArray = nearbyPlayers.toArray(new Player[0]);
|
||||
for (ArmorStand a : armorStandArray) a.spawn(viewer);
|
||||
}
|
||||
|
||||
public void addArmorStand(String name, ArmorStand as) {
|
||||
armorStands.put(name, as);
|
||||
armorStandArray = armorStands.values().toArray(new ArmorStand[0]);
|
||||
for (Player p : nearbyPlayerArray) as.spawn(p);
|
||||
}
|
||||
|
||||
public void unregisterPlayer(Player viewer) {
|
||||
if (nearbyPlayers.remove(viewer)) nearbyPlayerArray = nearbyPlayers.toArray(new Player[0]);
|
||||
}
|
||||
|
||||
public boolean isNearby(Player viewer) {
|
||||
return nearbyPlayers.contains(viewer);
|
||||
}
|
||||
|
||||
public void destroy(Player viewer) {
|
||||
for (ArmorStand a : armorStandArray) a.destroy(viewer);
|
||||
unregisterPlayer(viewer);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
for (ArmorStand a : armorStandArray) a.destroy();
|
||||
nearbyPlayers.clear();
|
||||
nearbyPlayerArray = new Player[0];
|
||||
}
|
||||
|
||||
public void refresh(boolean force) {
|
||||
for (ArmorStand as : armorStandArray) {
|
||||
if (as.getText().update() || force) {
|
||||
as.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mount(Player receiver) {
|
||||
try {
|
||||
CustomNameplates.protocolManager.sendServerPacket(receiver, getMountPacket(getArmorStandIDs()));
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
AdventureUtil.consoleMessage("<red>[CustomNameplates] Failed to mount player");
|
||||
}
|
||||
public void unregisterPlayer(Player viewer) {
|
||||
if (nearbyPlayers.remove(viewer)) nearbyPlayerArray = nearbyPlayers.toArray(new Player[0]);
|
||||
}
|
||||
|
||||
public int[] getArmorStandIDs() {
|
||||
@@ -135,10 +144,13 @@ public class ArmorStandManager {
|
||||
return passengers;
|
||||
}
|
||||
|
||||
private PacketContainer getMountPacket(int[] passengers) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.MOUNT);
|
||||
packet.getIntegers().write(0, owner.getEntityId());
|
||||
packet.getIntegerArrays().write(0, passengers);
|
||||
return packet;
|
||||
public void countdown(String random, ArmorStand as) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
as.destroy();
|
||||
armorStands.remove(random);
|
||||
}
|
||||
}.runTaskLater(CustomNameplates.instance, ConfigManager.Bubbles.stayTime * 20L);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode;
|
||||
package net.momirealms.customnameplates.nameplates;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
@@ -25,7 +25,6 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStand;
|
||||
import net.momirealms.customnameplates.objects.TextCache;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -48,8 +47,9 @@ public class FakeArmorStand implements ArmorStand {
|
||||
private final int entityId = idCounter++;
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
private boolean sneaking;
|
||||
private final TextCache text;
|
||||
private TextCache text;
|
||||
private final PacketContainer destroyPacket;
|
||||
private WrappedChatComponent wrappedChatComponent;
|
||||
|
||||
public FakeArmorStand(ArmorStandManager asm, Player owner, TextCache text, double yOffset) {
|
||||
this.asm = asm;
|
||||
@@ -61,6 +61,16 @@ public class FakeArmorStand implements ArmorStand {
|
||||
destroyPacket.getIntLists().write(0, List.of(entityId));
|
||||
}
|
||||
|
||||
public FakeArmorStand(ArmorStandManager asm, Player owner, WrappedChatComponent wrappedChatComponent) {
|
||||
this.asm = asm;
|
||||
this.owner = owner;
|
||||
this.yOffset = ConfigManager.Bubbles.yOffset;
|
||||
this.wrappedChatComponent = wrappedChatComponent;
|
||||
sneaking = owner.isSneaking();
|
||||
destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
||||
destroyPacket.getIntLists().write(0, List.of(entityId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
updateMetadata();
|
||||
@@ -176,6 +186,7 @@ public class FakeArmorStand implements ArmorStand {
|
||||
spawn(viewer);
|
||||
}
|
||||
|
||||
|
||||
//传送包
|
||||
public PacketContainer getTeleportPacket() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
||||
@@ -192,7 +203,7 @@ public class FakeArmorStand implements ArmorStand {
|
||||
for (Player viewer : asm.getNearbyPlayers()) {
|
||||
PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
metaPacket.getIntegers().write(0, entityId);
|
||||
metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher(getText().getViewerText(viewer)).getWatchableObjects());
|
||||
metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher(getText().getViewerText(viewer), true).getWatchableObjects());
|
||||
try {
|
||||
CustomNameplates.protocolManager.sendServerPacket(viewer, metaPacket);
|
||||
}
|
||||
@@ -239,13 +250,18 @@ public class FakeArmorStand implements ArmorStand {
|
||||
}
|
||||
|
||||
//创建实体信息包
|
||||
public WrappedDataWatcher createDataWatcher(String text) {
|
||||
public WrappedDataWatcher createDataWatcher(String text, boolean dynamic) {
|
||||
|
||||
WrappedDataWatcher wrappedDataWatcher = new WrappedDataWatcher();
|
||||
WrappedDataWatcher.Serializer serializer1 = WrappedDataWatcher.Registry.get(Boolean.class);
|
||||
WrappedDataWatcher.Serializer serializer2 = WrappedDataWatcher.Registry.get(Byte.class);
|
||||
//设置名称
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)), Optional.of(WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(text))).getHandle()));
|
||||
if (dynamic) {
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)), Optional.of(WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(text))).getHandle()));
|
||||
}
|
||||
else {
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)), Optional.of(wrappedChatComponent));
|
||||
}
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(3, serializer1), true);
|
||||
byte flag = 0x20; //隐身
|
||||
if (sneaking) flag += (byte) 0x02;
|
||||
@@ -272,8 +288,12 @@ public class FakeArmorStand implements ArmorStand {
|
||||
|
||||
PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
metaPacket.getIntegers().write(0, entityId);
|
||||
metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher(getText().getViewerText(viewer)).getWatchableObjects());
|
||||
|
||||
if (this.wrappedChatComponent == null) {
|
||||
metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher(getText().getViewerText(viewer), true).getWatchableObjects());
|
||||
}
|
||||
else {
|
||||
metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher("", false).getWatchableObjects());
|
||||
}
|
||||
return new PacketContainer[] {entityPacket, metaPacket};
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class NameplateUtil {
|
||||
stringBuilder.append(FontOffset.getShortestNegChars(16 - ((totalWidth + 1) % 16 + (isEven ? 0 : 1))));
|
||||
stringBuilder.append(middle).append(neg_1);
|
||||
stringBuilder.append(right).append(neg_1);
|
||||
stringBuilder.append(FontOffset.getShortestNegChars(isEven ? left_offset : left_offset + 1));
|
||||
stringBuilder.append(FontOffset.getShortestNegChars(left_offset - 1));
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,9 @@ public class NameplatesTeam {
|
||||
|
||||
if (!ConfigManager.Main.tab) {
|
||||
Team teamTemp = scoreboard.getTeam(teamName);
|
||||
if (teamTemp == null) teamTemp = scoreboard.registerNewTeam(teamName);
|
||||
if (teamTemp == null) {
|
||||
teamTemp = scoreboard.registerNewTeam(teamName);
|
||||
}
|
||||
teamTemp.addEntry(player.getName());
|
||||
}
|
||||
|
||||
@@ -79,8 +81,15 @@ public class NameplatesTeam {
|
||||
this.prefix = MiniMessage.miniMessage().deserialize(ConfigManager.Nameplate.player_prefix);
|
||||
this.suffix = MiniMessage.miniMessage().deserialize(ConfigManager.Nameplate.player_suffix);
|
||||
}
|
||||
this.prefixText = "";
|
||||
this.suffixText = "";
|
||||
if (ConfigManager.Main.placeholderAPI) {
|
||||
this.prefixText = CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(this.player, ConfigManager.Nameplate.player_prefix);
|
||||
this.suffixText = CustomNameplates.instance.getPlaceholderManager().parsePlaceholders(this.player, ConfigManager.Nameplate.player_suffix);
|
||||
}
|
||||
else {
|
||||
this.prefixText = ConfigManager.Nameplate.player_prefix;
|
||||
this.suffixText = ConfigManager.Nameplate.player_suffix;
|
||||
}
|
||||
|
||||
this.color = ChatColor.WHITE;
|
||||
return;
|
||||
}
|
||||
@@ -120,9 +129,9 @@ public class NameplatesTeam {
|
||||
name,
|
||||
MiniMessage.miniMessage().stripTags(playerSuffix),
|
||||
nameplateInstance
|
||||
);
|
||||
) + playerPrefix;
|
||||
|
||||
this.suffixText = NameplateUtil.getSuffixChar(
|
||||
this.suffixText = playerSuffix + NameplateUtil.getSuffixChar(
|
||||
MiniMessage.miniMessage().stripTags(playerPrefix) +
|
||||
name +
|
||||
MiniMessage.miniMessage().stripTags(playerSuffix)
|
||||
|
||||
@@ -23,10 +23,11 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TeamManager {
|
||||
|
||||
private final HashMap<String, NameplatesTeam> teams = new HashMap<>();
|
||||
private final ConcurrentHashMap<String, NameplatesTeam> teams = new ConcurrentHashMap<>();
|
||||
|
||||
public void createTeam(Player player) {
|
||||
String teamName = player.getName();
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package net.momirealms.customnameplates.nameplates.bubbles;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.Function;
|
||||
import net.momirealms.customnameplates.data.PlayerData;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.FakeArmorStand;
|
||||
import net.momirealms.customnameplates.nameplates.NameplateInstance;
|
||||
import net.momirealms.customnameplates.nameplates.NameplateUtil;
|
||||
import net.momirealms.customnameplates.nameplates.bubbles.lis.*;
|
||||
import net.momirealms.customnameplates.resource.ResourceManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BBPacketsHandle extends Function {
|
||||
|
||||
protected Map<Integer, Player> entityIdMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final ChatBubblesManager chatBubblesManager;
|
||||
|
||||
private ChatListener chatListener;
|
||||
|
||||
private EntityDestroy entityDestroy;
|
||||
private EntityMove entityMove;
|
||||
private EntitySpawn entitySpawn;
|
||||
private EntityLook entityLook;
|
||||
private EntityTeleport entityTeleport;
|
||||
|
||||
protected BBPacketsHandle(String name, ChatBubblesManager chatBubblesManager) {
|
||||
super(name);
|
||||
this.chatBubblesManager = chatBubblesManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
this.chatListener = new ChatListener(this);
|
||||
Bukkit.getPluginManager().registerEvents(chatListener, CustomNameplates.instance);
|
||||
|
||||
this.entityDestroy = new EntityDestroy(this);
|
||||
this.entityMove = new EntityMove(this);
|
||||
this.entitySpawn = new EntitySpawn(this);
|
||||
this.entityLook = new EntityLook(this);
|
||||
this.entityTeleport = new EntityTeleport(this);
|
||||
CustomNameplates.protocolManager.addPacketListener(entityDestroy);
|
||||
CustomNameplates.protocolManager.addPacketListener(entityMove);
|
||||
CustomNameplates.protocolManager.addPacketListener(entitySpawn);
|
||||
CustomNameplates.protocolManager.addPacketListener(entityLook);
|
||||
CustomNameplates.protocolManager.addPacketListener(entityTeleport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
super.unload();
|
||||
HandlerList.unregisterAll(chatListener);
|
||||
CustomNameplates.protocolManager.removePacketListener(entityDestroy);
|
||||
CustomNameplates.protocolManager.removePacketListener(entitySpawn);
|
||||
CustomNameplates.protocolManager.removePacketListener(entityMove);
|
||||
CustomNameplates.protocolManager.removePacketListener(entityLook);
|
||||
CustomNameplates.protocolManager.removePacketListener(entityTeleport);
|
||||
}
|
||||
|
||||
public void onEntityMove(Player receiver, int entityId) {
|
||||
Player mover = getPlayerFromMap(entityId);
|
||||
if (mover != null) {
|
||||
chatBubblesManager.getArmorStandManager(mover).teleport(receiver);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntitySpawn(Player receiver, int entityId) {
|
||||
Player spawnedPlayer = getPlayerFromMap(entityId);
|
||||
if (spawnedPlayer != null) {
|
||||
chatBubblesManager.getArmorStandManager(spawnedPlayer).spawn(receiver);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntityDestroy(Player receiver, List<Integer> entities) {
|
||||
for (int entity : entities) {
|
||||
onEntityDestroy(receiver, entity);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntityDestroy(Player receiver, int entity) {
|
||||
Player deSpawnedPlayer = getPlayerFromMap(entity);
|
||||
if (deSpawnedPlayer != null) {
|
||||
chatBubblesManager.getArmorStandManager(deSpawnedPlayer).destroy(receiver);
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayerFromMap(int entityID) {
|
||||
return entityIdMap.get(entityID);
|
||||
}
|
||||
|
||||
public void onChat(Player player, String text) {
|
||||
PlayerData playerData = CustomNameplates.instance.getDataManager().getOrEmpty(player);
|
||||
String nameplateName = playerData.getEquippedNameplate();
|
||||
NameplateInstance nameplateInstance = ResourceManager.NAMEPLATES.get(nameplateName);
|
||||
String nameplate = NameplateUtil.makeCustomNameplate("", text, "", nameplateInstance);
|
||||
String suffix = NameplateUtil.getSuffixChar(text);
|
||||
Component armorStand_Name = Component.text(nameplate).font(ConfigManager.Main.key).append(Component.text(text).font(Key.key("minecraft:default"))).append(Component.text(suffix).font(ConfigManager.Main.key));
|
||||
WrappedChatComponent wrappedChatComponent = WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(armorStand_Name));
|
||||
|
||||
ArmorStandManager asm = chatBubblesManager.getArmorStandManager(player);
|
||||
asm.ascent();
|
||||
String name = UUID.randomUUID().toString();
|
||||
FakeArmorStand fakeArmorStand = new FakeArmorStand(asm, player, wrappedChatComponent);
|
||||
asm.addArmorStand(name, fakeArmorStand);
|
||||
asm.countdown(name, fakeArmorStand);
|
||||
}
|
||||
|
||||
public void onJoin(Player player) {
|
||||
entityIdMap.put(player.getEntityId(), player);
|
||||
chatBubblesManager.onJoin(player);
|
||||
}
|
||||
|
||||
public void onQuit(Player player) {
|
||||
entityIdMap.remove(player.getEntityId());
|
||||
chatBubblesManager.onQuit(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.momirealms.customnameplates.nameplates.bubbles;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.Function;
|
||||
import net.momirealms.customnameplates.data.PlayerData;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStandManager;
|
||||
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;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ChatBubblesManager extends Function {
|
||||
|
||||
protected final HashMap<Player, ArmorStandManager> armorStandManagerMap = new HashMap<>();
|
||||
|
||||
private BBPacketsHandle packetsHandle;
|
||||
|
||||
public ChatBubblesManager(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
this.packetsHandle = new BBPacketsHandle("BUBBLES", this);
|
||||
this.packetsHandle.load();
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
armorStandManagerMap.put(all, new ArmorStandManager(all, true));
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
spawnArmorStands(player, all);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
this.packetsHandle.unload();
|
||||
}
|
||||
|
||||
private void spawnArmorStands(Player viewer, Player target) {
|
||||
if (target == viewer) return;
|
||||
if (viewer.getWorld() != target.getWorld()) return;
|
||||
if (getDistance(target, viewer) < 48 && viewer.canSee(target))
|
||||
getArmorStandManager(target).spawn(viewer);
|
||||
}
|
||||
|
||||
private double getDistance(Player player1, Player player2) {
|
||||
Location loc1 = player1.getLocation();
|
||||
Location loc2 = player2.getLocation();
|
||||
return Math.sqrt(Math.pow(loc1.getX()-loc2.getX(), 2) + Math.pow(loc1.getZ()-loc2.getZ(), 2));
|
||||
}
|
||||
|
||||
public ArmorStandManager getArmorStandManager(Player player) {
|
||||
return armorStandManagerMap.get(player);
|
||||
}
|
||||
|
||||
public void onJoin(Player player) {
|
||||
armorStandManagerMap.put(player, new ArmorStandManager(player, true));
|
||||
for (Player viewer : Bukkit.getOnlinePlayers()) {
|
||||
spawnArmorStands(viewer, player);
|
||||
spawnArmorStands(player, viewer);
|
||||
}
|
||||
}
|
||||
|
||||
public void onQuit(Player player) {
|
||||
ArmorStandManager asm = armorStandManagerMap.remove(player);
|
||||
if (asm != null) {
|
||||
asm.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.momirealms.customnameplates.nameplates.bubbles;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public record ChatListener(
|
||||
BBPacketsHandle bbPacketsHandle) implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
bbPacketsHandle.onChat(event.getPlayer(), event.getMessage());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
bbPacketsHandle.onJoin(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
bbPacketsHandle.onQuit(event.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.bubbles.lis;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.bubbles.BBPacketsHandle;
|
||||
|
||||
public class EntityDestroy extends PacketAdapter {
|
||||
|
||||
private final BBPacketsHandle handler;
|
||||
|
||||
public EntityDestroy(BBPacketsHandle handler) {
|
||||
super(CustomNameplates.instance, ListenerPriority.HIGHEST, PacketType.Play.Server.ENTITY_DESTROY);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
handler.onEntityDestroy(event.getPlayer(), packet.getIntLists().read(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.bubbles.lis;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.bubbles.BBPacketsHandle;
|
||||
|
||||
public class EntityLook extends PacketAdapter {
|
||||
|
||||
private final BBPacketsHandle handler;
|
||||
|
||||
public EntityLook(BBPacketsHandle handler) {
|
||||
super(CustomNameplates.instance, ListenerPriority.HIGHEST, PacketType.Play.Server.REL_ENTITY_MOVE_LOOK);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
handler.onEntityMove(event.getPlayer(), packet.getIntegers().read(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.bubbles.lis;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.bubbles.BBPacketsHandle;
|
||||
|
||||
public class EntityMove extends PacketAdapter {
|
||||
|
||||
private final BBPacketsHandle handler;
|
||||
|
||||
public EntityMove(BBPacketsHandle handler) {
|
||||
super(CustomNameplates.instance, ListenerPriority.NORMAL, PacketType.Play.Server.REL_ENTITY_MOVE);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
handler.onEntityMove(event.getPlayer(), packet.getIntegers().read(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.bubbles.lis;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.bubbles.BBPacketsHandle;
|
||||
|
||||
public class EntitySpawn extends PacketAdapter {
|
||||
|
||||
private final BBPacketsHandle handler;
|
||||
|
||||
public EntitySpawn(BBPacketsHandle handler) {
|
||||
super(CustomNameplates.instance, ListenerPriority.HIGHEST, PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public synchronized void onPacketSending(PacketEvent event) {
|
||||
handler.onEntitySpawn(event.getPlayer(), event.getPacket().getIntegers().read(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.bubbles.lis;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.bubbles.BBPacketsHandle;
|
||||
|
||||
public class EntityTeleport extends PacketAdapter {
|
||||
|
||||
private final BBPacketsHandle handler;
|
||||
|
||||
public EntityTeleport(BBPacketsHandle handler) {
|
||||
super(CustomNameplates.instance, ListenerPriority.HIGHEST, PacketType.Play.Server.ENTITY_TELEPORT);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
handler.onEntityMove(event.getPlayer(), packet.getIntegers().read(0));
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.listener;
|
||||
package net.momirealms.customnameplates.nameplates.listener;
|
||||
|
||||
import net.momirealms.customnameplates.nameplates.mode.PacketsHandler;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.listener;
|
||||
package net.momirealms.customnameplates.nameplates.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.listener;
|
||||
package net.momirealms.customnameplates.nameplates.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.listener;
|
||||
package net.momirealms.customnameplates.nameplates.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.listener;
|
||||
package net.momirealms.customnameplates.nameplates.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.listener;
|
||||
package net.momirealms.customnameplates.nameplates.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.listener;
|
||||
package net.momirealms.customnameplates.nameplates.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
@@ -19,17 +19,19 @@ package net.momirealms.customnameplates.nameplates.mode;
|
||||
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStandManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class EntityTag extends NameplateManager {
|
||||
|
||||
protected final HashMap<Player, ArmorStandManager> armorStandManagerMap = new HashMap<>();
|
||||
protected final ConcurrentHashMap<Player, ArmorStandManager> armorStandManagerMap = new ConcurrentHashMap<>();
|
||||
|
||||
private BukkitTask bukkitTask;
|
||||
protected BukkitTask bukkitTask;
|
||||
|
||||
protected EntityTag(String name) {
|
||||
super(name);
|
||||
@@ -38,18 +40,25 @@ public abstract class EntityTag extends NameplateManager {
|
||||
@Override
|
||||
public void load(){
|
||||
if (ConfigManager.Nameplate.update) {
|
||||
this.bukkitTask = Bukkit.getScheduler().runTaskTimerAsynchronously(CustomNameplates.instance, () -> {
|
||||
bukkitTask = Bukkit.getScheduler().runTaskTimerAsynchronously(CustomNameplates.instance, () -> {
|
||||
for (ArmorStandManager asm : armorStandManagerMap.values()) {
|
||||
asm.refresh(false);
|
||||
}
|
||||
}, 20, ConfigManager.Nameplate.refresh);
|
||||
}
|
||||
else {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomNameplates.instance, () -> {
|
||||
for (ArmorStandManager asm : armorStandManagerMap.values()) {
|
||||
asm.refresh(false);
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload(){
|
||||
if (bukkitTask != null) {
|
||||
this.bukkitTask.cancel();
|
||||
bukkitTask.cancel();
|
||||
}
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
getArmorStandManager(all).destroy();
|
||||
@@ -60,7 +69,7 @@ public abstract class EntityTag extends NameplateManager {
|
||||
@Override
|
||||
public void onJoin(Player player) {
|
||||
super.onJoin(player);
|
||||
armorStandManagerMap.put(player, new ArmorStandManager(player));
|
||||
armorStandManagerMap.put(player, new ArmorStandManager(player, false));
|
||||
for (Player viewer : Bukkit.getOnlinePlayers()) {
|
||||
spawnArmorStands(viewer, player);
|
||||
spawnArmorStands(player, viewer);
|
||||
@@ -70,10 +79,10 @@ public abstract class EntityTag extends NameplateManager {
|
||||
@Override
|
||||
public void onQuit(Player player) {
|
||||
super.onQuit(player);
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (getArmorStandManager(all) == null) continue;
|
||||
getArmorStandManager(all) .unregisterPlayer(player);
|
||||
}
|
||||
// for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
// if (getArmorStandManager(all) == null) continue;
|
||||
// getArmorStandManager(all) .unregisterPlayer(player);
|
||||
// }
|
||||
ArmorStandManager asm = armorStandManagerMap.remove(player);
|
||||
if (asm != null) {
|
||||
asm.destroy();
|
||||
@@ -102,13 +111,13 @@ public abstract class EntityTag extends NameplateManager {
|
||||
private void spawnArmorStands(Player viewer, Player target) {
|
||||
if (target == viewer) return;
|
||||
if (viewer.getWorld() != target.getWorld()) return;
|
||||
if (viewer.canSee(target))
|
||||
if (getDistance(target, viewer) < 48 && viewer.canSee(target))
|
||||
getArmorStandManager(target).spawn(viewer);
|
||||
}
|
||||
|
||||
// private double getDistance(Player player1, Player player2) {
|
||||
// Location loc1 = player1.getLocation();
|
||||
// Location loc2 = player2.getLocation();
|
||||
// return Math.sqrt(Math.pow(loc1.getX()-loc2.getX(), 2) + Math.pow(loc1.getZ()-loc2.getZ(), 2));
|
||||
// }
|
||||
private double getDistance(Player player1, Player player2) {
|
||||
Location loc1 = player1.getLocation();
|
||||
Location loc2 = player2.getLocation();
|
||||
return Math.sqrt(Math.pow(loc1.getX()-loc2.getX(), 2) + Math.pow(loc1.getZ()-loc2.getZ(), 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
package net.momirealms.customnameplates.nameplates.mode;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.Function;
|
||||
import net.momirealms.customnameplates.nameplates.mode.listener.BukkitListener;
|
||||
import net.momirealms.customnameplates.nameplates.listener.BukkitListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -20,11 +20,11 @@ package net.momirealms.customnameplates.nameplates.mode.rd;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.mode.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.mode.PacketsHandler;
|
||||
import net.momirealms.customnameplates.nameplates.mode.listener.EntityDestroyListener;
|
||||
import net.momirealms.customnameplates.nameplates.mode.listener.EntityMountListener;
|
||||
import net.momirealms.customnameplates.nameplates.mode.listener.EntitySpawnListener;
|
||||
import net.momirealms.customnameplates.nameplates.listener.EntityDestroyListener;
|
||||
import net.momirealms.customnameplates.nameplates.listener.EntityMountListener;
|
||||
import net.momirealms.customnameplates.nameplates.listener.EntitySpawnListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class RdPacketsHandler extends PacketsHandler {
|
||||
super.unload();
|
||||
CustomNameplates.protocolManager.removePacketListener(entityDestroyListener);
|
||||
CustomNameplates.protocolManager.removePacketListener(entitySpawnListener);
|
||||
if (entityDestroyListener != null) {
|
||||
if (entityMountListener != null) {
|
||||
CustomNameplates.protocolManager.removePacketListener(entityMountListener);
|
||||
}
|
||||
}
|
||||
@@ -72,9 +72,7 @@ public class RdPacketsHandler extends PacketsHandler {
|
||||
if (spawnedPlayer != null) {
|
||||
ArmorStandManager asm = ridingTag.getArmorStandManager(spawnedPlayer);
|
||||
asm.spawn(receiver);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(CustomNameplates.instance, ()-> {
|
||||
asm.mount(receiver);
|
||||
});
|
||||
Bukkit.getScheduler().runTaskAsynchronously(CustomNameplates.instance, ()-> asm.mount(receiver));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.rd;
|
||||
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.mode.EntityTag;
|
||||
import net.momirealms.customnameplates.nameplates.mode.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.mode.EventListenerE;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -38,7 +40,7 @@ public class RidingTag extends EntityTag {
|
||||
@Override
|
||||
public void load() {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
armorStandManagerMap.put(all, new ArmorStandManager(all));
|
||||
armorStandManagerMap.put(all, new ArmorStandManager(all, false));
|
||||
CustomNameplates.instance.getTeamPacketManager().sendUpdateToOne(all);
|
||||
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(all);
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
@@ -58,11 +60,6 @@ public class RidingTag extends EntityTag {
|
||||
super.unload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin(Player player) {
|
||||
super.onJoin(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuit(Player player) {
|
||||
super.onQuit(player);
|
||||
@@ -91,12 +88,18 @@ public class RidingTag extends EntityTag {
|
||||
private void ridingArmorStands(Player viewer, Player target) {
|
||||
if (target == viewer) return;
|
||||
if (viewer.getWorld() != target.getWorld()) return;
|
||||
if (viewer.canSee(target)) {
|
||||
ArmorStandManager asm = getArmorStandManager(target);
|
||||
if (getDistance(target, viewer) < 48 && viewer.canSee(target)) {
|
||||
ArmorStandManager asm = (ArmorStandManager) getArmorStandManager(target);
|
||||
asm.spawn(viewer);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(CustomNameplates.instance, () -> {
|
||||
asm.mount(viewer);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private double getDistance(Player player1, Player player2) {
|
||||
Location loc1 = player1.getLocation();
|
||||
Location loc2 = player2.getLocation();
|
||||
return Math.sqrt(Math.pow(loc1.getX()-loc2.getX(), 2) + Math.pow(loc1.getZ()-loc2.getZ(), 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,74 +34,59 @@ public class TeamTag extends NameplateManager {
|
||||
|
||||
private EventListener listener;
|
||||
|
||||
private BukkitTask task;
|
||||
|
||||
private final TeamManager teamManager;
|
||||
|
||||
private final HashMap<Player, BukkitTask> taskCache = new HashMap<>();
|
||||
|
||||
public TeamTag(String name) {
|
||||
public TeamTag(String name, TeamManager teamManager) {
|
||||
super(name);
|
||||
this.teamManager = teamManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
listener = new EventListener(this);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(listener, CustomNameplates.instance);
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
|
||||
CustomNameplates.instance.getTeamPacketManager().sendUpdateToOne(player);
|
||||
}
|
||||
|
||||
if (!ConfigManager.Nameplate.update) return;
|
||||
|
||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(CustomNameplates.instance, () -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
String teamName = TeamManager.getTeamName(player);
|
||||
NameplatesTeam nameplatesTeam = teamManager.getTeams().get(teamName);
|
||||
if (nameplatesTeam != null) {
|
||||
nameplatesTeam.updateNameplates();
|
||||
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
|
||||
}
|
||||
}
|
||||
}, 20, ConfigManager.Nameplate.refresh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
HandlerList.unregisterAll(listener);
|
||||
taskCache.clear();
|
||||
listener = null;
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin(Player player) {
|
||||
|
||||
super.onJoin(player);
|
||||
|
||||
if (!ConfigManager.Nameplate.update) return;
|
||||
|
||||
startRefresh(player);
|
||||
}
|
||||
|
||||
private void startRefresh(Player player) {
|
||||
|
||||
if (!player.isOnline()) return;
|
||||
|
||||
String teamName = TeamManager.getTeamName(player);
|
||||
TeamManager teamManager = CustomNameplates.instance.getTeamManager();
|
||||
NameplatesTeam nameplatesTeam = teamManager.getTeams().get(teamName);
|
||||
|
||||
if (nameplatesTeam != null) {
|
||||
BukkitTask task = Bukkit.getScheduler().runTaskTimerAsynchronously(CustomNameplates.instance, () -> {
|
||||
NameplatesTeam npTeam = teamManager.getTeams().get(teamName);
|
||||
if (npTeam != null) {
|
||||
nameplatesTeam.updateNameplates();
|
||||
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(player);
|
||||
}
|
||||
else {
|
||||
taskCache.remove(player).cancel();
|
||||
}
|
||||
}, 20, ConfigManager.Nameplate.refresh);
|
||||
taskCache.put(player, task);
|
||||
}
|
||||
else {
|
||||
Bukkit.getScheduler().runTaskLater(CustomNameplates.instance, () -> {
|
||||
startRefresh(player);
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuit(Player player) {
|
||||
|
||||
super.onQuit(player);
|
||||
BukkitTask bukkitTask = taskCache.remove(player);
|
||||
if (bukkitTask != null) bukkitTask.cancel();
|
||||
|
||||
super.onQuit(player);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -28,6 +28,7 @@ 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;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -41,6 +42,12 @@ public class TeamPacketA implements TeamPacketManager {
|
||||
|
||||
private final HashMap<Player, TeamInfo> teamInfoCache = new HashMap<>();
|
||||
|
||||
private final TeamManager teamManager;
|
||||
|
||||
public TeamPacketA(TeamManager teamManager) {
|
||||
this.teamManager = teamManager;
|
||||
}
|
||||
|
||||
public void sendUpdateToOne(Player player) {
|
||||
// boolean accepted = CustomNameplates.instance.getDataManager().getCache().get(player.getUniqueId()).getAccepted();
|
||||
for (Player otherPlayer : Bukkit.getOnlinePlayers()) {
|
||||
@@ -50,7 +57,7 @@ public class TeamPacketA implements TeamPacketManager {
|
||||
String teamName = otherPlayer.getName();
|
||||
if (ConfigManager.Main.tab) teamName = TABTeamHook.getTABTeam(teamName);
|
||||
packet.getStrings().write(0, teamName);
|
||||
NameplatesTeam nameplatesTeam = CustomNameplates.instance.getTeamManager().getTeams().get(teamName);
|
||||
NameplatesTeam nameplatesTeam = teamManager.getTeams().get(teamName);
|
||||
if (nameplatesTeam == null) return;
|
||||
Optional<InternalStructure> optional = packet.getOptionalStructures().read(0);
|
||||
if (optional.isEmpty()) return;
|
||||
@@ -78,7 +85,7 @@ public class TeamPacketA implements TeamPacketManager {
|
||||
public void sendUpdateToAll(Player player) {
|
||||
String teamName = player.getName();
|
||||
if (ConfigManager.Main.tab) teamName = TABTeamHook.getTABTeam(teamName);
|
||||
NameplatesTeam nameplatesTeam = CustomNameplates.instance.getTeamManager().getTeams().get(teamName);
|
||||
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;
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
|
||||
package net.momirealms.customnameplates.nameplates.mode.tp;
|
||||
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.mode.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.mode.EntityTag;
|
||||
import net.momirealms.customnameplates.nameplates.mode.EventListenerE;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@@ -43,7 +45,7 @@ public class TeleportingTag extends EntityTag {
|
||||
@Override
|
||||
public void load() {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
armorStandManagerMap.put(all, new ArmorStandManager(all));
|
||||
armorStandManagerMap.put(all, new ArmorStandManager(all, false));
|
||||
CustomNameplates.instance.getTeamPacketManager().sendUpdateToOne(all);
|
||||
CustomNameplates.instance.getTeamPacketManager().sendUpdateToAll(all);
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
@@ -85,17 +87,13 @@ public class TeleportingTag extends EntityTag {
|
||||
private void spawnArmorStands(Player viewer, Player target) {
|
||||
if (target == viewer) return;
|
||||
if (viewer.getWorld() != target.getWorld()) return;
|
||||
if (viewer.canSee(target))
|
||||
if (getDistance(target, viewer) < 48 && viewer.canSee(target))
|
||||
getArmorStandManager(target).spawn(viewer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin(Player player) {
|
||||
super.onJoin(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuit(Player player) {
|
||||
super.onQuit(player);
|
||||
private double getDistance(Player player1, Player player2) {
|
||||
Location loc1 = player1.getLocation();
|
||||
Location loc2 = player2.getLocation();
|
||||
return Math.sqrt(Math.pow(loc1.getX()-loc2.getX(), 2) + Math.pow(loc1.getZ()-loc2.getZ(), 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package net.momirealms.customnameplates.nameplates.mode.tp;
|
||||
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.nameplates.listener.*;
|
||||
import net.momirealms.customnameplates.nameplates.mode.PacketsHandler;
|
||||
import net.momirealms.customnameplates.nameplates.mode.listener.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,50 +25,50 @@ 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 offset_x, int size) {
|
||||
String offset_128, String end, int offset_y, int start_width, int end_width, int size) {
|
||||
|
||||
public String getBackGround(int n) {
|
||||
n += offset_x;
|
||||
String offset = FontOffset.getShortestNegChars(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));
|
||||
while (n > 128) {
|
||||
while (n >= 128) {
|
||||
stringBuilder.append(FontOffset.NEG_1.getCharacter());
|
||||
stringBuilder.append(chars.get(offset_128));
|
||||
n -= 128;
|
||||
}
|
||||
if (n - 64 > 0) {
|
||||
if (n - 64 >= 0) {
|
||||
stringBuilder.append(FontOffset.NEG_1.getCharacter());
|
||||
stringBuilder.append(chars.get(offset_64));
|
||||
n -= 64;
|
||||
}
|
||||
if (n - 32 > 0) {
|
||||
if (n - 32 >= 0) {
|
||||
stringBuilder.append(FontOffset.NEG_1.getCharacter());
|
||||
stringBuilder.append(chars.get(offset_32));
|
||||
n -= 32;
|
||||
}
|
||||
if (n - 16 > 0) {
|
||||
if (n - 16 >= 0) {
|
||||
stringBuilder.append(FontOffset.NEG_1.getCharacter());
|
||||
stringBuilder.append(chars.get(offset_16));
|
||||
n -= 16;
|
||||
}
|
||||
if (n - 8 > 0) {
|
||||
if (n - 8 >= 0) {
|
||||
stringBuilder.append(FontOffset.NEG_1.getCharacter());
|
||||
stringBuilder.append(chars.get(offset_8));
|
||||
n -= 8;
|
||||
}
|
||||
if (n - 4 > 0) {
|
||||
if (n - 4 >= 0) {
|
||||
stringBuilder.append(FontOffset.NEG_1.getCharacter());
|
||||
stringBuilder.append(chars.get(offset_4));
|
||||
n -= 4;
|
||||
}
|
||||
if (n - 2 > 0) {
|
||||
if (n - 2 >= 0) {
|
||||
stringBuilder.append(FontOffset.NEG_1.getCharacter());
|
||||
stringBuilder.append(chars.get(offset_2));
|
||||
n -= 2;
|
||||
}
|
||||
if (n - 1 > 0) {
|
||||
if (n - 1 >= 0) {
|
||||
stringBuilder.append(FontOffset.NEG_1.getCharacter());
|
||||
stringBuilder.append(chars.get(offset_1));
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ public class ConfigUtil {
|
||||
try {
|
||||
YamlDocument.create(new File(CustomNameplates.instance.getDataFolder(), "config.yml"), CustomNameplates.instance.getResource("config.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build());
|
||||
YamlDocument.create(new File(CustomNameplates.instance.getDataFolder(), "nameplate.yml"), CustomNameplates.instance.getResource("nameplate.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build());
|
||||
YamlDocument.create(new File(CustomNameplates.instance.getDataFolder(), "bubble.yml"), CustomNameplates.instance.getResource("bubble.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build());
|
||||
YamlDocument.create(new File(CustomNameplates.instance.getDataFolder(), "MODULES.yml"), CustomNameplates.instance.getResource("MODULES.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build());
|
||||
}catch (IOException e){
|
||||
Log.warn(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.momirealms.customnameplates.utils;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class JsonUtil {
|
||||
|
||||
public static void getText(JsonElement jsonElement, StringBuilder stringBuilder) {
|
||||
|
||||
if (jsonElement.isJsonObject()) {
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
for (Map.Entry<String, JsonElement> set : jsonObject.entrySet()) {
|
||||
if (set.getKey().equals("text")) {
|
||||
stringBuilder.append(set.getValue().getAsString());
|
||||
}
|
||||
else {
|
||||
getText(set.getValue(), stringBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (jsonElement.isJsonArray()) {
|
||||
for (JsonElement jsonElement1 : jsonElement.getAsJsonArray()) {
|
||||
getText(jsonElement1, stringBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
config-version: '5'
|
||||
|
||||
#Nameplate module require a restart because it requires a SQL connection
|
||||
nameplate: true
|
||||
|
||||
#These modules can be toggled by reloading
|
||||
background: true
|
||||
bossbar: true
|
||||
actionbar: false
|
||||
actionbar: true
|
||||
|
||||
#Chatting bubbles are still not available
|
||||
#They are in developments and will be available soon
|
||||
bubbles: false
|
||||
@@ -1,2 +1,2 @@
|
||||
text: '<font:nameplates:default>%nameplates_prefix%</font>%player_name%<font:nameplates:default>%nameplates_suffix%</font>'
|
||||
text: '<font:nameplates:default>%nameplates_bg_health%</font><font:nameplates:offset_-11><red>%player_health_rounded% Health</font> <font:nameplates:default>%nameplates_bg_food%</font><font:nameplates:offset_-11><#F0E68C>%player_food_level% Hunger</font>'
|
||||
refresh-rate: 5
|
||||
@@ -2,8 +2,9 @@ background:
|
||||
|
||||
bedrock_1:
|
||||
size: 14
|
||||
# x-offset = start + end
|
||||
x-offset: 4
|
||||
# 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
|
||||
@@ -19,7 +20,8 @@ background:
|
||||
|
||||
bedrock_2:
|
||||
size: 14
|
||||
x-offset: 4
|
||||
start-offset: 4
|
||||
end-offset: 4
|
||||
y-offset: 9
|
||||
start: b0
|
||||
offset_1: b1
|
||||
@@ -34,7 +36,8 @@ background:
|
||||
|
||||
bedrock_3:
|
||||
size: 14
|
||||
x-offset: 4
|
||||
start-offset: 1
|
||||
end-offset: 1
|
||||
y-offset: -7
|
||||
start: b0
|
||||
offset_1: b1
|
||||
|
||||
@@ -5,8 +5,8 @@ bossbar:
|
||||
color: YELLOW
|
||||
overlay: PROGRESS
|
||||
dynamic-text:
|
||||
- '<font:nameplates:default><color:#FFFEFD>%nameplates_bg_pos%</font><font:nameplates:offset_3> You are now at: %player_x%, %player_y%, %player_z% </font>'
|
||||
- '<font:nameplates:default><color:#FFFEFD>%nameplates_bg_player%</font><font:nameplates:offset_3> Hello! %player_name% </font>'
|
||||
- '<font:nameplates:default><color:#FFFEFD>%nameplates_bg_pos%</font><font:nameplates:offset_3>You are now at: %player_x%, %player_y%, %player_z%</font>'
|
||||
- '<font:nameplates:default><color:#FFFEFD>%nameplates_bg_player%</font><font:nameplates:offset_3>Hello! %player_name%</font>'
|
||||
# seconds
|
||||
switch-interval: 15
|
||||
# ticks
|
||||
|
||||
17
src/main/resources/bubble.yml
Normal file
17
src/main/resources/bubble.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
# Don't change
|
||||
config-version: '5'
|
||||
|
||||
bubble:
|
||||
|
||||
# Player's default chatting bubbles
|
||||
default-bubbles: 'none'
|
||||
|
||||
# Space between two lines of text
|
||||
line-spacing: 0.5
|
||||
|
||||
# This decides where the bottom line is
|
||||
bottom-line-Y-offset: 0.6
|
||||
|
||||
# Seconds
|
||||
# This decides how long will the chat hologram remains
|
||||
stay-time: 5
|
||||
@@ -1,5 +1,5 @@
|
||||
# don't change
|
||||
config-version: '4'
|
||||
config-version: '5'
|
||||
|
||||
config:
|
||||
# Language
|
||||
|
||||
@@ -11,10 +11,10 @@ papi:
|
||||
text: 'Hello! %player_name%'
|
||||
background: bedrock_1
|
||||
pos:
|
||||
text: ' You are now at: %player_x%, %player_y%, %player_z% '
|
||||
text: 'You are now at: %player_x%, %player_y%, %player_z%'
|
||||
background: bedrock_1
|
||||
text:
|
||||
text: ' Thanks for your purchase! '
|
||||
text: 'Thanks for your purchase!'
|
||||
background: bedrock_2
|
||||
health:
|
||||
text: '%player_health_rounded% Health'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
config-version: '4'
|
||||
# Don't change
|
||||
config-version: '5'
|
||||
|
||||
nameplate:
|
||||
# mode: Team / Riding / Teleporting
|
||||
@@ -33,7 +34,7 @@ nameplate:
|
||||
# Nameplates work on the custom font system where legacy color code is not supported!
|
||||
# Please use MiniMessage format: https://docs.adventure.kyori.net/minimessage/format.html
|
||||
prefix: '<font:minecraft:default><rainbow>Hello! </rainbow></font>'
|
||||
suffix: ' <red>%player_health_rounded%♥'
|
||||
suffix: '<font:minecraft:default> <red>%player_health_rounded%♥</font>'
|
||||
|
||||
# These options only work when using mode Team
|
||||
team:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: CustomNameplates
|
||||
version: '${version}'
|
||||
main: net.momirealms.customnameplates.CustomNameplates
|
||||
api-version: 1.16
|
||||
api-version: 1.17
|
||||
authors: [ XiaoMoMi ]
|
||||
depend:
|
||||
- ProtocolLib
|
||||
@@ -15,6 +15,10 @@ commands:
|
||||
usage: /customnameplates
|
||||
aliases:
|
||||
- nameplates
|
||||
chatbubbles:
|
||||
usage: /chatbubbles
|
||||
aliases:
|
||||
- bubbles
|
||||
|
||||
permissions:
|
||||
nameplates.*:
|
||||
|
||||
Reference in New Issue
Block a user