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;
|
2022-03-24 01:24:23 +01:00
|
|
|
import com.eu.habbo.habbohotel.rooms.Room;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
|
|
|
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class SummonCommand extends Command {
|
|
|
|
public SummonCommand() {
|
2018-07-06 15:30:00 +02:00
|
|
|
super("cmd_summon", Emulator.getTexts().getValue("commands.keys.cmd_summon").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
|
|
if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null)
|
2018-07-06 15:30:00 +02:00
|
|
|
return true;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (params.length >= 2) {
|
2018-07-06 15:30:00 +02:00
|
|
|
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_summon.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (gameClient.getHabbo().getHabboInfo().getUsername().equals(habbo.getHabboInfo().getUsername())) {
|
2018-07-06 15:30:00 +02:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summon.self").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) {
|
2018-07-06 15:30:00 +02:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summon.same_room").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-24 01:24:23 +01:00
|
|
|
Room room = habbo.getHabboInfo().getCurrentRoom();
|
|
|
|
if (room != null) {
|
|
|
|
Emulator.getGameEnvironment().getRoomManager().logExit(habbo);
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2022-03-24 01:24:23 +01:00
|
|
|
room.removeHabbo(habbo, true);
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2022-03-24 01:24:23 +01:00
|
|
|
habbo.getHabboInfo().setCurrentRoom(null);
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2022-03-24 01:24:23 +01:00
|
|
|
Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true);
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2022-03-24 01:24:23 +01:00
|
|
|
habbo.getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()));
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2022-03-24 01:24:23 +01:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_summon.summoned").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_summon.been_summoned").replace("%user%", gameClient.getHabbo().getHabboInfo().getUsername()));
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
return true;
|
2019-05-26 20:14:53 +02:00
|
|
|
} else {
|
2018-07-06 15:30:00 +02:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_summon.forgot_username"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|