mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-26 20:45:53 +01:00
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:
parent
b55cc822a9
commit
e5e022754b
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user