Skip to content

Commit 40da3db

Browse files
committed
化粧品登録されているものすべて表示するように
1 parent 51e4605 commit 40da3db

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

src/main/java/com/github/elic0de/thejpspit/gui/CosmeticsMenu.java

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,73 @@
11
package com.github.elic0de.thejpspit.gui;
22

33
import com.github.elic0de.thejpspit.TheJpsPit;
4-
import com.github.elic0de.thejpspit.cosmetics.Cosmetic;
4+
import com.github.elic0de.thejpspit.cosmetics.AbstractCosmetic;
55
import com.github.elic0de.thejpspit.player.PitPlayer;
66
import com.github.elic0de.thejpspit.player.PitPlayerManager;
77
import com.github.elic0de.thejpspit.player.PurchasedCosmeticsCollection;
88
import de.themoep.inventorygui.DynamicGuiElement;
9+
import de.themoep.inventorygui.GuiElementGroup;
10+
import de.themoep.inventorygui.GuiPageElement;
911
import de.themoep.inventorygui.InventoryGui;
1012
import de.themoep.inventorygui.StaticGuiElement;
13+
import java.util.List;
1114
import java.util.concurrent.atomic.AtomicBoolean;
15+
import java.util.stream.Collectors;
1216
import org.bukkit.Material;
1317
import org.bukkit.entity.Player;
1418
import org.bukkit.inventory.ItemStack;
15-
import org.checkerframework.checker.units.qual.A;
1619

1720
public class CosmeticsMenu {
1821

22+
private final int pageNumber = 1;
23+
1924
private static final String[] MENU_LAYOUT = {
2025
" ",
21-
" SCBoFLc ",
22-
" tvueG ",
23-
" "
26+
" ppppppp ",
27+
" ppppppp ",
28+
" ppppppp ",
29+
" ",
30+
"bl i ne"
2431
};
2532

2633
private final InventoryGui menu;
2734

2835
private CosmeticsMenu(TheJpsPit plugin, String title) {
2936
this.menu = new InventoryGui(plugin, title, MENU_LAYOUT);
30-
plugin.getCosmeticManager().getKillCosmetics().values().stream().map(killCosmetic -> getItemElement((Cosmetic) killCosmetic)).forEach(this.menu::addElement);
37+
this.menu.addElement(getPositionGroup(plugin.getCosmeticManager().getAllCosmetics().values().stream().collect(
38+
Collectors.toList())));
39+
menu.addElement(new GuiPageElement('b',
40+
new ItemStack(Material.ARROW),
41+
GuiPageElement.PageAction.FIRST,
42+
"最初のページ"));
43+
menu.addElement(new GuiPageElement('l',
44+
new ItemStack(Material.ARROW),
45+
GuiPageElement.PageAction.PREVIOUS,
46+
"前のページ"));
47+
menu.addElement(new GuiPageElement('n',
48+
new ItemStack(Material.ARROW),
49+
GuiPageElement.PageAction.NEXT,
50+
"次のページ"));
51+
menu.addElement(new GuiPageElement('e',
52+
new ItemStack(Material.ARROW),
53+
GuiPageElement.PageAction.LAST,
54+
"最後のページ"));
55+
menu.setPageNumber(pageNumber);
3156
}
3257

3358
public static CosmeticsMenu create(TheJpsPit plugin, String title) {
3459
return new CosmeticsMenu(plugin, title);
3560
}
3661

37-
private DynamicGuiElement getItemElement(Cosmetic cosmetic) {
38-
return new DynamicGuiElement(cosmetic.getId().charAt(0), (viewer) -> {
62+
private GuiElementGroup getPositionGroup(List<AbstractCosmetic> cosmetics) {
63+
final GuiElementGroup group = new GuiElementGroup('p');
64+
cosmetics.forEach(position -> group.addElement(getItemElement(position)));
65+
return group;
66+
}
67+
68+
69+
private DynamicGuiElement getItemElement(AbstractCosmetic cosmetic) {
70+
return new DynamicGuiElement(cosmetic.getSlot(), (viewer) -> {
3971
final PitPlayer pitPlayer = PitPlayerManager.getPitPlayer((Player) viewer);
4072
final AtomicBoolean hasCosmetic = new AtomicBoolean(false);
4173
final AtomicBoolean isSelected = new AtomicBoolean(false);
@@ -44,7 +76,7 @@ private DynamicGuiElement getItemElement(Cosmetic cosmetic) {
4476
hasCosmetic.set(cosmeticsCollection.has(cosmetic));
4577
isSelected.set(cosmeticsCollection.isSelectedCosmetic(cosmetic));
4678
});
47-
return new StaticGuiElement(cosmetic.getName().charAt(0), new ItemStack(Material.COMPASS), click -> {
79+
return new StaticGuiElement(cosmetic.getSlot(), new ItemStack(cosmetic.getMaterial()), click -> {
4880
pitPlayer.getPreferences().ifPresent(preferences -> {
4981
final PurchasedCosmeticsCollection cosmeticsCollection = preferences.getCosmeticsCollection();
5082
if (hasCosmetic.get()) {

0 commit comments

Comments
 (0)