Skip to content

Commit 65c93db

Browse files
committed
fix some stuff
1 parent 11d02cc commit 65c93db

File tree

7 files changed

+117
-27
lines changed

7 files changed

+117
-27
lines changed

src/main/java/net/oceanias/opal/menu/OMenu.java

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,18 @@ public static void addIngredients() {
5454
}
5555

5656
public static final class Previous extends PageItem {
57+
private final OMenu back;
58+
5759
public Previous() {
5860
super(false);
61+
62+
this.back = null;
63+
}
64+
65+
public Previous(final OMenu back) {
66+
super(false);
67+
68+
this.back = back;
5969
}
6070

6171
@Override
@@ -65,12 +75,24 @@ public ItemProvider getItemProvider(final @NotNull PagedGui<?> gui) {
6575

6676
if (gui.hasPreviousPage()) {
6777
return new OItemBuilder(Material.TIPPED_ARROW)
68-
.setPotionType(PotionType.LONG_LEAPING)
78+
.setPotionType(PotionType.SWIFTNESS)
6979
.setName(Opal.get().getColour() + "Previous Page")
7080
.addLore(List.of(
71-
"&7• &fTransition: &e" + now + " &7/ &e" + max + " &7» &6" + (now + 1) + " &7/ &6" + max,
81+
"&fPage: &e" + now + "&7/&e" + max + " &7» &a" + (now + 1) + "&7/&a" + max,
82+
"",
83+
Opal.get().getColour() + "Click &7to turn!"
84+
))
85+
.addGlint()
86+
.hideFlags();
87+
}
88+
89+
if (back != null) {
90+
return new OItemBuilder(Material.SPECTRAL_ARROW)
91+
.setName(Opal.get().getColour() + "Go Back")
92+
.addLore(List.of(
93+
"&fMenu: &6" + back.getWindow(back.getGui(null), null),
7294
"",
73-
Opal.get().getColour() + "Click &7to show!"
95+
Opal.get().getColour() + "Click &7to use!"
7496
))
7597
.addGlint()
7698
.hideFlags();
@@ -85,13 +107,17 @@ public void handleClick(
85107
final @NotNull Player player,
86108
final @NotNull InventoryClickEvent event
87109
) {
88-
if (!getGui().hasNextPage()) {
89-
return;
110+
if (getGui().hasPreviousPage()) {
111+
super.handleClick(click, player, event);
112+
113+
player.soundDSR(Sound.ITEM_BOOK_PAGE_TURN);
90114
}
91115

92-
super.handleClick(click, player, event);
116+
if (back == null) {
117+
return;
118+
}
93119

94-
player.soundDSR(Sound.ITEM_BOOK_PAGE_TURN);
120+
back.openMenu(player);
95121
}
96122
}
97123

@@ -107,12 +133,12 @@ public ItemProvider getItemProvider(final @NotNull PagedGui<?> gui) {
107133

108134
if (gui.hasNextPage()) {
109135
return new OItemBuilder(Material.TIPPED_ARROW)
110-
.setPotionType(PotionType.LONG_FIRE_RESISTANCE)
136+
.setPotionType(PotionType.SWIFTNESS)
111137
.setName(Opal.get().getColour() + "Next Page")
112138
.addLore(List.of(
113-
"&7• &fTransition: &6" + now + " &7/ &6" + max + " &7» &e" + (now - 1) + " &7/ &e" + max,
139+
"&fPage: &e" + now + "&7/&e" + max + " &7» &a" + (now - 1) + "&7/&a" + max,
114140
"",
115-
Opal.get().getColour() + "Click &7to show!"
141+
Opal.get().getColour() + "Click &7to turn!"
116142
))
117143
.addGlint()
118144
.hideFlags();

src/main/java/net/oceanias/opal/setting/OSetting.java

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22

33
import java.util.List;
44
import org.bukkit.Material;
5+
import xyz.xenondevs.invui.item.Item;
56
import lombok.Getter;
67
import lombok.Setter;
78
import lombok.experimental.Accessors;
89

9-
@SuppressWarnings("unused")
10+
@SuppressWarnings({ "unused", "unchecked" })
1011
@Getter
11-
@Accessors(fluent = true, chain = false)
12-
public abstract class OSetting<T> {
12+
public abstract class OSetting<T, S extends OSetting<T, S>> {
13+
@Accessors(fluent = true)
1314
protected final String pretty;
15+
16+
@Accessors(fluent = true)
17+
1418
protected final T initial;
1519

16-
@Setter
20+
@Accessors(fluent = true)
1721
protected List<String> description;
1822

19-
@Setter
23+
@Accessors(fluent = true)
2024
protected Material material;
2125

2226
@Setter
27+
@Accessors(fluent = true, chain = false)
2328
protected T value;
2429

2530
protected OSetting(final String pretty, final T initial) {
@@ -33,7 +38,25 @@ protected OSetting(final String pretty, final T initial) {
3338
value = initial;
3439
}
3540

36-
public void reset() {
37-
this.value = initial;
41+
protected S self() {
42+
return (S) this;
43+
}
44+
45+
public S description(final List<String> description) {
46+
this.description = description;
47+
48+
return self();
49+
}
50+
51+
public S material(final Material material) {
52+
this.material = material;
53+
54+
return self();
3855
}
56+
57+
public final void reset() {
58+
value = initial;
59+
}
60+
61+
public abstract Item item();
3962
}

src/main/java/net/oceanias/opal/setting/impl/OBooleanSetting.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,22 @@
1414
import xyz.xenondevs.invui.item.impl.AbstractItem;
1515
import lombok.RequiredArgsConstructor;
1616
import lombok.experimental.ExtensionMethod;
17+
import org.jetbrains.annotations.Contract;
1718
import org.jetbrains.annotations.NotNull;
1819

1920
@SuppressWarnings("unused")
2021
@ExtensionMethod(OCommandSenderExtension.class)
21-
public final class OBooleanSetting extends OSetting<Boolean> {
22+
public final class OBooleanSetting extends OSetting<Boolean, OBooleanSetting> {
2223
public OBooleanSetting(final String pretty, final boolean initial) {
2324
super(pretty, initial);
2425
}
2526

27+
@Contract(" -> new")
28+
@Override
29+
public @NotNull xyz.xenondevs.invui.item.Item item() {
30+
return new Item(this);
31+
}
32+
2633
@RequiredArgsConstructor
2734
public static class Item extends AbstractItem {
2835
private final OBooleanSetting setting;
@@ -52,7 +59,8 @@ public ItemProvider getItemProvider(final Player viewer) {
5259

5360
return new OItemBuilder(type)
5461
.setName("&e" + setting.pretty)
55-
.addLore(lore);
62+
.addLore(lore)
63+
.hideFlags();
5664
}
5765

5866
@Override

src/main/java/net/oceanias/opal/setting/impl/OChoiceSetting.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
import lombok.Getter;
1616
import lombok.RequiredArgsConstructor;
1717
import lombok.experimental.ExtensionMethod;
18+
import org.jetbrains.annotations.Contract;
1819
import org.jetbrains.annotations.NotNull;
1920

2021
@ExtensionMethod(OCommandSenderExtension.class)
2122
@SuppressWarnings("unused")
2223
@Getter
23-
public final class OChoiceSetting<T> extends OSetting<T> {
24+
public final class OChoiceSetting<T> extends OSetting<T, OChoiceSetting<T>> {
2425
private final List<T> choices;
2526

2627
public OChoiceSetting(final String pretty, final T initial, final @NotNull List<T> choices) {
@@ -44,6 +45,12 @@ public void value(final T value) {
4445
this.value = value;
4546
}
4647

48+
@Contract(" -> new")
49+
@Override
50+
public @NotNull xyz.xenondevs.invui.item.Item item() {
51+
return new Item<>(this);
52+
}
53+
4754
@RequiredArgsConstructor
4855
public static class Item<T> extends AbstractItem {
4956
private final OChoiceSetting<T> setting;
@@ -80,7 +87,8 @@ public ItemProvider getItemProvider(final Player viewer) {
8087

8188
return new OItemBuilder(type)
8289
.setName("&e" + setting.pretty)
83-
.addLore(lore);
90+
.addLore(lore)
91+
.hideFlags();
8492
}
8593

8694
@Override

src/main/java/net/oceanias/opal/setting/impl/ODoubleSetting.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
import xyz.xenondevs.invui.item.impl.AbstractItem;
1515
import lombok.Getter;
1616
import lombok.experimental.ExtensionMethod;
17+
import org.jetbrains.annotations.Contract;
1718
import org.jetbrains.annotations.NotNull;
1819

1920
@SuppressWarnings("unused")
2021
@ExtensionMethod(OCommandSenderExtension.class)
2122
@Getter
22-
public final class ODoubleSetting extends OSetting<Double> {
23+
public final class ODoubleSetting extends OSetting<Double, ODoubleSetting> {
2324
private final Double min;
2425
private final Double max;
2526

@@ -47,6 +48,12 @@ public void value(Double value) {
4748
this.value = value;
4849
}
4950

51+
@Contract(" -> new")
52+
@Override
53+
public @NotNull xyz.xenondevs.invui.item.Item item() {
54+
return new Item(this);
55+
}
56+
5057
public static class Item extends AbstractItem {
5158
private final ODoubleSetting setting;
5259
private final double change;
@@ -96,7 +103,8 @@ public ItemProvider getItemProvider(final Player viewer) {
96103

97104
return new OItemBuilder(type)
98105
.setName("&e" + setting.pretty)
99-
.addLore(lore);
106+
.addLore(lore)
107+
.hideFlags();
100108
}
101109

102110
@Override

src/main/java/net/oceanias/opal/setting/impl/OIntegerSetting.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
import org.bukkit.entity.Player;
1111
import org.bukkit.event.inventory.ClickType;
1212
import org.bukkit.event.inventory.InventoryClickEvent;
13+
import xyz.xenondevs.invui.item.Item;
1314
import xyz.xenondevs.invui.item.ItemProvider;
1415
import xyz.xenondevs.invui.item.impl.AbstractItem;
1516
import lombok.Getter;
1617
import lombok.experimental.ExtensionMethod;
18+
import org.jetbrains.annotations.Contract;
1719
import org.jetbrains.annotations.NotNull;
1820

1921
@SuppressWarnings("unused")
2022
@ExtensionMethod(OCommandSenderExtension.class)
2123
@Getter
22-
public final class OIntegerSetting extends OSetting<Integer> {
24+
public final class OIntegerSetting extends OSetting<Integer, OIntegerSetting> {
2325
private final Integer min;
2426
private final Integer max;
2527

@@ -47,6 +49,12 @@ public void value(Integer value) {
4749
this.value = value;
4850
}
4951

52+
@Contract(" -> new")
53+
@Override
54+
public @NotNull xyz.xenondevs.invui.item.Item item() {
55+
return new Item(this);
56+
}
57+
5058
public static class Item extends AbstractItem {
5159
private final OIntegerSetting setting;
5260
private final int change;
@@ -96,7 +104,8 @@ public ItemProvider getItemProvider(final Player viewer) {
96104

97105
return new OItemBuilder(type)
98106
.setName("&e" + setting.pretty)
99-
.addLore(lore);
107+
.addLore(lore)
108+
.hideFlags();
100109
}
101110

102111
@Override

src/main/java/net/oceanias/opal/setting/impl/OStringSetting.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@
3535
import lombok.RequiredArgsConstructor;
3636
import lombok.experimental.Accessors;
3737
import lombok.experimental.ExtensionMethod;
38+
import org.jetbrains.annotations.Contract;
3839
import org.jetbrains.annotations.NotNull;
3940

4041
@SuppressWarnings("unused")
4142
@ExtensionMethod({ OComponentExtension.class, OCommandSenderExtension.class })
4243
@Getter
43-
public final class OStringSetting extends OSetting<String> {
44+
public final class OStringSetting extends OSetting<String, OStringSetting> {
4445
private final Integer limit;
4546

4647
public OStringSetting(final String pretty, final String initial) {
@@ -62,6 +63,12 @@ public void value(String value) {
6263
this.value = value;
6364
}
6465

66+
@Contract(" -> new")
67+
@Override
68+
public @NotNull xyz.xenondevs.invui.item.Item item() {
69+
return new Item(this);
70+
}
71+
6572
@RequiredArgsConstructor
6673
public static class Item extends AbstractItem {
6774
private final OStringSetting setting;
@@ -96,7 +103,8 @@ public ItemProvider getItemProvider(final Player viewer) {
96103

97104
return new OItemBuilder(type)
98105
.setName("&e" + setting.pretty)
99-
.addLore(lore);
106+
.addLore(lore)
107+
.hideFlags();
100108
}
101109

102110
@Override

0 commit comments

Comments
 (0)