From 35e17f3ec573e18677e41aad85aa27fe91a2a7fe Mon Sep 17 00:00:00 2001 From: Brettflan Date: Fri, 3 Jun 2011 13:00:16 -0500 Subject: [PATCH] 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 --- .../factions/commands/FCommandHelp.java | 2 +- .../factions/commands/FCommandReload.java | 47 ++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/org/mcteam/factions/commands/FCommandHelp.java b/src/org/mcteam/factions/commands/FCommandHelp.java index aaa6b2e5..c19a16b9 100644 --- a/src/org/mcteam/factions/commands/FCommandHelp.java +++ b/src/org/mcteam/factions/commands/FCommandHelp.java @@ -67,7 +67,7 @@ public class FCommandHelp extends FBaseCommand { pageLines.add( "Create a faction using these two commands:" ); pageLines.add( new FCommandCreate().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 FCommandInvite().getUseageTemplate() ); pageLines.add( new FCommandDeinvite().getUseageTemplate() ); diff --git a/src/org/mcteam/factions/commands/FCommandReload.java b/src/org/mcteam/factions/commands/FCommandReload.java index 05e84ca0..07f32d36 100644 --- a/src/org/mcteam/factions/commands/FCommandReload.java +++ b/src/org/mcteam/factions/commands/FCommandReload.java @@ -12,7 +12,9 @@ public class FCommandReload extends FBaseCommand { public FCommandReload() { aliases.add("reload"); - helpDescription = "reloads the config"; + optionalParameters.add("file"); + + helpDescription = "reloads all json files, or a specific one"; } @Override @@ -23,16 +25,49 @@ public class FCommandReload extends FBaseCommand { public void perform() { Factions.log("=== RELOAD START ==="); long timeInitStart = System.currentTimeMillis(); + String fileName = "s"; - Conf.load(); - FPlayer.load(); - Faction.load(); - Board.load(); + // Was a single file specified? + if (parameters.size() > 0) { + String file = parameters.get(0); + 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); 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"); } }