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

61 lines
1.8 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
2014-04-04 20:55:21 +02:00
import com.massivecraft.factions.*;
2011-10-09 18:35:39 +02:00
import com.massivecraft.factions.struct.Permission;
2011-05-10 19:18:35 +02:00
2014-04-04 20:55:21 +02:00
public class CmdReload extends FCommand {
public CmdReload() {
super();
this.aliases.add("reload");
//this.requiredArgs.add("");
this.optionalArgs.put("file", "all");
this.permission = Permission.RELOAD.node;
this.disableOnLock = false;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
long timeInitStart = System.currentTimeMillis();
String file = this.argAsString(0, "all").toLowerCase();
String fileName;
if (file.startsWith("c")) {
Conf.load();
fileName = "conf.json";
} else if (file.startsWith("b")) {
Board.load();
fileName = "board.json";
} 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();
FPlayers.i.loadFromDisc();
Factions.i.loadFromDisc();
Board.load();
} else {
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
return;
}
long timeReload = (System.currentTimeMillis() - timeInitStart);
msg("<i>Reloaded <h>%s <i>from disk, took <h>%dms<i>.", fileName, timeReload);
}
2011-05-10 19:18:35 +02:00
}