Merge remote-tracking branch 'origin/world' into proto-125
# Conflicts: # proto125_netty/src/main/java/mc/core/network/proto_125/netty/PacketHandler.java
This commit is contained in:
@@ -13,16 +13,15 @@ import io.netty.util.AttributeKey;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import mc.core.*;
|
||||
import mc.core.network.CSPacket;
|
||||
import mc.core.network.NetChannel;
|
||||
import mc.core.network.proto_125.netty.wrappers.WrapperNetChannel;
|
||||
import mc.core.network.proto_125.packets.*;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.helpers.BasicMarkerFactory;
|
||||
import mc.core.world.World;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@@ -33,6 +32,8 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
private Config config;
|
||||
@Autowired
|
||||
private PlayerManager playerManager;
|
||||
@Autowired
|
||||
private World world;
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext context) throws Exception {
|
||||
@@ -71,7 +72,6 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
}
|
||||
|
||||
public void onLoginPacket(Channel channel, LoginPacket packet) {
|
||||
final Location spawnLoc = new Location(0, 6, 0);
|
||||
Player player;
|
||||
|
||||
Optional<Player> optPlayer = playerManager.getPlayer(packet.getPlayerName());
|
||||
@@ -85,7 +85,7 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
}
|
||||
} else {
|
||||
player = playerManager.createPlayer(packet.getPlayerName());
|
||||
player.setLocation(spawnLoc);
|
||||
player.setLocation(world.getSpawn());
|
||||
player.setLook(new Look(0f, 0f));
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
|
||||
// send Spawn position
|
||||
SpawnPositionPacket spawnPkt = new SpawnPositionPacket();
|
||||
spawnPkt.setLocation(spawnLoc);
|
||||
spawnPkt.setLocation(world.getSpawn());
|
||||
channel.write(spawnPkt);
|
||||
|
||||
// send Player abilities
|
||||
@@ -122,6 +122,7 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
ChunkDataPacket chDataPkt = new ChunkDataPacket();
|
||||
chDataPkt.setX(0);
|
||||
chDataPkt.setZ(0);
|
||||
chDataPkt.setChunk(world.getChunk(0, 0));
|
||||
chDataPkt.setNeedInitChunk(true);
|
||||
chDataPkt.setYMin(1);
|
||||
chDataPkt.setYMax(0);
|
||||
@@ -147,16 +148,6 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
channel.attr(ATTR_PLAYER).set(player);
|
||||
player.setChannel(new WrapperNetChannel(channel));
|
||||
playerManager.joinServer(player);
|
||||
|
||||
// send Player info
|
||||
List<Player> players = playerManager.getPlayers();
|
||||
players.forEach(pl -> {
|
||||
PlayerInfoPacket infoPkt = new PlayerInfoPacket();
|
||||
infoPkt.setPlayerName(pl.getName());
|
||||
infoPkt.setOnline(true);
|
||||
infoPkt.setPing(4);
|
||||
playerManager.getBroadcastChannel().writeAndFlush(infoPkt);
|
||||
});
|
||||
}
|
||||
|
||||
public void onKickPacket(Channel channel, KickPacket packet) {
|
||||
|
||||
Reference in New Issue
Block a user