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

Deprecate bundled item data #2514

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -24,6 +24,7 @@
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BundledItemRegistry;

@SuppressWarnings("removal")
class BukkitItemRegistry extends BundledItemRegistry {
@Override
public Component getRichName(ItemType itemType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BundledBlockData;
import com.sk89q.worldedit.world.registry.BundledItemData;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -405,8 +404,7 @@ private boolean checkFilename(String filename) {
*/
public void loadMappings() {
BundledBlockData.getInstance(); // Load block registry
BundledItemData.getInstance(); // Load item registry
LegacyMapper.getInstance(); // Load item registry
LegacyMapper.getInstance(); // Load legacy mappings
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class ItemType implements Keyed {
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getRichName(this)
);
@SuppressWarnings("removal")
private final LazyReference<ItemMaterial> itemMaterial = LazyReference.from(() ->
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getMaterial(this)
Expand Down Expand Up @@ -107,7 +108,10 @@ public BlockType getBlockType() {
* Get the material for this ItemType.
*
* @return The material
* @deprecated Deprecated without alternative
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
public ItemMaterial getMaterial() {
return itemMaterial.getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
* <p>The data is read from a JSON file that is bundled with WorldEdit. If
* reading fails (which occurs when this class is first instantiated), then
* the methods will return {@code null}s for all items.</p>
*
* @deprecated Deprecated without replacement.
*/
@Deprecated(forRemoval = true)
public final class BundledItemData {

private static final Logger LOGGER = LogManagerCompat.getLogger();
Expand Down Expand Up @@ -91,6 +94,7 @@ private void loadFromResource() throws IOException {
* @return the entry, or null
*/
@Nullable
@Deprecated
public ItemEntry findById(String id) {
// If it has no namespace, assume minecraft.
if (!id.contains(":")) {
Expand All @@ -104,8 +108,11 @@ public ItemEntry findById(String id) {
*
* @param id the string ID
* @return the material's properties, or null
* @deprecated Deprecated without alternative
*/
@Nullable
@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
public ItemMaterial getMaterialById(String id) {
ItemEntry entry = findById(id);
if (entry != null) {
Expand All @@ -121,6 +128,7 @@ public ItemMaterial getMaterialById(String id) {
*
* @return the instance
*/
@Deprecated
public static BundledItemData getInstance() {
if (INSTANCE == null) {
INSTANCE = new BundledItemData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@
/**
* A item registry that uses {@link BundledItemRegistry} to serve information
* about items.
*
* @deprecated Use the platform Item Registries
*/
@Deprecated(forRemoval = true)
public class BundledItemRegistry implements ItemRegistry {

@SuppressWarnings("removal")
private BundledItemData.ItemEntry getEntryById(ItemType itemType) {
return BundledItemData.getInstance().findById(itemType.id());
}

@Override
@SuppressWarnings("removal")
public Component getRichName(ItemType itemType) {
BundledItemData.ItemEntry itemEntry = getEntryById(itemType);
if (itemEntry != null && !itemEntry.localizedName.equals("Air")) {
Expand All @@ -56,7 +61,7 @@ public Component getRichName(ItemType itemType) {
@Override
@Deprecated
// dumb_intellij.jpg
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "removal"})
public String getName(ItemType itemType) {
BundledItemData.ItemEntry itemEntry = getEntryById(itemType);
if (itemEntry != null) {
Expand All @@ -73,6 +78,8 @@ public String getName(ItemType itemType) {

@Nullable
@Override
@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
public ItemMaterial getMaterial(ItemType itemType) {
return new PassthroughItemMaterial(BundledItemData.getInstance().getMaterialById(itemType.id()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static URL loadRegistry(String name) throws IOException {
}

private final BundledBlockRegistry blockRegistry = new BundledBlockRegistry();
@SuppressWarnings("removal")
private final BundledItemRegistry itemRegistry = new BundledItemRegistry();
private final NullEntityRegistry entityRegistry = new NullEntityRegistry();
private final NullBiomeRegistry biomeRegistry = new NullBiomeRegistry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.sk89q.worldedit.internal.util.DeprecationUtil;
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;

@Deprecated(forRemoval = true)
public interface ItemMaterial {
/**
* Gets the the maximum quantity of this item that can be in a single stack.
Expand All @@ -38,7 +39,9 @@ default int getMaxStackSize() {
* Gets the the maximum quantity of this item that can be in a single stack.
*
* @return the maximum quantity
* @deprecated Deprecated with no alternative
*/
@Deprecated(forRemoval = true)
@NonAbstractForCompatibility(delegateName = "getMaxStackSize", delegateParams = {})
default int maxStackSize() {
DeprecationUtil.checkDelegatingOverride(getClass());
Expand All @@ -60,7 +63,9 @@ default int getMaxDamage() {
* Gets the the maximum damage this item can take before being broken.
*
* @return the maximum damage, or 0 if not applicable
* @deprecated Deprecated with no alternative
*/
@Deprecated(forRemoval = true)
@NonAbstractForCompatibility(delegateName = "getMaxDamage", delegateParams = {})
default int maxDamage() {
DeprecationUtil.checkDelegatingOverride(getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ default String getName(ItemType itemType) {
*
* @param itemType the item
* @return the material, or null if the material information is not known
* @deprecated ItemMaterial is deprecated with no alternative.
*/
@Deprecated(forRemoval = true)
@Nullable
@SuppressWarnings("removal")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, any reference to something deprecated for removal is now erroring the build due to producing a warning, even if the current block is deprecated too

ItemMaterial getMaterial(ItemType itemType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;

@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

public class PassthroughItemMaterial implements ItemMaterial {

private static final ItemMaterial DEFAULT_MATERIAL = new SimpleItemMaterial(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@

package com.sk89q.worldedit.world.registry;

@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

public record SimpleItemMaterial(int maxStackSize, int maxDamage) implements ItemMaterial {
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BundledItemRegistry;

@SuppressWarnings("removal")
public class FabricItemRegistry extends BundledItemRegistry {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BundledItemRegistry;

@SuppressWarnings("removal")
public class ForgeItemRegistry extends BundledItemRegistry {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.RegistryTypes;

@SuppressWarnings("removal")
public class SpongeItemRegistry extends BundledItemRegistry {

@Override
Expand Down
Loading