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

@ -64,8 +64,10 @@ public class DefaultItemParser extends InputParser<BaseItem> {
}
if (item == null) {
item = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getItemRegistry().createFromId(input.toLowerCase());
ItemType type = ItemTypes.get(input.toLowerCase());
if (type != null) {
item = new BaseItem(type);
}
}
if (item == null) {

View File

@ -0,0 +1,61 @@
/*
* 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.extension.factory.parser.mask;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Set;
/**
* Parses mask input strings.
*/
public class BlocksMaskParser extends InputParser<Mask> {
public BlocksMaskParser(WorldEdit worldEdit) {
super(worldEdit);
}
public Mask parseFromInput(String component, ParserContext context) throws InputParseException {
Extent extent = Request.request().getEditSession();
ParserContext tempContext = new ParserContext(context);
tempContext.setRestricted(false);
tempContext.setPreferringWildcard(true);
try {
Set<BlockStateHolder> holders = worldEdit.getBlockFactory().parseFromListInput(component, tempContext);
if (holders.isEmpty()) {
return null;
}
return new BlockMask(extent, holders);
} catch (NoMatchException e) {
return null;
}
}
}