Saber-Factions/src/com/massivecraft/factions/cmd/CmdReload.java

79 lines
1.7 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
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 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-10-09 21:57:43 +02:00
this.permission = Permission.RELOAD.node;
this.disableOnLock = false;
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");
2011-10-10 13:40:24 +02:00
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
2011-10-09 18:35:39 +02:00
return;
}
2011-05-10 19:18:35 +02:00
long timeReload = (System.currentTimeMillis()-timeInitStart);
2011-10-10 13:40:24 +02:00
msg("<i>Reloaded <h>%s <i>from disk, took <h>%dms<i>.", fileName, timeReload);
2011-05-10 19:18:35 +02:00
}
}