Moved settings panels into Admin Settings and adds generic admin panel

Admin panel now can look at users and also set world/system settings.

User settings panel is now just island protection and settings.
This commit is contained in:
tastybento 2019-08-10 11:46:49 -07:00
parent 982072caad
commit 80a5727ec1
2 changed files with 22 additions and 10 deletions

View File

@ -12,6 +12,7 @@ import world.bentobox.bentobox.api.panels.builders.TabbedPanelBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.panels.settings.SettingsTab;
import world.bentobox.bentobox.panels.settings.WorldDefaultSettingsTab;
/**
* @author tastybento
@ -19,7 +20,6 @@ import world.bentobox.bentobox.panels.settings.SettingsTab;
*/
public class AdminSettingsCommand extends CompositeCommand {
private @Nullable UUID targetUUID;
private Island island;
public AdminSettingsCommand(CompositeCommand islandCommand) {
@ -36,13 +36,17 @@ public class AdminSettingsCommand extends CompositeCommand {
@Override
public boolean canExecute(User user, String label, List<String> args) {
if (args.size() != 1) {
if (args.size() > 1) {
// Show help
showHelp(this, user);
return false;
}
if (args.isEmpty()) {
// World settings
return true;
}
// Get target player
targetUUID = getPlayers().getUUID(args.get(0));
@Nullable UUID targetUUID = getPlayers().getUUID(args.get(0));
if (targetUUID == null) {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
return false;
@ -57,12 +61,23 @@ public class AdminSettingsCommand extends CompositeCommand {
@Override
public boolean execute(User user, String label, List<String> args) {
if (args.isEmpty()) {
new TabbedPanelBuilder()
.user(user)
.world(getWorld())
.tab(2, new SettingsTab(getWorld(), user, Flag.Type.WORLD_SETTING))
.tab(6, new WorldDefaultSettingsTab(getWorld(), user))
.startingSlot(2)
.build().openPanel();
return true;
}
// Player settings
new TabbedPanelBuilder()
.user(user)
.world(getWorld())
.tab(2, new SettingsTab(getWorld(), user, island, Flag.Type.PROTECTION))
.tab(6, new SettingsTab(getWorld(), user, island, Flag.Type.SETTING))
.startingSlot(1)
.startingSlot(2)
.build().openPanel();
return true;
}

View File

@ -8,7 +8,6 @@ import world.bentobox.bentobox.api.panels.builders.TabbedPanelBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.panels.settings.SettingsTab;
import world.bentobox.bentobox.panels.settings.WorldDefaultSettingsTab;
import world.bentobox.bentobox.util.Util;
/**
@ -44,11 +43,9 @@ public class IslandSettingsCommand extends CompositeCommand {
new TabbedPanelBuilder()
.user(user)
.world(getWorld())
.tab(1, new SettingsTab(getWorld(), user, island, Flag.Type.PROTECTION))
.tab(3, new SettingsTab(getWorld(), user, island, Flag.Type.SETTING))
.tab(5, new SettingsTab(getWorld(), user, Flag.Type.WORLD_SETTING))
.tab(7, new WorldDefaultSettingsTab(getWorld(), user))
.startingSlot(1)
.tab(2, new SettingsTab(getWorld(), user, island, Flag.Type.PROTECTION))
.tab(6, new SettingsTab(getWorld(), user, island, Flag.Type.SETTING))
.startingSlot(2)
.build().openPanel();
return true;
}