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

58 lines
2.3 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;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserIgnoredComposer;
2019-05-26 20:14:53 +02:00
public class MuteCommand extends Command {
public MuteCommand() {
2018-07-06 15:30:00 +02:00
super("cmd_mute", Emulator.getTexts().getValue("commands.keys.cmd_mute").split(";"));
}
@Override
2019-05-26 20:14:53 +02:00
public boolean handle(GameClient gameClient, String[] params) throws Exception {
if (params.length == 1) {
2018-07-06 15:30:00 +02:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mute.not_specified"), RoomChatMessageBubbles.ALERT);
return true;
}
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
2019-05-26 20:14:53 +02:00
if (habbo == null) {
2018-07-06 15:30:00 +02:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mute.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
return true;
2019-05-26 20:14:53 +02:00
} else {
if (habbo == gameClient.getHabbo()) {
2018-07-06 15:30:00 +02:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mute.self"), RoomChatMessageBubbles.ALERT);
return true;
}
int duration = Integer.MAX_VALUE;
2019-05-26 20:14:53 +02:00
if (params.length == 3) {
try {
2018-07-06 15:30:00 +02:00
duration = Integer.valueOf(params[2]);
2019-05-26 20:14:53 +02:00
if (duration <= 0)
2018-07-06 15:30:00 +02:00
throw new Exception("");
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2018-07-06 15:30:00 +02:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mute.time"), RoomChatMessageBubbles.ALERT);
return true;
}
}
habbo.mute(duration, false);
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
if (habbo.getHabboInfo().getCurrentRoom() != null) {
2018-07-06 15:30:00 +02:00
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED
}
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
}
return true;
}
}