mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-20 02:45:00 +00:00
Renamed some local variables in WorldEdit.getblock.
Also added a note about a potential concurrency problem i stumbled upon.
This commit is contained in:
parent
af1c600fc9
commit
04b7f40f46
@ -242,6 +242,7 @@ public class WorldEdit {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean hasSession(LocalPlayer player) {
|
public boolean hasSession(LocalPlayer player) {
|
||||||
|
// TODO: If this is indeed used in multiple threads, we should use Collections.synchronizedMap here to simplify things and exclude sources of error.
|
||||||
synchronized (sessions) {
|
synchronized (sessions) {
|
||||||
return sessions.containsKey(player.getName());
|
return sessions.containsKey(player.getName());
|
||||||
}
|
}
|
||||||
@ -268,9 +269,9 @@ public class WorldEdit {
|
|||||||
BlockType blockType;
|
BlockType blockType;
|
||||||
arg = arg.replace("_", " ");
|
arg = arg.replace("_", " ");
|
||||||
arg = arg.replace(";", "|");
|
arg = arg.replace(";", "|");
|
||||||
String[] args0 = arg.split("\\|");
|
String[] blockAndExtraData = arg.split("\\|");
|
||||||
String[] args1 = args0[0].split(":", 2);
|
String[] typeAndData = blockAndExtraData[0].split(":", 2);
|
||||||
String testID = args1[0];
|
String testID = typeAndData[0];
|
||||||
int blockId = -1;
|
int blockId = -1;
|
||||||
|
|
||||||
int data = -1;
|
int data = -1;
|
||||||
@ -314,25 +315,25 @@ public class WorldEdit {
|
|||||||
if (data == -1) { // Block data not yet detected
|
if (data == -1) { // Block data not yet detected
|
||||||
// Parse the block data (optional)
|
// Parse the block data (optional)
|
||||||
try {
|
try {
|
||||||
data = args1.length > 1 ? Integer.parseInt(args1[1]) : (allowNoData ? -1 : 0);
|
data = typeAndData.length > 1 ? Integer.parseInt(typeAndData[1]) : (allowNoData ? -1 : 0);
|
||||||
if (data > 15 || (data < 0 && !(allAllowed && data == -1))) {
|
if (data > 15 || (data < 0 && !(allAllowed && data == -1))) {
|
||||||
data = 0;
|
data = 0;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case CLOTH:
|
case CLOTH:
|
||||||
ClothColor col = ClothColor.lookup(args1[1]);
|
ClothColor col = ClothColor.lookup(typeAndData[1]);
|
||||||
|
|
||||||
if (col != null) {
|
if (col != null) {
|
||||||
data = col.getID();
|
data = col.getID();
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidItemException(arg, "Unknown cloth color '" + args1[1] + "'");
|
throw new InvalidItemException(arg, "Unknown cloth color '" + typeAndData[1] + "'");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STEP:
|
case STEP:
|
||||||
case DOUBLE_STEP:
|
case DOUBLE_STEP:
|
||||||
BlockType dataType = BlockType.lookup(args1[1]);
|
BlockType dataType = BlockType.lookup(typeAndData[1]);
|
||||||
|
|
||||||
if (dataType != null) {
|
if (dataType != null) {
|
||||||
switch (dataType) {
|
switch (dataType) {
|
||||||
@ -358,15 +359,15 @@ public class WorldEdit {
|
|||||||
data = 5;
|
data = 5;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidItemException(arg, "Invalid step type '" + args1[1] + "'");
|
throw new InvalidItemException(arg, "Invalid step type '" + typeAndData[1] + "'");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidItemException(arg, "Unknown step type '" + args1[1] + "'");
|
throw new InvalidItemException(arg, "Unknown step type '" + typeAndData[1] + "'");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidItemException(arg, "Unknown data value '" + args1[1] + "'");
|
throw new InvalidItemException(arg, "Unknown data value '" + typeAndData[1] + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,16 +380,16 @@ public class WorldEdit {
|
|||||||
if (blockType == BlockType.SIGN_POST
|
if (blockType == BlockType.SIGN_POST
|
||||||
|| blockType == BlockType.WALL_SIGN) {
|
|| blockType == BlockType.WALL_SIGN) {
|
||||||
String[] text = new String[4];
|
String[] text = new String[4];
|
||||||
text[0] = args0.length > 1 ? args0[1] : "";
|
text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : "";
|
||||||
text[1] = args0.length > 2 ? args0[2] : "";
|
text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
|
||||||
text[2] = args0.length > 3 ? args0[3] : "";
|
text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : "";
|
||||||
text[3] = args0.length > 4 ? args0[4] : "";
|
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
|
||||||
return new SignBlock(blockType.getID(), data, text);
|
return new SignBlock(blockType.getID(), data, text);
|
||||||
|
|
||||||
// Allow setting mob spawn type
|
// Allow setting mob spawn type
|
||||||
} else if (blockType == BlockType.MOB_SPAWNER) {
|
} else if (blockType == BlockType.MOB_SPAWNER) {
|
||||||
if (args0.length > 1) {
|
if (blockAndExtraData.length > 1) {
|
||||||
String mobName = args0[1];
|
String mobName = blockAndExtraData[1];
|
||||||
for (MobType mobType : MobType.values()){
|
for (MobType mobType : MobType.values()){
|
||||||
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())){
|
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())){
|
||||||
mobName = mobType.getName();
|
mobName = mobType.getName();
|
||||||
@ -405,10 +406,10 @@ public class WorldEdit {
|
|||||||
|
|
||||||
// Allow setting note
|
// Allow setting note
|
||||||
} else if (blockType == BlockType.NOTE_BLOCK) {
|
} else if (blockType == BlockType.NOTE_BLOCK) {
|
||||||
if (args0.length > 1) {
|
if (blockAndExtraData.length > 1) {
|
||||||
byte note = Byte.parseByte(args0[1]);
|
byte note = Byte.parseByte(blockAndExtraData[1]);
|
||||||
if (note < 0 || note > 24) {
|
if (note < 0 || note > 24) {
|
||||||
throw new InvalidItemException(arg, "Out of range note value: '" + args0[1] + "'");
|
throw new InvalidItemException(arg, "Out of range note value: '" + blockAndExtraData[1] + "'");
|
||||||
} else {
|
} else {
|
||||||
return new NoteBlock(data, note);
|
return new NoteBlock(data, note);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user