2018-07-06 13:30:00 +00:00
|
|
|
package com.eu.habbo.habbohotel.commands;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
2020-06-05 04:12:49 -04:00
|
|
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
2018-07-06 13:30:00 +00:00
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
2020-05-04 22:24:09 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2018-07-06 13:30:00 +00:00
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
public class EnableCommand extends Command {
|
2020-05-04 22:24:09 +02:00
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(EnableCommand.class);
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
public EnableCommand() {
|
2018-07-06 13:30:00 +00:00
|
|
|
super("cmd_enable", Emulator.getTexts().getValue("commands.keys.cmd_enable").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 21:14:53 +03:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
|
|
if (params.length >= 2) {
|
2019-03-18 01:22:00 +00:00
|
|
|
int effectId;
|
2019-05-26 21:14:53 +03:00
|
|
|
try {
|
2018-07-06 13:30:00 +00:00
|
|
|
effectId = Integer.parseInt(params[1]);
|
2019-05-26 21:14:53 +03:00
|
|
|
} catch (Exception e) {
|
2018-07-06 13:30:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Habbo target = gameClient.getHabbo();
|
2019-05-26 21:14:53 +03:00
|
|
|
if (params.length == 3) {
|
2018-07-06 13:30:00 +00:00
|
|
|
target = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[2]);
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (target != null) {
|
2020-06-05 04:12:49 -04:00
|
|
|
if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermission(Permission.ACC_ENABLE_OTHERS)) {
|
2019-05-26 21:14:53 +03:00
|
|
|
try {
|
|
|
|
if (target.getHabboInfo().getCurrentRoom() != null) {
|
|
|
|
if (target.getHabboInfo().getRiding() == null) {
|
|
|
|
if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getRank().getId())) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_enable.not_allowed"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-18 01:22:00 +00:00
|
|
|
target.getHabboInfo().getCurrentRoom().giveEffect(target, effectId, -1);
|
2018-07-06 13:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-26 21:14:53 +03:00
|
|
|
} catch (Exception e) {
|
2020-05-04 22:24:09 +02:00
|
|
|
LOGGER.error("Caught exception", e);
|
2018-07-06 13:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|