Skip to content

Commit

Permalink
Improve Schematic command further
Browse files Browse the repository at this point in the history
Yay for clearer error messages
  • Loading branch information
mcmonkey4eva committed Jan 15, 2015
1 parent a53ae03 commit e917ad4
Showing 1 changed file with 20 additions and 20 deletions.
Expand Up @@ -101,30 +101,30 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
switch (Type.valueOf(type.asString())) {
case CREATE:
if (schematics.containsKey(name.asString().toUpperCase())) {
dB.echoError("Schematic file " + name.asString() + " is already loaded.");
dB.echoError(scriptEntry.getResidingQueue(), "Schematic file " + name.asString() + " is already loaded.");
return;
}
if (cuboid == null) {
dB.echoError("Missing cuboid argument!");
dB.echoError(scriptEntry.getResidingQueue(), "Missing cuboid argument!");
return;
}
if (location == null) {
dB.echoError("Missing origin location argument!");
dB.echoError(scriptEntry.getResidingQueue(), "Missing origin location argument!");
return;
}
try {
set = new CuboidBlockSet(cuboid, location);
schematics.put(name.asString().toUpperCase(), set);
}
catch (Exception ex) {
dB.echoError("Error creating schematic object " + name.asString() + ".");
dB.echoError(ex);
dB.echoError(scriptEntry.getResidingQueue(), "Error creating schematic object " + name.asString() + ".");
dB.echoError(scriptEntry.getResidingQueue(), ex);
return;
}
break;
case LOAD:
if (schematics.containsKey(name.asString().toUpperCase())) {
dB.echoError("Schematic file " + name.asString() + " is already loaded.");
dB.echoError(scriptEntry.getResidingQueue(), "Schematic file " + name.asString() + " is already loaded.");
return;
}
try {
Expand All @@ -140,51 +140,51 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
schematics.put(name.asString().toUpperCase(), set);
}
catch (Exception ex) {
dB.echoError("Error loading schematic file " + name.asString() + ".");
dB.echoError(ex);
dB.echoError(scriptEntry.getResidingQueue(), "Error loading schematic file " + name.asString() + ".");
dB.echoError(scriptEntry.getResidingQueue(), ex);
return;
}
break;
case UNLOAD:
if (!schematics.containsKey(name.asString().toUpperCase())) {
dB.echoError("Schematic file " + name.asString() + " is not loaded.");
dB.echoError(scriptEntry.getResidingQueue(), "Schematic file " + name.asString() + " is not loaded.");
return;
}
schematics.remove(name.asString().toUpperCase());
break;
case ROTATE:
if (!schematics.containsKey(name.asString().toUpperCase())) {
dB.echoError("Schematic file " + name.asString() + " is not loaded.");
dB.echoError(scriptEntry.getResidingQueue(), "Schematic file " + name.asString() + " is not loaded.");
return;
}
if (angle == null) {
dB.echoError("Missing angle argument!");
dB.echoError(scriptEntry.getResidingQueue(), "Missing angle argument!");
return;
}
dB.echoError(scriptEntry.getResidingQueue(), "Schematic rotation is TODO!");
//schematics.get(name.asString().toUpperCase()).rotate2D(angle.asInt());
break;
case PASTE:
if (!schematics.containsKey(name.asString().toUpperCase())) {
dB.echoError("Schematic file " + name.asString() + " is not loaded.");
dB.echoError(scriptEntry.getResidingQueue(), "Schematic file " + name.asString() + " is not loaded.");
return;
}
if (location == null) {
dB.echoError("Missing location argument!");
dB.echoError(scriptEntry.getResidingQueue(), "Missing location argument!");
return;
}
try {
schematics.get(name.asString().toUpperCase()).setBlocks(location);
}
catch (Exception ex) {
dB.echoError("Exception pasting schematic file " + name.asString() + ".");
dB.echoError(ex);
dB.echoError(scriptEntry.getResidingQueue(), "Exception pasting schematic file " + name.asString() + ".");
dB.echoError(scriptEntry.getResidingQueue(), ex);
return;
}
break;
case SAVE:
if (!schematics.containsKey(name.asString().toUpperCase())) {
dB.echoError("Schematic file " + name.asString() + " is not loaded.");
dB.echoError(scriptEntry.getResidingQueue(), "Schematic file " + name.asString() + " is not loaded.");
return;
}
try {
Expand All @@ -201,8 +201,8 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
fs.close();
}
catch (Exception ex) {
dB.echoError("Error saving schematic file " + name.asString() + ".");
dB.echoError(ex);
dB.echoError(scriptEntry.getResidingQueue(), "Error saving schematic file " + name.asString() + ".");
dB.echoError(scriptEntry.getResidingQueue(), ex);
return;
}
break;
Expand All @@ -229,7 +229,7 @@ public void schematicTags(ReplaceableTagEvent event) {
return;
}

dB.echoError("Schematic file " + id + " is not loaded.");
dB.echoError(attribute.getScriptEntry() != null ? attribute.getScriptEntry().getResidingQueue(): null, "Schematic file " + id + " is not loaded.");
return;
}

Expand Down Expand Up @@ -301,7 +301,7 @@ public void schematicTags(ReplaceableTagEvent event) {
if (attribute.startsWith("block")) {
if (attribute.hasContext(1) && dLocation.matches(attribute.getContext(1))) {
dLocation location = dLocation.valueOf(attribute.getContext(1));
BlockData block = set.blockAt(location.getX(), location.getY(), location.getZ()));
BlockData block = set.blockAt(location.getX(), location.getY(), location.getZ());
event.setReplaced(dMaterial.getMaterialFrom(block.material, block.data)
.getAttribute(attribute.fulfill(1)));
return;
Expand Down

0 comments on commit e917ad4

Please sign in to comment.