mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-26 10:29:09 +00:00
2.0-PRE-11
This commit is contained in:
@@ -114,6 +114,7 @@ public class ConfigManager {
|
||||
public static boolean tab_bc;
|
||||
public static boolean oraxen;
|
||||
public static boolean extract;
|
||||
public static boolean trChat;
|
||||
public static List<Integer> offsets;
|
||||
public static char start;
|
||||
public static Key key;
|
||||
@@ -142,6 +143,7 @@ public class ConfigManager {
|
||||
tab = config.getBoolean("config.integrations.TAB",false);
|
||||
tab_bc = config.getBoolean("config.integrations.TAB-BC",false);
|
||||
oraxen = config.getBoolean("config.integrations.Oraxen",false);
|
||||
trChat = config.getBoolean("config.integrations.TrChat",false);
|
||||
offsets = config.getIntegerList("config.ascii-y-offset.offset");
|
||||
|
||||
if(config.getBoolean("config.extract-shader",true)) {
|
||||
@@ -162,6 +164,10 @@ public class ConfigManager {
|
||||
CustomNameplates.instance.getLogger().warning("Failed to initialize Oraxen!");
|
||||
oraxen = false;
|
||||
}
|
||||
if (trChat && CustomNameplates.instance.getServer().getPluginManager().getPlugin("TrChat") == null){
|
||||
CustomNameplates.instance.getLogger().warning("Failed to initialize TrChat!");
|
||||
trChat = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,6 +360,8 @@ public class ConfigManager {
|
||||
public static double lineSpace;
|
||||
public static double yOffset;
|
||||
public static int stayTime;
|
||||
public static int coolDown;
|
||||
public static int maxChar;
|
||||
public static void load() {
|
||||
YamlConfiguration config = getConfig("bubble.yml");
|
||||
defaultBubble = config.getString("bubble.default-bubbles", "none");
|
||||
@@ -363,6 +371,8 @@ public class ConfigManager {
|
||||
defaultFormat = config.getString("bubble.default-format", "<white><underlined>");
|
||||
yOffset = config.getDouble("bubble.bottom-line-Y-offset");
|
||||
stayTime = config.getInt("bubble.stay-time", 5);
|
||||
coolDown = config.getInt("bubble.cool-down", 1) * 1000;
|
||||
maxChar = config.getInt("bubble.max-char-length", 35);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ import net.momirealms.customnameplates.commands.np.TabCompleteN;
|
||||
import net.momirealms.customnameplates.data.DataManager;
|
||||
import net.momirealms.customnameplates.data.SqlHandler;
|
||||
import net.momirealms.customnameplates.helper.LibraryLoader;
|
||||
import net.momirealms.customnameplates.hook.IAImageHook;
|
||||
import net.momirealms.customnameplates.hook.ImageParser;
|
||||
import net.momirealms.customnameplates.hook.OXImageHook;
|
||||
import net.momirealms.customnameplates.hook.PlaceholderManager;
|
||||
import net.momirealms.customnameplates.nameplates.ProxyDataListener;
|
||||
import net.momirealms.customnameplates.nameplates.TeamManager;
|
||||
@@ -66,6 +69,7 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
private NameplateManager nameplateManager;
|
||||
private ChatBubblesManager chatBubblesManager;
|
||||
private ProxyDataListener proxyDataListener;
|
||||
private ImageParser imageParser;
|
||||
|
||||
@Override
|
||||
public void onLoad(){
|
||||
@@ -116,12 +120,12 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
if (bossBarManager != null) {
|
||||
bossBarManager.unload();
|
||||
}
|
||||
if (placeholderManager != null) {
|
||||
placeholderManager.unload();
|
||||
}
|
||||
if (chatBubblesManager != null) {
|
||||
chatBubblesManager.unload();
|
||||
}
|
||||
if (placeholderManager != null) {
|
||||
placeholderManager.unload();
|
||||
}
|
||||
if (adventure != null) {
|
||||
adventure.close();
|
||||
}
|
||||
@@ -236,6 +240,12 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
ConfigManager.Bubbles.load();
|
||||
this.chatBubblesManager = new ChatBubblesManager("BUBBLE");
|
||||
this.chatBubblesManager.load();
|
||||
if (ConfigManager.Main.itemsAdder) {
|
||||
this.imageParser = new IAImageHook();
|
||||
}
|
||||
if (ConfigManager.Main.oraxen) {
|
||||
this.imageParser = new OXImageHook();
|
||||
}
|
||||
}
|
||||
else if (this.chatBubblesManager != null) {
|
||||
this.chatBubblesManager.unload();
|
||||
@@ -281,4 +291,8 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
public NameplateManager getNameplateManager() {
|
||||
return nameplateManager;
|
||||
}
|
||||
|
||||
public ImageParser getImageParser() {
|
||||
return imageParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.momirealms.customnameplates.hook;
|
||||
|
||||
import dev.lone.itemsadder.api.FontImages.FontImageWrapper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class IAImageHook implements ImageParser{
|
||||
|
||||
@Override
|
||||
public String parse(Player player, String text) {
|
||||
return FontImageWrapper.replaceFontImages(player, text).replace("§f","<white>").replace("§r","</white>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.momirealms.customnameplates.hook;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ImageParser {
|
||||
|
||||
String parse(Player player, String text);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.momirealms.customnameplates.hook;
|
||||
|
||||
import io.th0rgal.oraxen.OraxenPlugin;
|
||||
import io.th0rgal.oraxen.font.FontManager;
|
||||
import io.th0rgal.oraxen.font.Glyph;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class OXImageHook implements ImageParser{
|
||||
|
||||
private final FontManager fontManager;
|
||||
|
||||
public OXImageHook() {
|
||||
this.fontManager = OraxenPlugin.get().getFontManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parse(Player player, String text) {
|
||||
for (Map.Entry<String, Glyph> entry : this.fontManager.getGlyphByPlaceholderMap().entrySet()) {
|
||||
if (entry.getValue().hasPermission(player)) {
|
||||
text = text.replace(entry.getKey(), "<white>" + entry.getValue().getCharacter() + "</white>");
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatBubblesManager extends EntityTag {
|
||||
@@ -26,6 +27,9 @@ public class ChatBubblesManager extends EntityTag {
|
||||
private BBPacketsHandle packetsHandle;
|
||||
|
||||
private ChatListener chatListener;
|
||||
private TrChatListener trChatListener;
|
||||
|
||||
private final HashMap<Player, Long> coolDown = new HashMap<>();
|
||||
|
||||
public ChatBubblesManager(String name) {
|
||||
super(name);
|
||||
@@ -37,9 +41,14 @@ public class ChatBubblesManager extends EntityTag {
|
||||
this.packetsHandle = new BBPacketsHandle("BUBBLES", this);
|
||||
this.packetsHandle.load();
|
||||
|
||||
this.chatListener = new ChatListener(this);
|
||||
Bukkit.getPluginManager().registerEvents(chatListener, CustomNameplates.instance);
|
||||
|
||||
if (ConfigManager.Main.trChat) {
|
||||
this.trChatListener = new TrChatListener(this);
|
||||
Bukkit.getPluginManager().registerEvents(trChatListener, CustomNameplates.instance);
|
||||
}
|
||||
else {
|
||||
this.chatListener = new ChatListener(this);
|
||||
Bukkit.getPluginManager().registerEvents(chatListener, CustomNameplates.instance);
|
||||
}
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
armorStandManagerMap.put(all, new ArmorStandManager(all));
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
@@ -50,7 +59,8 @@ public class ChatBubblesManager extends EntityTag {
|
||||
@Override
|
||||
public void unload() {
|
||||
this.packetsHandle.unload();
|
||||
HandlerList.unregisterAll(chatListener);
|
||||
if (chatListener != null) HandlerList.unregisterAll(chatListener);
|
||||
if (trChatListener != null) HandlerList.unregisterAll(trChatListener);
|
||||
super.unload();
|
||||
}
|
||||
|
||||
@@ -86,18 +96,28 @@ public class ChatBubblesManager extends EntityTag {
|
||||
if (asm != null) {
|
||||
asm.destroy();
|
||||
}
|
||||
coolDown.remove(player);
|
||||
}
|
||||
|
||||
public void onChat(Player player, String text) {
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
if (time - (coolDown.getOrDefault(player, time - ConfigManager.Bubbles.coolDown)) < ConfigManager.Bubbles.coolDown) return;
|
||||
coolDown.put(player, time);
|
||||
|
||||
PlayerData playerData = CustomNameplates.instance.getDataManager().getOrEmpty(player);
|
||||
String bubbles = playerData.getBubbles();
|
||||
BubbleConfig bubbleConfig = ResourceManager.BUBBLES.get(bubbles);
|
||||
WrappedChatComponent wrappedChatComponent;
|
||||
if (CustomNameplates.instance.getImageParser() != null) {
|
||||
text = CustomNameplates.instance.getImageParser().parse(player, text);
|
||||
}
|
||||
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)
|
||||
:
|
||||
ConfigManager.Bubbles.prefix + text + ConfigManager.Bubbles.suffix;
|
||||
if (text.length() > ConfigManager.Bubbles.maxChar) return;
|
||||
wrappedChatComponent = WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(text)));
|
||||
}
|
||||
else {
|
||||
@@ -106,6 +126,7 @@ public class ChatBubblesManager extends EntityTag {
|
||||
:
|
||||
ConfigManager.Bubbles.prefix + text + ConfigManager.Bubbles.suffix;
|
||||
String stripped = MiniMessage.miniMessage().stripTags(text);
|
||||
if (stripped.length() > ConfigManager.Bubbles.maxChar) return;
|
||||
String bubble = NameplateUtil.makeCustomBubble("", stripped, "", bubbleConfig);
|
||||
String suffix = NameplateUtil.getSuffixChar(stripped);
|
||||
Component armorStand_Name = Component.text(bubble).font(ConfigManager.Main.key)
|
||||
|
||||
@@ -11,7 +11,8 @@ public record ChatListener(
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
if (!event.isCancelled())
|
||||
if (!event.isCancelled()) {
|
||||
chatBubblesManager.onChat(event.getPlayer(), MiniMessage.miniMessage().stripTags(ChatColor.stripColor(event.getMessage())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.momirealms.customnameplates.nameplates.mode.bubbles;
|
||||
|
||||
import me.arasple.mc.trchat.api.event.TrChatEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public record TrChatListener(
|
||||
ChatBubblesManager chatBubblesManager) implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onTrChat(TrChatEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (!event.getForward()) return;
|
||||
chatBubblesManager.onChat(event.getSession().getPlayer(), event.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class TeamPacketA implements TeamPacketManager {
|
||||
NameplatesTeam nameplatesTeam = teamManager.getTeams().get(teamName);
|
||||
String newInfo = nameplatesTeam.getDynamic();
|
||||
String oldInfo = teamInfoCache.get(player);
|
||||
if (newInfo.equals(oldInfo) && !force) {
|
||||
if (newInfo != null && newInfo.equals(oldInfo) && !force) {
|
||||
return;
|
||||
}
|
||||
teamInfoCache.put(player, newInfo);
|
||||
|
||||
@@ -539,7 +539,7 @@ public class ResourceManager {
|
||||
}
|
||||
if (ConfigManager.Main.oraxen){
|
||||
try {
|
||||
FileUtils.copyDirectory(generated, new File(Bukkit.getPluginManager().getPlugin("Oraxen").getDataFolder() + File.separator + "pack"+ File.separator + "assets"));
|
||||
FileUtils.copyDirectory(new File(generated, File.separator + ConfigManager.Main.namespace), new File(Bukkit.getPluginManager().getPlugin("Oraxen").getDataFolder() + File.separator + "pack"+ File.separator + "assets" + File.separator + ConfigManager.Main.namespace));
|
||||
AdventureUtil.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>Detected <color:#90EE90>Oraxen!<color:#baffd1> Automatically sent rp to Oraxen folder!");
|
||||
}
|
||||
catch (IOException e){
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Do not change
|
||||
config-version: '7'
|
||||
config-version: '8'
|
||||
|
||||
bubble:
|
||||
|
||||
# Player's default chatting bubbles
|
||||
default-bubbles: 'none'
|
||||
default-bubbles: 'chat'
|
||||
|
||||
# Text format when no bubbles equipped
|
||||
default-format: '<white><underlined>'
|
||||
@@ -18,8 +18,15 @@ bubble:
|
||||
line-spacing: 0.5
|
||||
|
||||
# This decides where the bottom line is
|
||||
bottom-line-Y-offset: 0.6
|
||||
bottom-line-Y-offset: -1.5
|
||||
|
||||
# Seconds
|
||||
# This decides how long will the chat hologram remains
|
||||
stay-time: 5
|
||||
stay-time: 5
|
||||
|
||||
# Plugin would ignore player's chat message when its length is over a certain value
|
||||
max-char-length: 35
|
||||
|
||||
# Cool Down (seconds)
|
||||
# Plugin would ignore player's chat message when it is still in cool down
|
||||
cool-down: 1
|
||||
@@ -1,5 +1,5 @@
|
||||
# Do not change
|
||||
config-version: '9'
|
||||
config-version: '10'
|
||||
|
||||
config:
|
||||
# Language
|
||||
@@ -13,6 +13,7 @@ config:
|
||||
PlaceholderAPI: true
|
||||
# When enabled, the plugin will automatically place the resource pack
|
||||
# folder into the resource pack generated by ItemsAdder/Oraxen.
|
||||
# And players would be able to use emoji in chatting bubbles
|
||||
ItemsAdder: false
|
||||
Oraxen: false
|
||||
# When enabled, the plugin will hook into TAB's team management
|
||||
@@ -21,7 +22,8 @@ config:
|
||||
# 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
|
||||
|
||||
# TrChat
|
||||
TrChat: false
|
||||
|
||||
# Your namespace
|
||||
# If you don't know how font works, don't change this
|
||||
|
||||
@@ -10,6 +10,7 @@ softdepend:
|
||||
- PlaceholderAPI
|
||||
- TAB
|
||||
- Oraxen
|
||||
- TrChat
|
||||
commands:
|
||||
customnameplates:
|
||||
usage: /customnameplates
|
||||
@@ -54,6 +55,7 @@ permissions:
|
||||
children:
|
||||
bubbles.unequip: true
|
||||
bubbles.equip: true
|
||||
bubbles.help: true
|
||||
bubbles.forceequip: true
|
||||
bubbles.forceunequip: true
|
||||
bubbles.list: true
|
||||
|
||||
Reference in New Issue
Block a user