Skip to content

Commit

Permalink
WIP for #338 enable viewing of challenges by admins.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Apr 25, 2024
1 parent ec6b950 commit ace31c2
Show file tree
Hide file tree
Showing 8 changed files with 434 additions and 374 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import java.util.List;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.panel.admin.AdminPanel;
import world.bentobox.challenges.panel.user.ChallengesPanel;


public class ChallengesAdminCommand extends CompositeCommand
Expand All @@ -19,9 +21,9 @@ public class ChallengesAdminCommand extends CompositeCommand
public ChallengesAdminCommand(ChallengesAddon addon, CompositeCommand parent)
{
super(addon,
parent,
addon.getChallengesSettings().getAdminMainCommand().split(" ")[0],
addon.getChallengesSettings().getAdminMainCommand().split(" "));
parent,
addon.getChallengesSettings().getAdminMainCommand().split(" ")[0],
addon.getChallengesSettings().getAdminMainCommand().split(" "));
}


Expand Down Expand Up @@ -52,16 +54,36 @@ public void setup()
@Override
public boolean execute(User user, String label, List<String> args)
{
BentoBox.getInstance().logDebug("Args size = " + args.size());
// Open up the admin challenges GUI
if (user.isPlayer())
{
AdminPanel.open(this.getAddon(),
this.getWorld(),
user,
this.getTopLabel(),
this.getPermissionPrefix());
if (args.isEmpty()) {
AdminPanel.open(this.getAddon(),
this.getWorld(),
user,
this.getTopLabel(),
this.getPermissionPrefix());

return true;
return true;
} else if (args.size() == 1) {
User target = getPlayers().getUser(args.get(0).trim());
if (target == null) {
user.sendMessage("general.errors.unknown-player");
return false;
}
ChallengesPanel.view(this.getAddon(),
this.getWorld(),
target,
user,
this.getTopLabel(),
this.getPermissionPrefix());

return true;
}
// Show help
showHelp(this, user);
return false;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected CommonPagedPanel(ChallengesAddon addon,
User user,
World world, String topLabel, String permissionPrefix)
{
super(addon, user, world, topLabel, permissionPrefix);
super(addon, user, user, world, topLabel, permissionPrefix);
}


Expand Down
327 changes: 168 additions & 159 deletions src/main/java/world/bentobox/challenges/panel/CommonPanel.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public class AdminPanel extends CommonPanel
private AdminPanel(ChallengesAddon addon,
World world,
User user,
User viewer,
String topLabel,
String permissionPrefix)
{
super(addon, user, world, topLabel, permissionPrefix);
super(addon, user, viewer, world, topLabel, permissionPrefix);
}


Expand All @@ -66,7 +67,7 @@ public static void open(ChallengesAddon addon,
String topLabel,
String permissionPrefix)
{
new AdminPanel(addon, world, user, topLabel, permissionPrefix).build();
new AdminPanel(addon, world, user, user, topLabel, permissionPrefix).build();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class EditChallengePanel extends CommonPanel {
*/
private EditChallengePanel(ChallengesAddon addon, User user, World world, String topLabel, String permissionPrefix,
Challenge challenge) {
super(addon, user, world, topLabel, permissionPrefix);
super(addon, user, user, world, topLabel, permissionPrefix);
this.challenge = challenge;
this.currentMenuType = MenuType.PROPERTIES;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private EditSettingsPanel(ChallengesAddon addon,
String topLabel,
String permissionPrefix)
{
super(addon, user, world, topLabel, permissionPrefix);
super(addon, user, user, world, topLabel, permissionPrefix);
this.settings = this.addon.getChallengesSettings();
}

Expand Down
Loading

0 comments on commit ace31c2

Please sign in to comment.