51 lines
2.1 KiB
Java
Raw Normal View History

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;
2018-10-06 22:28:00 +00:00
import com.eu.habbo.habbohotel.rooms.RoomTrade;
2018-07-06 13:30:00 +00:00
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.HotelWillCloseInMinutesComposer;
import com.eu.habbo.threading.runnables.ShutdownEmulator;
2019-05-26 21:14:53 +03:00
public class ShutdownCommand extends Command {
public ShutdownCommand() {
2018-07-06 13:30:00 +00:00
super("cmd_shutdown", Emulator.getTexts().getValue("commands.keys.cmd_shutdown").split(";"));
}
@Override
2019-05-26 21:14:53 +03:00
public boolean handle(GameClient gameClient, String[] params) throws Exception {
2019-03-18 01:22:00 +00:00
StringBuilder reason = new StringBuilder("-");
2018-07-06 13:30:00 +00:00
int minutes = 0;
2019-05-26 21:14:53 +03:00
if (params.length > 2) {
2019-03-18 01:22:00 +00:00
reason = new StringBuilder();
2019-05-26 21:14:53 +03:00
for (int i = 1; i < params.length; i++) {
2019-03-18 01:22:00 +00:00
reason.append(params[i]).append(" ");
2018-07-06 13:30:00 +00:00
}
2019-05-26 21:14:53 +03:00
} else {
if (params.length == 2) {
try {
2018-07-06 13:30:00 +00:00
minutes = Integer.valueOf(params[1]);
2019-05-26 21:14:53 +03:00
} catch (Exception e) {
2019-03-18 01:22:00 +00:00
reason = new StringBuilder(params[1]);
2018-07-06 13:30:00 +00:00
}
}
}
2019-03-18 01:22:00 +00:00
ServerMessage message;
2019-05-26 21:14:53 +03:00
if (!reason.toString().equals("-")) {
2018-07-06 13:30:00 +00:00
message = new GenericAlertComposer("<b>" + Emulator.getTexts().getValue("generic.warning") + "</b> \r\n" +
Emulator.getTexts().getValue("generic.shutdown").replace("%minutes%", minutes + "") + "\r\n" +
Emulator.getTexts().getValue("generic.reason.specified") + ": <b>" + reason + "</b>\r" +
"\r" +
"- " + gameClient.getHabbo().getHabboInfo().getUsername()).compose();
2019-05-26 21:14:53 +03:00
} else {
2018-07-06 13:30:00 +00:00
message = new HotelWillCloseInMinutesComposer(minutes).compose();
}
2018-10-06 22:28:00 +00:00
RoomTrade.TRADING_ENABLED = false;
2018-07-06 13:30:00 +00:00
ShutdownEmulator.timestamp = Emulator.getIntUnixTimestamp() + (60 * minutes);
Emulator.getThreading().run(new ShutdownEmulator(message), minutes * 60 * 1000);
return true;
}
}