feat: add warning notification when no players hear local chat
This commit is contained in:
@@ -45,6 +45,7 @@ public class ChatHandler {
|
|||||||
.append(sender.getDisplayName());
|
.append(sender.getDisplayName());
|
||||||
|
|
||||||
if (text.startsWith(prefix)) {
|
if (text.startsWith(prefix)) {
|
||||||
|
// ГЛОБАЛЬНИЙ ЧАТ
|
||||||
String actualMessage = text.substring(1).trim();
|
String actualMessage = text.substring(1).trim();
|
||||||
Component globalMessage = Component.empty()
|
Component globalMessage = Component.empty()
|
||||||
.append(formattedName)
|
.append(formattedName)
|
||||||
@@ -55,6 +56,18 @@ public class ChatHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// ЛОКАЛЬНИЙ ЧАТ
|
||||||
|
int heardCount = 0;
|
||||||
|
|
||||||
|
for (ServerPlayer player : players) {
|
||||||
|
if (player.level() == serverLevel && player.distanceTo(sender) <= LOCAL_CHAT_RADIUS) {
|
||||||
|
if (player != sender) {
|
||||||
|
heardCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (heardCount > 0) {
|
||||||
Component localMessage = Component.empty()
|
Component localMessage = Component.empty()
|
||||||
.append(formattedName)
|
.append(formattedName)
|
||||||
.append(Component.literal(": " + text).withStyle(ChatFormatting.GRAY));
|
.append(Component.literal(": " + text).withStyle(ChatFormatting.GRAY));
|
||||||
@@ -64,6 +77,12 @@ public class ChatHandler {
|
|||||||
player.sendSystemMessage(localMessage);
|
player.sendSystemMessage(localMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendSystemMessage(
|
||||||
|
Component.literal("Вас ніхто не почув, додайте на початок повідомлення \"!\" аби написати в глобальний чат")
|
||||||
|
.withStyle(ChatFormatting.ITALIC, ChatFormatting.YELLOW)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user