Fixed the bundle being directly used outside of the registry system.

This commit is contained in:
Matthew Miller
2018-12-23 21:43:20 +10:00
committed by IronApollo
parent 53308416ff
commit 26d4ea101e
9 changed files with 125 additions and 5 deletions

View File

@ -35,6 +35,15 @@ import javax.annotation.Nullable;
*/
public interface BlockRegistry {
/**
* Gets the name for the given block.
*
* @param blockType the block
* @return The name, or null if it's unknown
*/
@Nullable
String getName(BlockType blockType);
/**
* Get the material for the given block.
*

View File

@ -33,6 +33,13 @@ import javax.annotation.Nullable;
*/
public class BundledBlockRegistry implements BlockRegistry {
@Nullable
@Override
public String getName(BlockType blockType) {
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId());
return blockEntry != null ? blockEntry.localizedName : null;
}
@Nullable
@Override
public BlockMaterial getMaterial(BlockType blockType) {

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.registry;
<<<<<<< HEAD
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
@ -26,6 +27,11 @@ import com.sk89q.worldedit.world.item.ItemTypes;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
=======
import com.sk89q.worldedit.world.item.ItemType;
import javax.annotation.Nullable;
>>>>>>> b75d5149... Fixed the bundle being directly used outside of the registry system.
/**
* A item registry that uses {@link BundledItemRegistry} to serve information
@ -35,6 +41,7 @@ public class BundledItemRegistry implements ItemRegistry {
@Nullable
@Override
<<<<<<< HEAD
public BaseItem createFromId(String id) {
ItemType itemType = ItemTypes.get(id);
return itemType == null ? null : new BaseItem(itemType);
@ -47,6 +54,8 @@ public class BundledItemRegistry implements ItemRegistry {
@Nullable
@Override
=======
>>>>>>> b75d5149... Fixed the bundle being directly used outside of the registry system.
public String getName(ItemType itemType) {
BundledItemData.ItemEntry itemEntry = BundledItemData.getInstance().findById(itemType.getId());
return itemEntry != null ? itemEntry.localizedName : null;

View File

@ -19,16 +19,23 @@
package com.sk89q.worldedit.world.registry;
<<<<<<< HEAD
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.world.item.ItemType;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
=======
import com.sk89q.worldedit.world.item.ItemType;
import javax.annotation.Nullable;
>>>>>>> b75d5149... Fixed the bundle being directly used outside of the registry system.
public interface ItemRegistry {
/**
<<<<<<< HEAD
* Create a new item using its ID.
*
* @param id the id
@ -45,6 +52,8 @@ public interface ItemRegistry {
}
/**
=======
>>>>>>> b75d5149... Fixed the bundle being directly used outside of the registry system.
* Gets the name for the given item.
*
* @param itemType the item