mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 04:28:34 +00:00
Further BaseBlock modernisation
This commit is contained in:
@ -125,7 +125,7 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
return blockInHand;
|
||||
}
|
||||
|
||||
blockType = blockInHand.getType();
|
||||
blockType = blockInHand.getBlockType();
|
||||
blockStates = blockInHand.getStates();
|
||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the item in the user's off hand.
|
||||
@ -134,7 +134,7 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
return blockInHand;
|
||||
}
|
||||
|
||||
blockType = blockInHand.getType();
|
||||
blockType = blockInHand.getBlockType();
|
||||
blockStates = blockInHand.getStates();
|
||||
} else if ("pos1".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the "primary position"
|
||||
@ -150,7 +150,7 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
return blockInHand;
|
||||
}
|
||||
|
||||
blockType = blockInHand.getType();
|
||||
blockType = blockInHand.getBlockType();
|
||||
blockStates = blockInHand.getStates();
|
||||
} else {
|
||||
// Attempt to lookup a block from ID or name.
|
||||
|
@ -33,45 +33,11 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
|
||||
@Override
|
||||
public BaseItem parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
String[] tokens = input.split(":", 3);
|
||||
BaseItem item;
|
||||
short damage = 0;
|
||||
|
||||
try {
|
||||
int id = Integer.parseInt(tokens[0]);
|
||||
|
||||
// Parse metadata
|
||||
if (tokens.length == 2) {
|
||||
try {
|
||||
damage = Short.parseShort(tokens[1]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
throw new InputParseException("Expected '" + tokens[1] + "' to be a damage value but it's not a number");
|
||||
}
|
||||
}
|
||||
|
||||
item = context.requireWorld().getWorldData().getItemRegistry().createFromId(id);
|
||||
} catch (NumberFormatException e) {
|
||||
String name = tokens[0];
|
||||
if (input.length() >= 2) {
|
||||
name += ":" + tokens[1];
|
||||
}
|
||||
|
||||
// Parse metadata
|
||||
if (tokens.length == 3) {
|
||||
try {
|
||||
damage = Short.parseShort(tokens[2]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
throw new InputParseException("Expected '" + tokens[2] + "' to be a damage value but it's not a number");
|
||||
}
|
||||
}
|
||||
|
||||
item = context.requireWorld().getWorldData().getItemRegistry().createFromId(name);
|
||||
}
|
||||
BaseItem item = context.requireWorld().getWorldData().getItemRegistry().createFromId(input);
|
||||
|
||||
if (item == null) {
|
||||
throw new InputParseException("'" + input + "' did not match any item");
|
||||
} else {
|
||||
item.setDamage(damage);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user