Skip to content

Commit

Permalink
Added challenges reload admin command.
Browse files Browse the repository at this point in the history
This reloads from the database files so admins can edit the challenges
and then reload them without restarting the server.

#27
  • Loading branch information
tastybento committed Nov 12, 2018
1 parent b55cc82 commit e5e0227
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void setup() {
// Register sub commands
new ImportCommand(getAddon(), this);
new CompleteChallenge(getAddon(), this);
new ReloadChallenges(getAddon(), this);
//new ShowChallenges(getAddon(), this);
//new CreateChallenge(getAddon(), this);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package bentobox.addon.challenges.commands.admin;

import java.util.List;

import bentobox.addon.challenges.ChallengesAddon;
import bentobox.addon.challenges.ChallengesManager;
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;

public class ReloadChallenges extends CompositeCommand {

private ChallengesManager manager;

/**
* Admin command to complete user challenges
* @param parent
*/
public ReloadChallenges(Addon addon, CompositeCommand parent) {
super(addon, parent, "reload");
}

@Override
public void setup() {
this.setPermission("admin.challenges");
this.setParametersHelp("challenges.admin.reload.parameters");
this.setDescription("challenges.admin.reload.description");
manager = ((ChallengesAddon)getAddon()).getChallengesManager();
}

@Override
public boolean execute(User user, String label, List<String> args) {
if (!args.isEmpty()) {
// Show help
showHelp(this, user);
return false;
}
manager.load();
user.sendMessage("general.success");
return true;
}

}
3 changes: 3 additions & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ challenges:
admin:
parameters: ""
description: "challenges admin"
reload:
parameters: ""
description: "reload challenges from the database"
import:
parameters: "[overwrite]"
description: "import challenges from challenges.yml"
Expand Down

0 comments on commit e5e0227

Please sign in to comment.