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