forked from BLOCKFANTASY/LOOHP-Limbo
Merge pull request #13 from drunderscore/master
Allow modifying of the spawn location (and thus, the spawn world) of players joining through the PlayerJoinEvent
This commit is contained in:
commit
201bafcc87
|
|
@ -1,11 +1,22 @@
|
|||
package com.loohp.limbo.Events;
|
||||
|
||||
import com.loohp.limbo.Location.Location;
|
||||
import com.loohp.limbo.Player.Player;
|
||||
|
||||
public class PlayerJoinEvent extends PlayerEvent {
|
||||
|
||||
public PlayerJoinEvent(Player player) {
|
||||
private Location spawnLocation;
|
||||
|
||||
public PlayerJoinEvent(Player player, Location spawnLoc) {
|
||||
super(player);
|
||||
spawnLocation = spawnLoc;
|
||||
}
|
||||
|
||||
public Location getSpawnLocation() {
|
||||
return spawnLocation;
|
||||
}
|
||||
|
||||
public void setSpawnLocation(Location spawnLocation) {
|
||||
this.spawnLocation = spawnLocation;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,13 +293,17 @@ public class ClientConnection extends Thread {
|
|||
|
||||
TimeUnit.MILLISECONDS.sleep(500);
|
||||
|
||||
ServerProperties p = Limbo.getInstance().getServerProperties();
|
||||
ServerProperties p = Limbo.getInstance().getServerProperties();
|
||||
Location s = p.getWorldSpawn();
|
||||
|
||||
PlayerJoinEvent evt = new PlayerJoinEvent(player, s);
|
||||
Limbo.getInstance().getEventsManager().callEvent(evt);
|
||||
s = evt.getSpawnLocation();
|
||||
|
||||
PacketPlayOutLogin join = new PacketPlayOutLogin(player.getEntityId(), false, p.getDefaultGamemode(), Limbo.getInstance().getWorlds().stream().map(each -> new NamespacedKey(each.getName()).toString()).collect(Collectors.toList()).toArray(new String[Limbo.getInstance().getWorlds().size()]), Limbo.getInstance().getDimensionRegistry().getCodec(), p.getWorldSpawn().getWorld(), 0, (byte) p.getMaxPlayers(), 8, p.isReducedDebugInfo(), true, false, true);
|
||||
sendPacket(join);
|
||||
Limbo.getInstance().getUnsafe().setPlayerGameModeSilently(player, p.getDefaultGamemode());
|
||||
|
||||
Location s = p.getWorldSpawn();
|
||||
|
||||
//PacketPlayOutKeepAlive alive = new PacketPlayOutKeepAlive((long) (Math.random() * Long.MAX_VALUE));
|
||||
|
||||
World world = s.getWorld();
|
||||
|
|
@ -336,8 +340,6 @@ public class ClientConnection extends Thread {
|
|||
sendPacket(declare);
|
||||
}
|
||||
|
||||
Limbo.getInstance().getEventsManager().callEvent(new PlayerJoinEvent(player));
|
||||
|
||||
PacketPlayOutSpawnPosition spawnPos = new PacketPlayOutSpawnPosition(BlockPosition.from(s));
|
||||
sendPacket(spawnPos);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue