simplified event message handling logic in ChatMessagesListener
This commit is contained in:
@@ -21,18 +21,17 @@ class ChatMessagesListener extends ApplianceListener<ChatMessages> {
|
|||||||
public void onPlayerChatEvent(AsyncChatEvent event) {
|
public void onPlayerChatEvent(AsyncChatEvent event) {
|
||||||
event.renderer(
|
event.renderer(
|
||||||
(source, sourceDisplayName, message, viewer) ->
|
(source, sourceDisplayName, message, viewer) ->
|
||||||
Component.text("")
|
Component.text()
|
||||||
.append(this.getAppliance().getReportablePlayerName(source))
|
.append(this.getAppliance().getReportablePlayerName(source))
|
||||||
.append(Component.text(" > ").color(TextColor.color(Color.GRAY.asRGB())))
|
.append(Component.text(" > ").color(TextColor.color(Color.GRAY.asRGB())))
|
||||||
.append(message).color(TextColor.color(Color.SILVER.asRGB()))
|
.append(message).color(TextColor.color(Color.SILVER.asRGB()))
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
boolean wasHidden = event.joinMessage() == null;
|
if(event.joinMessage() == null) return;
|
||||||
event.joinMessage(null);
|
|
||||||
if(wasHidden) return;
|
|
||||||
IteratorUtil.onlinePlayers(player -> {
|
IteratorUtil.onlinePlayers(player -> {
|
||||||
if(!Settings.instance().getSetting(player, Settings.Key.ShowJoinAndLeaveMessages, Boolean.class)) return;
|
if(!Settings.instance().getSetting(player, Settings.Key.ShowJoinAndLeaveMessages, Boolean.class)) return;
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
@@ -45,9 +44,7 @@ class ChatMessagesListener extends ApplianceListener<ChatMessages> {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
public void onPlayerLeave(PlayerQuitEvent event) {
|
||||||
boolean wasHidden = event.quitMessage() == null;
|
if(event.quitMessage() == null) return;
|
||||||
event.quitMessage(null);
|
|
||||||
if(wasHidden) return;
|
|
||||||
IteratorUtil.onlinePlayers(player -> {
|
IteratorUtil.onlinePlayers(player -> {
|
||||||
if(!Settings.instance().getSetting(player, Settings.Key.ShowJoinAndLeaveMessages, Boolean.class)) return;
|
if(!Settings.instance().getSetting(player, Settings.Key.ShowJoinAndLeaveMessages, Boolean.class)) return;
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
|
|||||||
Reference in New Issue
Block a user