@@ -14,34 +14,49 @@ class EventListener(val plugin: Plugin): Listener {
14
14
@EventHandler(priority = EventPriority .MONITOR )
15
15
fun onChat (event : AsyncPlayerChatEvent ) {
16
16
plugin.logDebug(" Received a chat event from ${event.player.name} : ${event.message} " )
17
- if (! event.isCancelled || plugin.configuration.RELAY_CANCELLED_MESSAGES ) {
18
- val username = ChatColor .stripColor(event.player.name)
19
- val formattedMessage = Util .formatMessage(
20
- plugin.configuration.TEMPLATES_DISCORD_CHAT_MESSAGE ,
21
- mapOf (
22
- " %u" to username,
23
- " %m" to ChatColor .stripColor(event.message),
24
- " %d" to ChatColor .stripColor(event.player.displayName),
25
- " %w" to event.player.world.name
26
- )
27
- )
28
-
29
- plugin.sendToDiscord(formattedMessage)
30
- }
17
+
18
+
19
+ if (! plugin.configuration.MESSAGES_CHAT ) return
20
+ if (event.isCancelled && ! plugin.configuration.RELAY_CANCELLED_MESSAGES ) return
21
+
22
+ // Check for vanished
23
+ val player = event.player;
24
+ if (player.hasMetadata(" vanished" ) &&
25
+ player.getMetadata(" vanished" )[0 ].asBoolean() &&
26
+ ! plugin.configuration.IF_VANISHED_CHAT ) return
27
+
28
+ val username = ChatColor .stripColor(event.player.name)
29
+ val formattedMessage = Util .formatMessage(
30
+ plugin.configuration.TEMPLATES_DISCORD_CHAT_MESSAGE ,
31
+ mapOf (
32
+ " %u" to username,
33
+ " %m" to ChatColor .stripColor(event.message),
34
+ " %d" to ChatColor .stripColor(player.displayName),
35
+ " %w" to player.world.name
36
+ )
37
+ )
38
+
39
+ plugin.sendToDiscord(formattedMessage)
31
40
}
32
41
33
42
@EventHandler(priority = EventPriority .MONITOR , ignoreCancelled = true )
34
43
fun onPlayerJoin (event : PlayerJoinEvent ) {
35
44
if (! plugin.configuration.MESSAGES_JOIN ) return
36
45
37
- val username = ChatColor .stripColor(event.player.name)
46
+ // Check for vanished
47
+ val player = event.player;
48
+ if (player.hasMetadata(" vanished" ) &&
49
+ player.getMetadata(" vanished" )[0 ].asBoolean() &&
50
+ ! plugin.configuration.IF_VANISHED_JOIN ) return
51
+
52
+ val username = ChatColor .stripColor(player.name)
38
53
plugin.logDebug(" Received a join event for $username " )
39
54
40
55
val formattedMessage = Util .formatMessage(
41
56
plugin.configuration.TEMPLATES_DISCORD_PLAYER_JOIN ,
42
57
mapOf (
43
58
" %u" to username,
44
- " %d" to ChatColor .stripColor(event. player.displayName)
59
+ " %d" to ChatColor .stripColor(player.displayName)
45
60
)
46
61
)
47
62
@@ -52,6 +67,12 @@ class EventListener(val plugin: Plugin): Listener {
52
67
fun onPlayerQuit (event : PlayerQuitEvent ) {
53
68
if (! plugin.configuration.MESSAGES_LEAVE ) return
54
69
70
+ // Check for vanished
71
+ val player = event.player;
72
+ if (player.hasMetadata(" vanished" ) &&
73
+ player.getMetadata(" vanished" )[0 ].asBoolean() &&
74
+ ! plugin.configuration.IF_VANISHED_LEAVE ) return
75
+
55
76
val username = ChatColor .stripColor(event.player.name)
56
77
plugin.logDebug(" Received a leave event for $username " )
57
78
@@ -70,6 +91,12 @@ class EventListener(val plugin: Plugin): Listener {
70
91
fun onPlayerDeath (event : PlayerDeathEvent ) {
71
92
if (! plugin.configuration.MESSAGES_DEATH ) return
72
93
94
+ // Check for vanished
95
+ val player = event.entity;
96
+ if (player.hasMetadata(" vanished" ) &&
97
+ player.getMetadata(" vanished" )[0 ].asBoolean() &&
98
+ ! plugin.configuration.IF_VANISHED_DEATH ) return
99
+
73
100
val username = ChatColor .stripColor(event.entity.name)
74
101
plugin.logDebug(" Received a death event for $username " )
75
102
0 commit comments