chore: address deprecations from new records (#2768)

* Category should implement Keyed
This commit is contained in:
Jordan
2024-06-12 15:00:40 +02:00
committed by GitHub
parent 62297f9479
commit 9843bb0188
70 changed files with 166 additions and 167 deletions

View File

@ -283,11 +283,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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();
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@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())));

View File

@ -480,7 +480,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
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())));
@ -547,7 +547,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.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);
}

View File

@ -284,11 +284,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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
@ -480,7 +480,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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();
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@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())));

View File

@ -480,7 +480,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
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())));
@ -547,7 +547,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.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);
}

View File

@ -281,11 +281,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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();
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@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())));

View File

@ -483,7 +483,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
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())));
@ -550,7 +550,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.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);
}

View File

@ -281,11 +281,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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();
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@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())));

View File

@ -483,7 +483,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
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())));
@ -550,7 +550,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.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);
}

View File

@ -291,12 +291,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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
@ -470,7 +470,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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();
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
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());

View File

@ -492,7 +492,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
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());
@ -572,7 +572,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.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);
}

View File

@ -166,10 +166,10 @@ public interface IBukkitAdapter {
*/
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));
}
/**
@ -180,10 +180,10 @@ public interface IBukkitAdapter {
*/
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);
}
@ -293,11 +293,11 @@ public interface IBukkitAdapter {
}
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;
}

View File

@ -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())
);
}

View File

@ -162,7 +162,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
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();
@ -267,7 +267,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@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

View File

@ -230,7 +230,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
//FAWE start
@Override
public String getId() {
public String id() {
return "intellectualsites:bukkit";
}
//FAWE end

View File

@ -224,7 +224,7 @@ public class BukkitWorld extends AbstractWorld {
//FAWE end
@Override
public String getId() {
public String id() {
return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
}