mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 12:06:41 +00:00
Added a category system and refactored registries
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
|
||||
/**
|
||||
* A registry for BlockType categories.
|
||||
*/
|
||||
public interface BlockCategoryRegistry extends CategoryRegistry<BlockType> {
|
||||
|
||||
}
|
@ -20,21 +20,23 @@
|
||||
package com.sk89q.worldedit.world.registry;
|
||||
|
||||
/**
|
||||
* An implementation of {@link WorldData} that converts legacy numeric IDs and
|
||||
* An implementation of {@link Registries} that converts legacy numeric IDs and
|
||||
* a contains a built-in block and item database.
|
||||
*/
|
||||
public class BundledWorldData implements WorldData {
|
||||
public class BundledRegistries implements Registries {
|
||||
|
||||
private static final BundledWorldData INSTANCE = new BundledWorldData();
|
||||
private static final BundledRegistries INSTANCE = new BundledRegistries();
|
||||
private final BundledBlockRegistry blockRegistry = new BundledBlockRegistry();
|
||||
private final BundledItemRegistry itemRegistry = new BundledItemRegistry();
|
||||
private final NullEntityRegistry entityRegistry = new NullEntityRegistry();
|
||||
private final NullBiomeRegistry biomeRegistry = new NullBiomeRegistry();
|
||||
private final NullBlockCategoryRegistry blockCategoryRegistry = new NullBlockCategoryRegistry();
|
||||
private final NullItemCategoryRegistry itemCategoryRegistry = new NullItemCategoryRegistry();
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
protected BundledWorldData() {
|
||||
protected BundledRegistries() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,12 +59,22 @@ public class BundledWorldData implements WorldData {
|
||||
return biomeRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCategoryRegistry getBlockCategoryRegistry() {
|
||||
return blockCategoryRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCategoryRegistry getItemCategoryRegistry() {
|
||||
return itemCategoryRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a singleton instance.
|
||||
*
|
||||
* @return an instance
|
||||
*/
|
||||
public static BundledWorldData getInstance() {
|
||||
public static BundledRegistries getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.world.registry;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A registry of categories. Minecraft internally calls these 'Tags'.
|
||||
*/
|
||||
public interface CategoryRegistry<T> {
|
||||
|
||||
/**
|
||||
* Gets a set of values with a given category.
|
||||
*
|
||||
* @param category The category
|
||||
* @return A set of values
|
||||
*/
|
||||
Set<T> getCategorisedByName(String category);
|
||||
|
||||
/**
|
||||
* Gets a list of categories given to a value.
|
||||
*
|
||||
* @param categorised The value
|
||||
* @return A set of categories
|
||||
*/
|
||||
Set<String> getCategories(T categorised);
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.type.ItemType;
|
||||
|
||||
/**
|
||||
* A registry for ItemType categories.
|
||||
*/
|
||||
public interface ItemCategoryRegistry extends CategoryRegistry<ItemType> {
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class NullBlockCategoryRegistry implements BlockCategoryRegistry {
|
||||
|
||||
@Override
|
||||
public Set<BlockType> getCategorisedByName(String category) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCategories(BlockType categorised) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.type.ItemType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class NullItemCategoryRegistry implements ItemCategoryRegistry {
|
||||
|
||||
@Override
|
||||
public Set<ItemType> getCategorisedByName(String category) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCategories(ItemType categorised) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
@ -20,10 +20,9 @@
|
||||
package com.sk89q.worldedit.world.registry;
|
||||
|
||||
/**
|
||||
* Describes the necessary data for blocks, entities, and other objects
|
||||
* on a world.
|
||||
* Contains getters for the various registries.
|
||||
*/
|
||||
public interface WorldData {
|
||||
public interface Registries {
|
||||
|
||||
/**
|
||||
* Get the block registry.
|
||||
@ -53,4 +52,18 @@ public interface WorldData {
|
||||
*/
|
||||
BiomeRegistry getBiomeRegistry();
|
||||
|
||||
/**
|
||||
* Get the block category registry.
|
||||
*
|
||||
* @return the block category registry
|
||||
*/
|
||||
BlockCategoryRegistry getBlockCategoryRegistry();
|
||||
|
||||
/**
|
||||
* Get the item category registry.
|
||||
*
|
||||
* @return the item category registry
|
||||
*/
|
||||
ItemCategoryRegistry getItemCategoryRegistry();
|
||||
|
||||
}
|
Reference in New Issue
Block a user