Added challenges reload admin command.

This reloads from the database files so admins can edit the challenges
and then reload them without restarting the server.

https://github.com/BentoBoxWorld/addon-challenges/issues/27
This commit is contained in:
tastybento 2018-11-12 11:44:43 -08:00
parent b55cc822a9
commit e5e022754b
3 changed files with 47 additions and 0 deletions

View File

@ -26,6 +26,7 @@ public class Challenges extends CompositeCommand {
// Register sub commands
new ImportCommand(getAddon(), this);
new CompleteChallenge(getAddon(), this);
new ReloadChallenges(getAddon(), this);
//new ShowChallenges(getAddon(), this);
//new CreateChallenge(getAddon(), this);

View File

@ -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;
}
}

View File

@ -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"