Skip to content

Commit d97278a

Browse files
committed
fix: not getting teleported back when falling into the void
1 parent b042cb9 commit d97278a

5 files changed

Lines changed: 24 additions & 25 deletions

File tree

type.bedwarslobby/src/main/java/net/swofty/type/bedwarslobby/TypeBedWarsLobbyLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
public class TypeBedWarsLobbyLoader implements LobbyTypeLoader {
5151
public static BedWarsLobbyMap bedWarsLobbyMap = new BedWarsLobbyMap();
5252
public static LobbyParkourManager parkourManager;
53+
private final Pos spawnPoint = new Pos(-39.5, 72, 0, -90, 0);
5354

5455
@Getter
5556
private final LobbyItemHandler itemHandler = new LobbyItemHandler();
@@ -149,7 +150,7 @@ public List<TablistModule> getModules() {
149150
@Override
150151
public LoaderValues getLoaderValues() {
151152
return new LoaderValues(
152-
(type) -> new Pos(-39.5, 72, 0, -90, 0),
153+
(type) -> spawnPoint,
153154
false
154155
);
155156
}
@@ -166,6 +167,7 @@ public List<HypixelEventClass> getTraditionalEvents() {
166167
events.add(new LobbyLaunchPadEvents());
167168
events.add(new LobbyPlayerJoinEvents());
168169
events.add(new LobbyBlockBreak());
170+
events.add(new LobbyPlayerMove(spawnPoint));
169171
return events;
170172
}
171173

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
package net.swofty.type.lobby.events;
22

3+
import net.minestom.server.coordinate.Pos;
34
import net.minestom.server.entity.Player;
45
import net.minestom.server.event.player.PlayerMoveEvent;
56
import net.swofty.type.generic.event.EventNodes;
67
import net.swofty.type.generic.event.HypixelEvent;
78
import net.swofty.type.generic.event.HypixelEventClass;
89

910
public class LobbyPlayerMove implements HypixelEventClass {
11+
private final Pos spawnPoint;
12+
13+
public LobbyPlayerMove(Pos spawnPoint) {
14+
this.spawnPoint = spawnPoint;
15+
}
1016

1117
@HypixelEvent(node = EventNodes.PLAYER, requireDataLoaded = false)
1218
public void onPlayerMove(PlayerMoveEvent event) {
1319
Player player = event.getPlayer();
14-
if (player.getPosition().y() < -60) {
15-
teleportToSpawn(player);
20+
if (player.getPosition().y() < 0) {
21+
player.teleport(spawnPoint);
22+
player.sendMessage("§cYou are not allowed to leave this area!");
1623
}
1724
}
18-
19-
private void teleportToSpawn(Player player) {
20-
player.respawn();
21-
player.sendMessage("§cYou are not allowed to leave this area!");
22-
}
23-
2425
}

type.murdermysterylobby/src/main/java/net/swofty/type/murdermysterylobby/TypeMurderMysteryLobbyLoader.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.swofty.type.generic.data.handlers.MurderMysteryDataHandler;
1616
import net.swofty.type.generic.command.HypixelCommand;
1717
import net.swofty.type.generic.entity.hologram.PlayerHolograms;
18+
import net.swofty.type.lobby.events.*;
1819
import net.swofty.type.murdermysterylobby.hologram.LeaderboardHologramManager;
1920
import net.swofty.type.generic.entity.npc.HypixelNPC;
2021
import net.swofty.type.generic.event.HypixelEventClass;
@@ -23,18 +24,13 @@
2324
import net.swofty.type.murdermysterylobby.tab.MurderMysteryPlayersOnlineModule;
2425
import net.swofty.type.murdermysterylobby.util.MurderMysteryLobbyMap;
2526
import net.swofty.type.lobby.LobbyTypeLoader;
26-
import net.swofty.type.lobby.events.LobbyBlockBreak;
27-
import net.swofty.type.lobby.events.LobbyItemEvents;
28-
import net.swofty.type.lobby.events.LobbyLaunchPadEvents;
29-
import net.swofty.type.lobby.events.LobbyPlayerJoinEvents;
3027
import net.swofty.type.lobby.item.LobbyItem;
3128
import net.swofty.type.lobby.item.LobbyItemHandler;
3229
import net.swofty.type.lobby.item.impl.HidePlayers;
3330
import net.swofty.type.lobby.item.impl.LobbySelector;
3431
import net.swofty.type.lobby.item.impl.PlayCompass;
3532
import net.swofty.type.lobby.item.impl.ProfileItem;
3633
import net.swofty.type.lobby.launchpad.LaunchPad;
37-
import net.swofty.type.lobby.events.LobbyParkourEvents;
3834
import net.swofty.type.lobby.parkour.LobbyParkourManager;
3935
import net.swofty.type.lobby.parkour.Parkour;
4036
import net.swofty.type.murdermysterylobby.parkour.MurderMysteryLobbyParkour;
@@ -47,6 +43,7 @@
4743

4844
public class TypeMurderMysteryLobbyLoader implements LobbyTypeLoader {
4945
public static MurderMysteryLobbyMap lobbyMap = new MurderMysteryLobbyMap();
46+
private final Pos spawnPoint = new Pos(1.5, 72, 0.5, -90, 0);
5047

5148
@Getter
5249
private final LobbyItemHandler itemHandler = new LobbyItemHandler();
@@ -132,7 +129,7 @@ public List<TablistModule> getModules() {
132129
@Override
133130
public LoaderValues getLoaderValues() {
134131
return new LoaderValues(
135-
(type) -> new Pos(1.5, 72, 0.5, -90, 0),
132+
(type) -> spawnPoint,
136133
false
137134
);
138135
}
@@ -149,6 +146,7 @@ public List<HypixelEventClass> getTraditionalEvents() {
149146
events.add(new LobbyPlayerJoinEvents());
150147
events.add(new LobbyBlockBreak());
151148
events.add(new LobbyParkourEvents());
149+
events.add(new LobbyPlayerMove(spawnPoint));
152150
return events;
153151
}
154152

type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/TypePrototypeLobbyLoader.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
import net.swofty.type.generic.tab.TablistManager;
1818
import net.swofty.type.generic.tab.TablistModule;
1919
import net.swofty.type.lobby.LobbyTypeLoader;
20-
import net.swofty.type.lobby.events.LobbyBlockBreak;
21-
import net.swofty.type.lobby.events.LobbyItemEvents;
22-
import net.swofty.type.lobby.events.LobbyParkourEvents;
23-
import net.swofty.type.lobby.events.LobbyPlayerJoinEvents;
20+
import net.swofty.type.lobby.events.*;
2421
import net.swofty.type.lobby.item.LobbyItem;
2522
import net.swofty.type.lobby.item.LobbyItemHandler;
2623
import net.swofty.type.lobby.item.impl.HidePlayers;
@@ -41,6 +38,7 @@
4138
public class TypePrototypeLobbyLoader implements LobbyTypeLoader {
4239
private static final LobbyItemHandler itemHandler = new LobbyItemHandler();
4340
public static LobbyParkourManager parkourManager;
41+
private final Pos spawnPoint = new Pos(11.5, 76, 0.5, 90, 0);
4442

4543
@Override
4644
public ServerType getType() {
@@ -119,7 +117,7 @@ public List<TablistModule> getModules() {
119117
@Override
120118
public LoaderValues getLoaderValues() {
121119
return new LoaderValues(
122-
(type) -> new Pos(11.5, 76, 0.5, 90, 0),
120+
(type) -> spawnPoint,
123121
false
124122
);
125123
}
@@ -135,6 +133,7 @@ public List<HypixelEventClass> getTraditionalEvents() {
135133
events.add(new LobbyPlayerJoinEvents());
136134
events.add(new LobbyParkourEvents());
137135
events.add(new LobbyBlockBreak());
136+
events.add(new LobbyPlayerMove(spawnPoint));
138137
return events;
139138
}
140139

type.skywarslobby/src/main/java/net/swofty/type/skywarslobby/TypeSkywarsLobbyLoader.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
import net.swofty.type.generic.tab.TablistManager;
2121
import net.swofty.type.generic.tab.TablistModule;
2222
import net.swofty.type.lobby.LobbyTypeLoader;
23-
import net.swofty.type.lobby.events.LobbyBlockBreak;
24-
import net.swofty.type.lobby.events.LobbyItemEvents;
25-
import net.swofty.type.lobby.events.LobbyLaunchPadEvents;
26-
import net.swofty.type.lobby.events.LobbyPlayerJoinEvents;
23+
import net.swofty.type.lobby.events.*;
2724
import net.swofty.type.lobby.item.LobbyItem;
2825
import net.swofty.type.lobby.item.LobbyItemHandler;
2926
import net.swofty.type.lobby.item.impl.HidePlayers;
@@ -56,6 +53,7 @@ public class TypeSkywarsLobbyLoader implements LobbyTypeLoader {
5653
@Getter
5754
private static LeaderboardHologramManager leaderboardManager;
5855
private LobbyParkourManager parkourManager;
56+
private final Pos spawnPont = new Pos(-3.5, 66, 0.5, -90, 0);
5957

6058
@Override
6159
public ServerType getType() {
@@ -158,7 +156,7 @@ public List<TablistModule> getModules() {
158156
@Override
159157
public LoaderValues getLoaderValues() {
160158
return new LoaderValues(
161-
(type) -> new Pos(-3.5, 66, 0.5, -90, 0),
159+
(type) -> spawnPont,
162160
false
163161
);
164162
}
@@ -174,6 +172,7 @@ public List<HypixelEventClass> getTraditionalEvents() {
174172
events.add(new LobbyLaunchPadEvents());
175173
events.add(new LobbyPlayerJoinEvents());
176174
events.add(new LobbyBlockBreak());
175+
events.add(new LobbyPlayerMove(spawnPont));
177176
return events;
178177
}
179178

0 commit comments

Comments
 (0)