13
0
geforkt von Mirrors/Paper

Implement PlayerSpawnLocationEvent.

By: ninja <xninja@openmailbox.org>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2014-04-08 14:05:19 +02:00
Ursprung 542b7a7eb1
Commit 7e097e5d53

Datei anzeigen

@ -129,11 +129,24 @@
ServerLevel worldserver = this.server.getLevel(resourcekey);
ServerLevel worldserver1;
@@ -182,10 +223,11 @@
@@ -182,10 +223,24 @@
player.setServerLevel(worldserver1);
String s1 = connection.getLoggableAddress(this.server.logIPs());
- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{player.getName().getString(), s1, player.getId(), player.getX(), player.getY(), player.getZ()});
+ // Spigot start - spawn location event
+ Player spawnPlayer = player.getBukkitEntity();
+ org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent(spawnPlayer, spawnPlayer.getLocation());
+ this.cserver.getPluginManager().callEvent(ev);
+
+ Location loc = ev.getSpawnLocation();
+ worldserver1 = ((CraftWorld) loc.getWorld()).getHandle();
+
+ player.spawnIn(worldserver1);
+ player.gameMode.setLevel((ServerLevel) player.level());
+ player.absMoveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
+ // Spigot end
+
+ // CraftBukkit - Moved message to after join
+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()});
LevelData worlddata = worldserver1.getLevelData();
@ -143,7 +156,7 @@
ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData);
connection.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection);
@@ -194,7 +236,9 @@
@@ -194,7 +249,9 @@
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
@ -154,7 +167,7 @@
playerconnection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities()));
playerconnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected));
@@ -213,8 +257,10 @@
@@ -213,8 +270,10 @@
} else {
ichatmutablecomponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), s);
}
@ -166,7 +179,7 @@
playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
ServerStatus serverping = this.server.getStatus();
@@ -222,17 +268,70 @@
@@ -222,17 +281,70 @@
player.sendServerStatus(serverping);
}
@ -241,7 +254,7 @@
}
public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {
@@ -269,30 +368,31 @@
@@ -269,30 +381,31 @@
}
public void addWorldborderListener(ServerLevel world) {
@ -278,7 +291,7 @@
}
@Override
@@ -319,14 +419,15 @@
@@ -319,14 +432,15 @@
}
protected void save(ServerPlayer player) {
@ -296,7 +309,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -334,95 +435,175 @@
@@ -334,95 +448,175 @@
}
@ -510,7 +523,7 @@
if (entityplayer1 != null) {
set.add(entityplayer1);
@@ -431,30 +612,49 @@
@@ -431,30 +625,49 @@
Iterator iterator1 = set.iterator();
while (iterator1.hasNext()) {
@ -573,7 +586,7 @@
while (iterator.hasNext()) {
String s = (String) iterator.next();
@@ -462,41 +662,86 @@
@@ -462,40 +675,85 @@
entityplayer1.addTag(s);
}
@ -642,14 +655,14 @@
if (iblockdata.is(Blocks.RESPAWN_ANCHOR)) {
entityplayer1.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver.getRandom().nextLong()));
}
}
+ }
+ // Added from changeDimension
+ this.sendAllPlayerInfo(entityplayer); // Update health, etc...
+ entityplayer.onUpdateAbilities();
+ for (MobEffectInstance mobEffect : entityplayer.getActiveEffects()) {
+ entityplayer.connection.send(new ClientboundUpdateMobEffectPacket(entityplayer.getId(), mobEffect, false)); // blend = false
+ }
+
+ // Fire advancement trigger
+ entityplayer.triggerDimensionChangeTriggers(worldserver);
+
@ -662,13 +675,12 @@
+ // Save player file again if they were disconnected
+ if (entityplayer.connection.isDisconnected()) {
+ this.save(entityplayer);
+ }
}
+ // CraftBukkit end
+
return entityplayer1;
}
@@ -524,7 +769,18 @@
@@ -524,7 +782,18 @@
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
@ -688,7 +700,7 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -541,6 +797,25 @@
@@ -541,6 +810,25 @@
}
@ -714,7 +726,7 @@
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
Iterator iterator = this.players.iterator();
@@ -554,7 +829,7 @@
@@ -554,7 +842,7 @@
}
@ -723,7 +735,7 @@
PlayerTeam scoreboardteam = source.getTeam();
if (scoreboardteam != null) {
@@ -573,7 +848,7 @@
@@ -573,7 +861,7 @@
}
}
@ -732,7 +744,7 @@
PlayerTeam scoreboardteam = source.getTeam();
if (scoreboardteam == null) {
@@ -619,7 +894,7 @@
@@ -619,7 +907,7 @@
}
public void deop(GameProfile profile) {
@ -741,7 +753,7 @@
ServerPlayer entityplayer = this.getPlayer(profile.getId());
if (entityplayer != null) {
@@ -643,6 +918,7 @@
@@ -643,6 +931,7 @@
player.connection.send(new ClientboundEntityEventPacket(player, b0));
}
@ -749,7 +761,7 @@
this.server.getCommands().sendCommands(player);
}
@@ -669,10 +945,16 @@
@@ -669,10 +958,16 @@
return null;
}
@ -767,7 +779,7 @@
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
double d4 = x - entityplayer.getX();
double d5 = y - entityplayer.getY();
@@ -712,15 +994,19 @@
@@ -712,15 +1007,19 @@
public void reloadWhiteList() {}
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {
@ -791,7 +803,7 @@
}
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
@@ -729,8 +1015,16 @@
@@ -729,8 +1028,16 @@
public void sendAllPlayerInfo(ServerPlayer player) {
player.inventoryMenu.sendAllDataToRemote();
@ -809,7 +821,7 @@
}
public int getPlayerCount() {
@@ -786,12 +1080,22 @@
@@ -786,12 +1093,22 @@
}
public void removeAll() {
@ -834,7 +846,7 @@
public void broadcastSystemMessage(Component message, boolean overlay) {
this.broadcastSystemMessage(message, (entityplayer) -> {
return message;
@@ -849,16 +1153,23 @@
@@ -849,16 +1166,23 @@
return message.hasSignature() && !message.hasExpiredServer(Instant.now());
}
@ -862,7 +874,7 @@
Path path = file2.toPath();
if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -867,7 +1178,7 @@
@@ -867,7 +1191,7 @@
}
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
@ -871,7 +883,7 @@
}
return serverstatisticmanager;
@@ -875,13 +1186,13 @@
@@ -875,13 +1199,13 @@
public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) {
UUID uuid = player.getUUID();
@ -887,7 +899,7 @@
}
advancementdataplayer.setPlayer(player);
@@ -932,15 +1243,28 @@
@@ -932,15 +1256,28 @@
}
public void reloadResources() {