Skip to content

Commit cedb1e8

Browse files
chore(): fixed various problems
1 parent eb6d5b0 commit cedb1e8

8 files changed

Lines changed: 106 additions & 106 deletions

File tree

proxy.api/src/main/java/net/swofty/proxyapi/redis/ServerOutboundMessage.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ public static void sendMessageToService(ServiceType service,
7474
Object rawMessage,
7575
Consumer<String> response) {
7676
UUID requestId = UUID.randomUUID();
77-
UUID toCallback = UUID.fromString(RedisAPI.getInstance().getFilterId());
77+
UUID toCallback = null;
78+
try {
79+
toCallback = UUID.fromString(RedisAPI.getInstance().getFilterId());
80+
} catch (Error e) {
81+
return;
82+
}
7883
redisMessageListeners.put(requestId, response);
7984

8085
String message = specification.translateToString(rawMessage);

type.generic/src/main/java/net/swofty/type/generic/gui/inventory/ItemStackCreator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public static ItemStack.Builder getStackHead(String name, String texture, int am
246246
.collect(Collectors.toList()))
247247
.set(DataComponents.CUSTOM_NAME, Component.text(name).decoration(TextDecoration.ITALIC, false))
248248
.set(DataComponents.TOOLTIP_DISPLAY, DEFAULT_TOOLTIP_DISPLAY)
249-
.set(DataComponents.PROFILE, new HeadProfile(new PlayerSkin(texturesEncoded, null)))
249+
.set(DataComponents.PROFILE, new ResolvableProfile(new PlayerSkin(texturesEncoded, null)))
250250
.amount(amount);
251251
}
252252

@@ -276,7 +276,7 @@ public static ItemStack.Builder getStackHead(String name, PlayerSkin skin, int a
276276
DataComponents.BASE_COLOR,
277277
DataComponents.UNBREAKABLE
278278
)))
279-
.set(DataComponents.PROFILE, new HeadProfile(skin))
279+
.set(DataComponents.PROFILE, new ResolvableProfile(skin))
280280
.amount(amount));
281281
}
282282

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/calendar/CalendarEvent.java

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33
import net.minestom.server.component.DataComponents;
44
import net.minestom.server.item.ItemStack;
55
import net.minestom.server.item.Material;
6-
import net.swofty.commons.StringUtility;
7-
8-
import net.minestom.server.component.DataComponents;
9-
import net.minestom.server.item.ItemStack;
10-
import net.minestom.server.item.Material;
11-
import net.swofty.commons.StringUtility;
12-
136
import net.swofty.commons.ServiceType;
7+
import net.swofty.commons.StringUtility;
148
import net.swofty.commons.protocol.objects.darkauction.TriggerDarkAuctionProtocol;
159
import net.swofty.proxyapi.ProxyService;
1610
import org.tinylog.Logger;
@@ -20,7 +14,6 @@
2014
import java.util.List;
2115
import java.util.Map;
2216
import java.util.function.BiConsumer;
23-
import java.util.function.Consumer;
2417
import java.util.function.Function;
2518

2619
public record CalendarEvent(
@@ -33,6 +26,8 @@ public record CalendarEvent(
3326
boolean tracksYear,
3427
BiConsumer<Long, Integer> action
3528
) {
29+
private static final long THREE_DAYS = 20 * 60 * 3; // 3 SkyBlock days in ticks
30+
private static final long YEAR = 20 * 60 * 24 * 31 * 12; // Full SkyBlock year in ticks
3631
private static final Map<Long, List<CalendarEvent>> eventCache = new HashMap<>();
3732
private static final List<CalendarEvent> allEvents = new ArrayList<>();
3833

@@ -53,23 +48,36 @@ public record CalendarEvent(
5348
);
5449

5550
// Dark Auction occurs every 3 SkyBlock days at midnight
56-
public static CalendarEvent DARK_AUCTION = new CalendarEvent(calculateDarkAuctionTimes(), time -> {
57-
ProxyService darkAuctionService = new ProxyService(ServiceType.DARK_AUCTION);
58-
darkAuctionService.handleRequest(new TriggerDarkAuctionProtocol.TriggerMessage(time))
59-
.thenAccept(response -> {
60-
if (response instanceof TriggerDarkAuctionProtocol.TriggerResponse triggerResponse) {
61-
if (triggerResponse.success()) {
62-
Logger.info("Dark Auction started successfully");
63-
} else {
64-
Logger.debug("Dark Auction trigger: {}", triggerResponse.message());
65-
}
66-
}
67-
})
68-
.exceptionally(throwable -> {
69-
Logger.error(throwable, "Failed to trigger Dark Auction");
70-
return null;
71-
});
72-
});
51+
public static CalendarEvent DARK_AUCTION = new CalendarEvent(
52+
"dark_auction",
53+
ItemStack.of(Material.NETHER_STAR).with(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, true),
54+
year -> "§5Dark Auction",
55+
List.of(
56+
"§7The Dark Auction is a secret",
57+
"§7underground auction where",
58+
"§7special items are sold."
59+
),
60+
calculateDarkAuctionTimes(),
61+
5 * 60L, // 5 minutes duration
62+
false,
63+
(time, year) -> {
64+
ProxyService darkAuctionService = new ProxyService(ServiceType.DARK_AUCTION);
65+
darkAuctionService.handleRequest(new TriggerDarkAuctionProtocol.TriggerMessage(time))
66+
.thenAccept(response -> {
67+
if (response instanceof TriggerDarkAuctionProtocol.TriggerResponse triggerResponse) {
68+
if (triggerResponse.success()) {
69+
Logger.info("Dark Auction started successfully");
70+
} else {
71+
Logger.debug("Dark Auction trigger: {}", triggerResponse.message());
72+
}
73+
}
74+
})
75+
.exceptionally(throwable -> {
76+
Logger.error(throwable, "Failed to trigger Dark Auction");
77+
return null;
78+
});
79+
}
80+
);
7381

7482
private static List<Long> calculateDarkAuctionTimes() {
7583
List<Long> times = new ArrayList<>();
@@ -89,10 +97,6 @@ public String getDisplayName(int year) {
8997
return displayName.apply(year);
9098
}
9199

92-
public String getDisplayName(int year) {
93-
return displayName.apply(year);
94-
}
95-
96100
private static void registerEvent(CalendarEvent event) {
97101
allEvents.add(event);
98102
for (Long time : event.times()) {

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/player/ActionPlayerLaunchPads.java

Lines changed: 59 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.kyori.adventure.key.Key;
44
import net.swofty.commons.StringUtility;
5+
import net.swofty.commons.UnderstandableProxyServer;
56
import org.tinylog.Logger;
67
import net.kyori.adventure.sound.Sound;
78
import net.minestom.server.coordinate.Pos;
@@ -35,7 +36,6 @@ public class ActionPlayerLaunchPads implements HypixelEventClass {
3536
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
3637
private static final Set<UUID> notifiedPlayers = ConcurrentHashMap.newKeySet();
3738

38-
3939
@HypixelEvent(node = EventNodes.PLAYER, requireDataLoaded = true, isAsync = true)
4040
public void run(PlayerMoveEvent event) {
4141
SkyBlockPlayer player = (SkyBlockPlayer) event.getPlayer();
@@ -56,6 +56,7 @@ public void run(PlayerMoveEvent event) {
5656
player.setInLaunchpad(true);
5757

5858
boolean accepted = pad.getShouldAllow().apply(player);
59+
String rejectionMessage = pad.getRejectionMessage();
5960
if (!accepted && player.getRank().isStaff()) {
6061
accepted = true;
6162
player.getLogHandler().debug("As a staff member, you have bypassed the launchpad requirement.");
@@ -76,84 +77,73 @@ public void run(PlayerMoveEvent event) {
7677
));
7778
player.playSound(Sound.sound(Key.key("entity.generic.explode"), Sound.Source.PLAYER, 1, 1));
7879

80+
ServerType targetServerType = pad.getTargetServerType();
81+
ProxyInformation proxyInfo = new ProxyInformation();
82+
83+
List<UnderstandableProxyServer> informations =
84+
proxyInfo.getServerInformation(targetServerType).join();
85+
if (informations.isEmpty()) {
86+
accepted = false;
87+
rejectionMessage = "§cThere are no " + StringUtility.toNormalCase(targetServerType.name()) + " servers available at the moment. Please try again later.";
88+
}
89+
7990
if (!accepted) {
8091
player.setVelocity(player.getPosition().direction().mul(-30).withY(5));
81-
player.sendMessage(pad.getRejectionMessage());
92+
player.sendMessage(rejectionMessage);
8293
player.setInLaunchpad(false);
8394
return;
8495
}
8596

86-
// Check server availability before starting animation
87-
ServerType targetServerType = pad.getTargetServerType();
88-
ProxyInformation proxyInfo = new ProxyInformation();
89-
proxyInfo.getServerInformation(targetServerType).thenAccept(servers -> {
90-
if (servers == null || servers.isEmpty()) {
91-
player.setInLaunchpad(false);
92-
if (!notifiedPlayers.contains(player.getUuid())) {
93-
notifiedPlayers.add(player.getUuid());
94-
player.sendMessage("§cThere are no " + StringUtility.toNormalCase(targetServerType.name()) + " servers available at the moment. Please try again later.");
97+
Pos originalPosition = player.getPosition();
98+
player.playSound(Sound.sound(Key.key("entity.firework_rocket.launch"), Sound.Source.PLAYER, 1, 1));
99+
100+
LivingEntity armorStand = new LivingEntity(EntityType.ARMOR_STAND);
101+
armorStand.getEntityMeta().setInvisible(true);
102+
armorStand.getEntityMeta().setHasNoGravity(true);
103+
armorStand.setInstance(player.getInstance(), player.getPosition());
104+
armorStand.addPassenger(player);
105+
106+
List<Pos> curve = MathUtility.bezierCurve(player.getPosition(), pad.getDestination(), SEGMENTS);
107+
long timeToSleep = 3000 / SEGMENTS;
108+
109+
// Use ScheduledExecutorService to run the launch trajectory with delays
110+
AtomicInteger index = new AtomicInteger(0);
111+
ScheduledFuture<?>[] taskHolder = new ScheduledFuture<?>[1];
112+
taskHolder[0] = scheduler.scheduleAtFixedRate(() -> {
113+
int currentIndex = index.getAndIncrement();
114+
if (currentIndex >= curve.size()) {
115+
// Cancel the task
116+
if (taskHolder[0] != null) {
117+
taskHolder[0].cancel(false);
95118
}
96-
return;
97-
}
98-
99-
notifiedPlayers.remove(player.getUuid());
100119

101-
Pos originalPosition = player.getPosition();
102-
player.playSound(Sound.sound(Key.key("entity.firework_rocket.launch"), Sound.Source.PLAYER, 1, 1));
103-
104-
LivingEntity armorStand = new LivingEntity(EntityType.ARMOR_STAND);
105-
armorStand.getEntityMeta().setInvisible(true);
106-
armorStand.getEntityMeta().setHasNoGravity(true);
107-
armorStand.setInstance(player.getInstance(), player.getPosition());
108-
armorStand.addPassenger(player);
109-
110-
List<Pos> curve = MathUtility.bezierCurve(player.getPosition(), pad.getDestination(), SEGMENTS);
111-
long timeToSleep = 3000 / SEGMENTS;
112-
113-
// Use ScheduledExecutorService to run the launch trajectory with delays
114-
AtomicInteger index = new AtomicInteger(0);
115-
ScheduledFuture<?>[] taskHolder = new ScheduledFuture<?>[1];
116-
taskHolder[0] = scheduler.scheduleAtFixedRate(() -> {
117-
int currentIndex = index.getAndIncrement();
118-
if (currentIndex >= curve.size()) {
119-
// Cancel the task
120-
if (taskHolder[0] != null) {
121-
taskHolder[0].cancel(false);
120+
player.setInLaunchpad(false);
121+
notifiedPlayers.remove(player.getUuid());
122+
123+
// Execute the after finished callback
124+
player.sendMessage("Done");
125+
pad.getAfterFinished().accept(player);
126+
127+
// Check after a delay if player is still on this server (transfer failed)
128+
scheduler.schedule(() -> {
129+
// If player is still on the same server and instance, teleport them back
130+
if (player.getInstance() != null && player.getInstance().equals(armorStand.getInstance())) {
131+
player.teleport(originalPosition);
132+
player.sendMessage("§cFailed to connect to the server. You have been teleported back.");
133+
}
134+
try {
135+
armorStand.remove();
136+
} catch (Exception e) {
122137
}
138+
}, 2, TimeUnit.SECONDS);
123139

124-
player.setInLaunchpad(false);
125-
notifiedPlayers.remove(player.getUuid());
126-
127-
// Execute the after finished callback
128-
player.sendMessage("Done");
129-
pad.getAfterFinished().accept(player);
130-
131-
// Check after a delay if player is still on this server (transfer failed)
132-
scheduler.schedule(() -> {
133-
// If player is still on the same server and instance, teleport them back
134-
if (player.getInstance() != null && player.getInstance().equals(armorStand.getInstance())) {
135-
player.teleport(originalPosition);
136-
player.sendMessage("§cFailed to connect to the server. You have been teleported back.");
137-
}
138-
try {
139-
armorStand.remove();
140-
} catch (Exception e) {
141-
}
142-
}, 2, TimeUnit.SECONDS);
143-
144-
return;
145-
}
140+
return;
141+
}
146142

147-
Pos pos = curve.get(currentIndex);
148-
Vec toGoTo = pos.asVec();
149-
Vec direction = toGoTo.sub(player.getPosition().asVec()).normalize();
150-
armorStand.setVelocity(direction.mul(50, 5, 50));
151-
}, 0, timeToSleep, TimeUnit.MILLISECONDS);
152-
}).exceptionally(ex -> {
153-
Logger.error(ex, "Error checking server availability for launch pad");
154-
player.setInLaunchpad(false);
155-
player.sendMessage("§cAn error occurred while checking server availability. Please try again later.");
156-
return null;
157-
});
143+
Pos pos = curve.get(currentIndex);
144+
Vec toGoTo = pos.asVec();
145+
Vec direction = toGoTo.sub(player.getPosition().asVec()).normalize();
146+
armorStand.setVelocity(direction.mul(50, 5, 50));
147+
}, 0, timeToSleep, TimeUnit.MILLISECONDS);
158148
}
159149
}

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/utility/LaunchPads.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ public enum LaunchPads {
7777
boolean hasRequirement = player.getSkills().getCurrentLevel(SkillCategories.MINING) >= 1;
7878
if (!hasRequirement) {
7979
return PlayerHolograms.ExternalPlayerHologram.builder()
80-
.pos(new Pos(-9, 63.3, -232))
80+
.pos(new Pos(-9.5, 64.7, -230.5))
8181
.player(player)
8282
.text(new String[]{"§bTravel To:", "§aGold Mine", "§cRequires Mining Level 1"})
8383
.build();
8484
} else {
8585
return PlayerHolograms.ExternalPlayerHologram.builder()
86-
.pos(new Pos(-9, 63.3, -232))
86+
.pos(new Pos(-9.5, 64.7, -230.5))
8787
.player(player)
8888
.text(new String[]{"§bTravel To:", "§aGold Mine"})
8989
.build();

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/warps/TravelScrollIslands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public enum TravelScrollIslands {
1717
"f151cffdaf303673531a7651b36637cad912ba485643158e548d59b2ead5011",
1818
(unused) -> "Your very own chunk of SkyBlock. Nice housing for your minions.", ServerType.SKYBLOCK_ISLAND),
1919
SKYBLOCK_HUB("hub", "§bSkyBlock Hub", "9c465a5d348c53d473f8115ed8923be416f35149f73ebaf5f2b05e13401e814f", (unused) -> "Where everything happens and anything is possible.",
20-
ServerType.SKYBLOCK_HUB, List.of(TravelScrollType.HUB_CASTLE, TravelScrollType.HUB_MUSEUM, TravelScrollType.HUB_CRYPTS)),
20+
ServerType.SKYBLOCK_HUB, List.of(TravelScrollType.HUB_CASTLE, TravelScrollType.HUB_MUSEUM, TravelScrollType.HUB_CRYPTS, TravelScrollType.HUB_DARK_AUCTION)),
2121
GOLD_MINE("gold", "§aGold Mine §7- §bSpawn",
2222
"d8573ed917444316b0b28dd9927fd68e56f6625fcfa73ad80b8770d5139891b1",
2323
(unused) -> "Your first stop for extended mining related activities and home to SkyBlock's local janitor Rusty", ServerType.SKYBLOCK_GOLD_MINE, SkillCategories.MINING, 1),

velocity.extension/src/main/java/net/swofty/velocity/SkyBlockVelocity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
180180
public void onPlayerJoin(PlayerChooseInitialServerEvent event) {
181181
Player player = event.getPlayer();
182182

183-
if (!GameManager.hasType(ServerType.SKYBLOCK_HUB) || !GameManager.isAnyEmpty(ServerType.SKYBLOCK_HUB)) {
183+
if (!GameManager.hasType(ServerType.PROTOTYPE_LOBBY)) {
184184
player.disconnect(
185185
Component.text("§cThere are no Prototype Lobby servers available at the moment.")
186186
);
187187
return;
188188
}
189189

190-
List<GameManager.GameServer> gameServers = GameManager.getFromType(ServerType.SKYBLOCK_HUB);
190+
List<GameManager.GameServer> gameServers = GameManager.getFromType(ServerType.PROTOTYPE_LOBBY);
191191
if (TestFlowManager.isPlayerInTestFlow(player.getUsername())) {
192192
TestFlowManager.ProxyTestFlowInstance instance = TestFlowManager.getTestFlowForPlayer(player.getUsername());
193193
player.sendPlainMessage("§7You are currently in test flow " + instance.getName() + ".");

velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerServersInformation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public JSONObject receivedMessage(JSONObject message, UUID serverUUID) {
5858
case "TYPE" -> {
5959
String type = message.getString("type");
6060
List<GameManager.GameServer> servers = GameManager.getFromType(ServerType.valueOf(type));
61+
if (servers == null) servers = new ArrayList<>();
6162

6263
if (isInTestFlow) {
6364
// Remove all servers that are not in the current test flow

0 commit comments

Comments
 (0)