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;
|
2018-10-07 00:28:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomTrade;
|
2018-07-06 15:30:00 +02: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;
|
|
|
|
|
|
|
|
public class ShutdownCommand extends Command
|
|
|
|
{
|
|
|
|
public ShutdownCommand()
|
|
|
|
{
|
|
|
|
super("cmd_shutdown", Emulator.getTexts().getValue("commands.keys.cmd_shutdown").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
StringBuilder reason = new StringBuilder("-");
|
2018-07-06 15:30:00 +02:00
|
|
|
int minutes = 0;
|
|
|
|
if(params.length > 2)
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
reason = new StringBuilder();
|
2018-07-06 15:30:00 +02:00
|
|
|
for(int i = 1; i < params.length; i++)
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
reason.append(params[i]).append(" ");
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (params.length == 2)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
minutes = Integer.valueOf(params[1]);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2019-03-18 02:22:00 +01:00
|
|
|
reason = new StringBuilder(params[1]);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
ServerMessage message;
|
|
|
|
if (!reason.toString().equals("-"))
|
2018-07-06 15:30:00 +02: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();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message = new HotelWillCloseInMinutesComposer(minutes).compose();
|
|
|
|
}
|
2018-10-07 00:28:00 +02:00
|
|
|
RoomTrade.TRADING_ENABLED = false;
|
2018-07-06 15:30:00 +02:00
|
|
|
ShutdownEmulator.timestamp = Emulator.getIntUnixTimestamp() + (60 * minutes);
|
|
|
|
Emulator.getThreading().run(new ShutdownEmulator(message), minutes * 60 * 1000);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|