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;
|
2011-10-08 22:03:44 +02:00
|
|
|
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");
|
|
|
|
|
2011-06-08 23:19:02 +02:00
|
|
|
senderMustBePlayer = false;
|
|
|
|
|
2011-06-03 20:00:16 +02:00
|
|
|
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) {
|
2011-10-08 22:03:44 +02:00
|
|
|
return P.hasPermReload(sender);
|
2011-05-10 19:18:35 +02:00
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-05-10 19:18:35 +02:00
|
|
|
public void perform() {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.log("=== RELOAD START ===");
|
2011-05-10 19:18:35 +02:00
|
|
|
long timeInitStart = System.currentTimeMillis();
|
2011-06-03 20:00:16 +02:00
|
|
|
String fileName = "s";
|
2011-05-10 19:18:35 +02:00
|
|
|
|
2011-06-03 20:00:16 +02:00
|
|
|
// Was a single file specified?
|
|
|
|
if (parameters.size() > 0) {
|
|
|
|
String file = parameters.get(0);
|
|
|
|
if (file.equalsIgnoreCase("conf") || file.equalsIgnoreCase("conf.json")) {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.log("RELOADING CONF.JSON");
|
2011-06-03 20:00:16 +02:00
|
|
|
Conf.load();
|
|
|
|
fileName = " conf.json";
|
|
|
|
}
|
|
|
|
else if (file.equalsIgnoreCase("board") || file.equalsIgnoreCase("board.json")) {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.log("RELOADING BOARD.JSON");
|
2011-06-03 20:00:16 +02:00
|
|
|
Board.load();
|
|
|
|
fileName = " board.json";
|
|
|
|
}
|
|
|
|
else if (file.equalsIgnoreCase("factions") || file.equalsIgnoreCase("factions.json")) {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.log("RELOADING FACTIONS.JSON");
|
2011-06-03 20:00:16 +02:00
|
|
|
Faction.load();
|
|
|
|
fileName = " factions.json";
|
|
|
|
}
|
|
|
|
else if (file.equalsIgnoreCase("players") || file.equalsIgnoreCase("players.json")) {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.log("RELOADING PLAYERS.JSON");
|
2011-06-03 20:00:16 +02:00
|
|
|
FPlayer.load();
|
|
|
|
fileName = " players.json";
|
|
|
|
}
|
|
|
|
else {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
2011-06-10 21:22:29 +02:00
|
|
|
sendMessage("Invalid file specified. Valid files: conf, board, factions, players.");
|
2011-06-03 20:00:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.log("RELOADING ALL FILES");
|
2011-06-03 20:00:16 +02:00
|
|
|
Conf.load();
|
|
|
|
FPlayer.load();
|
|
|
|
Faction.load();
|
|
|
|
Board.load();
|
|
|
|
}
|
2011-05-10 19:18:35 +02:00
|
|
|
|
|
|
|
long timeReload = (System.currentTimeMillis()-timeInitStart);
|
2011-10-08 22:03:44 +02:00
|
|
|
P.log("=== RELOAD DONE (Took "+timeReload+"ms) ===");
|
2011-05-10 19:18:35 +02:00
|
|
|
|
2011-06-10 21:22:29 +02:00
|
|
|
sendMessage("Factions file" + fileName + " reloaded from disk, took " + timeReload + "ms");
|
2011-05-10 19:18:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|