Saber-Factions/src/com/massivecraft/factions/commands/FCommandReload.java

78 lines
1.7 KiB
Java
Raw Normal View History

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;
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 18:35:39 +02:00
public class FCommandReload extends FCommand
{
2011-05-10 19:18:35 +02:00
2011-10-09 18:35:39 +02:00
public FCommandReload()
{
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-10-09 18:35:39 +02:00
this.permission = Permission.COMMAND_RELOAD.node;
2011-10-09 18:35:39 +02:00
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
2011-05-10 19:18:35 +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-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";
Conf.load();
2011-10-09 18:35:39 +02:00
FPlayers.i.loadFromDisc();
Factions.i.loadFromDisc();
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
}
}