Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP for #338 enable viewing of challenges by admins. #339

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading