2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.commands;
|
2011-05-10 19:18:35 +02:00
|
|
|
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Board;
|
|
|
|
import com.massivecraft.factions.Conf;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.FPlayers;
|
|
|
|
import com.massivecraft.factions.Factions;
|
2011-10-08 22:03:44 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2011-05-10 19:18:35 +02:00
|
|
|
|
2011-10-09 20:10:19 +02:00
|
|
|
public class CmdReload extends FCommand
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2011-05-10 19:18:35 +02:00
|
|
|
|
2011-10-09 20:10:19 +02:00
|
|
|
public CmdReload()
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.aliases.add("reload");
|
2011-05-10 19:18:35 +02:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("file", "all");
|
2011-06-08 23:19:02 +02:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
this.permission = Permission.COMMAND_RELOAD.node;
|
2011-06-03 20:00:16 +02:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
senderMustBePlayer = false;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
2011-05-10 19:18:35 +02:00
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-10-09 18:35:39 +02:00
|
|
|
public void perform()
|
|
|
|
{
|
2011-05-10 19:18:35 +02:00
|
|
|
long timeInitStart = System.currentTimeMillis();
|
2011-10-09 18:35:39 +02:00
|
|
|
String file = this.argAsString(0, "all").toLowerCase();
|
|
|
|
|
|
|
|
String fileName;
|
2011-05-10 19:18:35 +02:00
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
if (file.startsWith("c"))
|
|
|
|
{
|
|
|
|
Conf.load();
|
|
|
|
fileName = "conf.json";
|
|
|
|
}
|
|
|
|
else if (file.startsWith("b"))
|
|
|
|
{
|
|
|
|
Board.load();
|
|
|
|
fileName = "board.json";
|
2011-06-03 20:00:16 +02:00
|
|
|
}
|
2011-10-09 18:35:39 +02:00
|
|
|
else if (file.startsWith("f"))
|
|
|
|
{
|
|
|
|
Factions.i.loadFromDisc();
|
|
|
|
fileName = "factions.json";
|
|
|
|
}
|
|
|
|
else if (file.startsWith("p"))
|
|
|
|
{
|
|
|
|
FPlayers.i.loadFromDisc();
|
|
|
|
fileName = "players.json";
|
|
|
|
}
|
|
|
|
else if (file.startsWith("a"))
|
|
|
|
{
|
|
|
|
fileName = "all";
|
2011-06-03 20:00:16 +02:00
|
|
|
Conf.load();
|
2011-10-09 18:35:39 +02:00
|
|
|
FPlayers.i.loadFromDisc();
|
|
|
|
Factions.i.loadFromDisc();
|
2011-06-03 20:00:16 +02:00
|
|
|
Board.load();
|
|
|
|
}
|
2011-10-09 18:35:39 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
|
|
|
sendMessageParsed("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
|
|
|
|
return;
|
|
|
|
}
|
2011-05-10 19:18:35 +02:00
|
|
|
|
|
|
|
long timeReload = (System.currentTimeMillis()-timeInitStart);
|
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
sendMessageParsed("reloaded %s from disk, took %dms", fileName, timeReload);
|
2011-05-10 19:18:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|