mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 21:27:44 +01:00
Blueprint manager localization - WIP
This commit is contained in:
parent
3a34133d1a
commit
6024423dad
@ -1,5 +1,11 @@
|
|||||||
package world.bentobox.bentobox.api.commands.admin.blueprints;
|
package world.bentobox.bentobox.api.commands.admin.blueprints;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
@ -12,12 +18,6 @@ import world.bentobox.bentobox.blueprints.BlueprintClipboard;
|
|||||||
import world.bentobox.bentobox.managers.BlueprintsManager;
|
import world.bentobox.bentobox.managers.BlueprintsManager;
|
||||||
import world.bentobox.bentobox.panels.BlueprintManagementPanel;
|
import world.bentobox.bentobox.panels.BlueprintManagementPanel;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class AdminBlueprintCommand extends ConfirmableCommand {
|
public class AdminBlueprintCommand extends ConfirmableCommand {
|
||||||
// Clipboards
|
// Clipboards
|
||||||
private Map<UUID, BlueprintClipboard> clipboards;
|
private Map<UUID, BlueprintClipboard> clipboards;
|
||||||
@ -53,7 +53,7 @@ public class AdminBlueprintCommand extends ConfirmableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, String label, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
new BlueprintManagementPanel(getPlugin()).openPanel(user, (GameModeAddon)getAddon());
|
new BlueprintManagementPanel(getPlugin(), user, (GameModeAddon)getAddon()).openPanel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,11 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
||||||
import org.bukkit.conversations.Prompt;
|
import org.bukkit.conversations.Prompt;
|
||||||
import org.bukkit.conversations.StringPrompt;
|
import org.bukkit.conversations.StringPrompt;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,23 +32,24 @@ public class DescriptionPrompt extends StringPrompt {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
|
User user = User.getInstance((Player)context.getForWhom());
|
||||||
if (context.getSessionData("description") != null) {
|
if (context.getSessionData("description") != null) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (String line : ((List<String>) context.getSessionData("description"))) {
|
for (String line : ((List<String>) context.getSessionData("description"))) {
|
||||||
sb.append(ChatColor.DARK_PURPLE);
|
sb.append(user.getTranslation("commands.admin.blueprint.management.description.default-color"));
|
||||||
sb.append(line);
|
sb.append(line);
|
||||||
sb.append(System.getProperty("line.separator"));
|
sb.append(System.getProperty("line.separator"));
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
return "Enter a multi line description for " + bb.getDisplayName() + System.getProperty("line.separator")
|
return user.getTranslation("commands.admin.blueprint.management.description.instructions", TextVariables.NAME, bb.getDisplayName());
|
||||||
+ ChatColor.GOLD + " and 'quit' on a line by itself to finish.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Prompt acceptInput(ConversationContext context, String input) {
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
if (input.equals("quit")) {
|
User user = User.getInstance((Player)context.getForWhom());
|
||||||
|
if (input.equals(user.getTranslation("commands.admin.blueprint.management.description.quit"))) {
|
||||||
return new DescriptionSuccessPrompt(addon, bb);
|
return new DescriptionSuccessPrompt(addon, bb);
|
||||||
}
|
}
|
||||||
List<String> desc = new ArrayList<>();
|
List<String> desc = new ArrayList<>();
|
||||||
|
@ -29,18 +29,19 @@ public class DescriptionSuccessPrompt extends MessagePrompt {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
|
User user = User.getInstance((Player)context.getForWhom());
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> description = (List<String>)context.getSessionData("description");
|
List<String> description = (List<String>)context.getSessionData("description");
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
bb.setDescription(description);
|
bb.setDescription(description);
|
||||||
BentoBox.getInstance().getBlueprintsManager().addBlueprintBundle(addon, bb);
|
BentoBox.getInstance().getBlueprintsManager().addBlueprintBundle(addon, bb);
|
||||||
BentoBox.getInstance().getBlueprintsManager().saveBlueprintBundle(addon, bb);
|
BentoBox.getInstance().getBlueprintsManager().saveBlueprintBundle(addon, bb);
|
||||||
new BlueprintManagementPanel(BentoBox.getInstance()).openBB(User.getInstance((Player)context.getForWhom()), addon, bb);
|
new BlueprintManagementPanel(BentoBox.getInstance(), user, addon).openBB(bb);
|
||||||
// Set the name
|
// Set the name
|
||||||
// if successfully
|
// if successfully
|
||||||
return "Success!";
|
return user.getTranslation("commands.admin.blueprint.management.description.success");
|
||||||
} else {
|
} else {
|
||||||
return "Cancelling";
|
return user.getTranslation("commands.admin.blueprint.management.description.cancelling");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package world.bentobox.bentobox.blueprints.conversation;
|
package world.bentobox.bentobox.blueprints.conversation;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
||||||
import org.bukkit.conversations.ConversationPrefix;
|
import org.bukkit.conversations.ConversationPrefix;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
public class NameConversationPrefix implements ConversationPrefix {
|
public class NameConversationPrefix implements ConversationPrefix {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrefix(ConversationContext conversationContext) {
|
public String getPrefix(ConversationContext context) {
|
||||||
return ChatColor.GOLD + "> ";
|
User user = User.getInstance((Player)context.getForWhom());
|
||||||
|
return user.getTranslation("commands.admin.blueprint.management.name.conversation-prefix");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,11 @@ package world.bentobox.bentobox.blueprints.conversation;
|
|||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
||||||
import org.bukkit.conversations.Prompt;
|
import org.bukkit.conversations.Prompt;
|
||||||
import org.bukkit.conversations.StringPrompt;
|
import org.bukkit.conversations.StringPrompt;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
|
||||||
public class NamePrompt extends StringPrompt {
|
public class NamePrompt extends StringPrompt {
|
||||||
|
|
||||||
@ -17,11 +19,13 @@ public class NamePrompt extends StringPrompt {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
return "Enter a name, or 'quit' to quit";
|
User user = User.getInstance((Player)context.getForWhom());
|
||||||
|
return user.getTranslation("commands.admin.blueprint.management.name.prompt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Prompt acceptInput(ConversationContext context, String input) {
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
User user = User.getInstance((Player)context.getForWhom());
|
||||||
// Convert color codes
|
// Convert color codes
|
||||||
input = ChatColor.translateAlternateColorCodes('&', input);
|
input = ChatColor.translateAlternateColorCodes('&', input);
|
||||||
if (ChatColor.stripColor(input).length() > 32) {
|
if (ChatColor.stripColor(input).length() > 32) {
|
||||||
@ -36,7 +40,7 @@ public class NamePrompt extends StringPrompt {
|
|||||||
uniqueId.append("x");
|
uniqueId.append("x");
|
||||||
}
|
}
|
||||||
if (max == 32) {
|
if (max == 32) {
|
||||||
context.getForWhom().sendRawMessage("Please pick a more unique name");
|
context.getForWhom().sendRawMessage(user.getTranslation("commands.admin.blueprint.management.name.pick-a-unique-name"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
context.setSessionData("uniqueId", uniqueId.toString());
|
context.setSessionData("uniqueId", uniqueId.toString());
|
||||||
|
@ -30,10 +30,11 @@ public class NameSuccessPrompt extends MessagePrompt {
|
|||||||
bb.setDisplayName(name);
|
bb.setDisplayName(name);
|
||||||
BentoBox.getInstance().getBlueprintsManager().addBlueprintBundle(addon, bb);
|
BentoBox.getInstance().getBlueprintsManager().addBlueprintBundle(addon, bb);
|
||||||
BentoBox.getInstance().getBlueprintsManager().saveBlueprintBundle(addon, bb);
|
BentoBox.getInstance().getBlueprintsManager().saveBlueprintBundle(addon, bb);
|
||||||
new BlueprintManagementPanel(BentoBox.getInstance()).openPanel(User.getInstance((Player)context.getForWhom()), addon);
|
User user = User.getInstance((Player)context.getForWhom());
|
||||||
|
new BlueprintManagementPanel(BentoBox.getInstance(), user, addon).openPanel();
|
||||||
// Set the name
|
// Set the name
|
||||||
// if successfully
|
// if successfully
|
||||||
return "Success!";
|
return user.getTranslation("commands.admin.blueprint.management.description.success");
|
||||||
// Else return failure
|
// Else return failure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +37,6 @@ public abstract class AbstractJSONDatabaseHandler<T> extends AbstractDatabaseHan
|
|||||||
GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().enableComplexMapKeySerialization().setPrettyPrinting();
|
GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().enableComplexMapKeySerialization().setPrettyPrinting();
|
||||||
// Register adapter factory
|
// Register adapter factory
|
||||||
builder.registerTypeAdapterFactory(new BentoboxTypeAdapterFactory(plugin));
|
builder.registerTypeAdapterFactory(new BentoboxTypeAdapterFactory(plugin));
|
||||||
// Keep null in the database
|
|
||||||
builder.serializeNulls();
|
|
||||||
// Allow characters like < or > without escaping them
|
// Allow characters like < or > without escaping them
|
||||||
builder.disableHtmlEscaping();
|
builder.disableHtmlEscaping();
|
||||||
|
|
||||||
|
@ -133,17 +133,21 @@ public class MySQLDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
|
|||||||
String json = resultSet.getString("json");
|
String json = resultSet.getString("json");
|
||||||
if (json != null) {
|
if (json != null) {
|
||||||
try {
|
try {
|
||||||
|
plugin.logDebug("Trying to load " + dataObject.getCanonicalName());
|
||||||
T gsonResult = gson.fromJson(json, dataObject);
|
T gsonResult = gson.fromJson(json, dataObject);
|
||||||
if (gsonResult != null) {
|
if (gsonResult != null) {
|
||||||
list.add(gsonResult);
|
list.add(gsonResult);
|
||||||
}
|
}
|
||||||
} catch (JsonSyntaxException ex) {
|
} catch (JsonSyntaxException ex) {
|
||||||
plugin.logError(COULD_NOT_LOAD_OBJECT + ex.getMessage());
|
plugin.logError(COULD_NOT_LOAD_OBJECT + ex.getMessage());
|
||||||
|
ex.printStackTrace();
|
||||||
|
plugin.logError(json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.logError(COULD_NOT_LOAD_OBJECTS + e.getMessage());
|
plugin.logError(COULD_NOT_LOAD_OBJECTS + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ import org.eclipse.jdt.annotation.NonNull;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.panels.Panel;
|
import world.bentobox.bentobox.api.panels.Panel;
|
||||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||||
@ -32,6 +32,7 @@ import world.bentobox.bentobox.blueprints.conversation.DescriptionPrompt;
|
|||||||
import world.bentobox.bentobox.blueprints.conversation.NameConversationPrefix;
|
import world.bentobox.bentobox.blueprints.conversation.NameConversationPrefix;
|
||||||
import world.bentobox.bentobox.blueprints.conversation.NamePrompt;
|
import world.bentobox.bentobox.blueprints.conversation.NamePrompt;
|
||||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
||||||
|
import world.bentobox.bentobox.managers.BlueprintsManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,36 +42,52 @@ import world.bentobox.bentobox.util.Util;
|
|||||||
public class BlueprintManagementPanel {
|
public class BlueprintManagementPanel {
|
||||||
|
|
||||||
private static final String INFO = "Click on blueprint then click here";
|
private static final String INFO = "Click on blueprint then click here";
|
||||||
private BentoBox plugin;
|
private final BentoBox plugin;
|
||||||
private final static Blueprint NORMAL_BP = new Blueprint().setIcon(Material.GREEN_STAINED_GLASS_PANE).setName("Normal").setDescription(INFO);
|
private final Blueprint NORMAL_BP;
|
||||||
private final static Blueprint NETHER_BP = new Blueprint().setIcon(Material.RED_STAINED_GLASS_PANE).setName("Nether").setDescription(INFO);
|
private final Blueprint NETHER_BP;
|
||||||
private final static Blueprint END_BP = new Blueprint().setIcon(Material.YELLOW_STAINED_GLASS_PANE).setName("The End").setDescription(INFO);
|
private final Blueprint END_BP;
|
||||||
private final static Map<Integer, World.Environment> SLOT_TO_ENV = ImmutableMap.of(3, World.Environment.NORMAL, 5, World.Environment.NETHER, 7, World.Environment.THE_END);
|
private final Map<Integer, World.Environment> SLOT_TO_ENV;
|
||||||
private final static Map<World.Environment, Blueprint> ENV_TO_BP = ImmutableMap.of(World.Environment.NORMAL, NORMAL_BP, World.Environment.NETHER, NETHER_BP, World.Environment.THE_END, END_BP);
|
private final Map<World.Environment, Blueprint> ENV_TO_BP;
|
||||||
private static final int MAX_WORLD_SLOT = 9;
|
private static final int MAX_WORLD_SLOT = 9;
|
||||||
private static final int MIN_WORLD_SLOT = 0;
|
private static final int MIN_WORLD_SLOT = 0;
|
||||||
private Entry<Integer, Blueprint> selected;
|
private Entry<Integer, Blueprint> selected;
|
||||||
private Map<Integer, Blueprint> blueprints = new HashMap<>();
|
private Map<Integer, Blueprint> blueprints = new HashMap<>();
|
||||||
|
private final User user;
|
||||||
|
private final GameModeAddon addon;
|
||||||
|
|
||||||
public BlueprintManagementPanel(BentoBox plugin) {
|
public BlueprintManagementPanel(@NonNull BentoBox plugin, @NonNull User user, @NonNull GameModeAddon addon) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.user = user;
|
||||||
|
this.addon = addon;
|
||||||
|
NORMAL_BP = new Blueprint().setIcon(Material.GREEN_STAINED_GLASS_PANE).setName(t("normal")).setDescription(INFO);
|
||||||
|
NETHER_BP = new Blueprint().setIcon(Material.RED_STAINED_GLASS_PANE).setName(t("nether")).setDescription(INFO);
|
||||||
|
END_BP = new Blueprint().setIcon(Material.YELLOW_STAINED_GLASS_PANE).setName(t("end")).setDescription(INFO);
|
||||||
|
SLOT_TO_ENV = ImmutableMap.of(3, World.Environment.NORMAL, 5, World.Environment.NETHER, 7, World.Environment.THE_END);
|
||||||
|
ENV_TO_BP = ImmutableMap.of(World.Environment.NORMAL, NORMAL_BP, World.Environment.NETHER, NETHER_BP, World.Environment.THE_END, END_BP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openPanel(@NonNull User user, @NonNull GameModeAddon addon) {
|
private String t(String t) {
|
||||||
|
return user.getTranslation("commands.admin.blueprint.management." + t);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String t(String t, String... vars) {
|
||||||
|
return user.getTranslation("commands.admin.blueprint.management." + t, vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openPanel() {
|
||||||
// Show panel of blueprint bundles
|
// Show panel of blueprint bundles
|
||||||
// Clicking on a bundle opens up the bundle edit panel
|
// Clicking on a bundle opens up the bundle edit panel
|
||||||
|
|
||||||
// Create the panel
|
// Create the panel
|
||||||
PanelBuilder pb = new PanelBuilder().name("Blueprint Bundle Manager").user(user).size(45);
|
PanelBuilder pb = new PanelBuilder().name(t("title")).user(user).size(45);
|
||||||
// Get the bundles
|
// Get the bundles
|
||||||
plugin.getBlueprintsManager().getBlueprintBundles(addon).values().stream().limit(36)
|
plugin.getBlueprintsManager().getBlueprintBundles(addon).values().stream().limit(36)
|
||||||
.forEach(bb -> pb.item(new PanelItemBuilder()
|
.forEach(bb -> pb.item(new PanelItemBuilder()
|
||||||
.name(bb.getDisplayName())
|
.name(bb.getDisplayName())
|
||||||
.description("Click to edit")
|
.description(t("edit"))
|
||||||
.icon(bb.getIcon())
|
.icon(bb.getIcon())
|
||||||
.clickHandler((panel, u, clickType, slot) -> {
|
.clickHandler((panel, u, clickType, slot) -> {
|
||||||
u.closeInventory();
|
u.closeInventory();
|
||||||
openBB(u, addon, bb);
|
openBB(bb);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.build()));
|
.build()));
|
||||||
@ -81,7 +98,7 @@ public class BlueprintManagementPanel {
|
|||||||
pb.build();
|
pb.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openBB(User user, @NonNull GameModeAddon addon, BlueprintBundle bb) {
|
public void openBB(BlueprintBundle bb) {
|
||||||
int index = 18;
|
int index = 18;
|
||||||
for (Blueprint bp : plugin.getBlueprintsManager().getBlueprints(addon).values()) {
|
for (Blueprint bp : plugin.getBlueprintsManager().getBlueprints(addon).values()) {
|
||||||
blueprints.put(index++, bp);
|
blueprints.put(index++, bp);
|
||||||
@ -90,7 +107,7 @@ public class BlueprintManagementPanel {
|
|||||||
PanelBuilder pb = new PanelBuilder().name(bb.getDisplayName()).user(user).size(45);
|
PanelBuilder pb = new PanelBuilder().name(bb.getDisplayName()).user(user).size(45);
|
||||||
// Display bundle icon
|
// Display bundle icon
|
||||||
pb.item(0, new PanelItemBuilder()
|
pb.item(0, new PanelItemBuilder()
|
||||||
.name("Click to edit description")
|
.name(t("edit-description"))
|
||||||
.description(bb.getDescription())
|
.description(bb.getDescription())
|
||||||
.icon(bb.getIcon())
|
.icon(bb.getIcon())
|
||||||
.clickHandler((panel, u, clickType, slot) -> {
|
.clickHandler((panel, u, clickType, slot) -> {
|
||||||
@ -111,15 +128,15 @@ public class BlueprintManagementPanel {
|
|||||||
}
|
}
|
||||||
blueprints.entrySet().stream().limit(18).forEach(b -> pb.item(getBlueprintItem(addon, b.getKey(), bb, b.getValue())));
|
blueprints.entrySet().stream().limit(18).forEach(b -> pb.item(getBlueprintItem(addon, b.getKey(), bb, b.getValue())));
|
||||||
// Buttons for non-default bundle
|
// Buttons for non-default bundle
|
||||||
if (!bb.getUniqueId().equals("default")) {
|
if (!bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME)) {
|
||||||
// Panel has a Trash icon. If right clicked it is discarded
|
// Panel has a Trash icon. If right clicked it is discarded
|
||||||
pb.item(36, getTrashIcon(addon, bb));
|
pb.item(36, getTrashIcon(addon, bb));
|
||||||
// Toggle permission - default is always allowed
|
// Toggle permission - default is always allowed
|
||||||
pb.item(39, getPermissionIcon(addon, bb));
|
pb.item(39, getPermissionIcon(addon, bb));
|
||||||
}
|
}
|
||||||
// Panel has a Back icon.
|
// Panel has a Back icon.
|
||||||
pb.item(44, new PanelItemBuilder().icon(Material.ARROW).name("Back").clickHandler((panel, u, clickType, slot) -> {
|
pb.item(44, new PanelItemBuilder().icon(Material.ARROW).name(t("back")).clickHandler((panel, u, clickType, slot) -> {
|
||||||
openPanel(u,addon);
|
openPanel();
|
||||||
return true;
|
return true;
|
||||||
}).build());
|
}).build());
|
||||||
|
|
||||||
@ -129,22 +146,22 @@ public class BlueprintManagementPanel {
|
|||||||
|
|
||||||
private PanelItem getWorldInstrTile(Environment env) {
|
private PanelItem getWorldInstrTile(Environment env) {
|
||||||
return new PanelItemBuilder()
|
return new PanelItemBuilder()
|
||||||
.name(Util.prettifyText(env.name()) + " world")
|
.name(t("world-name-syntax", TextVariables.NAME, Util.prettifyText(env.name())))
|
||||||
.description("Place bluprint", "to right to set")
|
.description(t("world-instuctions"))
|
||||||
.icon(Material.GRAY_STAINED_GLASS_PANE)
|
.icon(Material.GRAY_STAINED_GLASS_PANE)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PanelItem getTrashIcon(@NonNull GameModeAddon addon, BlueprintBundle bb) {
|
private PanelItem getTrashIcon(@NonNull GameModeAddon addon, BlueprintBundle bb) {
|
||||||
return new PanelItemBuilder()
|
return new PanelItemBuilder()
|
||||||
.name("Trash")
|
.name(t("trash"))
|
||||||
.description("Right click here to delete")
|
.description(t("trash-instructions"))
|
||||||
.icon(Material.TNT)
|
.icon(Material.TNT)
|
||||||
.clickHandler((panel, u, clickType, slot) -> {
|
.clickHandler((panel, u, clickType, slot) -> {
|
||||||
if (clickType.equals(ClickType.RIGHT)) {
|
if (clickType.equals(ClickType.RIGHT)) {
|
||||||
u.getPlayer().playSound(u.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
u.getPlayer().playSound(u.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
||||||
plugin.getBlueprintsManager().deleteBlueprintBundle(addon, bb);
|
plugin.getBlueprintsManager().deleteBlueprintBundle(addon, bb);
|
||||||
openPanel(u,addon);
|
openPanel();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
@ -152,9 +169,9 @@ public class BlueprintManagementPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PanelItem getPermissionIcon(@NonNull GameModeAddon addon, BlueprintBundle bb) {
|
private PanelItem getPermissionIcon(@NonNull GameModeAddon addon, BlueprintBundle bb) {
|
||||||
return new PanelItemBuilder().icon(Material.PAINTING).name("Permission")
|
return new PanelItemBuilder().icon(Material.PAINTING).name(t("permission"))
|
||||||
.description(bb.isRequirePermission() ? ChatColor.RED + "Required" : ChatColor.GREEN + "Not required")
|
.description(bb.isRequirePermission() ? t("perm-required") : t("perm-not-required"))
|
||||||
.description(bb.isRequirePermission() ? addon.getPermissionPrefix() + "island.create." + bb.getUniqueId() : "")
|
.description(bb.isRequirePermission() ? t("perm-format") + addon.getPermissionPrefix() + "island.create." + bb.getUniqueId() : "")
|
||||||
.clickHandler((panel, u, clickType, slot) -> {
|
.clickHandler((panel, u, clickType, slot) -> {
|
||||||
// Toggle permission
|
// Toggle permission
|
||||||
u.getPlayer().playSound(u.getLocation(), Sound.UI_BUTTON_CLICK, 1F, 1F);
|
u.getPlayer().playSound(u.getLocation(), Sound.UI_BUTTON_CLICK, 1F, 1F);
|
||||||
@ -171,9 +188,9 @@ public class BlueprintManagementPanel {
|
|||||||
List<String> desc = blueprint.getDescription() == null ? new ArrayList<>() : blueprint.getDescription();
|
List<String> desc = blueprint.getDescription() == null ? new ArrayList<>() : blueprint.getDescription();
|
||||||
if ((!blueprint.equals(END_BP) && !blueprint.equals(NORMAL_BP) && !blueprint.equals(NETHER_BP))) {
|
if ((!blueprint.equals(END_BP) && !blueprint.equals(NORMAL_BP) && !blueprint.equals(NETHER_BP))) {
|
||||||
if ((pos > MIN_WORLD_SLOT && pos < MAX_WORLD_SLOT)) {
|
if ((pos > MIN_WORLD_SLOT && pos < MAX_WORLD_SLOT)) {
|
||||||
desc.add(ChatColor.RED + "Right click to remove");
|
desc.add(t("remove"));
|
||||||
} else {
|
} else {
|
||||||
desc.add(ChatColor.GREEN + "Click to select, then add to bundle");
|
desc.add(t("blueprint-instruction"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new PanelItemBuilder()
|
return new PanelItemBuilder()
|
||||||
@ -193,7 +210,7 @@ public class BlueprintManagementPanel {
|
|||||||
// Save
|
// Save
|
||||||
plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb);
|
plugin.getBlueprintsManager().saveBlueprintBundle(addon, bb);
|
||||||
} else if (selected == null) {
|
} else if (selected == null) {
|
||||||
u.sendRawMessage("Select Blueprint first");
|
u.sendMessage("commands.admin.blueprint.management.select-first");
|
||||||
u.getPlayer().playSound(u.getLocation(), Sound.BLOCK_ANVIL_HIT, 1F, 1F);
|
u.getPlayer().playSound(u.getLocation(), Sound.BLOCK_ANVIL_HIT, 1F, 1F);
|
||||||
} else {
|
} else {
|
||||||
// Add
|
// Add
|
||||||
@ -235,8 +252,8 @@ public class BlueprintManagementPanel {
|
|||||||
|
|
||||||
private PanelItem getNewBundle(@NonNull User user, @NonNull GameModeAddon addon) {
|
private PanelItem getNewBundle(@NonNull User user, @NonNull GameModeAddon addon) {
|
||||||
return new PanelItemBuilder()
|
return new PanelItemBuilder()
|
||||||
.name("New Bundle")
|
.name(t("new-bundle"))
|
||||||
.description("Click to make a new bundle")
|
.description(t("new-bundle-instructions"))
|
||||||
.icon(Material.GREEN_BANNER)
|
.icon(Material.GREEN_BANNER)
|
||||||
.clickHandler((panel, u, clickType, slot) -> {
|
.clickHandler((panel, u, clickType, slot) -> {
|
||||||
u.closeInventory();
|
u.closeInventory();
|
||||||
@ -257,8 +274,7 @@ public class BlueprintManagementPanel {
|
|||||||
.withPrefix(new NameConversationPrefix())
|
.withPrefix(new NameConversationPrefix())
|
||||||
.withTimeout(90)
|
.withTimeout(90)
|
||||||
.withFirstPrompt(new NamePrompt(addon))
|
.withFirstPrompt(new NamePrompt(addon))
|
||||||
.withEscapeSequence("exit")
|
.withEscapeSequence(t("name.quit"))
|
||||||
.withEscapeSequence("quit")
|
|
||||||
.buildConversation(whom).begin();
|
.buildConversation(whom).begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package world.bentobox.bentobox.panels;
|
package world.bentobox.bentobox.panels;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
@ -14,9 +18,6 @@ import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
|||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.versions.ServerCompatibility;
|
import world.bentobox.bentobox.versions.ServerCompatibility;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
@ -72,7 +73,7 @@ public class ManagementPanel {
|
|||||||
.name(user.getTranslation(LOCALE_REF + "views.gamemodes.blueprints.name"))
|
.name(user.getTranslation(LOCALE_REF + "views.gamemodes.blueprints.name"))
|
||||||
.description(user.getTranslation(LOCALE_REF + "views.gamemodes.blueprints.description"))
|
.description(user.getTranslation(LOCALE_REF + "views.gamemodes.blueprints.description"))
|
||||||
.clickHandler((panel, user1, clickType, slot) -> {
|
.clickHandler((panel, user1, clickType, slot) -> {
|
||||||
new BlueprintManagementPanel(plugin).openPanel(user, gameModeAddon);
|
new BlueprintManagementPanel(plugin, user, gameModeAddon).openPanel();
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
|
@ -224,6 +224,44 @@ commands:
|
|||||||
save:
|
save:
|
||||||
parameters: "<blueprint name>"
|
parameters: "<blueprint name>"
|
||||||
description: "save the copied clipboard"
|
description: "save the copied clipboard"
|
||||||
|
management:
|
||||||
|
instruction: "Click on blueprint then click here"
|
||||||
|
normal: "Normal"
|
||||||
|
nether: "Nether"
|
||||||
|
end: "The End"
|
||||||
|
title: "Blueprint Bundle Manager"
|
||||||
|
edit: "Click to edit"
|
||||||
|
edit-description: "Click to edit description"
|
||||||
|
world-name-syntax: "[name] world"
|
||||||
|
world-instructions: |
|
||||||
|
Place blueprint
|
||||||
|
to right to set
|
||||||
|
trash: "Trash"
|
||||||
|
trash-instructions: "Right click here to delete"
|
||||||
|
permission: "Permission"
|
||||||
|
perm-required: "Required"
|
||||||
|
perm-not-required: "Not Required"
|
||||||
|
perm-format: "&e"
|
||||||
|
remove: "Right click to remove"
|
||||||
|
blueprint-instruction: "Click to select, then add to bundle"
|
||||||
|
select-first: "Select Blueprint first"
|
||||||
|
new-bundle: "New Bundle"
|
||||||
|
new-bundle-instructions: "Click to make a new bundle"
|
||||||
|
name:
|
||||||
|
quit: "quit"
|
||||||
|
prompt: "Enter a name, or 'quit' to quit"
|
||||||
|
too-long: "&cToo long"
|
||||||
|
pick-a-unique-name: "Please pick a more unique name"
|
||||||
|
success: "Success!"
|
||||||
|
conversation-prefix: ">"
|
||||||
|
description:
|
||||||
|
quit: "quit"
|
||||||
|
instructions: |
|
||||||
|
Enter a multi line description for [name]
|
||||||
|
and 'quit' on a line by itself to finish.
|
||||||
|
default-color: ""
|
||||||
|
success: "Success!"
|
||||||
|
cancelling: "Cancelling"
|
||||||
resetflags:
|
resetflags:
|
||||||
description: "Reset all islands to default flag settings in config.yml"
|
description: "Reset all islands to default flag settings in config.yml"
|
||||||
world:
|
world:
|
||||||
|
Loading…
Reference in New Issue
Block a user