Fixes and additions to the spawn reason API
Expose an entities spawn reason on the entity. Pre existing entities will return NATURAL if it was a non persistenting Living Entity, SPAWNER for spawners, or DEFAULT since data was not stored. Additionally, add missing spawn reasons. Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Doc <nachito94@msn.com>
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
--- a/net/minecraft/server/commands/SummonCommand.java
|
||||
+++ b/net/minecraft/server/commands/SummonCommand.java
|
||||
@@ -67,7 +67,7 @@
|
||||
@@ -57,6 +57,7 @@
|
||||
ServerLevel worldserver = source.getLevel();
|
||||
Entity entity = EntityType.loadEntityRecursive(nbttagcompound1, worldserver, EntitySpawnReason.COMMAND, (entity1) -> {
|
||||
entity1.moveTo(pos.x, pos.y, pos.z, entity1.getYRot(), entity1.getXRot());
|
||||
+ entity1.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND; // Paper - Entity#getEntitySpawnReason
|
||||
return entity1;
|
||||
});
|
||||
|
||||
@@ -67,7 +68,7 @@
|
||||
((Mob) entity).finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.COMMAND, (SpawnGroupData) null);
|
||||
}
|
||||
|
||||
|
||||
@@ -568,7 +568,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -939,41 +1169,92 @@
|
||||
@@ -939,41 +1169,93 @@
|
||||
this.entityManager.addNewEntity(player);
|
||||
}
|
||||
|
||||
@@ -582,6 +582,7 @@
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end - extra debug info
|
||||
+ if (entity.spawnReason == null) entity.spawnReason = spawnReason; // Paper - Entity#getEntitySpawnReason
|
||||
if (entity.isRemoved()) {
|
||||
- ServerLevel.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityType.getKey(entity.getType()));
|
||||
+ // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit
|
||||
@@ -666,7 +667,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
||||
|
||||
@@ -982,6 +1263,12 @@
|
||||
@@ -982,6 +1264,12 @@
|
||||
double d1 = (double) pos.getY() - entityplayer.getY();
|
||||
double d2 = (double) pos.getZ() - entityplayer.getZ();
|
||||
|
||||
@@ -679,7 +680,7 @@
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.connection.send(new ClientboundBlockDestructionPacket(entityId, pos, progress));
|
||||
}
|
||||
@@ -1030,7 +1317,7 @@
|
||||
@@ -1030,7 +1318,7 @@
|
||||
|
||||
@Override
|
||||
public void levelEvent(@Nullable Player player, int eventId, BlockPos pos, int data) {
|
||||
@@ -688,7 +689,7 @@
|
||||
}
|
||||
|
||||
public int getLogicalHeight() {
|
||||
@@ -1060,7 +1347,18 @@
|
||||
@@ -1060,7 +1348,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -708,7 +709,7 @@
|
||||
PathNavigation navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (navigationabstract.shouldRecomputePath(pos)) {
|
||||
@@ -1086,11 +1384,13 @@
|
||||
@@ -1086,11 +1385,13 @@
|
||||
|
||||
@Override
|
||||
public void updateNeighborsAt(BlockPos pos, Block block) {
|
||||
@@ -722,7 +723,7 @@
|
||||
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, (Direction) null, orientation);
|
||||
}
|
||||
|
||||
@@ -1126,9 +1426,20 @@
|
||||
@@ -1126,9 +1427,20 @@
|
||||
|
||||
@Override
|
||||
public void explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions smallParticle, ParticleOptions largeParticle, Holder<SoundEvent> soundEvent) {
|
||||
@@ -744,15 +745,14 @@
|
||||
case NONE:
|
||||
explosion_effect = Explosion.BlockInteraction.KEEP;
|
||||
break;
|
||||
@@ -1143,17 +1454,28 @@
|
||||
break;
|
||||
@@ -1144,16 +1456,27 @@
|
||||
case TRIGGER:
|
||||
explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK;
|
||||
+ break;
|
||||
break;
|
||||
+ // CraftBukkit start - handle custom explosion type
|
||||
+ case STANDARD:
|
||||
+ explosion_effect = Explosion.BlockInteraction.DESTROY;
|
||||
break;
|
||||
+ break;
|
||||
+ // CraftBukkit end
|
||||
default:
|
||||
throw new MatchException((String) null, (Throwable) null);
|
||||
@@ -776,7 +776,7 @@
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -1162,10 +1484,11 @@
|
||||
@@ -1162,10 +1485,11 @@
|
||||
if (entityplayer.distanceToSqr(vec3d) < 4096.0D) {
|
||||
Optional<Vec3> optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer));
|
||||
|
||||
@@ -789,7 +789,7 @@
|
||||
}
|
||||
|
||||
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayRule) {
|
||||
@@ -1226,17 +1549,29 @@
|
||||
@@ -1226,17 +1550,29 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleOptions> int sendParticles(T parameters, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double speed) {
|
||||
@@ -825,7 +825,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1292,7 +1627,7 @@
|
||||
@@ -1292,7 +1628,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipReferencedStructures) {
|
||||
@@ -834,7 +834,7 @@
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag);
|
||||
@@ -1334,11 +1669,22 @@
|
||||
@@ -1334,11 +1670,22 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public MapItemSavedData getMapData(MapId id) {
|
||||
@@ -858,7 +858,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(id.key(), state);
|
||||
}
|
||||
|
||||
@@ -1649,6 +1995,11 @@
|
||||
@@ -1649,6 +1996,11 @@
|
||||
@Override
|
||||
public void blockUpdated(BlockPos pos, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
@@ -870,7 +870,7 @@
|
||||
this.updateNeighborsAt(pos, block);
|
||||
}
|
||||
|
||||
@@ -1668,12 +2019,12 @@
|
||||
@@ -1668,12 +2020,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@@ -885,7 +885,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1696,7 +2047,7 @@
|
||||
@@ -1696,7 +2048,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> items, Function<T, String> classifier) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@@ -894,7 +894,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1705,7 +2056,7 @@
|
||||
@@ -1705,7 +2057,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1717,6 +2068,7 @@
|
||||
@@ -1717,6 +2069,7 @@
|
||||
|
||||
@Override
|
||||
public LevelEntityGetter<Entity> getEntities() {
|
||||
@@ -911,7 +911,7 @@
|
||||
return this.entityManager.getEntityGetter();
|
||||
}
|
||||
|
||||
@@ -1802,6 +2154,17 @@
|
||||
@@ -1802,6 +2155,17 @@
|
||||
return this.serverLevelData.getGameRules();
|
||||
}
|
||||
|
||||
@@ -929,7 +929,7 @@
|
||||
@Override
|
||||
public CrashReportCategory fillReportDetails(CrashReport report) {
|
||||
CrashReportCategory crashreportsystemdetails = super.fillReportDetails(report);
|
||||
@@ -1836,6 +2199,7 @@
|
||||
@@ -1836,6 +2200,7 @@
|
||||
}
|
||||
|
||||
public void onTrackingStart(Entity entity) {
|
||||
@@ -937,7 +937,7 @@
|
||||
ServerLevel.this.getChunkSource().addEntity(entity);
|
||||
if (entity instanceof ServerPlayer entityplayer) {
|
||||
ServerLevel.this.players.add(entityplayer);
|
||||
@@ -1864,9 +2228,52 @@
|
||||
@@ -1864,9 +2229,52 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@@ -990,7 +990,7 @@
|
||||
ServerLevel.this.getChunkSource().removeEntity(entity);
|
||||
if (entity instanceof ServerPlayer entityplayer) {
|
||||
ServerLevel.this.players.remove(entityplayer);
|
||||
@@ -1895,6 +2302,15 @@
|
||||
@@ -1895,6 +2303,15 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
@Nullable
|
||||
private Vec3 startingToFallPosition;
|
||||
@Nullable
|
||||
@@ -258,6 +293,31 @@
|
||||
@@ -258,7 +293,32 @@
|
||||
private final CommandSource commandSource;
|
||||
private int containerCounter;
|
||||
public boolean wonGame;
|
||||
@@ -124,7 +124,7 @@
|
||||
+ public boolean queueHealthUpdatePacket;
|
||||
+ public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket;
|
||||
+ // Paper end - cancellable death event
|
||||
+
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public CraftPlayer.TransferCookieConnection transferCookieConnection;
|
||||
+ public String displayName;
|
||||
@@ -143,9 +143,10 @@
|
||||
+ // CraftBukkit end
|
||||
+ public boolean isRealPlayer; // Paper
|
||||
+ public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
|
||||
|
||||
+
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
||||
this.chatVisibility = ChatVisiblity.FULL;
|
||||
@@ -266,7 +326,7 @@
|
||||
this.canChatColor = true;
|
||||
this.lastActionTime = Util.getMillis();
|
||||
@@ -179,8 +180,8 @@
|
||||
+ this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper
|
||||
+ this.bukkitPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // Use method to resend items in hands in case of client desync, because the item use got cancelled.
|
||||
+ // For example, when cancelling the leash event
|
||||
+ public void resendItemInHands() {
|
||||
@@ -226,9 +227,9 @@
|
||||
+ }
|
||||
+
|
||||
+ return blockposition;
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
public BlockPos adjustSpawnLocation(ServerLevel world, BlockPos basePos) {
|
||||
AABB axisalignedbb = this.getDimensions(Pose.STANDING).makeBoundingBox(Vec3.ZERO);
|
||||
@@ -347,6 +348,15 @@
|
||||
CompoundTag nbttagcompound1 = new CompoundTag();
|
||||
CompoundTag nbttagcompound2 = new CompoundTag();
|
||||
|
||||
@@ -564,7 +714,7 @@
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
CompoundTag nbttagcompound = ((CompoundTag) nbt.get()).getCompound("RootVehicle");
|
||||
Entity entity = EntityType.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver, EntitySpawnReason.LOAD, (entity1) -> {
|
||||
- return !worldserver.addWithUUID(entity1) ? null : entity1;
|
||||
+ return !worldserver.addWithUUID(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // CraftBukkit - decompile error // Paper - Entity#getEntitySpawnReason
|
||||
});
|
||||
|
||||
if (entity == null) {
|
||||
@@ -598,12 +748,12 @@
|
||||
|
||||
if (!this.isPassenger()) {
|
||||
@@ -461,15 +471,17 @@
|
||||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float) this.lastRecordedLevel));
|
||||
@@ -865,6 +1053,20 @@
|
||||
CriteriaTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
@@ -863,8 +1051,22 @@
|
||||
|
||||
if (this.tickCount % 20 == 0) {
|
||||
CriteriaTriggers.LOCATION.trigger(this);
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border
|
||||
+ if (this.oldLevel == -1) {
|
||||
+ this.oldLevel = this.experienceLevel;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ if (this.oldLevel != this.experienceLevel) {
|
||||
+ CraftEventFactory.callPlayerLevelChangeEvent(this.getBukkitEntity(), this.oldLevel, this.experienceLevel);
|
||||
+ this.oldLevel = this.experienceLevel;
|
||||
@@ -526,7 +538,7 @@
|
||||
+ // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
|
||||
+ this.dropFromLootTable(this.serverLevel(), damageSource, this.lastHurtByPlayerTime > 0);
|
||||
+ this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag);
|
||||
|
||||
+
|
||||
+ loot.addAll(this.drops);
|
||||
+ this.drops.clear(); // SPIGOT-5188: make sure to clear
|
||||
+
|
||||
@@ -552,7 +564,7 @@
|
||||
+ }
|
||||
+
|
||||
+ net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure
|
||||
+
|
||||
|
||||
+ if (deathMessage != null && deathMessage != net.kyori.adventure.text.Component.empty() && flag) { // Paper - Adventure // TODO: allow plugins to override?
|
||||
+ Component ichatbasecomponent = PaperAdventure.asVanilla(deathMessage); // Paper - Adventure
|
||||
+
|
||||
@@ -1498,8 +1510,8 @@
|
||||
+ } else {
|
||||
+ // Adds timeOffset to the beginning of this day.
|
||||
+ return this.level().getDayTime() - (this.level().getDayTime() % 24000) + this.timeOffset;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public WeatherType weather = null;
|
||||
+
|
||||
@@ -1514,14 +1526,14 @@
|
||||
+
|
||||
+ if (plugin) {
|
||||
+ this.weather = type;
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ if (type == WeatherType.DOWNFALL) {
|
||||
+ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.STOP_RAINING, 0));
|
||||
+ } else {
|
||||
+ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0));
|
||||
+ }
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ private float pluginRainPosition;
|
||||
+ private float pluginRainPositionPrevious;
|
||||
|
||||
@@ -134,7 +134,15 @@
|
||||
ServerLevel worldserver = this.server.getLevel(resourcekey);
|
||||
ServerLevel worldserver1;
|
||||
|
||||
@@ -182,10 +226,27 @@
|
||||
@@ -179,13 +223,35 @@
|
||||
worldserver1 = worldserver;
|
||||
}
|
||||
|
||||
+ // Paper start - Entity#getEntitySpawnReason
|
||||
+ if (optional.isEmpty()) {
|
||||
+ player.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT; // set Player SpawnReason to DEFAULT on first login
|
||||
+ }
|
||||
+ // Paper end - Entity#getEntitySpawnReason
|
||||
player.setServerLevel(worldserver1);
|
||||
String s1 = connection.getLoggableAddress(this.server.logIPs());
|
||||
|
||||
@@ -164,7 +172,7 @@
|
||||
ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData);
|
||||
|
||||
connection.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection);
|
||||
@@ -194,7 +255,9 @@
|
||||
@@ -194,7 +260,9 @@
|
||||
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
|
||||
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
|
||||
|
||||
@@ -175,7 +183,7 @@
|
||||
playerconnection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
playerconnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities()));
|
||||
playerconnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected));
|
||||
@@ -213,8 +276,10 @@
|
||||
@@ -213,8 +281,10 @@
|
||||
} else {
|
||||
ichatmutablecomponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), s);
|
||||
}
|
||||
@@ -187,7 +195,7 @@
|
||||
playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||
ServerStatus serverping = this.server.getStatus();
|
||||
|
||||
@@ -222,17 +287,77 @@
|
||||
@@ -222,17 +292,77 @@
|
||||
player.sendServerStatus(serverping);
|
||||
}
|
||||
|
||||
@@ -269,7 +277,7 @@
|
||||
}
|
||||
|
||||
public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {
|
||||
@@ -269,30 +394,31 @@
|
||||
@@ -269,30 +399,31 @@
|
||||
}
|
||||
|
||||
public void addWorldborderListener(ServerLevel world) {
|
||||
@@ -306,7 +314,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -319,14 +445,15 @@
|
||||
@@ -319,14 +450,15 @@
|
||||
}
|
||||
|
||||
protected void save(ServerPlayer player) {
|
||||
@@ -324,7 +332,7 @@
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.save();
|
||||
@@ -334,95 +461,186 @@
|
||||
@@ -334,95 +466,186 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -549,7 +557,7 @@
|
||||
|
||||
if (entityplayer1 != null) {
|
||||
set.add(entityplayer1);
|
||||
@@ -431,30 +649,50 @@
|
||||
@@ -431,30 +654,50 @@
|
||||
Iterator iterator1 = set.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -613,7 +621,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String s = (String) iterator.next();
|
||||
@@ -462,41 +700,88 @@
|
||||
@@ -462,41 +705,88 @@
|
||||
entityplayer1.addTag(s);
|
||||
}
|
||||
|
||||
@@ -710,7 +718,7 @@
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -516,15 +801,32 @@
|
||||
@@ -516,15 +806,32 @@
|
||||
}
|
||||
|
||||
public void sendPlayerPermissionLevel(ServerPlayer player) {
|
||||
@@ -745,7 +753,7 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -541,6 +843,25 @@
|
||||
@@ -541,6 +848,25 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -771,7 +779,7 @@
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -554,7 +875,7 @@
|
||||
@@ -554,7 +880,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -780,7 +788,7 @@
|
||||
PlayerTeam scoreboardteam = source.getTeam();
|
||||
|
||||
if (scoreboardteam != null) {
|
||||
@@ -573,7 +894,7 @@
|
||||
@@ -573,7 +899,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,7 +797,7 @@
|
||||
PlayerTeam scoreboardteam = source.getTeam();
|
||||
|
||||
if (scoreboardteam == null) {
|
||||
@@ -619,7 +940,7 @@
|
||||
@@ -619,7 +945,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile profile) {
|
||||
@@ -798,7 +806,7 @@
|
||||
ServerPlayer entityplayer = this.getPlayer(profile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -643,11 +964,30 @@
|
||||
@@ -643,36 +969,51 @@
|
||||
player.connection.send(new ClientboundEntityEventPacket(player, b0));
|
||||
}
|
||||
|
||||
@@ -810,12 +818,12 @@
|
||||
- return !this.doWhiteList || this.ops.contains(profile) || this.whitelist.contains(profile);
|
||||
+ // Paper start - ProfileWhitelistVerifyEvent
|
||||
+ return this.isWhiteListed(profile, null);
|
||||
+ }
|
||||
}
|
||||
+ public boolean isWhiteListed(GameProfile gameprofile, @Nullable org.bukkit.event.player.PlayerLoginEvent loginEvent) {
|
||||
+ boolean isOp = this.ops.contains(gameprofile);
|
||||
+ boolean isWhitelisted = !this.doWhiteList || isOp || this.whitelist.contains(gameprofile);
|
||||
+ final com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent event;
|
||||
+
|
||||
|
||||
+ final net.kyori.adventure.text.Component configuredMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.whitelistMessage);
|
||||
+ event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile), this.doWhiteList, isWhitelisted, isOp, configuredMessage);
|
||||
+ event.callEvent();
|
||||
@@ -827,10 +835,11 @@
|
||||
+ }
|
||||
+ return true;
|
||||
+ // Paper end - ProfileWhitelistVerifyEvent
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
public boolean isOp(GameProfile profile) {
|
||||
@@ -656,23 +996,19 @@
|
||||
return this.ops.contains(profile) || this.server.isSingleplayerOwner(profile) && this.server.getWorldData().isAllowCommands() || this.allowCommandsForAllPlayers;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ServerPlayer getPlayerByName(String name) {
|
||||
@@ -862,7 +871,7 @@
|
||||
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
|
||||
double d4 = x - entityplayer.getX();
|
||||
double d5 = y - entityplayer.getY();
|
||||
@@ -687,10 +1023,12 @@
|
||||
@@ -687,10 +1028,12 @@
|
||||
}
|
||||
|
||||
public void saveAll() {
|
||||
@@ -875,7 +884,7 @@
|
||||
}
|
||||
|
||||
public UserWhiteList getWhiteList() {
|
||||
@@ -712,15 +1050,19 @@
|
||||
@@ -712,15 +1055,19 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {
|
||||
@@ -899,7 +908,7 @@
|
||||
}
|
||||
|
||||
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
|
||||
@@ -729,8 +1071,16 @@
|
||||
@@ -729,8 +1076,16 @@
|
||||
|
||||
public void sendAllPlayerInfo(ServerPlayer player) {
|
||||
player.inventoryMenu.sendAllDataToRemote();
|
||||
@@ -917,7 +926,7 @@
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -746,6 +1096,7 @@
|
||||
@@ -746,6 +1101,7 @@
|
||||
}
|
||||
|
||||
public void setUsingWhiteList(boolean whitelistEnabled) {
|
||||
@@ -925,7 +934,7 @@
|
||||
this.doWhiteList = whitelistEnabled;
|
||||
}
|
||||
|
||||
@@ -786,11 +1137,35 @@
|
||||
@@ -786,11 +1142,35 @@
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
@@ -963,7 +972,7 @@
|
||||
|
||||
public void broadcastSystemMessage(Component message, boolean overlay) {
|
||||
this.broadcastSystemMessage(message, (entityplayer) -> {
|
||||
@@ -819,24 +1194,43 @@
|
||||
@@ -819,24 +1199,43 @@
|
||||
}
|
||||
|
||||
public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
|
||||
@@ -1010,7 +1019,7 @@
|
||||
}
|
||||
|
||||
if (flag1 && sender != null) {
|
||||
@@ -845,20 +1239,27 @@
|
||||
@@ -845,20 +1244,27 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1043,7 +1052,7 @@
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -867,7 +1268,7 @@
|
||||
@@ -867,7 +1273,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
|
||||
@@ -1052,7 +1061,7 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -875,13 +1276,13 @@
|
||||
@@ -875,13 +1281,13 @@
|
||||
|
||||
public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) {
|
||||
UUID uuid = player.getUUID();
|
||||
@@ -1068,7 +1077,7 @@
|
||||
}
|
||||
|
||||
advancementdataplayer.setPlayer(player);
|
||||
@@ -932,15 +1333,28 @@
|
||||
@@ -932,15 +1338,28 @@
|
||||
}
|
||||
|
||||
public void reloadResources() {
|
||||
|
||||
Reference in New Issue
Block a user