From e2013c8451e0df5dd399e25ccf9570a826972fc5 Mon Sep 17 00:00:00 2001 From: Swirny Date: Sat, 16 May 2020 15:35:20 +0200 Subject: [PATCH 1/4] Added official moderation command softkick --- sqlupdates/2_3_1_TO_2_4_0-RC-1.sql | 4 +++ .../habbohotel/commands/CommandHandler.java | 1 + .../habbohotel/commands/SoftKickCommand.java | 25 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java diff --git a/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql b/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql index 5cebe121..24f16927 100644 --- a/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql +++ b/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql @@ -1,3 +1,7 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.stickies.max', '200'); INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('retro.style.homeroom', '1'); + +ALTER TABLE `permissions` ADD `cmd_softkick` ENUM( '0', '1' ) NOT NULL DEFAULT '0' AFTER `cmd_kickall`; + +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_softkick', 'softkick'); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java index a8e550a1..33974e59 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -284,6 +284,7 @@ public class CommandHandler { addCommand(new WordQuizCommand()); addCommand(new UpdateYoutubePlaylistsCommand()); addCommand(new AddYoutubePlaylistCommand()); + addCommand(new SoftKickCommand()); addCommand(new TestCommand()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java new file mode 100644 index 00000000..7323e0dc --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java @@ -0,0 +1,25 @@ +package com.eu.habbo.habbohotel.commands; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.Habbo; + +public class SoftKickCommand extends Command { + public SoftKickCommand() { + super("cmd_softkick", Emulator.getTexts().getValue("commands.keys.cmd_softkick").split(";")); + } + + @Override + public boolean handle(GameClient gameClient, String[] params) throws Exception { + final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + + for (Habbo habbo : room.getHabbos()) { + if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) { + room.kickHabbo(habbo, false); + } + } + return true; + } +} From 25c9f887189ea6e663434ab1e789923a737596f4 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Wed, 3 Jun 2020 03:15:09 +0200 Subject: [PATCH 2/4] Changes by Swirny, squashed to make merging easier --- sqlupdates/2_3_1_TO_2_4_0-RC-1.sql | 6 +----- sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql | 4 ++++ .../habbohotel/commands/SoftKickCommand.java | 20 ++++++++++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql diff --git a/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql b/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql index 24f16927..3e2d7895 100644 --- a/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql +++ b/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql @@ -1,7 +1,3 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.stickies.max', '200'); -INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('retro.style.homeroom', '1'); - -ALTER TABLE `permissions` ADD `cmd_softkick` ENUM( '0', '1' ) NOT NULL DEFAULT '0' AFTER `cmd_kickall`; - -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_softkick', 'softkick'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('retro.style.homeroom', '1'); \ No newline at end of file diff --git a/sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql b/sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql new file mode 100644 index 00000000..77f75ee3 --- /dev/null +++ b/sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql @@ -0,0 +1,4 @@ +ALTER TABLE `permissions` ADD `cmd_softkick` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_kickall`; +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_softkick', 'softkick'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_not_found', '%user% not found'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_error_self', 'You can not softkick yourself!'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java index 7323e0dc..8f9eb699 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; public class SoftKickCommand extends Command { @@ -13,13 +14,22 @@ public class SoftKickCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { - final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + if (params.length == 2) { + Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]); - for (Habbo habbo : room.getHabbos()) { - if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) { - room.kickHabbo(habbo, false); - } + if (habbo == null) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.keys.cmd_softkick_error").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); + return true; } + else if (habbo == gameClient.getHabbo()) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.keys.cmd_softkick_error_self"), RoomChatMessageBubbles.ALERT); + return true; + } + else { + final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + room.kickHabbo(habbo, false); + } + } return true; } } From f5dd2088097145e15a71deb54dba49c1a72bd0b0 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Wed, 3 Jun 2020 03:17:32 +0200 Subject: [PATCH 3/4] Move SQL to correct file --- sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql | 4 ---- sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql | 10 +++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql diff --git a/sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql b/sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql deleted file mode 100644 index 77f75ee3..00000000 --- a/sqlupdates/2_4_0 RC-1 to 2_4_0 RC-2.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `permissions` ADD `cmd_softkick` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_kickall`; -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_softkick', 'softkick'); -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_not_found', '%user% not found'); -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_error_self', 'You can not softkick yourself!'); \ No newline at end of file diff --git a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql index cb3bef84..e44e9474 100644 --- a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql +++ b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql @@ -1,3 +1,11 @@ +-- Hide email from specific ranks. ALTER TABLE `permissions` ADD `acc_hide_mail` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_hide_ip`; -INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('flood.with.rights', '0'); \ No newline at end of file +-- Flood with rights. +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('flood.with.rights', '0'); + +-- Softkick command. +ALTER TABLE `permissions` ADD `cmd_softkick` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_kickall`; +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_softkick', 'softkick'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_not_found', '%user% not found'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_error_self', 'You can not softkick yourself!'); \ No newline at end of file From e4e8b5fe6f4eccc05074597efb829d07b4420d9d Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Wed, 3 Jun 2020 03:25:06 +0200 Subject: [PATCH 4/4] Improve code --- sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql | 2 +- .../habbohotel/commands/SoftKickCommand.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql index e44e9474..2f68174f 100644 --- a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql +++ b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql @@ -5,7 +5,7 @@ ALTER TABLE `permissions` ADD `acc_hide_mail` ENUM('0', '1') NOT NULL DEFAULT '0 INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('flood.with.rights', '0'); -- Softkick command. -ALTER TABLE `permissions` ADD `cmd_softkick` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_kickall`; +ALTER TABLE `permissions` ADD `cmd_softkick` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_kickall`; INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_softkick', 'softkick'); INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_not_found', '%user% not found'); INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_error_self', 'You can not softkick yourself!'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java index 8f9eb699..c89ab075 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java @@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; @@ -15,18 +14,22 @@ public class SoftKickCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { if (params.length == 2) { - Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]); + final String username = params[1]; + final Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(username); if (habbo == null) { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.keys.cmd_softkick_error").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.keys.cmd_softkick_error").replace("%user%", username), RoomChatMessageBubbles.ALERT); return true; } - else if (habbo == gameClient.getHabbo()) { + + if (habbo == gameClient.getHabbo()) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.keys.cmd_softkick_error_self"), RoomChatMessageBubbles.ALERT); return true; } - else { - final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + + final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + + if (room != null) { room.kickHabbo(habbo, false); } }