/*
* Created by Andrey Cherkashin (acherkashin)
* http://acherkashin.me
*
* License
* Copyright (c) 2015 Andrey Cherkashin
* The project released under the MIT license: http://opensource.org/licenses/MIT
*/
package ragefist.packets.rpc;
import com.juniform.JUniformObject;
import ragefist.packets.IncomingPacket;
import ragefist.packets.IncomingPacketException;
/**
*
* @author acherkashin
*/
public class Reload extends IncomingPacket
{
/**
*
* @throws IncomingPacketException
*/
@Override
public void run() throws IncomingPacketException {
JUniformObject data = this.getPacket().getProperty("data");
if (data.isNull()) {
throw new IncomingPacketException("ERROR_BAD_DATA");
}
Integer environmentId = data.getProperty("environmentId").toIntegerDefault(-1);
if (environmentId < 0 ||
environmentId > this.getPacketHandler().getServerControllerAPI().getEnvironmentCount() - 1
) {
throw new IncomingPacketException("ERROR_BAD_ENVIRONMENT");
}
this.getPacketHandler().getServerControllerAPI().getEnvironmentById(environmentId).reload();
this.getPacketHandler().whenIncomingPacketIsFinished(this, true, null);
}
}