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

78 lines
2.1 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
import org.bukkit.command.CommandSender;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
2011-05-10 19:18:35 +02:00
2011-10-08 23:22:02 +02:00
public class FCommandReload extends FCommand {
2011-05-10 19:18:35 +02:00
public FCommandReload() {
aliases.add("reload");
senderMustBePlayer = false;
optionalParameters.add("file");
helpDescription = "reloads all json files, or a specific one";
2011-05-10 19:18:35 +02:00
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermReload(sender);
2011-05-10 19:18:35 +02:00
}
@Override
2011-05-10 19:18:35 +02:00
public void perform() {
P.log("=== RELOAD START ===");
2011-05-10 19:18:35 +02:00
long timeInitStart = System.currentTimeMillis();
String fileName = "s";
2011-05-10 19:18:35 +02:00
// Was a single file specified?
if (parameters.size() > 0) {
String file = parameters.get(0);
if (file.equalsIgnoreCase("conf") || file.equalsIgnoreCase("conf.json")) {
P.log("RELOADING CONF.JSON");
Conf.load();
fileName = " conf.json";
}
else if (file.equalsIgnoreCase("board") || file.equalsIgnoreCase("board.json")) {
P.log("RELOADING BOARD.JSON");
Board.load();
fileName = " board.json";
}
else if (file.equalsIgnoreCase("factions") || file.equalsIgnoreCase("factions.json")) {
P.log("RELOADING FACTIONS.JSON");
Faction.load();
fileName = " factions.json";
}
else if (file.equalsIgnoreCase("players") || file.equalsIgnoreCase("players.json")) {
P.log("RELOADING PLAYERS.JSON");
FPlayer.load();
fileName = " players.json";
}
else {
P.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
sendMessage("Invalid file specified. Valid files: conf, board, factions, players.");
return;
}
}
else {
P.log("RELOADING ALL FILES");
Conf.load();
FPlayer.load();
Faction.load();
Board.load();
}
2011-05-10 19:18:35 +02:00
long timeReload = (System.currentTimeMillis()-timeInitStart);
P.log("=== RELOAD DONE (Took "+timeReload+"ms) ===");
2011-05-10 19:18:35 +02:00
sendMessage("Factions file" + fileName + " reloaded from disk, took " + timeReload + "ms");
2011-05-10 19:18:35 +02:00
}
}