mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-24 01:58:39 +01:00
Shifted panel to IslandCreationPanel
This commit is contained in:
parent
7c07982669
commit
7ea0edea91
@ -25,7 +25,7 @@ public class AdminBlueprintCommand extends ConfirmableCommand {
|
||||
private static final Particle.DustOptions PARTICLE_DUST_OPTIONS = new Particle.DustOptions(Color.RED, 1.0F);
|
||||
|
||||
public AdminBlueprintCommand(CompositeCommand parent) {
|
||||
super(parent, "blueprint", "bp");
|
||||
super(parent, "blueprint", "bp", "blu");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,8 +66,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
||||
return makeIsland(user, name);
|
||||
} else {
|
||||
// Show panel
|
||||
getPlugin().getBlueprintsManager().showPanel(this, user, label);
|
||||
//IslandCreationPanel.openPanel(user, (GameModeAddon) getAddon());
|
||||
IslandCreationPanel.openPanel(this, user, label);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -86,10 +86,9 @@ public class IslandResetCommand extends ConfirmableCommand {
|
||||
} else {
|
||||
// Show panel after confirmation
|
||||
if (getPlugin().getSettings().isResetConfirmation()) {
|
||||
this.askConfirmation(user, () -> getPlugin().getBlueprintsManager().showPanel(this, user, label));
|
||||
this.askConfirmation(user, () -> IslandCreationPanel.openPanel(this, user, label));
|
||||
} else {
|
||||
getPlugin().getBlueprintsManager().showPanel(this, user, label);
|
||||
//IslandCreationPanel.openPanel(user, (GameModeAddon) getAddon());
|
||||
IslandCreationPanel.openPanel(this, user, label);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,22 +1,35 @@
|
||||
package world.bentobox.bentobox.managers;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.InstanceCreator;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.InstanceCreator;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.blueprints.Blueprint;
|
||||
import world.bentobox.bentobox.blueprints.BlueprintPaster;
|
||||
@ -27,22 +40,6 @@ import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.schems.SchemToBlueprint;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
/**
|
||||
* Handles Blueprints
|
||||
* @since 1.5.0
|
||||
@ -367,37 +364,6 @@ public class BlueprintsManager {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a player a panel of selectable blueprint bundles. Checks user's permission
|
||||
* @param command - the command requesting the panel, e.g., create or reset
|
||||
* @param user - the user
|
||||
* @param label - label
|
||||
*/
|
||||
public void showPanel(CompositeCommand command, User user, String label) {
|
||||
// Create the panel
|
||||
PanelBuilder pb = new PanelBuilder().name(user.getTranslation("commands.island.create.pick")).user(user);
|
||||
// Get the bundles
|
||||
Collection<BlueprintBundle> bbs = getBlueprintBundles((@NonNull GameModeAddon) command.getAddon()).values();
|
||||
// Loop through them and create items in the panel
|
||||
for (BlueprintBundle bb : bbs) {
|
||||
String perm = command.getPermissionPrefix() + "island.create." + bb.getUniqueId();
|
||||
if (!bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME)
|
||||
&& bb.isRequirePermission()
|
||||
&& !user.hasPermission(perm)) {
|
||||
// Skip bundles that the user has no permission for
|
||||
continue;
|
||||
}
|
||||
PanelItem pi = new PanelItemBuilder().name(bb.getDisplayName()).description(bb.getDescription())
|
||||
.icon(bb.getIcon()).name(bb.getUniqueId()).clickHandler((panel, user1, clickType, slot1) -> {
|
||||
user1.closeInventory();
|
||||
command.execute(user1, label, Collections.singletonList(bb.getUniqueId()));
|
||||
return true;
|
||||
}).build();
|
||||
pb.item(pi);
|
||||
}
|
||||
pb.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has permission to see or use this blueprint bundle.
|
||||
* @param addon - addon making the request
|
||||
|
@ -1,48 +1,55 @@
|
||||
package world.bentobox.bentobox.panels;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
||||
import world.bentobox.bentobox.managers.BlueprintsManager;
|
||||
|
||||
/**
|
||||
* Displays the available BlueprintBundles to pick up as the island.
|
||||
* @author Poslovitch, tastybento
|
||||
* @author tastybento
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class IslandCreationPanel {
|
||||
|
||||
private static final String LOCALE_REF = "island-creation.";
|
||||
|
||||
private IslandCreationPanel() {}
|
||||
|
||||
/**
|
||||
* Shows the island creation panel for this Gamemode to this User.
|
||||
* @param user the User to show the panel to.
|
||||
* @param addon the addon to display the blueprint bundles from.
|
||||
* Shows a player a panel of selectable blueprint bundles. Checks user's permission
|
||||
* @param command - the command requesting the panel, e.g., create or reset
|
||||
* @param user - the user
|
||||
* @param label - label
|
||||
*/
|
||||
public static void openPanel(@NonNull User user, @NonNull GameModeAddon addon) {
|
||||
public static void openPanel(@NonNull CompositeCommand command, @NonNull User user, @NonNull String label) {
|
||||
BentoBox plugin = BentoBox.getInstance();
|
||||
PanelBuilder builder = new PanelBuilder()
|
||||
.name(user.getTranslation(LOCALE_REF + "title"));
|
||||
|
||||
plugin.getBlueprintsManager().getBlueprintBundles(addon).forEach((id, bundle) -> {
|
||||
PanelItemBuilder itemBuilder = new PanelItemBuilder()
|
||||
.icon(bundle.getIcon())
|
||||
.name(bundle.getDisplayName())
|
||||
.description(bundle.getDescription())
|
||||
.clickHandler((panel, user1, clickType, slot) -> {
|
||||
user1.closeInventory();
|
||||
// TODO create the island;
|
||||
return true;
|
||||
});
|
||||
|
||||
builder.item(itemBuilder.build());
|
||||
});
|
||||
|
||||
builder.build().open(user);
|
||||
// Create the panel
|
||||
PanelBuilder pb = new PanelBuilder().name(user.getTranslation("commands.island.create.pick")).user(user);
|
||||
// Get the bundles
|
||||
Collection<BlueprintBundle> bbs = plugin.getBlueprintsManager().getBlueprintBundles((@NonNull GameModeAddon) command.getAddon()).values();
|
||||
// Loop through them and create items in the panel
|
||||
for (BlueprintBundle bb : bbs) {
|
||||
String perm = command.getPermissionPrefix() + "island.create." + bb.getUniqueId();
|
||||
if (bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME)
|
||||
|| !bb.isRequirePermission()
|
||||
|| user.hasPermission(perm)) {
|
||||
// Add an item
|
||||
pb.item(new PanelItemBuilder().name(bb.getDisplayName()).description(bb.getDescription())
|
||||
.icon(bb.getIcon()).name(bb.getUniqueId()).clickHandler((panel, user1, clickType, slot1) -> {
|
||||
user1.closeInventory();
|
||||
command.execute(user1, label, Collections.singletonList(bb.getUniqueId()));
|
||||
return true;
|
||||
}).build());
|
||||
}
|
||||
}
|
||||
pb.build();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user