Continued working on the SettingsPanel. Did minor fixes in PanelItemBuilder

This commit is contained in:
Florian CUNY 2018-02-26 20:18:09 +01:00
parent c6c7e0b4ee
commit f648c936ad
5 changed files with 33 additions and 12 deletions

View File

@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack;
import us.tastybento.bskyblock.api.commands.User;
import us.tastybento.bskyblock.api.panels.PanelItem;
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
import us.tastybento.bskyblock.managers.RanksManager;
public class Flag implements Comparable<Flag> {
@ -108,7 +109,10 @@ public class Flag implements Comparable<Flag> {
public PanelItem toPanelItem(User user) {
return new PanelItemBuilder()
.icon(new ItemStack(icon))
.name(user.getTranslation("protection.flags." + id))
.name(user.getTranslation("protection.panel.flag-item.name-layout", "[name]", user.getTranslation("protection.flags." + id + ".name")))
.description(user.getTranslation("protection.panel.flag-item.description-layout",
"[description]", user.getTranslation("protection.flags." + id + ".description"),
"[rank]", "Owner"))
.clickHandler((clicker, click) -> {
clicker.sendRawMessage("You clicked on : " + id);
return true;

View File

@ -31,7 +31,8 @@ public class Panel {
inventory = Bukkit.createInventory(null, size, name);
// Fill the inventory and return
for (Map.Entry<Integer, PanelItem> en: items.entrySet()) {
inventory.setItem(en.getKey(), en.getValue().getItem());
//TODO allow multi-paging
if (en.getKey() < 54) inventory.setItem(en.getKey(), en.getValue().getItem());
}
} else {
inventory = Bukkit.createInventory(null, 9, name);

View File

@ -1,9 +1,6 @@
package us.tastybento.bskyblock.api.panels.builders;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.*;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -46,11 +43,11 @@ public class PanelItemBuilder {
*/
@SuppressWarnings("deprecation")
public PanelItemBuilder icon(String playerName) {
ItemStack item = new ItemStack(Material.SKULL_ITEM,1,(short)3);
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta meta = (SkullMeta)item.getItemMeta();
// This is deprecated, but apparently the only way to make it work right now
meta.setOwner(playerName);
item.setItemMeta( meta );
item.setItemMeta(meta);
this.icon = item;
return this;
}
@ -90,7 +87,9 @@ public class PanelItemBuilder {
* @return PanelItemBuilder
*/
public PanelItemBuilder description(String description) {
this.description.add(description);
for (String line : description.split("\n")) {
this.description.add(line);
}
return this;
}

View File

@ -30,6 +30,17 @@ import us.tastybento.bskyblock.listeners.flags.TeleportationListener;
public class Flags {
// TODO: add HURT_VILLAGERS
// TODO: add TRAPDOOR
// TODO: add DYEING sheeps
// TODO: add ELYTRA
// TODO: add FISHING
// TODO: rename HURT_MOBS to HURT_ANIMALS
// TODO: add INTERACT_TAMED
// TODO: split LEVER_BUTTON into BUTTON and LEVER
// TODO: add KEEP_INVENTORY
// TODO: rename MOB_SPAWN to ANIMAL_SPAWN
public static final Flag BREAK_BLOCKS = new FlagBuilder().id("BREAK_BLOCKS").icon(Material.STONE).listener(new BreakBlocksListener()).build();
public static final Flag PLACE_BLOCKS = new FlagBuilder().id("PLACE_BLOCKS").icon(Material.BEDROCK).listener(new PlaceBlocksListener()).build();

View File

@ -5,6 +5,7 @@ import us.tastybento.bskyblock.api.commands.User;
import us.tastybento.bskyblock.api.flags.Flag;
import us.tastybento.bskyblock.api.panels.PanelItem;
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
/**
* @author Poslovitch
@ -17,7 +18,14 @@ public class SettingsPanel {
*/
public static void openPanel(User user) {
PanelBuilder panelBuilder = new PanelBuilder()
.setName(user.getTranslation("panels.settings.title"));
.setName(user.getTranslation("protection.panel.title"));
PanelItem help = new PanelItemBuilder()
.name(user.getTranslation("protection.panel.help-item.name"))
.icon("crashdummie99") // Question marks
.build();
panelBuilder.addItem(8, help);
for (Flag flag : BSkyBlock.getInstance().getFlagsManager().getFlags()) {
PanelItem flagIcon = flag.toPanelItem(user);
@ -26,6 +34,4 @@ public class SettingsPanel {
panelBuilder.build().open(user);
}
}