geforkt von Mirrors/FastAsyncWorldEdit
category changes
Dieser Commit ist enthalten in:
Ursprung
e1c2ea3a3b
Commit
70208c38fd
@ -41,13 +41,13 @@ public final class Blocks {
|
|||||||
*/
|
*/
|
||||||
private static final Set<BlockType> shouldPlaceLast = new HashSet<>();
|
private static final Set<BlockType> shouldPlaceLast = new HashSet<>();
|
||||||
static {
|
static {
|
||||||
shouldPlaceLast.addAll(BlockCategories.SAPLINGS.getBlockTypes());
|
shouldPlaceLast.addAll(BlockCategories.SAPLINGS.getAll());
|
||||||
shouldPlaceLast.addAll(BlockCategories.FLOWER_POTS.getBlockTypes());
|
shouldPlaceLast.addAll(BlockCategories.FLOWER_POTS.getAll());
|
||||||
shouldPlaceLast.addAll(BlockCategories.BUTTONS.getBlockTypes());
|
shouldPlaceLast.addAll(BlockCategories.BUTTONS.getAll());
|
||||||
shouldPlaceLast.addAll(BlockCategories.ANVIL.getBlockTypes()); // becomes relevant with asynchronous placement
|
shouldPlaceLast.addAll(BlockCategories.ANVIL.getAll()); // becomes relevant with asynchronous placement
|
||||||
shouldPlaceLast.addAll(BlockCategories.WOODEN_PRESSURE_PLATES.getBlockTypes());
|
shouldPlaceLast.addAll(BlockCategories.WOODEN_PRESSURE_PLATES.getAll());
|
||||||
shouldPlaceLast.addAll(BlockCategories.CARPETS.getBlockTypes());
|
shouldPlaceLast.addAll(BlockCategories.CARPETS.getAll());
|
||||||
shouldPlaceLast.addAll(BlockCategories.RAILS.getBlockTypes());
|
shouldPlaceLast.addAll(BlockCategories.RAILS.getAll());
|
||||||
shouldPlaceLast.add(BlockTypes.BLACK_BED);
|
shouldPlaceLast.add(BlockTypes.BLACK_BED);
|
||||||
shouldPlaceLast.add(BlockTypes.BLUE_BED);
|
shouldPlaceLast.add(BlockTypes.BLUE_BED);
|
||||||
shouldPlaceLast.add(BlockTypes.BROWN_BED);
|
shouldPlaceLast.add(BlockTypes.BROWN_BED);
|
||||||
@ -128,8 +128,8 @@ public final class Blocks {
|
|||||||
*/
|
*/
|
||||||
private static final Set<BlockType> shouldPlaceFinal = new HashSet<>();
|
private static final Set<BlockType> shouldPlaceFinal = new HashSet<>();
|
||||||
static {
|
static {
|
||||||
shouldPlaceFinal.addAll(BlockCategories.DOORS.getBlockTypes());
|
shouldPlaceFinal.addAll(BlockCategories.DOORS.getAll());
|
||||||
shouldPlaceFinal.addAll(BlockCategories.BANNERS.getBlockTypes());
|
shouldPlaceFinal.addAll(BlockCategories.BANNERS.getAll());
|
||||||
shouldPlaceFinal.add(BlockTypes.SIGN);
|
shouldPlaceFinal.add(BlockTypes.SIGN);
|
||||||
shouldPlaceFinal.add(BlockTypes.WALL_SIGN);
|
shouldPlaceFinal.add(BlockTypes.WALL_SIGN);
|
||||||
shouldPlaceFinal.add(BlockTypes.CACTUS);
|
shouldPlaceFinal.add(BlockTypes.CACTUS);
|
||||||
|
@ -186,7 +186,7 @@ public class GeneralCommands {
|
|||||||
|
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
for (ItemType searchType : ItemTypes.values()) {
|
for (ItemType searchType : ItemType.REGISTRY) {
|
||||||
if (found >= 15) {
|
if (found >= 15) {
|
||||||
actor.print("Too many results!");
|
actor.print("Too many results!");
|
||||||
break;
|
break;
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.registry;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public abstract class Category<T> {
|
||||||
|
private final Set<T> set = new HashSet<>();
|
||||||
|
protected final String id;
|
||||||
|
private boolean empty = true;
|
||||||
|
|
||||||
|
protected Category(final String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Set<T> getAll() {
|
||||||
|
if (this.empty) {
|
||||||
|
this.set.addAll(this.load());
|
||||||
|
this.empty = false;
|
||||||
|
}
|
||||||
|
return this.set;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Set<T> load();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this category contains {@code object}.
|
||||||
|
*
|
||||||
|
* @param object the object
|
||||||
|
* @return {@code true} if this category contains the object
|
||||||
|
*/
|
||||||
|
public boolean contains(final T object) {
|
||||||
|
return this.getAll().contains(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invalidateCache() {
|
||||||
|
this.set.clear();
|
||||||
|
this.empty = true;
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.registry;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -30,9 +31,14 @@ import javax.annotation.Nullable;
|
|||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
public final class NamespacedRegistry<V> {
|
public final class NamespacedRegistry<V> implements Iterable<V> {
|
||||||
private static final String MINECRAFT_NAMESPACE = "minecraft";
|
private static final String MINECRAFT_NAMESPACE = "minecraft";
|
||||||
private final Map<String, V> map = new HashMap<>();
|
private final Map<String, V> map = new HashMap<>();
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public NamespacedRegistry(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable V get(final String key) {
|
public @Nullable V get(final String key) {
|
||||||
checkState(key.equals(key.toLowerCase()), "key must be lowercase");
|
checkState(key.equals(key.toLowerCase()), "key must be lowercase");
|
||||||
@ -44,7 +50,7 @@ public final class NamespacedRegistry<V> {
|
|||||||
requireNonNull(value, "value");
|
requireNonNull(value, "value");
|
||||||
checkState(key.indexOf(':') > -1, "key is not namespaced");
|
checkState(key.indexOf(':') > -1, "key is not namespaced");
|
||||||
checkState(key.equals(key.toLowerCase()), "key must be lowercase");
|
checkState(key.equals(key.toLowerCase()), "key must be lowercase");
|
||||||
checkState(!this.map.containsKey(key), "key %s already has an entry", key);
|
checkState(!this.map.containsKey(key), "key '%s' already has an associated %s", key, this.name);
|
||||||
this.map.put(key, value);
|
this.map.put(key, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -63,4 +69,9 @@ public final class NamespacedRegistry<V> {
|
|||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<V> iterator() {
|
||||||
|
return this.map.values().iterator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,20 +19,12 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.block;
|
package com.sk89q.worldedit.world.block;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a list of categories of Block Types.
|
* Stores a list of categories of Block Types.
|
||||||
*/
|
*/
|
||||||
public class BlockCategories {
|
public final class BlockCategories {
|
||||||
|
|
||||||
private BlockCategories() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final BlockCategory ACACIA_LOGS = register("minecraft:acacia_logs");
|
public static final BlockCategory ACACIA_LOGS = register("minecraft:acacia_logs");
|
||||||
public static final BlockCategory ANVIL = register("minecraft:anvil");
|
public static final BlockCategory ANVIL = register("minecraft:anvil");
|
||||||
@ -67,6 +59,9 @@ public class BlockCategories {
|
|||||||
public static final BlockCategory WOODEN_STAIRS = register("minecraft:wooden_stairs");
|
public static final BlockCategory WOODEN_STAIRS = register("minecraft:wooden_stairs");
|
||||||
public static final BlockCategory WOOL = register("minecraft:wool");
|
public static final BlockCategory WOOL = register("minecraft:wool");
|
||||||
|
|
||||||
|
private BlockCategories() {
|
||||||
|
}
|
||||||
|
|
||||||
private static BlockCategory register(final String id) {
|
private static BlockCategory register(final String id) {
|
||||||
return register(new BlockCategory(id));
|
return register(new BlockCategory(id));
|
||||||
}
|
}
|
||||||
@ -75,12 +70,7 @@ public class BlockCategories {
|
|||||||
return BlockCategory.REGISTRY.register(tag.getId(), tag);
|
return BlockCategory.REGISTRY.register(tag.getId(), tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable BlockCategory get(final String id) {
|
||||||
public static BlockCategory get(final String id) {
|
|
||||||
return BlockCategory.REGISTRY.get(id);
|
return BlockCategory.REGISTRY.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<BlockCategory> values() {
|
|
||||||
return BlockCategory.REGISTRY.values();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.block;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
|
import com.sk89q.worldedit.registry.Category;
|
||||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -29,35 +30,19 @@ import java.util.Set;
|
|||||||
* A category of blocks. This is due to the splitting up of
|
* A category of blocks. This is due to the splitting up of
|
||||||
* blocks such as wool into separate ids.
|
* blocks such as wool into separate ids.
|
||||||
*/
|
*/
|
||||||
public class BlockCategory {
|
public class BlockCategory extends Category<BlockType> {
|
||||||
|
|
||||||
public static final NamespacedRegistry<BlockCategory> REGISTRY = new NamespacedRegistry<>();
|
public static final NamespacedRegistry<BlockCategory> REGISTRY = new NamespacedRegistry<>("block tag");
|
||||||
|
|
||||||
private final String id;
|
public BlockCategory(final String id) {
|
||||||
|
super(id);
|
||||||
public BlockCategory(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
@Override
|
||||||
return this.id;
|
protected Set<BlockType> load() {
|
||||||
}
|
|
||||||
|
|
||||||
public Set<BlockType> getBlockTypes() {
|
|
||||||
return WorldEdit.getInstance().getPlatformManager()
|
return WorldEdit.getInstance().getPlatformManager()
|
||||||
.queryCapability(Capability.GAME_HOOKS).getRegistries()
|
.queryCapability(Capability.GAME_HOOKS).getRegistries()
|
||||||
.getBlockCategoryRegistry().getCategorisedByName(this.id);
|
.getBlockCategoryRegistry().getAll(this);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the BlocKType is contained within
|
|
||||||
* this category.
|
|
||||||
*
|
|
||||||
* @param blockType The blocktype
|
|
||||||
* @return If it's a part of this category
|
|
||||||
*/
|
|
||||||
public boolean contains(BlockType blockType) {
|
|
||||||
return getBlockTypes().contains(blockType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,6 +53,6 @@ public class BlockCategory {
|
|||||||
* @return If it's a part of this category
|
* @return If it's a part of this category
|
||||||
*/
|
*/
|
||||||
public boolean contains(BlockStateHolder blockStateHolder) {
|
public boolean contains(BlockStateHolder blockStateHolder) {
|
||||||
return getBlockTypes().contains(blockStateHolder.getBlockType());
|
return this.getAll().contains(blockStateHolder.getBlockType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class BlockType {
|
public class BlockType {
|
||||||
|
|
||||||
public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>();
|
public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type");
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private BlockState defaultState;
|
private BlockState defaultState;
|
||||||
|
@ -19,17 +19,12 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.block;
|
package com.sk89q.worldedit.world.block;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a list of common Block String IDs.
|
* Stores a list of common Block String IDs.
|
||||||
*/
|
*/
|
||||||
public class BlockTypes {
|
public final class BlockTypes {
|
||||||
|
|
||||||
private BlockTypes() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final BlockType ACACIA_BARK = register("minecraft:acacia_bark");
|
public static final BlockType ACACIA_BARK = register("minecraft:acacia_bark");
|
||||||
public static final BlockType ACACIA_BUTTON = register("minecraft:acacia_button");
|
public static final BlockType ACACIA_BUTTON = register("minecraft:acacia_button");
|
||||||
@ -604,6 +599,9 @@ public class BlockTypes {
|
|||||||
public static final BlockType ZOMBIE_HEAD = register("minecraft:zombie_head");
|
public static final BlockType ZOMBIE_HEAD = register("minecraft:zombie_head");
|
||||||
public static final BlockType ZOMBIE_WALL_HEAD = register("minecraft:zombie_wall_head");
|
public static final BlockType ZOMBIE_WALL_HEAD = register("minecraft:zombie_wall_head");
|
||||||
|
|
||||||
|
private BlockTypes() {
|
||||||
|
}
|
||||||
|
|
||||||
private static BlockType register(final String id) {
|
private static BlockType register(final String id) {
|
||||||
return register(new BlockType(id));
|
return register(new BlockType(id));
|
||||||
}
|
}
|
||||||
@ -612,12 +610,7 @@ public class BlockTypes {
|
|||||||
return BlockType.REGISTRY.register(block.getId(), block);
|
return BlockType.REGISTRY.register(block.getId(), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable BlockType get(final String id) {
|
||||||
public static BlockType get(final String id) {
|
|
||||||
return BlockType.REGISTRY.get(id);
|
return BlockType.REGISTRY.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<BlockType> values() {
|
|
||||||
return BlockType.REGISTRY.values();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,21 +19,19 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.fluid;
|
package com.sk89q.worldedit.world.fluid;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a list of categories of Block Types.
|
* Stores a list of categories of Block Types.
|
||||||
*/
|
*/
|
||||||
public class FluidCategories {
|
public final class FluidCategories {
|
||||||
|
|
||||||
private FluidCategories() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final FluidCategory LAVA = register("minecraft:lava");
|
public static final FluidCategory LAVA = register("minecraft:lava");
|
||||||
public static final FluidCategory WATER = register("minecraft:water");
|
public static final FluidCategory WATER = register("minecraft:water");
|
||||||
|
|
||||||
|
private FluidCategories() {
|
||||||
|
}
|
||||||
|
|
||||||
private static FluidCategory register(final String id) {
|
private static FluidCategory register(final String id) {
|
||||||
return register(new FluidCategory(id));
|
return register(new FluidCategory(id));
|
||||||
}
|
}
|
||||||
@ -42,12 +40,7 @@ public class FluidCategories {
|
|||||||
return FluidCategory.REGISTRY.register(tag.getId(), tag);
|
return FluidCategory.REGISTRY.register(tag.getId(), tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable FluidCategory get(final String id) {
|
||||||
public static FluidCategory get(final String id) {
|
|
||||||
return FluidCategory.REGISTRY.get(id);
|
return FluidCategory.REGISTRY.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<FluidCategory> values() {
|
|
||||||
return FluidCategory.REGISTRY.values();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.fluid;
|
package com.sk89q.worldedit.world.fluid;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.registry.Category;
|
||||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -28,35 +29,19 @@ import java.util.Set;
|
|||||||
* A category of fluids. This is due to the splitting up of
|
* A category of fluids. This is due to the splitting up of
|
||||||
* blocks such as wool into separate ids.
|
* blocks such as wool into separate ids.
|
||||||
*/
|
*/
|
||||||
public class FluidCategory {
|
public class FluidCategory extends Category<FluidType> {
|
||||||
|
|
||||||
public static final NamespacedRegistry<FluidCategory> REGISTRY = new NamespacedRegistry<>();
|
public static final NamespacedRegistry<FluidCategory> REGISTRY = new NamespacedRegistry<>("fluid tag");
|
||||||
|
|
||||||
private final String id;
|
public FluidCategory(final String id) {
|
||||||
|
super(id);
|
||||||
public FluidCategory(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
@Override
|
||||||
return this.id;
|
protected Set<FluidType> load() {
|
||||||
}
|
|
||||||
|
|
||||||
public Set<FluidType> getFluidTypes() {
|
|
||||||
return Collections.emptySet(); // TODO Make this work.
|
return Collections.emptySet(); // TODO Make this work.
|
||||||
// return WorldEdit.getInstance().getPlatformManager()
|
// return WorldEdit.getInstance().getPlatformManager()
|
||||||
// .queryCapability(Capability.GAME_HOOKS).getRegistries()
|
// .queryCapability(Capability.GAME_HOOKS).getRegistries()
|
||||||
// .getBlockCategoryRegistry().getCategorisedByName(this.id);
|
// .getBlockCategoryRegistry().getCategorisedByName(this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the FluidType is contained within
|
|
||||||
* this category.
|
|
||||||
*
|
|
||||||
* @param fluidType The fluidType
|
|
||||||
* @return If it's a part of this category
|
|
||||||
*/
|
|
||||||
public boolean contains(FluidType fluidType) {
|
|
||||||
return getFluidTypes().contains(fluidType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import com.sk89q.worldedit.registry.NamespacedRegistry;
|
|||||||
*/
|
*/
|
||||||
public class FluidType {
|
public class FluidType {
|
||||||
|
|
||||||
public static final NamespacedRegistry<FluidType> REGISTRY = new NamespacedRegistry<>();
|
public static final NamespacedRegistry<FluidType> REGISTRY = new NamespacedRegistry<>("fluid type");
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ -19,17 +19,12 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.fluid;
|
package com.sk89q.worldedit.world.fluid;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a list of common Fluid String IDs.
|
* Stores a list of common Fluid String IDs.
|
||||||
*/
|
*/
|
||||||
public class FluidTypes {
|
public final class FluidTypes {
|
||||||
|
|
||||||
private FluidTypes() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final FluidType EMPTY = register("minecraft:empty");
|
public static final FluidType EMPTY = register("minecraft:empty");
|
||||||
public static final FluidType FLOWING_LAVA = register("minecraft:flowing_lava");
|
public static final FluidType FLOWING_LAVA = register("minecraft:flowing_lava");
|
||||||
@ -37,6 +32,9 @@ public class FluidTypes {
|
|||||||
public static final FluidType LAVA = register("minecraft:lava");
|
public static final FluidType LAVA = register("minecraft:lava");
|
||||||
public static final FluidType WATER = register("minecraft:water");
|
public static final FluidType WATER = register("minecraft:water");
|
||||||
|
|
||||||
|
private FluidTypes() {
|
||||||
|
}
|
||||||
|
|
||||||
private static FluidType register(final String id) {
|
private static FluidType register(final String id) {
|
||||||
return register(new FluidType(id));
|
return register(new FluidType(id));
|
||||||
}
|
}
|
||||||
@ -45,12 +43,7 @@ public class FluidTypes {
|
|||||||
return FluidType.REGISTRY.register(fluid.getId(), fluid);
|
return FluidType.REGISTRY.register(fluid.getId(), fluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable FluidType get(final String id) {
|
||||||
public static FluidType getFluidType(final String id) {
|
|
||||||
return FluidType.REGISTRY.get(id);
|
return FluidType.REGISTRY.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<FluidType> values() {
|
|
||||||
return FluidType.REGISTRY.values();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,20 +19,12 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.item;
|
package com.sk89q.worldedit.world.item;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a list of categories of Item Types.
|
* Stores a list of categories of Item Types.
|
||||||
*/
|
*/
|
||||||
public class ItemCategories {
|
public final class ItemCategories {
|
||||||
|
|
||||||
private ItemCategories() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ItemCategory ACACIA_LOGS = register("minecraft:acacia_logs");
|
public static final ItemCategory ACACIA_LOGS = register("minecraft:acacia_logs");
|
||||||
public static final ItemCategory ANVIL = register("minecraft:anvil");
|
public static final ItemCategory ANVIL = register("minecraft:anvil");
|
||||||
@ -65,6 +57,9 @@ public class ItemCategories {
|
|||||||
public static final ItemCategory WOODEN_STAIRS = register("minecraft:wooden_stairs");
|
public static final ItemCategory WOODEN_STAIRS = register("minecraft:wooden_stairs");
|
||||||
public static final ItemCategory WOOL = register("minecraft:wool");
|
public static final ItemCategory WOOL = register("minecraft:wool");
|
||||||
|
|
||||||
|
private ItemCategories() {
|
||||||
|
}
|
||||||
|
|
||||||
private static ItemCategory register(final String id) {
|
private static ItemCategory register(final String id) {
|
||||||
return register(new ItemCategory(id));
|
return register(new ItemCategory(id));
|
||||||
}
|
}
|
||||||
@ -73,12 +68,7 @@ public class ItemCategories {
|
|||||||
return ItemCategory.REGISTRY.register(tag.getId(), tag);
|
return ItemCategory.REGISTRY.register(tag.getId(), tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable ItemCategory get(final String id) {
|
||||||
public static ItemCategory get(final String id) {
|
|
||||||
return ItemCategory.REGISTRY.get(id);
|
return ItemCategory.REGISTRY.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<ItemCategory> values() {
|
|
||||||
return ItemCategory.REGISTRY.values();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.world.item;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
|
import com.sk89q.worldedit.registry.Category;
|
||||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -30,35 +31,19 @@ import java.util.Set;
|
|||||||
* A category of items. This is due to the splitting up of
|
* A category of items. This is due to the splitting up of
|
||||||
* items such as wool into separate ids.
|
* items such as wool into separate ids.
|
||||||
*/
|
*/
|
||||||
public class ItemCategory {
|
public class ItemCategory extends Category<ItemType> {
|
||||||
|
|
||||||
public static final NamespacedRegistry<ItemCategory> REGISTRY = new NamespacedRegistry<>();
|
public static final NamespacedRegistry<ItemCategory> REGISTRY = new NamespacedRegistry<>("item tag");
|
||||||
|
|
||||||
private final String id;
|
public ItemCategory(final String id) {
|
||||||
|
super(id);
|
||||||
public ItemCategory(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
@Override
|
||||||
return this.id;
|
protected Set<ItemType> load() {
|
||||||
}
|
|
||||||
|
|
||||||
public Set<ItemType> getItemTypes() {
|
|
||||||
return WorldEdit.getInstance().getPlatformManager()
|
return WorldEdit.getInstance().getPlatformManager()
|
||||||
.queryCapability(Capability.GAME_HOOKS).getRegistries()
|
.queryCapability(Capability.GAME_HOOKS).getRegistries()
|
||||||
.getItemCategoryRegistry().getCategorisedByName(this.id);
|
.getItemCategoryRegistry().getAll(this);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the ItemType is contained within
|
|
||||||
* this category.
|
|
||||||
*
|
|
||||||
* @param itemType The itemType
|
|
||||||
* @return If it's a part of this category
|
|
||||||
*/
|
|
||||||
public boolean contains(ItemType itemType) {
|
|
||||||
return getItemTypes().contains(itemType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,6 +54,6 @@ public class ItemCategory {
|
|||||||
* @return If it's a part of this category
|
* @return If it's a part of this category
|
||||||
*/
|
*/
|
||||||
public boolean contains(BaseItem baseItem) {
|
public boolean contains(BaseItem baseItem) {
|
||||||
return getItemTypes().contains(baseItem.getType());
|
return this.getAll().contains(baseItem.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class ItemType {
|
public class ItemType {
|
||||||
|
|
||||||
public static final NamespacedRegistry<ItemType> REGISTRY = new NamespacedRegistry<>();
|
public static final NamespacedRegistry<ItemType> REGISTRY = new NamespacedRegistry<>("item type");
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ -19,17 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.item;
|
package com.sk89q.worldedit.world.item;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ItemTypes {
|
public final class ItemTypes {
|
||||||
|
|
||||||
private ItemTypes() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ItemType ACACIA_BARK = register("minecraft:acacia_bark");
|
public static final ItemType ACACIA_BARK = register("minecraft:acacia_bark");
|
||||||
public static final ItemType ACACIA_BOAT = register("minecraft:acacia_boat");
|
public static final ItemType ACACIA_BOAT = register("minecraft:acacia_boat");
|
||||||
@ -743,6 +735,9 @@ public class ItemTypes {
|
|||||||
public static final ItemType ZOMBIE_SPAWN_EGG = register("minecraft:zombie_spawn_egg");
|
public static final ItemType ZOMBIE_SPAWN_EGG = register("minecraft:zombie_spawn_egg");
|
||||||
public static final ItemType ZOMBIE_VILLAGER_SPAWN_EGG = register("minecraft:zombie_villager_spawn_egg");
|
public static final ItemType ZOMBIE_VILLAGER_SPAWN_EGG = register("minecraft:zombie_villager_spawn_egg");
|
||||||
|
|
||||||
|
private ItemTypes() {
|
||||||
|
}
|
||||||
|
|
||||||
private static ItemType register(final String id) {
|
private static ItemType register(final String id) {
|
||||||
return register(new ItemType(id));
|
return register(new ItemType(id));
|
||||||
}
|
}
|
||||||
@ -751,12 +746,7 @@ public class ItemTypes {
|
|||||||
return ItemType.REGISTRY.register(item.getId(), item);
|
return ItemType.REGISTRY.register(item.getId(), item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public static @Nullable ItemType get(final String id) {
|
||||||
public static ItemType get(final String id) {
|
|
||||||
return ItemType.REGISTRY.get(id);
|
return ItemType.REGISTRY.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<ItemType> values() {
|
|
||||||
return ItemType.REGISTRY.values();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.registry;
|
package com.sk89q.worldedit.world.registry;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.registry.Category;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +36,8 @@ public interface CategoryRegistry<T> {
|
|||||||
*/
|
*/
|
||||||
Set<T> getCategorisedByName(String category);
|
Set<T> getCategorisedByName(String category);
|
||||||
|
|
||||||
|
Set<T> getAll(final Category<T> category);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of categories given to a value.
|
* Gets a list of categories given to a value.
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.registry;
|
package com.sk89q.worldedit.world.registry;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.registry.Category;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -31,6 +32,11 @@ public class NullBlockCategoryRegistry implements BlockCategoryRegistry {
|
|||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<BlockType> getAll(final Category<BlockType> category) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getCategories(BlockType categorised) {
|
public Set<String> getCategories(BlockType categorised) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.registry;
|
package com.sk89q.worldedit.world.registry;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.registry.Category;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -31,6 +32,11 @@ public class NullItemCategoryRegistry implements ItemCategoryRegistry {
|
|||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<ItemType> getAll(final Category<ItemType> category) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getCategories(ItemType categorised) {
|
public Set<String> getCategories(ItemType categorised) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren