geforkt von Mirrors/FastAsyncWorldEdit
Reduced indentation level in some methods in WorldEdit.java and made WorldEdit.getBlock less confusing.
Dieser Commit ist enthalten in:
Ursprung
3acc82e97b
Commit
8dbabe344d
@ -391,10 +391,13 @@ public class WorldEdit {
|
|||||||
String[] blockAndExtraData = arg.split("\\|");
|
String[] blockAndExtraData = arg.split("\\|");
|
||||||
String[] typeAndData = blockAndExtraData[0].split(":", 2);
|
String[] typeAndData = blockAndExtraData[0].split(":", 2);
|
||||||
String testID = typeAndData[0];
|
String testID = typeAndData[0];
|
||||||
|
|
||||||
int blockId = -1;
|
int blockId = -1;
|
||||||
|
|
||||||
int data = -1;
|
int data = -1;
|
||||||
|
|
||||||
|
boolean parseDataValue = true;
|
||||||
|
|
||||||
// Attempt to parse the item ID or otherwise resolve an item/block
|
// Attempt to parse the item ID or otherwise resolve an item/block
|
||||||
// name to its numeric ID
|
// name to its numeric ID
|
||||||
try {
|
try {
|
||||||
@ -414,13 +417,15 @@ public class WorldEdit {
|
|||||||
if (blockId == -1 && blockType == null) {
|
if (blockId == -1 && blockType == null) {
|
||||||
// Maybe it's a cloth
|
// Maybe it's a cloth
|
||||||
ClothColor col = ClothColor.lookup(testID);
|
ClothColor col = ClothColor.lookup(testID);
|
||||||
|
if (col == null) {
|
||||||
if (col != null) {
|
|
||||||
blockType = BlockType.CLOTH;
|
|
||||||
data = col.getID();
|
|
||||||
} else {
|
|
||||||
throw new UnknownItemException(arg);
|
throw new UnknownItemException(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockType = BlockType.CLOTH;
|
||||||
|
data = col.getID();
|
||||||
|
|
||||||
|
// Prevent overriding the data value
|
||||||
|
parseDataValue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read block ID
|
// Read block ID
|
||||||
@ -432,33 +437,50 @@ public class WorldEdit {
|
|||||||
throw new UnknownItemException(arg);
|
throw new UnknownItemException(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data == -1) { // Block data not yet detected
|
if (!allowNoData && data == -1) {
|
||||||
|
// No wildcards allowed => eliminate them.
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseDataValue) { // Block data not yet detected
|
||||||
// Parse the block data (optional)
|
// Parse the block data (optional)
|
||||||
try {
|
try {
|
||||||
data = (typeAndData.length > 1 && typeAndData[1].length() > 0) ? Integer.parseInt(typeAndData[1]) : (allowNoData ? -1 : 0);
|
if (typeAndData.length > 1 && typeAndData[1].length() > 0) {
|
||||||
if (data > 15 || (data < 0 && !(allAllowed && data == -1))) {
|
data = Integer.parseInt(typeAndData[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data > 15) {
|
||||||
|
throw new InvalidItemException(arg, "Unknown invalid data value '" + typeAndData[1] + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data < 0 && !(allAllowed && data == -1)) {
|
||||||
data = 0;
|
data = 0;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
if (blockType != null) {
|
if (blockType == null) {
|
||||||
|
throw new InvalidItemException(arg, "Unknown data value '" + typeAndData[1] + "'");
|
||||||
|
}
|
||||||
|
|
||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case CLOTH:
|
case CLOTH:
|
||||||
case STAINED_CLAY:
|
case STAINED_CLAY:
|
||||||
case CARPET:
|
case CARPET:
|
||||||
ClothColor col = ClothColor.lookup(typeAndData[1]);
|
ClothColor col = ClothColor.lookup(typeAndData[1]);
|
||||||
|
if (col == null) {
|
||||||
if (col != null) {
|
|
||||||
data = col.getID();
|
|
||||||
} else {
|
|
||||||
throw new InvalidItemException(arg, "Unknown cloth color '" + typeAndData[1] + "'");
|
throw new InvalidItemException(arg, "Unknown cloth color '" + typeAndData[1] + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data = col.getID();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STEP:
|
case STEP:
|
||||||
case DOUBLE_STEP:
|
case DOUBLE_STEP:
|
||||||
BlockType dataType = BlockType.lookup(typeAndData[1]);
|
BlockType dataType = BlockType.lookup(typeAndData[1]);
|
||||||
|
|
||||||
if (dataType != null) {
|
if (dataType == null) {
|
||||||
|
throw new InvalidItemException(arg, "Unknown step type '" + typeAndData[1] + "'");
|
||||||
|
}
|
||||||
|
|
||||||
switch (dataType) {
|
switch (dataType) {
|
||||||
case STONE:
|
case STONE:
|
||||||
data = 0;
|
data = 0;
|
||||||
@ -488,23 +510,23 @@ public class WorldEdit {
|
|||||||
default:
|
default:
|
||||||
throw new InvalidItemException(arg, "Invalid step type '" + typeAndData[1] + "'");
|
throw new InvalidItemException(arg, "Invalid step type '" + typeAndData[1] + "'");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new InvalidItemException(arg, "Unknown step type '" + typeAndData[1] + "'");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidItemException(arg, "Unknown data value '" + typeAndData[1] + "'");
|
throw new InvalidItemException(arg, "Unknown data value '" + typeAndData[1] + "'");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new InvalidItemException(arg, "Unknown data value '" + typeAndData[1] + "'");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the item is allowed
|
// Check if the item is allowed
|
||||||
if (allAllowed || player.hasPermission("worldedit.anyblock") || !config.disallowedBlocks.contains(blockId)) {
|
if (!allAllowed && !player.hasPermission("worldedit.anyblock") && config.disallowedBlocks.contains(blockId)) {
|
||||||
if (blockType != null) {
|
throw new DisallowedItemException(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockType == null) {
|
||||||
|
return new BaseBlock(blockId, data);
|
||||||
|
}
|
||||||
|
|
||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case SIGN_POST:
|
case SIGN_POST:
|
||||||
case WALL_SIGN:
|
case WALL_SIGN:
|
||||||
@ -536,21 +558,23 @@ public class WorldEdit {
|
|||||||
|
|
||||||
case NOTE_BLOCK:
|
case NOTE_BLOCK:
|
||||||
// Allow setting note
|
// Allow setting note
|
||||||
if (blockAndExtraData.length > 1) {
|
if (blockAndExtraData.length <= 1) {
|
||||||
byte note = Byte.parseByte(blockAndExtraData[1]);
|
|
||||||
if (note < 0 || note > 24) {
|
|
||||||
throw new InvalidItemException(arg, "Out of range note value: '" + blockAndExtraData[1] + "'");
|
|
||||||
} else {
|
|
||||||
return new NoteBlock(data, note);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return new NoteBlock(data, (byte) 0);
|
return new NoteBlock(data, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte note = Byte.parseByte(blockAndExtraData[1]);
|
||||||
|
if (note < 0 || note > 24) {
|
||||||
|
throw new InvalidItemException(arg, "Out of range note value: '" + blockAndExtraData[1] + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NoteBlock(data, note);
|
||||||
|
|
||||||
case HEAD:
|
case HEAD:
|
||||||
// allow setting type/player/rotation
|
// allow setting type/player/rotation
|
||||||
if (blockAndExtraData.length > 1) {
|
if (blockAndExtraData.length <= 1) {
|
||||||
// and thus, the format shall be "|type|rotation" or "|type" or "|rotation"
|
return new SkullBlock(data);
|
||||||
|
}
|
||||||
|
|
||||||
byte rot = 0;
|
byte rot = 0;
|
||||||
String type = "";
|
String type = "";
|
||||||
try {
|
try {
|
||||||
@ -580,19 +604,10 @@ public class WorldEdit {
|
|||||||
} else {
|
} else {
|
||||||
return new SkullBlock(data, skullType, rot);
|
return new SkullBlock(data, skullType, rot);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return new SkullBlock(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new BaseBlock(blockId, data);
|
return new BaseBlock(blockId, data);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return new BaseBlock(blockId, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new DisallowedItemException(arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -646,21 +661,18 @@ public class WorldEdit {
|
|||||||
|
|
||||||
// Handle special block pattern types
|
// Handle special block pattern types
|
||||||
if (patternString.charAt(0) == '#') {
|
if (patternString.charAt(0) == '#') {
|
||||||
if (patternString.equals("#clipboard") || patternString.equals("#copy")) {
|
if (!patternString.equals("#clipboard") && !patternString.equals("#copy")) {
|
||||||
|
throw new UnknownItemException(patternString);
|
||||||
|
}
|
||||||
|
|
||||||
LocalSession session = getSession(player);
|
LocalSession session = getSession(player);
|
||||||
CuboidClipboard clipboard;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
clipboard = session.getClipboard();
|
return new ClipboardPattern(session.getClipboard());
|
||||||
} catch (EmptyClipboardException e) {
|
} catch (EmptyClipboardException e) {
|
||||||
player.printError("Copy a selection first with //copy.");
|
player.printError("Copy a selection first with //copy.");
|
||||||
throw new UnknownItemException("#clipboard");
|
throw new UnknownItemException("#clipboard");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ClipboardPattern(clipboard);
|
|
||||||
} else {
|
|
||||||
throw new UnknownItemException(patternString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's only one block, then just return that single one
|
// If it's only one block, then just return that single one
|
||||||
@ -902,25 +914,25 @@ public class WorldEdit {
|
|||||||
public int getMaximumPolygonalPoints(LocalPlayer player) {
|
public int getMaximumPolygonalPoints(LocalPlayer player) {
|
||||||
if (player.hasPermission("worldedit.limit.unrestricted") || config.maxPolygonalPoints < 0) {
|
if (player.hasPermission("worldedit.limit.unrestricted") || config.maxPolygonalPoints < 0) {
|
||||||
return config.defaultMaxPolygonalPoints;
|
return config.defaultMaxPolygonalPoints;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
if (config.defaultMaxPolygonalPoints < 0) {
|
if (config.defaultMaxPolygonalPoints < 0) {
|
||||||
return config.maxPolygonalPoints;
|
return config.maxPolygonalPoints;
|
||||||
}
|
}
|
||||||
return Math.min(config.defaultMaxPolygonalPoints,
|
|
||||||
config.maxPolygonalPoints);
|
return Math.min(config.defaultMaxPolygonalPoints, config.maxPolygonalPoints);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaximumPolyhedronPoints(LocalPlayer player) {
|
public int getMaximumPolyhedronPoints(LocalPlayer player) {
|
||||||
if (player.hasPermission("worldedit.limit.unrestricted") || config.maxPolyhedronPoints < 0) {
|
if (player.hasPermission("worldedit.limit.unrestricted") || config.maxPolyhedronPoints < 0) {
|
||||||
return config.defaultMaxPolyhedronPoints;
|
return config.defaultMaxPolyhedronPoints;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
if (config.defaultMaxPolyhedronPoints < 0) {
|
if (config.defaultMaxPolyhedronPoints < 0) {
|
||||||
return config.maxPolyhedronPoints;
|
return config.maxPolyhedronPoints;
|
||||||
}
|
}
|
||||||
return Math.min(config.defaultMaxPolyhedronPoints,
|
|
||||||
config.maxPolyhedronPoints);
|
return Math.min(config.defaultMaxPolyhedronPoints, config.maxPolyhedronPoints);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -958,9 +970,9 @@ public class WorldEdit {
|
|||||||
File f = new File(path);
|
File f = new File(path);
|
||||||
if (f.isAbsolute()) {
|
if (f.isAbsolute()) {
|
||||||
return f;
|
return f;
|
||||||
} else {
|
|
||||||
return new File(config.getWorkingDirectory(), path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new File(config.getWorkingDirectory(), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren