Improve code

This commit is contained in:
Mike 2020-06-03 03:25:06 +02:00
parent f5dd208809
commit e4e8b5fe6f
2 changed files with 10 additions and 7 deletions

View File

@ -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!');

View File

@ -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);
}
}