Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java

65 lines
2.2 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
public class EnableCommand extends Command
{
public EnableCommand()
{
super("cmd_enable", Emulator.getTexts().getValue("commands.keys.cmd_enable").split(";"));
}
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception
{
if(params.length >= 2)
{
2019-03-18 02:22:00 +01:00
int effectId;
2018-07-06 15:30:00 +02:00
try
{
effectId = Integer.parseInt(params[1]);
}
catch (Exception e)
{
return false;
}
Habbo target = gameClient.getHabbo();
if (params.length == 3)
{
target = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[2]);
}
if (target != null)
{
if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermission("acc_enable_others"))
{
try
{
if (target.getHabboInfo().getCurrentRoom() != null)
{
if (target.getHabboInfo().getRiding() == null)
{
if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getRank().getId()))
{
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_enable.not_allowed"), RoomChatMessageBubbles.ALERT);
return true;
}
2019-03-18 02:22:00 +01:00
target.getHabboInfo().getCurrentRoom().giveEffect(target, effectId, -1);
2018-07-06 15:30:00 +02:00
}
}
}
catch (Exception e)
{
2019-03-18 02:22:00 +01:00
Emulator.getLogging().logErrorLine(e);
2018-07-06 15:30:00 +02:00
}
}
}
}
return true;
}
}