mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Small changes
This commit is contained in:
@ -56,6 +56,7 @@ import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Parses block input strings.
|
||||
@ -112,8 +113,9 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
* @param string Input string
|
||||
* @return Mapped string
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private String woolMapper(String string) {
|
||||
switch (string.toLowerCase()) {
|
||||
switch (string.toLowerCase(Locale.ROOT)) {
|
||||
case "white":
|
||||
return BlockTypes.WHITE_WOOL.getId();
|
||||
case "black":
|
||||
|
@ -21,13 +21,19 @@ package com.sk89q.worldedit.extension.factory.parser;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
|
||||
public DefaultItemParser(WorldEdit worldEdit) {
|
||||
@ -42,18 +48,22 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
try {
|
||||
String[] split = input.split(":");
|
||||
ItemType type;
|
||||
if (split.length == 1) {
|
||||
if (split.length == 0) {
|
||||
throw new InputParseException("Invalid colon.");
|
||||
} else if (split.length == 1) {
|
||||
type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]));
|
||||
} else {
|
||||
type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
}
|
||||
item = new BaseItem(type);
|
||||
} catch (NumberFormatException e) {
|
||||
if (type != null) {
|
||||
item = new BaseItem(type);
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
ItemType type = ItemTypes.get(input.toLowerCase());
|
||||
ItemType type = ItemTypes.get(input.toLowerCase(Locale.ROOT));
|
||||
if (type != null) {
|
||||
item = new BaseItem(type);
|
||||
}
|
||||
@ -66,4 +76,11 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
}
|
||||
}
|
||||
|
||||
private BaseItemStack getItemInHand(Actor actor, HandSide handSide) throws InputParseException {
|
||||
if (actor instanceof Player) {
|
||||
return ((Player) actor).getItemInHand(handSide);
|
||||
} else {
|
||||
throw new InputParseException("The user is not a player!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user