ability to specify a single file with /f reload (i.e. /f reload conf), so you don't have to reload all 4 of them

also a trivial typo fix
This commit is contained in:
Brettflan 2011-06-03 13:00:16 -05:00
parent 6f0dcf4b29
commit 35e17f3ec5
2 changed files with 42 additions and 7 deletions

View File

@ -67,7 +67,7 @@ public class FCommandHelp extends FBaseCommand {
pageLines.add( "Create a faction using these two commands:" ); pageLines.add( "Create a faction using these two commands:" );
pageLines.add( new FCommandCreate().getUseageTemplate() ); pageLines.add( new FCommandCreate().getUseageTemplate() );
pageLines.add( new FCommandDescription().getUseageTemplate() ); pageLines.add( new FCommandDescription().getUseageTemplate() );
pageLines.add( "You might wan't to close it and use invitations:" ); pageLines.add( "You might want to close it and use invitations:" );
pageLines.add( new FCommandOpen().getUseageTemplate() ); pageLines.add( new FCommandOpen().getUseageTemplate() );
pageLines.add( new FCommandInvite().getUseageTemplate() ); pageLines.add( new FCommandInvite().getUseageTemplate() );
pageLines.add( new FCommandDeinvite().getUseageTemplate() ); pageLines.add( new FCommandDeinvite().getUseageTemplate() );

View File

@ -12,7 +12,9 @@ public class FCommandReload extends FBaseCommand {
public FCommandReload() { public FCommandReload() {
aliases.add("reload"); aliases.add("reload");
helpDescription = "reloads the config"; optionalParameters.add("file");
helpDescription = "reloads all json files, or a specific one";
} }
@Override @Override
@ -23,16 +25,49 @@ public class FCommandReload extends FBaseCommand {
public void perform() { public void perform() {
Factions.log("=== RELOAD START ==="); Factions.log("=== RELOAD START ===");
long timeInitStart = System.currentTimeMillis(); long timeInitStart = System.currentTimeMillis();
String fileName = "s";
Conf.load(); // Was a single file specified?
FPlayer.load(); if (parameters.size() > 0) {
Faction.load(); String file = parameters.get(0);
Board.load(); if (file.equalsIgnoreCase("conf") || file.equalsIgnoreCase("conf.json")) {
Factions.log("RELOADING CONF.JSON");
Conf.load();
fileName = " conf.json";
}
else if (file.equalsIgnoreCase("board") || file.equalsIgnoreCase("board.json")) {
Factions.log("RELOADING BOARD.JSON");
Board.load();
fileName = " board.json";
}
else if (file.equalsIgnoreCase("factions") || file.equalsIgnoreCase("factions.json")) {
Factions.log("RELOADING FACTIONS.JSON");
Faction.load();
fileName = " factions.json";
}
else if (file.equalsIgnoreCase("players") || file.equalsIgnoreCase("players.json")) {
Factions.log("RELOADING PLAYERS.JSON");
FPlayer.load();
fileName = " players.json";
}
else {
Factions.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
me.sendMessage("Invalid file specified. Valid files: conf, board, factions, players.");
return;
}
}
else {
Factions.log("RELOADING ALL FILES");
Conf.load();
FPlayer.load();
Faction.load();
Board.load();
}
long timeReload = (System.currentTimeMillis()-timeInitStart); long timeReload = (System.currentTimeMillis()-timeInitStart);
Factions.log("=== RELOAD DONE (Took "+timeReload+"ms) ==="); Factions.log("=== RELOAD DONE (Took "+timeReload+"ms) ===");
me.sendMessage("FACTIONS RELOAD DONE IN " + timeReload + "ms"); me.sendMessage("Factions file" + fileName + " reloaded from disk, took " + timeReload + "ms");
} }
} }