Fix TextDisplay height + visibility settings + fix PM placeholders showing gradient names
This commit is contained in:
parent
d8721138d9
commit
8712a98a87
5 changed files with 50 additions and 3 deletions
|
|
@ -84,8 +84,9 @@ public class GradientConfig {
|
||||||
public boolean isUpdateDisplayName() { return config.getBoolean("display.update-display-name", true); }
|
public boolean isUpdateDisplayName() { return config.getBoolean("display.update-display-name", true); }
|
||||||
public boolean isUpdateTabList() { return config.getBoolean("display.update-tab-list", true); }
|
public boolean isUpdateTabList() { return config.getBoolean("display.update-tab-list", true); }
|
||||||
public boolean isUseTextDisplay() { return config.getBoolean("display.use-text-display", true); }
|
public boolean isUseTextDisplay() { return config.getBoolean("display.use-text-display", true); }
|
||||||
public double getTextDisplayHeight() { return config.getDouble("display.text-display-height", 2.3); }
|
public double getTextDisplayHeight() { return config.getDouble("display.text-display-height", 2.8); }
|
||||||
public float getTextDisplayScale() { return (float) config.getDouble("display.text-display-scale", 0.8); }
|
public float getTextDisplayScale() { return (float) config.getDouble("display.text-display-scale", 0.8); }
|
||||||
|
public boolean isTextDisplaySeeThrough() { return config.getBoolean("display.text-display-see-through", false); }
|
||||||
|
|
||||||
// Метод для временного изменения настройки TextDisplay
|
// Метод для временного изменения настройки TextDisplay
|
||||||
public void setUseTextDisplay(boolean useTextDisplay) {
|
public void setUseTextDisplay(boolean useTextDisplay) {
|
||||||
|
|
|
||||||
|
|
@ -57,4 +57,16 @@ public class GradientPlayerListener implements Listener {
|
||||||
FoliaUtil.runAsync(module.getPlugin(),
|
FoliaUtil.runAsync(module.getPlugin(),
|
||||||
() -> module.getDataManager().savePlayerData(player.getUniqueId()));
|
() -> module.getDataManager().savePlayerData(player.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerToggleSneak(org.bukkit.event.player.PlayerToggleSneakEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
// Обновляем TextDisplay чтобы он не скрывался при приседании
|
||||||
|
if (module.getTextDisplayManager() != null && module.getTextDisplayManager().hasDisplay(player.getUniqueId())) {
|
||||||
|
FoliaUtil.runEntityTask(module.getPlugin(), player, () -> {
|
||||||
|
module.getTextDisplayManager().updateDisplayPosition(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ public class TextDisplayManager {
|
||||||
|
|
||||||
double height = module.getConfig().getTextDisplayHeight();
|
double height = module.getConfig().getTextDisplayHeight();
|
||||||
float scale = module.getConfig().getTextDisplayScale();
|
float scale = module.getConfig().getTextDisplayScale();
|
||||||
|
boolean seeThrough = module.getConfig().isTextDisplaySeeThrough();
|
||||||
|
|
||||||
// Создаем новый TextDisplay
|
// Создаем новый TextDisplay
|
||||||
TextDisplay display = player.getWorld().spawn(
|
TextDisplay display = player.getWorld().spawn(
|
||||||
|
|
@ -70,7 +71,7 @@ public class TextDisplayManager {
|
||||||
entity.text(textComponent);
|
entity.text(textComponent);
|
||||||
entity.setBillboard(org.bukkit.entity.Display.Billboard.CENTER);
|
entity.setBillboard(org.bukkit.entity.Display.Billboard.CENTER);
|
||||||
entity.setViewRange(64.0f); // Видимость на 64 блока
|
entity.setViewRange(64.0f); // Видимость на 64 блока
|
||||||
entity.setSeeThrough(true); // Видно через стены
|
entity.setSeeThrough(seeThrough); // Настраиваемая видимость через стены
|
||||||
entity.setShadowRadius(0.0f); // Без тени
|
entity.setShadowRadius(0.0f); // Без тени
|
||||||
entity.setShadowStrength(0.0f); // Без тени
|
entity.setShadowStrength(0.0f); // Без тени
|
||||||
|
|
||||||
|
|
@ -81,6 +82,9 @@ public class TextDisplayManager {
|
||||||
new Vector3f(scale, scale, scale), // Размер текста
|
new Vector3f(scale, scale, scale), // Размер текста
|
||||||
new AxisAngle4f(0, 0, 0, 1) // Без поворота после масштабирования
|
new AxisAngle4f(0, 0, 0, 1) // Без поворота после масштабирования
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Отключаем скрытие при приседании
|
||||||
|
entity.setVisibleByDefault(true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,15 @@ public final class ChatFormatter {
|
||||||
Player receiver,
|
Player receiver,
|
||||||
String message
|
String message
|
||||||
) {
|
) {
|
||||||
|
// Получаем отображаемые имена игроков
|
||||||
|
String senderDisplay = getPlayerDisplayName(sender);
|
||||||
|
String receiverDisplay = getPlayerDisplayName(receiver);
|
||||||
|
|
||||||
return parse(format
|
return parse(format
|
||||||
.replace("{sender}", sender.getName())
|
.replace("{sender}", sender.getName())
|
||||||
.replace("{receiver}", receiver.getName())
|
.replace("{receiver}", receiver.getName())
|
||||||
|
.replace("{sender_display}", senderDisplay)
|
||||||
|
.replace("{receiver_display}", receiverDisplay)
|
||||||
.replace("{message}", message));
|
.replace("{message}", message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,12 +103,34 @@ public final class ChatFormatter {
|
||||||
Player receiver,
|
Player receiver,
|
||||||
String message
|
String message
|
||||||
) {
|
) {
|
||||||
|
// Получаем отображаемые имена игроков
|
||||||
|
String senderDisplay = getPlayerDisplayName(sender);
|
||||||
|
String receiverDisplay = getPlayerDisplayName(receiver);
|
||||||
|
|
||||||
return parse(format
|
return parse(format
|
||||||
.replace("{sender}", sender.getName())
|
.replace("{sender}", sender.getName())
|
||||||
.replace("{receiver}", receiver.getName())
|
.replace("{receiver}", receiver.getName())
|
||||||
|
.replace("{sender_display}", senderDisplay)
|
||||||
|
.replace("{receiver_display}", receiverDisplay)
|
||||||
.replace("{message}", message));
|
.replace("{message}", message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получает отображаемое имя игрока с градиентом
|
||||||
|
*/
|
||||||
|
private static String getPlayerDisplayName(Player player) {
|
||||||
|
// Получаем экземпляр плагина
|
||||||
|
com.loki.lochat.LoChat plugin = com.loki.lochat.LoChat.getInstance();
|
||||||
|
|
||||||
|
// Если градиентный модуль включен, используем его
|
||||||
|
if (plugin.getGradientModule() != null && plugin.getGradientModule().isEnabled()) {
|
||||||
|
return plugin.getGradientModule().getFormattedName(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Иначе просто имя игрока
|
||||||
|
return player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/* ===================== FORMAT (Component-based) ===================== */
|
/* ===================== FORMAT (Component-based) ===================== */
|
||||||
|
|
||||||
public static Component format(
|
public static Component format(
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,11 @@ display:
|
||||||
# Использовать TextDisplay вместо обычного display name (1.19.4+)
|
# Использовать TextDisplay вместо обычного display name (1.19.4+)
|
||||||
use-text-display: true
|
use-text-display: true
|
||||||
# Высота TextDisplay над игроком (в блоках)
|
# Высота TextDisplay над игроком (в блоках)
|
||||||
text-display-height: 2.3
|
text-display-height: 2.8
|
||||||
# Размер TextDisplay (от 0.1 до 2.0)
|
# Размер TextDisplay (от 0.1 до 2.0)
|
||||||
text-display-scale: 0.8
|
text-display-scale: 0.8
|
||||||
|
# Видно ли TextDisplay через стены
|
||||||
|
text-display-see-through: false
|
||||||
|
|
||||||
# Тип хранилища: YAML или SQLITE
|
# Тип хранилища: YAML или SQLITE
|
||||||
storage-type: YAML
|
storage-type: YAML
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue