Item Registry Test is now functional

Dieser Commit ist enthalten in:
MattBDev 2019-09-19 14:56:03 -04:00
Ursprung 16e24a2400
Commit c926cddbd6
4 geänderte Dateien mit 15 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -354,6 +354,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private void loadConfig() { private void loadConfig() {
createDefaultConfiguration("config-legacy.yml"); // Create the default configuration file createDefaultConfiguration("config-legacy.yml"); // Create the default configuration file
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this); config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this);
config.load(); config.load();
// Create schematics folder // Create schematics folder

Datei anzeigen

@ -20,21 +20,20 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import org.bukkit.Material; import org.bukkit.Material;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class ItemRegistryTest { public class ItemRegistryTest {
@Test @Test
public void testTreeTypeMapping() { public void testItemRegistry() {
for (Material material : Material.values()) { for (Material material : Material.values()) {
if (material.isItem() && !material.isLegacy()) { if (material.isItem() && !material.isLegacy()) {
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString())); ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
System.out.println(material.getKey().toString());
} }
} }
System.out.println(ItemType.REGISTRY.getKnownNamespaces().toString()); Assertions.assertNotNull(ItemType.REGISTRY.get("minecraft:wooden_axe"));
} }
} }

Datei anzeigen

@ -923,7 +923,6 @@ public final class BlockTypes {
{ // Register new blocks { // Register new blocks
int internalId = 1; int internalId = 1;
for (Map.Entry<String, String> entry : blockMap.entrySet()) { for (Map.Entry<String, String> entry : blockMap.entrySet()) {
String id = entry.getKey();
String defaultState = entry.getValue(); String defaultState = entry.getValue();
// Skip already registered ids // Skip already registered ids
for (; values[internalId] != null; internalId++); for (; values[internalId] != null; internalId++);
@ -994,7 +993,7 @@ public final class BlockTypes {
throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of(BlockTypes.values) throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of(BlockTypes.values)
.filter(b -> StringMan.blockStateMatches(inputLower, b.getId())) .filter(b -> StringMan.blockStateMatches(inputLower, b.getId()))
.map(e1 -> e1.getId()) .map(BlockType::getId)
.sorted(StringMan.blockStateComparator(inputLower)) .sorted(StringMan.blockStateComparator(inputLower))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
@ -1004,12 +1003,14 @@ public final class BlockTypes {
return $NAMESPACES; return $NAMESPACES;
} }
public static @Nullable BlockType get(final String id) { @Nullable
return BlockType.REGISTRY.getMap().get(id); public static BlockType get(final String id) {
return BlockType.REGISTRY.get(id);
} }
public static @Nullable BlockType get(final CharSequence id) { @Nullable
return BlockType.REGISTRY.getMap().get(id); public static BlockType get(final CharSequence id) {
return BlockType.REGISTRY.get(id.toString());
} }
@Deprecated @Deprecated

Datei anzeigen

@ -232,7 +232,7 @@ public final class ItemTypes {
@Nullable public static final ItemType CYAN_WOOL = get("minecraft:cyan_wool"); @Nullable public static final ItemType CYAN_WOOL = get("minecraft:cyan_wool");
@Nullable public static final ItemType DAMAGED_ANVIL = get("minecraft:damaged_anvil"); @Nullable public static final ItemType DAMAGED_ANVIL = get("minecraft:damaged_anvil");
@Nullable public static final ItemType DANDELION = get("minecraft:dandelion"); @Nullable public static final ItemType DANDELION = get("minecraft:dandelion");
@Deprecated @Nullable public static final ItemType DANDELION_YELLOW = Optional.ofNullable(get("minecraft:dandelion_yellow")).orElseGet(() -> get("minecraft:yellow_dye")); @Deprecated @Nullable public static final ItemType DANDELION_YELLOW = Optional.ofNullable(get("minecraft:dandelion_yellow")).orElseGet(() -> (get("minecraft:yellow_dye")));
@Nullable public static final ItemType DARK_OAK_BOAT = get("minecraft:dark_oak_boat"); @Nullable public static final ItemType DARK_OAK_BOAT = get("minecraft:dark_oak_boat");
@Nullable public static final ItemType DARK_OAK_BUTTON = get("minecraft:dark_oak_button"); @Nullable public static final ItemType DARK_OAK_BUTTON = get("minecraft:dark_oak_button");
@Nullable public static final ItemType DARK_OAK_DOOR = get("minecraft:dark_oak_door"); @Nullable public static final ItemType DARK_OAK_DOOR = get("minecraft:dark_oak_door");
@ -730,7 +730,7 @@ public final class ItemTypes {
@Nullable public static final ItemType REPEATER = get("minecraft:repeater"); @Nullable public static final ItemType REPEATER = get("minecraft:repeater");
@Nullable public static final ItemType REPEATING_COMMAND_BLOCK = get("minecraft:repeating_command_block"); @Nullable public static final ItemType REPEATING_COMMAND_BLOCK = get("minecraft:repeating_command_block");
@Nullable public static final ItemType ROSE_BUSH = get("minecraft:rose_bush"); @Nullable public static final ItemType ROSE_BUSH = get("minecraft:rose_bush");
@Deprecated @Nullable public static final ItemType ROSE_RED = Optional.ofNullable(get("minecraft:rose_red")).orElseGet(() -> get("minecraft:red_dye")); @Deprecated @Nullable public static final ItemType ROSE_RED = Optional.ofNullable(get("minecraft:rose_red")).orElseGet(() -> (get("minecraft:red_dye")));
@Nullable public static final ItemType ROTTEN_FLESH = get("minecraft:rotten_flesh"); @Nullable public static final ItemType ROTTEN_FLESH = get("minecraft:rotten_flesh");
@Nullable public static final ItemType SADDLE = get("minecraft:saddle"); @Nullable public static final ItemType SADDLE = get("minecraft:saddle");
@Nullable public static final ItemType SALMON = get("minecraft:salmon"); @Nullable public static final ItemType SALMON = get("minecraft:salmon");
@ -752,7 +752,7 @@ public final class ItemTypes {
@Nullable public static final ItemType SHULKER_BOX = get("minecraft:shulker_box"); @Nullable public static final ItemType SHULKER_BOX = get("minecraft:shulker_box");
@Nullable public static final ItemType SHULKER_SHELL = get("minecraft:shulker_shell"); @Nullable public static final ItemType SHULKER_SHELL = get("minecraft:shulker_shell");
@Nullable public static final ItemType SHULKER_SPAWN_EGG = get("minecraft:shulker_spawn_egg"); @Nullable public static final ItemType SHULKER_SPAWN_EGG = get("minecraft:shulker_spawn_egg");
@Deprecated @Nullable public static final ItemType SIGN = Optional.ofNullable(get("minecraft:sign")).orElseGet(() -> get("minecraft:oak_sign")); @Deprecated @Nullable public static final ItemType SIGN = Optional.ofNullable(get("minecraft:sign")).orElseGet(() -> (get("minecraft:oak_sign")));
@Nullable public static final ItemType SILVERFISH_SPAWN_EGG = get("minecraft:silverfish_spawn_egg"); @Nullable public static final ItemType SILVERFISH_SPAWN_EGG = get("minecraft:silverfish_spawn_egg");
@Nullable public static final ItemType SKELETON_HORSE_SPAWN_EGG = get("minecraft:skeleton_horse_spawn_egg"); @Nullable public static final ItemType SKELETON_HORSE_SPAWN_EGG = get("minecraft:skeleton_horse_spawn_egg");
@Nullable public static final ItemType SKELETON_SKULL = get("minecraft:skeleton_skull"); @Nullable public static final ItemType SKELETON_SKULL = get("minecraft:skeleton_skull");
@ -929,7 +929,7 @@ public final class ItemTypes {
return get(input); return get(input);
} }
public static @Nullable ItemType get(String id) { public static @Nullable ItemType get(final String id) {
return ItemType.REGISTRY.get(id); return ItemType.REGISTRY.get(id);
} }