Skip to content

Commit caacba4

Browse files
committed
update plugin
1 parent 113e641 commit caacba4

2 files changed

Lines changed: 30 additions & 19 deletions

File tree

pom.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<parent>
88
<groupId>me.hsgamer.bettergui</groupId>
99
<artifactId>addon-parent</artifactId>
10-
<version>3.0</version>
10+
<version>4.0</version>
1111
</parent>
1212

1313
<artifactId>AnvilGUI</artifactId>
14-
<version>6.3</version>
14+
<version>7.0</version>
1515
<packaging>jar</packaging>
1616

1717
<name>AnvilGUI</name>
@@ -43,6 +43,12 @@
4343
<shadedPattern>me.hsgamer.bettergui.lib.core</shadedPattern>
4444
</relocation>
4545

46+
<!-- MineLib -->
47+
<relocation>
48+
<pattern>io.github.projectunified.minelib</pattern>
49+
<shadedPattern>me.hsgamer.bettergui.lib.minelib</shadedPattern>
50+
</relocation>
51+
4652
<!-- bStats -->
4753
<relocation>
4854
<pattern>org.bstats</pattern>
@@ -73,7 +79,7 @@
7379
<dependency>
7480
<groupId>net.wesjd</groupId>
7581
<artifactId>anvilgui</artifactId>
76-
<version>1.9.2-SNAPSHOT</version>
82+
<version>1.10.0-SNAPSHOT</version>
7783
</dependency>
7884
</dependencies>
7985
</project>

src/main/java/me/hsgamer/bettergui/anvilgui/AnvilMenu.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
import me.hsgamer.bettergui.api.menu.StandardMenu;
66
import me.hsgamer.bettergui.builder.ButtonBuilder;
77
import me.hsgamer.bettergui.button.WrappedDummyButton;
8+
import me.hsgamer.bettergui.manager.MenuCommandManager;
89
import me.hsgamer.bettergui.util.ProcessApplierConstants;
10+
import me.hsgamer.bettergui.util.SchedulerUtil;
911
import me.hsgamer.bettergui.util.StringReplacerApplier;
1012
import me.hsgamer.hscore.bukkit.gui.object.BukkitItem;
11-
import me.hsgamer.hscore.bukkit.scheduler.Scheduler;
1213
import me.hsgamer.hscore.collections.map.CaseInsensitiveStringMap;
1314
import me.hsgamer.hscore.common.CollectionUtils;
1415
import me.hsgamer.hscore.common.StringReplacer;
15-
import me.hsgamer.hscore.config.CaseInsensitivePathString;
1616
import me.hsgamer.hscore.config.Config;
17+
import me.hsgamer.hscore.minecraft.gui.button.DisplayButton;
1718
import me.hsgamer.hscore.minecraft.gui.object.Item;
1819
import me.hsgamer.hscore.task.BatchRunnable;
1920
import net.wesjd.anvilgui.AnvilGUI;
@@ -29,8 +30,8 @@
2930
public class AnvilMenu extends StandardMenu {
3031
private final Map<UUID, AnvilGUI> anvilGUIList = new ConcurrentHashMap<>();
3132
private final Map<UUID, String> userInputs = new ConcurrentHashMap<>();
32-
private ActionApplier completeAction = new ActionApplier(Collections.emptyList());
33-
private ActionApplier closeAction = new ActionApplier(Collections.emptyList());
33+
private ActionApplier completeAction = ActionApplier.EMPTY;
34+
private ActionApplier closeAction = ActionApplier.EMPTY;
3435
private String title;
3536
private String text;
3637
private WrappedButton button;
@@ -56,25 +57,25 @@ protected AnvilMenu(Config config) {
5657
if (s.contains(" ")) {
5758
getInstance().getLogger().warning("Illegal characters in command '" + s + "'" + "in the menu '" + getName() + "'. Ignored");
5859
} else {
59-
getInstance().getMenuCommandManager().registerMenuCommand(s, this);
60+
getInstance().get(MenuCommandManager.class).registerMenuCommand(s, this);
6061
}
6162
}
6263
});
6364

64-
for (Map.Entry<CaseInsensitivePathString, Object> entry : configSettings.entrySet()) {
65-
CaseInsensitivePathString key = entry.getKey();
65+
for (Map.Entry<String, Object> entry : configSettings.entrySet()) {
66+
String key = entry.getKey();
6667
Object value = entry.getValue();
6768
if (!(value instanceof Map)) {
6869
continue;
6970
}
7071
//noinspection unchecked
7172
Map<String, Object> values = new CaseInsensitiveStringMap<>((Map<String, Object>) value);
72-
if (key.equals(new CaseInsensitivePathString("left-button"))) {
73+
if (key.equalsIgnoreCase("left-button")) {
7374
leftButton = ButtonBuilder.INSTANCE.build(new ButtonBuilder.Input(this, "left_button", values)).orElse(null);
7475
if (leftButton != null) {
7576
leftButton.init();
7677
}
77-
} else if (key.equals(new CaseInsensitivePathString("right-button"))) {
78+
} else if (key.equalsIgnoreCase("right-button")) {
7879
rightButton = ButtonBuilder.INSTANCE.build(new ButtonBuilder.Input(this, "right_button", values)).orElse(null);
7980
if (rightButton != null) {
8081
rightButton.init();
@@ -86,7 +87,11 @@ protected AnvilMenu(Config config) {
8687
}
8788
}
8889

89-
private static Optional<ItemStack> getItem(Item item) {
90+
private static Optional<ItemStack> getItem(DisplayButton displayButton) {
91+
if (displayButton == null) {
92+
return Optional.empty();
93+
}
94+
Item item = displayButton.getItem();
9095
if (item instanceof BukkitItem) {
9196
return Optional.of(((BukkitItem) item).getItemStack());
9297
}
@@ -101,9 +106,9 @@ public boolean create(Player player, String[] strings, boolean bypass) {
101106
batchRunnable
102107
.getTaskPool(ProcessApplierConstants.ACTION_STAGE)
103108
.addLast(process -> closeAction.accept(stateSnapshot.getPlayer().getUniqueId(), process));
104-
Scheduler.current().async().runTask(batchRunnable);
109+
SchedulerUtil.async().run(batchRunnable);
105110
});
106-
builder.mainThreadExecutor(runnable -> Scheduler.current().sync().runEntityTask(player, runnable));
111+
builder.mainThreadExecutor(runnable -> SchedulerUtil.entity(player).run(runnable));
107112
builder.onClickAsync((slot, stateSnapshot) -> {
108113
if (slot != AnvilGUI.Slot.OUTPUT) {
109114
return CompletableFuture.completedFuture(Collections.emptyList());
@@ -122,7 +127,7 @@ public boolean create(Player player, String[] strings, boolean bypass) {
122127
}
123128

124129
return CompletableFuture
125-
.runAsync(batchRunnable, runnable -> Scheduler.current().async().runTask(runnable))
130+
.runAsync(batchRunnable, runnable -> SchedulerUtil.async().run(runnable))
126131
.thenApply(v -> Arrays.asList(
127132
AnvilGUI.ResponseAction.run(() -> remove(stateSnapshot.getPlayer().getUniqueId(), false)),
128133
AnvilGUI.ResponseAction.close()
@@ -142,15 +147,15 @@ public boolean create(Player player, String[] strings, boolean bypass) {
142147
}
143148

144149
if (button != null) {
145-
getItem(button.getItem(player.getUniqueId())).ifPresent(builder::itemOutput);
150+
getItem(button.display(player.getUniqueId())).ifPresent(builder::itemOutput);
146151
}
147152

148153
if (leftButton != null) {
149-
getItem(leftButton.getItem(player.getUniqueId())).ifPresent(builder::itemLeft);
154+
getItem(leftButton.display(player.getUniqueId())).ifPresent(builder::itemLeft);
150155
}
151156

152157
if (rightButton != null) {
153-
getItem(rightButton.getItem(player.getUniqueId())).ifPresent(builder::itemRight);
158+
getItem(rightButton.display(player.getUniqueId())).ifPresent(builder::itemRight);
154159
}
155160

156161
anvilGUIList.put(player.getUniqueId(), builder.open(player));

0 commit comments

Comments
 (0)