@@ -30,6 +30,7 @@ private function load(Player $player) {
30
30
"prefix " => null ,
31
31
"nick " => null ,
32
32
"mute " => false ,
33
+ "pause " => false ,
33
34
];
34
35
$ this ->players [$ n ] = (new Config ($ path ,Config::YAML ,$ defaults ))->getAll ();
35
36
}
@@ -99,7 +100,23 @@ public function onChat(PlayerChatEvent $ev) {
99
100
$ player ->sendMessage (TextFormat::RED ."[YouChat] You have been muted from chat! " );
100
101
return ;
101
102
}
103
+ if ($ this ->players [$ n ]["pause " ]) {
104
+ $ ev ->setCancelled ();
105
+ $ player ->sendMessage (TextFormat::RED ."[YouChat] You have paused chat! " );
106
+ return ;
107
+ }
108
+ }
109
+
110
+ $ recvr = [];
111
+ foreach ($ ev ->getRecipients () as $ to ) {
112
+ $ m = strtolower ($ to ->getName ());
113
+ if (isset ($ this ->players [$ m ])) {
114
+ if ($ this ->players [$ m ]["pause " ]) continue ;
115
+ }
116
+ $ recvr [] = $ to ;
102
117
}
118
+ $ ev ->setRecipients ($ recvr );
119
+
103
120
$ vars = [
104
121
"{YouChat} " => $ this ->getDescription ()->getFullName (),
105
122
"{player} " => $ player ->getName (),
@@ -170,7 +187,14 @@ private function findPlayer($pn) {
170
187
echo __METHOD__ .", " .__LINE__ ."\n" ;//##DEBUG
171
188
return $ target ;
172
189
}
190
+ private function chgUsrCfg ($ target ,$ setting ,$ value ) {
191
+ $ this ->load ($ target ); // Make sure defautls are there
192
+ $ n = trim (strtolower ($ target ->getName ()));
193
+ $ this ->players [$ n ][$ setting ] = $ value ;
194
+ $ this ->save ($ target );
195
+ return true ;
173
196
197
+ }
174
198
private function checkOther ($ sender ,$ setting ,$ args ,$ perm ,$ null =false ) {
175
199
if (count ($ args ) == 0
176
200
|| ($ target = $ this ->findPlayer ($ args [0 ])) === null ) {
@@ -198,10 +222,7 @@ private function checkOther($sender,$setting,$args,$perm,$null=false) {
198
222
if (count ($ args ) == 0 ) return false ;
199
223
$ value = implode (" " ,$ args );
200
224
}
201
- $ this ->load ($ target ); // Make sure defautls are there
202
- $ n = trim (strtolower ($ target ->getName ()));
203
- $ this ->players [$ n ][$ setting ] = $ value ;
204
- $ this ->save ($ target );
225
+ $ this ->chgUsrCfg ($ target ,$ setting ,$ value );
205
226
if ($ target ->isOnline ()) {
206
227
if ($ value === null ) {
207
228
$ target ->sendMessage (TextFormat::AQUA .
@@ -256,6 +277,26 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar
256
277
if (count ($ args ) != 1 ) return false ;
257
278
$ this ->mute ($ sender ,implode (" " ,$ args ),false );
258
279
return true ;
280
+ case "ycstop " :
281
+ if (!($ sender instanceof Player)) {
282
+ $ sender ->sendMessage (TextFormat::YELLOW .
283
+ "[YouChat] In-game only command " );
284
+ return true ;
285
+ }
286
+ if (count ($ args ) != 0 ) return false ;
287
+ $ this ->chgUsrCfg ($ sender ,"pause " ,true );
288
+ $ sender ->sendMessage (TextFormat::RED ."[YouChat] Chat suspended " );
289
+ return true ;
290
+ case "ycstart " :
291
+ if (!($ sender instanceof Player)) {
292
+ $ sender ->sendMessage (TextFormat::YELLOW .
293
+ "[YouChat] In-game only command " );
294
+ return true ;
295
+ }
296
+ if (count ($ args ) != 0 ) return false ;
297
+ $ this ->chgUsrCfg ($ sender ,"pause " ,false );
298
+ $ sender ->sendMessage (TextFormat::GREEN ."[YouChat] Chat resumed " );
299
+ return true ;
259
300
case "yce " : // enable chat
260
301
$ this ->chgCfg ("chat " ,true );
261
302
$ this ->getServer ()->broadcastMessage (TextFormat::GREEN ."[YouChat] Chat is now enabled " );
@@ -264,6 +305,15 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar
264
305
$ this ->chgCfg ("chat " ,false );
265
306
$ this ->getServer ()->broadcastMessage (TextFormat::RED ."[YouChat] Chat is now disabled " );
266
307
return true ;
308
+ case "clearchat " : // Clear chat window
309
+ if (!($ sender instanceof Player)) {
310
+ $ sender ->sendMessage (TextFormat::YELLOW .
311
+ "[YouChat] In-game only command " );
312
+ return true ;
313
+ }
314
+ if (count ($ args ) != 0 ) return false ;
315
+ for ($ i =0 ;$ i <32 ;++$ i ) $ sender ->sendMessage (" " );
316
+ return true ;
267
317
}
268
318
return false ;
269
319
}
0 commit comments