File tree Expand file tree Collapse file tree 5 files changed +61
-0
lines changed Expand file tree Collapse file tree 5 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
- Games are now deactivatable by setting their game time to -1
14
14
- Added an option to send the user to the lobby when they join the server.
15
15
- Added fireworks for the arena winner.
16
+ - Divided chat by arena (Including lobby)
16
17
17
18
### Fixed
18
19
Original file line number Diff line number Diff line change
1
+ package dev ._2lstudios .jelly .utils ;
2
+
3
+ public class ObjectUtils {
4
+ public static boolean checkEquals (final Object obj1 , final Object obj2 ) {
5
+ if (obj1 == null && obj2 == null ) {
6
+ return true ;
7
+ }
8
+
9
+ if (obj1 == null || obj2 == null ) {
10
+ return false ;
11
+ }
12
+
13
+ return obj1 .equals (obj2 );
14
+ }
15
+ }
Original file line number Diff line number Diff line change 12
12
import dev ._2lstudios .squidgame .commands .SquidGameCommand ;
13
13
import dev ._2lstudios .squidgame .hooks .PlaceholderAPIHook ;
14
14
import dev ._2lstudios .squidgame .hooks .ScoreboardHook ;
15
+ import dev ._2lstudios .squidgame .listeners .AsyncPlayerChatListener ;
15
16
import dev ._2lstudios .squidgame .listeners .BlockBreakListener ;
16
17
import dev ._2lstudios .squidgame .listeners .BlockPlaceListener ;
17
18
import dev ._2lstudios .squidgame .listeners .EntityDamageListener ;
@@ -57,6 +58,7 @@ public void onEnable() {
57
58
this .addCommand (new SquidGameCommand ());
58
59
59
60
// Register listeners
61
+ this .addEventListener (new AsyncPlayerChatListener (this ));
60
62
this .addEventListener (new BlockBreakListener (this ));
61
63
this .addEventListener (new BlockPlaceListener (this ));
62
64
this .addEventListener (new EntityDamageListener (this ));
Original file line number Diff line number Diff line change
1
+ package dev ._2lstudios .squidgame .listeners ;
2
+
3
+ import java .util .Iterator ;
4
+
5
+ import org .bukkit .entity .Player ;
6
+ import org .bukkit .event .EventHandler ;
7
+ import org .bukkit .event .Listener ;
8
+ import org .bukkit .event .player .AsyncPlayerChatEvent ;
9
+
10
+ import dev ._2lstudios .jelly .utils .ObjectUtils ;
11
+ import dev ._2lstudios .squidgame .SquidGame ;
12
+ import dev ._2lstudios .squidgame .player .SquidPlayer ;
13
+
14
+ public class AsyncPlayerChatListener implements Listener {
15
+
16
+ private final SquidGame plugin ;
17
+
18
+ public AsyncPlayerChatListener (final SquidGame plugin ) {
19
+ this .plugin = plugin ;
20
+ }
21
+
22
+ @ EventHandler
23
+ public void onAsyncPlayerChat (final AsyncPlayerChatEvent e ) {
24
+ if (this .plugin .getMainConfig ().getBoolean ("game-settings.per-arena-chat" , true )) {
25
+ final SquidPlayer thisPlayer = (SquidPlayer ) this .plugin .getPlayerManager ().getPlayer (e .getPlayer ());
26
+ final Iterator <Player > players = e .getRecipients ().iterator ();
27
+
28
+ if (thisPlayer == null ) {
29
+ return ;
30
+ }
31
+
32
+ while (players .hasNext ()) {
33
+ final Player bukkitPlayer = players .next ();
34
+ final SquidPlayer recipient = (SquidPlayer ) this .plugin .getPlayerManager ().getPlayer (bukkitPlayer );
35
+
36
+ if (!ObjectUtils .checkEquals (recipient .getArena (), thisPlayer .getArena ())) {
37
+ players .remove ();
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
Original file line number Diff line number Diff line change 1
1
game-settings :
2
2
allow-victory-before-completing-game : false
3
3
give-blindness-in-game-3 : true
4
+ per-arena-chat : true
4
5
send-player-to-lobby-on-join : true
5
6
spawn-fireworks-on-win : true
6
7
min-players : 2
You can’t perform that action at this time.
0 commit comments