Other random classes

net/minecraft/core/dispenser/
This commit is contained in:
Owen1212055
2025-05-29 20:56:26 -04:00
parent 4a82168542
commit 6d71abd25f
10 changed files with 106 additions and 175 deletions

View File

@@ -1,26 +0,0 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/server/commands/GameModeCommand.java b/net/minecraft/server/commands/GameModeCommand.java
index c112ca29596a68c6ba12dcc4d33460b4c181fa47..c44cdbbdc06b25bd20a208386545a10af9b96df8 100644
--- a/net/minecraft/server/commands/GameModeCommand.java
+++ b/net/minecraft/server/commands/GameModeCommand.java
@@ -54,9 +54,14 @@ public class GameModeCommand {
int i = 0;
for (ServerPlayer serverPlayer : players) {
- if (serverPlayer.setGameMode(gameType)) {
+ // Paper start - Expand PlayerGameModeChangeEvent
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = serverPlayer.setGameMode(gameType, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.COMMAND, net.kyori.adventure.text.Component.empty());
+ if (event != null && !event.isCancelled()) {
logGamemodeChange(source.getSource(), serverPlayer, gameType);
i++;
+ } else if (event != null && event.cancelMessage() != null) {
+ source.getSource().sendSuccess(() -> io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), true);
+ // Paper end - Expand PlayerGameModeChangeEvent
}
}

View File

@@ -1,18 +0,0 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/util/datafix/fixes/RaidRenamesDataFix.java b/net/minecraft/util/datafix/fixes/RaidRenamesDataFix.java
index 6d1a64758c2f383cf7f047539daa2b869614694d..682c75c4c61181fb50214326c317f2fe7e893dbd 100644
--- a/net/minecraft/util/datafix/fixes/RaidRenamesDataFix.java
+++ b/net/minecraft/util/datafix/fixes/RaidRenamesDataFix.java
@@ -39,6 +39,6 @@ public class RaidRenamesDataFix extends DataFix {
.renameField("PostRaidTicks", "post_raid_ticks")
.renameField("TotalHealth", "total_health")
.renameField("NumGroups", "group_count")
- .renameField("Status", "status");
+ .renameField("Status", "status").renameField("HeroesOfTheVillage", "heroes_of_the_village"); // Paper - Add missing rename
}
}

View File

@@ -1,31 +0,0 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java b/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java
index 39893361d4af95e74f89a5a99352cababc073856..a9be3acbf4ea52d2988347abfa6f4f8c02b1da26 100644
--- a/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java
+++ b/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java
@@ -24,8 +24,19 @@ public class BabyFollowAdult {
if (!mob.isBaby()) {
return false;
} else {
- AgeableMob ageableMob = instance.get(nearestVisibleAdult);
+ LivingEntity ageableMob = instance.get(nearestVisibleAdult); // CraftBukkit - type
if (mob.closerThan(ageableMob, followRange.getMaxValue() + 1) && !mob.closerThan(ageableMob, followRange.getMinValue())) {
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(mob, ageableMob, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER);
+ if (event.isCancelled()) {
+ return false;
+ }
+ if (event.getTarget() == null) {
+ nearestVisibleAdult.erase();
+ return true;
+ }
+ ageableMob = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle();
+ // CraftBukkit end
WalkTarget walkTarget1 = new WalkTarget(
new EntityTracker(ageableMob, false), speedModifier.apply(mob), followRange.getMinValue() - 1
);

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
index 51206597d13d8c2d539268b92c076377f2d1573d..c1bd6d91cf9828ccc7275efe0f5c959c0f457c13 100644
--- a/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
+++ b/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
@@ -20,9 +20,30 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior {
@@ -20,9 +_,30 @@
@Override
protected ItemStack execute(BlockSource blockSource, ItemStack item) {
ServerLevel serverLevel = blockSource.level();
@@ -35,29 +27,31 @@ index 51206597d13d8c2d539268b92c076377f2d1573d..c1bd6d91cf9828ccc7275efe0f5c959c
+ // CraftBukkit end
if (!serverLevel.isClientSide()) {
BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING));
- this.setSuccess(tryShearBeehive(serverLevel, blockPos) || tryShearLivingEntity(serverLevel, blockPos, item));
+ this.setSuccess(tryShearBeehive(serverLevel, blockPos) || tryShearLivingEntity(serverLevel, blockPos, item, bukkitBlock, craftItem)); // CraftBukkit
- this.setSuccess(tryShearBeehive(serverLevel, blockPos) || tryShearEntity(serverLevel, blockPos, item));
+ this.setSuccess(tryShearBeehive(serverLevel, blockPos) || tryShearEntity(serverLevel, blockPos, item, bukkitBlock, craftItem)); // CraftBukkit
if (this.isSuccess()) {
item.hurtAndBreak(1, serverLevel, null, item1 -> {});
}
@@ -50,10 +71,18 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior {
@@ -50,13 +_,21 @@
return false;
}
- private static boolean tryShearLivingEntity(ServerLevel level, BlockPos pos, ItemStack stack) {
+ private static boolean tryShearLivingEntity(ServerLevel level, BlockPos pos, ItemStack stack, org.bukkit.block.Block bukkitBlock, org.bukkit.craftbukkit.inventory.CraftItemStack craftItem) { // CraftBukkit - add args
for (LivingEntity livingEntity : level.getEntitiesOfClass(LivingEntity.class, new AABB(pos), EntitySelector.NO_SPECTATORS)) {
if (livingEntity instanceof Shearable shearable && shearable.readyForShearing()) {
- shearable.shear(level, SoundSource.BLOCKS, stack);
- private static boolean tryShearEntity(ServerLevel level, BlockPos pos, ItemStack stack) {
+ private static boolean tryShearEntity(ServerLevel level, BlockPos pos, ItemStack stack, org.bukkit.block.Block bukkitBlock, org.bukkit.craftbukkit.inventory.CraftItemStack craftItem) { // CraftBukkit - add args
for (Entity entity : level.getEntitiesOfClass(Entity.class, new AABB(pos), EntitySelector.NO_SPECTATORS)) {
if (entity.shearOffAllLeashConnections(null)) {
return true;
}
if (entity instanceof Shearable shearable && shearable.readyForShearing()) {
+ // CraftBukkit start
+ // Paper start - Add drops to shear events
+ org.bukkit.event.block.BlockShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockShearEntityEvent(livingEntity, bukkitBlock, craftItem, shearable.generateDefaultDrops(level, stack));
+ org.bukkit.event.block.BlockShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockShearEntityEvent(entity, bukkitBlock, craftItem, shearable.generateDefaultDrops(level, stack));
+ if (event.isCancelled()) {
+ // Paper end - Add drops to shear events
+ continue;
+ }
+ // CraftBukkit end
+ shearable.shear(level, SoundSource.BLOCKS, stack, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops())); // Paper - Add drops to shear events
shearable.shear(level, SoundSource.BLOCKS, stack);
level.gameEvent(null, GameEvent.SHEAR, pos);
return true;
}

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/nbt/CompoundTag.java b/net/minecraft/nbt/CompoundTag.java
index 163443001458b939a49a560cb79a9194498a0e31..052ca6beb06a3256fdf04bac5f2085ad622d7df0 100644
--- a/net/minecraft/nbt/CompoundTag.java
+++ b/net/minecraft/nbt/CompoundTag.java
@@ -54,7 +54,7 @@ public final class CompoundTag implements Tag {
@@ -54,7 +_,7 @@
private static CompoundTag loadCompound(DataInput input, NbtAccounter nbtAccounter) throws IOException {
nbtAccounter.accountBytes(48L);
@@ -17,7 +9,7 @@ index 163443001458b939a49a560cb79a9194498a0e31..052ca6beb06a3256fdf04bac5f2085ad
byte b;
while ((b = input.readByte()) != 0) {
@@ -171,7 +171,7 @@ public final class CompoundTag implements Tag {
@@ -171,7 +_,7 @@
}
public CompoundTag() {
@@ -26,12 +18,12 @@ index 163443001458b939a49a560cb79a9194498a0e31..052ca6beb06a3256fdf04bac5f2085ad
}
@Override
@@ -402,9 +402,16 @@ public final class CompoundTag implements Tag {
@@ -402,9 +_,16 @@
@Override
public CompoundTag copy() {
- HashMap<String, Tag> map = new HashMap<>();
- this.tags.forEach((string, tag) -> map.put(string, tag.copy()));
- this.tags.forEach((key, value) -> map.put(key, value.copy()));
- return new CompoundTag(map);
+ // Paper start - Reduce memory footprint of CompoundTag
+ it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<String, Tag> ret = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(this.tags.size(), 0.8f);
@@ -46,7 +38,7 @@ index 163443001458b939a49a560cb79a9194498a0e31..052ca6beb06a3256fdf04bac5f2085ad
}
@Override
@@ -525,22 +532,47 @@ public final class CompoundTag implements Tag {
@@ -525,22 +_,47 @@
this.merge((CompoundTag)mapCodec.encoder().encodeStart(ops, data).getOrThrow());
}

View File

@@ -0,0 +1,20 @@
--- a/net/minecraft/server/commands/GameModeCommand.java
+++ b/net/minecraft/server/commands/GameModeCommand.java
@@ -69,9 +_,16 @@
}
private static boolean setGameMode(CommandSourceStack source, ServerPlayer player, GameType gameMode) {
- if (player.setGameMode(gameMode)) {
+ // Paper start
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = player.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.COMMAND, net.kyori.adventure.text.Component.empty());
+ if (event != null && !event.isCancelled()) {
+ // Paper end
logGamemodeChange(source, player, gameMode);
return true;
+ } else if (event != null && event.cancelMessage() != null) {
+ source.sendSuccess(() -> io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), true);
+ return false;
+ // Paper end - Expand PlayerGameModeChangeEvent
} else {
return false;
}

View File

@@ -0,0 +1,20 @@
--- a/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java
+++ b/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java
@@ -30,6 +_,17 @@
} else {
LivingEntity livingEntity = instance.get(memoryAccessor);
if (entity.closerThan(livingEntity, followRange.getMaxValue() + 1) && !entity.closerThan(livingEntity, followRange.getMinValue())) {
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(mob, ageableMob, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER);
+ if (event.isCancelled()) {
+ return false;
+ }
+ if (event.getTarget() == null) {
+ memoryAccessor.erase();
+ return true;
+ }
+ livingEntity = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle();
+ // CraftBukkit end
WalkTarget walkTarget = new WalkTarget(
new EntityTracker(livingEntity, targetEyeHeight, targetEyeHeight),
speedModifier.apply(entity),

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java
index 20bd64ee79a22af97e3ea1331fcabb3d2a08f707..ebdfd3fb6c0de48982d392bb2aa415f3676c6056 100644
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
@@ -63,6 +63,7 @@ public class Tadpole extends AbstractFish {
@@ -65,6 +_,7 @@
MemoryModuleType.BREED_TARGET,
MemoryModuleType.IS_PANICKING
);
@@ -16,7 +8,7 @@ index 20bd64ee79a22af97e3ea1331fcabb3d2a08f707..ebdfd3fb6c0de48982d392bb2aa415f3
public Tadpole(EntityType<? extends AbstractFish> entityType, Level level) {
super(entityType, level);
@@ -114,7 +115,7 @@ public class Tadpole extends AbstractFish {
@@ -116,7 +_,7 @@
@Override
public void aiStep() {
super.aiStep();
@@ -25,22 +17,22 @@ index 20bd64ee79a22af97e3ea1331fcabb3d2a08f707..ebdfd3fb6c0de48982d392bb2aa415f3
this.setAge(this.age + 1);
}
}
@@ -123,12 +124,14 @@ public class Tadpole extends AbstractFish {
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("Age", this.age);
+ compound.putBoolean("AgeLocked", this.ageLocked); // Paper
@@ -125,12 +_,14 @@
protected void addAdditionalSaveData(ValueOutput output) {
super.addAdditionalSaveData(output);
output.putInt("Age", this.age);
+ output.putBoolean("AgeLocked", this.ageLocked); // Paper
}
@Override
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
this.setAge(compound.getIntOr("Age", 0));
+ this.ageLocked = compound.getBooleanOr("AgeLocked", false); // Paper
protected void readAdditionalSaveData(ValueInput input) {
super.readAdditionalSaveData(input);
this.setAge(input.getIntOr("Age", 0));
+ this.ageLocked = input.getBooleanOr("AgeLocked", false); // Paper
}
@Nullable
@@ -178,13 +181,19 @@ public class Tadpole extends AbstractFish {
@@ -180,13 +_,19 @@
@Override
public void saveToBucketTag(ItemStack stack) {
Bucketable.saveDefaultDataToBucketTag(this, stack);
@@ -61,7 +53,7 @@ index 20bd64ee79a22af97e3ea1331fcabb3d2a08f707..ebdfd3fb6c0de48982d392bb2aa415f3
}
@Override
@@ -216,6 +225,7 @@ public class Tadpole extends AbstractFish {
@@ -218,6 +_,7 @@
}
private void ageUp(int offset) {
@@ -69,7 +61,7 @@ index 20bd64ee79a22af97e3ea1331fcabb3d2a08f707..ebdfd3fb6c0de48982d392bb2aa415f3
this.setAge(this.age + offset * 20);
}
@@ -228,12 +238,17 @@ public class Tadpole extends AbstractFish {
@@ -230,12 +_,17 @@
private void ageUp() {
if (this.level() instanceof ServerLevel serverLevel) {

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/inventory/AnvilMenu.java b/net/minecraft/world/inventory/AnvilMenu.java
index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6b1ea7af2 100644
--- a/net/minecraft/world/inventory/AnvilMenu.java
+++ b/net/minecraft/world/inventory/AnvilMenu.java
@@ -43,6 +43,12 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -44,6 +_,12 @@
private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76;
private static final int RESULT_SLOT_X_PLACEMENT = 134;
private static final int SLOT_Y_PLACEMENT = 47;
@@ -21,7 +13,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
public AnvilMenu(int containerId, Inventory playerInventory) {
this(containerId, playerInventory, ContainerLevelAccess.NULL);
@@ -68,7 +74,7 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -69,7 +_,7 @@
@Override
protected boolean mayPickup(Player player, boolean hasStack) {
@@ -30,14 +22,16 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
}
@Override
@@ -89,12 +95,22 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -90,7 +_,7 @@
this.inputSlots.setItem(1, ItemStack.EMPTY);
}
- this.cost.set(0);
+ this.cost.set(AnvilMenu.DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
this.inputSlots.setItem(0, ItemStack.EMPTY);
this.access.execute((level, blockPos) -> {
if (player instanceof ServerPlayer serverPlayer
&& !StringUtil.isBlank(this.itemName)
&& !this.inputSlots.getItem(0).getHoverName().getString().equals(this.itemName)) {
@@ -102,6 +_,16 @@
BlockState blockState = level.getBlockState(blockPos);
if (!player.hasInfiniteMaterials() && blockState.is(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) {
BlockState blockState1 = AnvilBlock.damage(blockState);
@@ -54,7 +48,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
if (blockState1 == null) {
level.removeBlock(blockPos, false);
level.levelEvent(1029, blockPos, 0);
@@ -127,8 +143,8 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -134,8 +_,8 @@
if (itemStack.isDamageableItem() && item.isValidRepairItem(item1)) {
int min = Math.min(itemStack.getDamageValue(), itemStack.getMaxDamage() / 4);
if (min <= 0) {
@@ -65,7 +59,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
return;
}
@@ -143,8 +159,8 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -150,8 +_,8 @@
this.repairItemCountCost = i2;
} else {
if (!hasStoredEnchantments && (!itemStack.is(item1.getItem()) || !itemStack.isDamageableItem())) {
@@ -76,7 +70,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
return;
}
@@ -190,7 +206,7 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -197,7 +_,7 @@
flag1 = true;
} else {
flag = true;
@@ -85,7 +79,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
intValue = enchantment.getMaxLevel();
}
@@ -208,8 +224,8 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -215,8 +_,8 @@
}
if (flag1 && !flag) {
@@ -96,7 +90,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
return;
}
}
@@ -234,14 +250,16 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -241,14 +_,16 @@
}
if (i1 == i && i1 > 0) {
@@ -116,7 +110,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
itemStack = ItemStack.EMPTY;
}
@@ -259,12 +277,13 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -266,12 +_,13 @@
EnchantmentHelper.setEnchantments(itemStack, mutable.toImmutable());
}
@@ -133,7 +127,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
}
public static int calculateIncreasedRepairCost(int oldRepairCost) {
@@ -285,6 +304,7 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -292,6 +_,7 @@
}
this.createResult();
@@ -141,7 +135,7 @@ index fa76f539268a77c67dbc489ca47447cf80aa4622..65c400444314049d5529f1f76d65fbd6
return true;
} else {
return false;
@@ -300,4 +320,19 @@ public class AnvilMenu extends ItemCombinerMenu {
@@ -307,4 +_,19 @@
public int getCost() {
return this.cost.get();
}

View File

@@ -1,27 +1,19 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/storage/PlayerDataStorage.java b/net/minecraft/world/level/storage/PlayerDataStorage.java
index cd6cf2da514a1128c8761c99aa9ddd13ceca9073..ab9282c04c1996b037567d07f95e2b150bcfcd38 100644
--- a/net/minecraft/world/level/storage/PlayerDataStorage.java
+++ b/net/minecraft/world/level/storage/PlayerDataStorage.java
@@ -31,6 +31,7 @@ public class PlayerDataStorage {
@@ -32,6 +_,7 @@
}
public void save(Player player) {
+ if (org.spigotmc.SpigotConfig.disablePlayerDataSaving) return; // Spigot
try {
CompoundTag compoundTag = player.saveWithoutId(new CompoundTag());
Path path = this.playerDir.toPath();
@@ -40,30 +41,46 @@ public class PlayerDataStorage {
try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(player.problemPath(), LOGGER)) {
TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, player.registryAccess());
player.saveWithoutId(tagValueOutput);
@@ -43,30 +_,46 @@
Path path3 = path.resolve(player.getStringUUID() + ".dat_old");
Util.safeReplaceFile(path2, path1, path3);
} catch (Exception var7) {
} catch (Exception var11) {
- LOGGER.warn("Failed to save player data for {}", player.getName().getString());
+ LOGGER.warn("Failed to save player data for {}", player.getScoreboardName(), var7); // Paper - Print exception
+ LOGGER.warn("Failed to save player data for {}", player.getScoreboardName(), var11); // Paper - Print exception
}
}
@@ -72,13 +64,13 @@ index cd6cf2da514a1128c8761c99aa9ddd13ceca9073..ab9282c04c1996b037567d07f95e2b15
}
}
@@ -71,16 +88,40 @@ public class PlayerDataStorage {
@@ -74,17 +_,40 @@
}
public Optional<CompoundTag> load(Player player) {
public Optional<ValueInput> load(Player player, ProblemReporter problemReporter) {
- Optional<CompoundTag> optional = this.load(player, ".dat");
+ // CraftBukkit start
+ return this.load(player.getName().getString(), player.getStringUUID()).map((tag) -> {
+ return this.load(player.getName().getString(), player.getStringUUID(), problemReporter).map((tag) -> {
+ if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
+ org.bukkit.craftbukkit.entity.CraftPlayer craftPlayer = serverPlayer.getBukkitEntity();
+ // Only update first played if it is older than the one we have
@@ -88,12 +80,13 @@ index cd6cf2da514a1128c8761c99aa9ddd13ceca9073..ab9282c04c1996b037567d07f95e2b15
+ }
+ }
+
+ player.load(tag); // From below
+ return tag;
+ ValueInput valueInput = TagValueInput.create(problemReporter, player.registryAccess(), tag);
+ player.load(valueInput); // From below
+ return valueInput;
+ });
+ }
+
+ public Optional<CompoundTag> load(String name, String uuid) {
+ public Optional<CompoundTag> load(String name, String uuid, ProblemReporter problemReporter) {
+ // CraftBukkit end
+ Optional<CompoundTag> optional = this.load(name, uuid, ".dat"); // CraftBukkit
if (optional.isEmpty()) {
@@ -105,9 +98,10 @@ index cd6cf2da514a1128c8761c99aa9ddd13ceca9073..ab9282c04c1996b037567d07f95e2b15
+ return optional.or(() -> this.load(name, uuid, ".dat_old")).map(compoundTag -> { // CraftBukkit
int dataVersion = NbtUtils.getDataVersion(compoundTag, -1);
compoundTag = DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, compoundTag, dataVersion);
- player.load(compoundTag);
+ // player.load(compoundTag); // CraftBukkit - handled above
return compoundTag;
- ValueInput valueInput = TagValueInput.create(problemReporter, player.registryAccess(), compoundTag);
- player.load(valueInput);
- return valueInput;
+ return compoundTag; // CraftBukkit - handled above
});
}
+