File tree Expand file tree Collapse file tree 8 files changed +131
-66
lines changed Expand file tree Collapse file tree 8 files changed +131
-66
lines changed Original file line number Diff line number Diff line change 286286 </HBox >
287287 </children >
288288 </VBox >
289- <VBox fx : id =" vboxRoomSettings" alignment =" TOP_RIGHT" layoutX =" 100.0" layoutY =" 50.0" prefHeight =" 300.0" prefWidth =" 400.0" spacing =" 5.0" style =" -fx-background-color: black;" >
289+ <VBox fx : id =" vboxRoomSettings" alignment =" TOP_RIGHT" layoutX =" 100.0" layoutY =" 50.0" prefHeight =" 300.0" prefWidth =" 400.0" spacing =" 5.0" style =" -fx-background-color: black;" visible = " false " >
290290 <children >
291291 <HBox alignment =" BOTTOM_RIGHT" prefHeight =" 30.0" prefWidth =" 400.0" >
292292 <children >
320320 <ListView id =" BU" fx : id =" listViewBannedUsers" prefHeight =" 200.0" prefWidth =" 400.0" style =" -fx-background-color: black; -fx-text-fill: white;" />
321321 </children >
322322 </HBox >
323- <HBox alignment =" CENTER" prefHeight =" 32.0" prefWidth =" 400.0" spacing =" 10.0" visible = " false " >
323+ <HBox alignment =" CENTER" prefHeight =" 32.0" prefWidth =" 400.0" spacing =" 10.0" >
324324 <children >
325- <TextField fx : id =" textFieldBanUsername " prefHeight =" 30.0" prefWidth =" 150.0" />
326- <TextField fx : id =" textFieldBanAddress" prefHeight =" 30.0" prefWidth =" 150.0" />
327- <Button fx : id =" buttonBan" mnemonicParsing =" false" onAction =" #banUser " prefHeight =" 30.0" prefWidth =" 60.0" text =" Ban" />
325+ <TextField fx : id =" textFieldBanNickname " onKeyTyped = " #validateBanNicknameAndAddress " prefHeight =" 30.0" prefWidth =" 150.0" promptText = " Nickname " />
326+ <TextField fx : id =" textFieldBanAddress" onKeyTyped = " #validateBanNicknameAndAddress " prefHeight =" 30.0" prefWidth =" 150.0" promptText = " Address " />
327+ <Button fx : id =" buttonBan" disable = " true " mnemonicParsing =" false" onAction =" #addManualBan " prefHeight =" 30.0" prefWidth =" 60.0" text =" Ban" />
328328 </children >
329329 </HBox >
330330 </children >
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public interface IServer {
66 public void sendChatMessage (String content );
77 public void sendKickUser (String kickNickname );
88 public User sendBanUser (String banNickname );
9- // public boolean sendBanUser(String banNickname, String banAddress);
9+ public boolean sendBanUser (String banNickname , String banAddress );
1010 public boolean removeBan (String address );
1111 public boolean checkCanStartGame ();
1212 public void sendClose ();
Original file line number Diff line number Diff line change @@ -390,22 +390,21 @@ public User sendBanUser(String banNickname)
390390 return result ;
391391 }
392392
393- /* @Override
393+ @ Override
394394 public boolean sendBanUser (String banNickname , String banAddress )
395395 {
396- if(!this.controller.checkNickname(banNickname) || !this.controller.checkIP(banAddress))
397- return false;
398-
396+ // we check if the entry is already present
399397 for (User u : this .bannedUsers )
400- {
401398 if (banNickname .equals (u .getNickname ()) && banAddress .equals (u .getAddress ().getHostAddress ()))
399+ return false ;
400+ try {
401+ User u = new User (banNickname , InetAddress .getByName (banAddress ));
402+ this .bannedUsers .add (u );
403+ } catch (UnknownHostException e ) {
404+ e .printStackTrace ();
402405 }
403- if(!this.bannedUsers.contains(this.bannedUsers.contains()))
404- {
405- return true;
406- }
407- return false;
408- }*/
406+ return true ;
407+ }
409408
410409 @ Override
411410 public boolean removeBan (String address )
Original file line number Diff line number Diff line change 286286 </HBox >
287287 </children >
288288 </VBox >
289- <VBox fx : id =" vboxRoomSettings" alignment =" TOP_RIGHT" layoutX =" 100.0" layoutY =" 50.0" prefHeight =" 300.0" prefWidth =" 400.0" spacing =" 5.0" style =" -fx-background-color: black;" >
289+ <VBox fx : id =" vboxRoomSettings" alignment =" TOP_RIGHT" layoutX =" 100.0" layoutY =" 50.0" prefHeight =" 300.0" prefWidth =" 400.0" spacing =" 5.0" style =" -fx-background-color: black;" visible = " false " >
290290 <children >
291291 <HBox alignment =" BOTTOM_RIGHT" prefHeight =" 30.0" prefWidth =" 400.0" >
292292 <children >
320320 <ListView id =" BU" fx : id =" listViewBannedUsers" prefHeight =" 200.0" prefWidth =" 400.0" style =" -fx-background-color: black; -fx-text-fill: white;" />
321321 </children >
322322 </HBox >
323- <HBox alignment =" CENTER" prefHeight =" 32.0" prefWidth =" 400.0" spacing =" 10.0" visible = " false " >
323+ <HBox alignment =" CENTER" prefHeight =" 32.0" prefWidth =" 400.0" spacing =" 10.0" >
324324 <children >
325- <TextField fx : id =" textFieldBanUsername " prefHeight =" 30.0" prefWidth =" 150.0" />
326- <TextField fx : id =" textFieldBanAddress" prefHeight =" 30.0" prefWidth =" 150.0" />
327- <Button fx : id =" buttonBan" mnemonicParsing =" false" onAction =" #banUser " prefHeight =" 30.0" prefWidth =" 60.0" text =" Ban" />
325+ <TextField fx : id =" textFieldBanNickname " onKeyTyped = " #validateBanNicknameAndAddress " prefHeight =" 30.0" prefWidth =" 150.0" promptText = " Nickname " />
326+ <TextField fx : id =" textFieldBanAddress" onKeyTyped = " #validateBanNicknameAndAddress " prefHeight =" 30.0" prefWidth =" 150.0" promptText = " Address " />
327+ <Button fx : id =" buttonBan" disable = " true " mnemonicParsing =" false" onAction =" #addManualBan " prefHeight =" 30.0" prefWidth =" 60.0" text =" Ban" />
328328 </children >
329329 </HBox >
330330 </children >
You can’t perform that action at this time.
0 commit comments