9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-27 18:59:19 +00:00
This commit is contained in:
XiaoMoMi
2024-10-09 22:33:22 +08:00
parent 7eb3296294
commit aa919d18e0
4 changed files with 22 additions and 12 deletions

View File

@@ -32,6 +32,7 @@ import net.momirealms.customnameplates.api.ConfigManager;
import net.momirealms.customnameplates.api.CustomNameplates;
import net.momirealms.customnameplates.api.feature.ChatListener;
import net.momirealms.customnameplates.api.feature.ConfiguredCharacter;
import net.momirealms.customnameplates.api.feature.OffsetFont;
import net.momirealms.customnameplates.api.feature.bubble.Bubble;
import net.momirealms.customnameplates.api.feature.bubble.BubbleConfig;
import net.momirealms.customnameplates.api.feature.bubble.BubbleManager;
@@ -304,6 +305,9 @@ public class BubbleManagerImpl implements BubbleManager, ChatListener {
String fullText = config.textPrefix() + AdventureHelper.stripTags(message.replace("\\", "\\\\")) + config.textSuffix();
int lines = plugin.getAdvanceManager().getLines(fullText, config.lineWidth());
if (lines > config.maxLines()) return;
int space = (int) plugin.getAdvanceManager().getLineAdvance(" ");
String fakeSpace = AdventureHelper.surroundWithNameplatesFont(OffsetFont.createOffsets(space));
fullText = fullText.replace(" ", fakeSpace);
TagRenderer renderer = plugin.getUnlimitedTagManager().getTagRender(player);
if (renderer == null) return;

View File

@@ -110,6 +110,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
}
private void loadNestNameplatePlaceholders() {
if (!ConfigManager.nameplateModule()) return;
PreParsedDynamicText nameTag = new PreParsedDynamicText(plugin.getNameplateManager().playerNameTag());
Placeholder placeholder1 = this.registerPlayerPlaceholder("%np_tag-image%", (player -> {
String equippedNameplate = player.equippedNameplate();
@@ -171,15 +172,20 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
this.registerPlayerPlaceholder("%np_offset_" + i + "%", (p) -> AdventureHelper.surroundWithNameplatesFont(characters));
}
this.registerPlayerPlaceholder("%np_equipped_nameplate%", CNPlayer::equippedNameplate);
this.registerPlayerPlaceholder("%np_equipped_bubble%", CNPlayer::equippedBubble);
this.registerPlayerPlaceholder("%np_equipped_nameplate-name%", (player) -> {
Nameplate nameplate = plugin.getNameplateManager().nameplateById(player.equippedNameplate());
return Optional.ofNullable(nameplate).map(Nameplate::displayName).orElse("");
});
this.registerPlayerPlaceholder("%np_equipped_bubble-name%", (player) -> {
BubbleConfig bubble = plugin.getBubbleManager().bubbleConfigById(player.equippedBubble());
return Optional.ofNullable(bubble).map(BubbleConfig::displayName).orElse("");
});
if (ConfigManager.nameplateModule()) {
this.registerPlayerPlaceholder("%np_equipped_nameplate-name%", (player) -> {
Nameplate nameplate = plugin.getNameplateManager().nameplateById(player.equippedNameplate());
return Optional.ofNullable(nameplate).map(Nameplate::displayName).orElse("");
});
}
if (ConfigManager.bubbleModule()) {
this.registerPlayerPlaceholder("%np_equipped_bubble%", CNPlayer::equippedBubble);
this.registerPlayerPlaceholder("%np_equipped_bubble-name%", (player) -> {
BubbleConfig bubble = plugin.getBubbleManager().bubbleConfigById(player.equippedBubble());
return Optional.ofNullable(bubble).map(BubbleConfig::displayName).orElse("");
});
}
this.registerSharedPlaceholder("%shared_np_is-latest%", () -> String.valueOf(plugin.isUpToDate()));
this.registerPlayerPlaceholder("%np_is-latest%", (player) -> String.valueOf(plugin.isUpToDate()));
for (int i = 1; i <= 20; i++) {