Skip to content

Commit 92abbc6

Browse files
committed
Deprecate Raid#getId for removal
Deprecate as raid instances are not tied to an id until the server actually starts tracking them. Best attempt at keeping compat by passing the id to the raid instance once tracked, prior the API will return -1.
1 parent 93872b2 commit 92abbc6

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

paper-api/src/main/java/org/bukkit/Raid.java

+3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ public enum RaidStatus {
137137
* Gets the id of this raid.
138138
*
139139
* @return the raid id
140+
* @deprecated Raid identifiers are magic internal values and may or may not be present.
141+
* -1 is returned for raids without an assigned id.
140142
*/
143+
@Deprecated(forRemoval = true, since = "1.21.5")
141144
int getId();
142145

143146
/**

paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
--- a/net/minecraft/world/entity/raid/Raid.java
22
+++ b/net/minecraft/world/entity/raid/Raid.java
3-
@@ -59,6 +_,11 @@
3+
@@ -59,6 +_,12 @@
44
import net.minecraft.world.phys.Vec3;
55

66
public class Raid {
77
+ // Paper start
88
+ private static final String PDC_NBT_KEY = "BukkitValues";
99
+ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry PDC_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
1010
+ public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer;
11+
+ public int idOrNegativeOne = -1;
1112
+ // Paper end
1213
public static final SpawnPlacementType RAVAGER_SPAWN_PLACEMENT_TYPE = SpawnPlacements.getPlacementType(EntityType.RAVAGER);
1314
public static final MapCodec<Raid> MAP_CODEC = RecordCodecBuilder.mapCodec(

paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
--- a/net/minecraft/world/entity/raid/Raids.java
22
+++ b/net/minecraft/world/entity/raid/Raids.java
3-
@@ -141,11 +_,22 @@
3+
@@ -57,6 +_,7 @@
4+
private Raids(List<Raids.RaidWithId> raids, int nextId, int tick) {
5+
for (Raids.RaidWithId raidWithId : raids) {
6+
this.raidMap.put(raidWithId.id, raidWithId.raid);
7+
+ raidWithId.raid.idOrNegativeOne = raidWithId.id; // Paper - expose id of raids while method is kept around as deprecated for removal
8+
}
9+
10+
this.nextId = nextId;
11+
@@ -141,11 +_,23 @@
412
}
513

614
Raid raid = this.getOrCreateRaid(serverLevel, blockPos);
@@ -23,6 +31,7 @@
2331
+
2432
+ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) {
2533
+ this.raidMap.put(this.getUniqueId(), raid);
34+
+ raid.idOrNegativeOne = this.nextId; // Paper - expose id of raids while method is kept around as deprecated for removal
2635
+ }
2736
+ // CraftBukkit end
2837
raid.absorbRaidOmen(player);

paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public net.minecraft.world.entity.raid.Raid getHandle() {
105105

106106
@Override
107107
public int getId() {
108-
return this.handle.getId();
108+
return this.handle.idOrNegativeOne;
109109
}
110110

111111
@Override

0 commit comments

Comments
 (0)