mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-30 12:01:30 +01:00
Merge branch 'develop' into jsondb
This commit is contained in:
commit
6626a9a4b0
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -70,14 +70,4 @@ public class FlagsManager {
|
||||
public Flag getFlagByID(String id) {
|
||||
return flags.stream().filter(flag -> flag.getID().equals(id)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get flag by icon
|
||||
* @param icon material
|
||||
* @return flag or null if it does not exist
|
||||
*/
|
||||
public Flag getFlagByIcon(Material icon) {
|
||||
return flags.stream().filter(flag -> flag.getIcon().equals(icon)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -520,7 +520,6 @@ public class TestBSkyBlock {
|
||||
// Add it to the Flag Manager
|
||||
flagsManager.registerFlag(customFlag);
|
||||
assertEquals(customFlag, flagsManager.getFlagByID("CUSTOM_FLAG"));
|
||||
assertEquals(customFlag, flagsManager.getFlagByIcon(customFlag.getIcon()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,14 +104,4 @@ public class FlagsManagerTest {
|
||||
Flags.values().stream().sorted(Comparator.reverseOrder()).forEach(flag -> assertEquals(flag, fm.getFlagByID(flag.getID())));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFlagByIcon() {
|
||||
BSkyBlock plugin = mock(BSkyBlock.class);
|
||||
FlagsManager fm = new FlagsManager(plugin);
|
||||
// Test in forward and reverse order so that any duplicates are caught
|
||||
Flags.values().stream().sorted().forEach(flag -> assertEquals(flag, fm.getFlagByIcon(flag.getIcon())));
|
||||
Flags.values().stream().sorted(Comparator.reverseOrder()).forEach(flag -> assertEquals(flag, fm.getFlagByIcon(flag.getIcon())));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user