Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: address deprecations from new records #2768

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,11 @@ private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundT

private static Block getBlockFromType(BlockType blockType) {

return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
}

private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
}

@Override
Expand Down Expand Up @@ -440,7 +440,7 @@ public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle();

Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());

if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt();
Expand Down Expand Up @@ -547,7 +547,7 @@ public void sendFakeOP(Player player) {
@Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, Blo
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
Expand Down Expand Up @@ -547,7 +547,7 @@ public int getInternalBiomeId(BiomeType biomeType) {
.getServer()
.registryAccess()
.registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation);
return registry.getId(biome);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundT

private static Block getBlockFromType(BlockType blockType) {

return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
}

private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
}

@Override
Expand Down Expand Up @@ -480,7 +480,7 @@ public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle();

Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());

if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt();
Expand Down Expand Up @@ -598,7 +598,7 @@ public void sendFakeOP(Player player) {
@Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, Blo
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
Expand Down Expand Up @@ -547,7 +547,7 @@ public int getInternalBiomeId(BiomeType biomeType) {
.getServer()
.registryAccess()
.registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation);
return registry.getId(biome);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundT

private static Block getBlockFromType(BlockType blockType) {

return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
}

private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
}

@Override
Expand Down Expand Up @@ -440,7 +440,7 @@ public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle();

Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());

if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt();
Expand Down Expand Up @@ -547,7 +547,7 @@ public void sendFakeOP(Player player) {
@Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, Blo
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
Expand Down Expand Up @@ -550,7 +550,7 @@ public int getInternalBiomeId(BiomeType biomeType) {
.getServer()
.registryAccess()
.registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation);
return registry.getId(biome);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundT

private static Block getBlockFromType(BlockType blockType) {

return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
}

private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
}

@Override
Expand Down Expand Up @@ -440,7 +440,7 @@ public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle();

Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());

if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt();
Expand Down Expand Up @@ -547,7 +547,7 @@ public void sendFakeOP(Player player) {
@Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, Blo
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
Expand Down Expand Up @@ -550,7 +550,7 @@ public int getInternalBiomeId(BiomeType biomeType) {
.getServer()
.registryAccess()
.registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation);
return registry.getId(biome);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundT
private static Block getBlockFromType(BlockType blockType) {

return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(
blockType.getId()));
blockType.id()));
}

private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(
itemType.getId()));
itemType.id()));
}

@Override
Expand Down Expand Up @@ -470,7 +470,7 @@ public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle();

Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());

if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt();
Expand Down Expand Up @@ -598,7 +598,7 @@ public void sendFakeOP(Player player) {
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
ItemStack stack = new ItemStack(
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount()
);
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, Blo
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
ItemStack stack = new ItemStack(
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount()
);
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData());
Expand Down Expand Up @@ -572,7 +572,7 @@ public int getInternalBiomeId(BiomeType biomeType) {
.getServer()
.registryAccess()
.registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation);
return registry.getId(biome);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ default Entity adapt(org.bukkit.entity.Entity entity) {
*/
default Material adapt(ItemType itemType) {
checkNotNull(itemType);
if (!itemType.getId().startsWith("minecraft:")) {
if (!itemType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
}
return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT));
return Material.getMaterial(itemType.id().substring(10).toUpperCase(Locale.ROOT));
}

/**
Expand All @@ -180,10 +180,10 @@ default Material adapt(ItemType itemType) {
*/
default Material adapt(BlockType blockType) {
checkNotNull(blockType);
if (!blockType.getId().startsWith("minecraft:")) {
if (!blockType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
}
String id = blockType.getId().substring(10).toUpperCase(Locale.ROOT);
String id = blockType.id().substring(10).toUpperCase(Locale.ROOT);
return Material.getMaterial(id);
}

Expand Down Expand Up @@ -293,11 +293,11 @@ default Player adapt(com.sk89q.worldedit.entity.Player player) {
}

default Biome adapt(BiomeType biomeType) {
if (!biomeType.getId().startsWith("minecraft:")) {
if (!biomeType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
}
try {
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT));
return Biome.valueOf(biomeType.id().substring(10).toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
@Override
public Component getRichName(BiomeType biomeType) {
return TranslatableComponent.of(
TranslationManager.makeTranslationKey("biome", biomeType.getId())
TranslationManager.makeTranslationKey("biome", biomeType.id())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void giveItem(BaseItemStack itemStack) {
final PlayerInventory inv = player.getInventory();
ItemStack newItem = BukkitAdapter.adapt(itemStack);
TaskManager.taskManager().sync(() -> {
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
if (itemStack.getType().id().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
inv.remove(newItem);
}
final ItemStack item = player.getInventory().getItemInMainHand();
Expand Down Expand Up @@ -267,7 +267,7 @@ public GameMode getGameMode() {

@Override
public void setGameMode(GameMode gameMode) {
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase(Locale.ROOT)));
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.id().toUpperCase(Locale.ROOT)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public String getPlatformVersion() {

//FAWE start
@Override
public String getId() {
public String id() {
return "intellectualsites:bukkit";
}
//FAWE end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public String getNameUnsafe() {
//FAWE end

@Override
public String getId() {
public String id() {
return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private Property<?> createProperty(String type, String key, List<String> values)
@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, FileRegistries.BlockProperty> properties =
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties;
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.id()).properties;
Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>> entryTransform =
(key, value) -> createProperty(value.type, key, value.values);
return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public Player matchPlayer(Player player) {
@Override
public World matchWorld(World world) {
return this.worlds.stream()
.filter(w -> w.getId().equals(world.getId()))
.filter(w -> w.id().equals(world.id()))
.findAny()
.orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public String getNameUnsafe() {
//FAWE end

@Override
public String getId() {
public String id() {
return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
}

Expand Down
Loading
Loading