Skip to content

Commit 92c3ec8

Browse files
chore(): add uncommitted file
1 parent 291fff9 commit 92c3ec8

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package net.swofty.type.hub.darkauction;
2+
3+
import net.minestom.server.coordinate.Pos;
4+
import net.minestom.server.instance.Instance;
5+
import net.swofty.commons.item.ItemType;
6+
import net.swofty.type.hub.gui.GUIDarkAuction;
7+
import net.swofty.type.skyblockgeneric.darkauction.DarkAuctionHandler;
8+
import net.swofty.type.skyblockgeneric.entity.GlassDisplay;
9+
import net.swofty.type.skyblockgeneric.item.SkyBlockItem;
10+
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
11+
12+
/**
13+
* Manages the glass display for the Dark Auction that shows the current item being bid on.
14+
*/
15+
public class DarkAuctionDisplay {
16+
private static final Pos DISPLAY_POSITION = new Pos(88, 49, 149);
17+
18+
private final Instance instance;
19+
private GlassDisplay currentDisplay;
20+
21+
public DarkAuctionDisplay(Instance instance) {
22+
this.instance = instance;
23+
}
24+
25+
/**
26+
* Updates the display to show the current auction item.
27+
* Removes the old display and spawns a new one with the current item.
28+
*/
29+
public void update() {
30+
remove();
31+
32+
DarkAuctionHandler.DarkAuctionLocalState state = DarkAuctionHandler.getLocalState();
33+
if (state == null) {
34+
return;
35+
}
36+
37+
String itemTypeName = state.getCurrentItemType();
38+
if (itemTypeName == null) {
39+
return;
40+
}
41+
42+
SkyBlockItem item;
43+
try {
44+
ItemType itemType = ItemType.valueOf(itemTypeName);
45+
item = new SkyBlockItem(itemType);
46+
} catch (Exception e) {
47+
return;
48+
}
49+
50+
currentDisplay = GlassDisplay.create(item, instance, DISPLAY_POSITION, (player, event) -> {
51+
if (!(player instanceof SkyBlockPlayer skyBlockPlayer)) {
52+
return;
53+
}
54+
55+
if (!DarkAuctionHandler.isPlayerInAuction(skyBlockPlayer.getUuid())) {
56+
skyBlockPlayer.sendMessage("§cYou must join the Dark Auction to bid!");
57+
return;
58+
}
59+
60+
new GUIDarkAuction().open(skyBlockPlayer);
61+
});
62+
}
63+
64+
/**
65+
* Removes the current display from the world.
66+
*/
67+
public void remove() {
68+
if (currentDisplay != null) {
69+
currentDisplay.remove();
70+
currentDisplay = null;
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)