fixed scarpet error msgs

This commit is contained in:
gnembon committed 2019-10-19 22:17:41 -03:00
1 parent 88d2ad75ad
commit 0226965ba0
13 files changed
+105 -106

No files matched your search

@@ -171,7 +171,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext) c;
if (params.size() == 0)
{
throw new InternalExpressionException(name + " requires at least one parameter");
throw new InternalExpressionException("'" + name + "' requires at least one parameter");
}
Value v0 = params.get(0).evalValue(c);
if (v0 instanceof BlockValue)
@@ -194,7 +194,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext) c;
if (params.size() == 0)
{
throw new InternalExpressionException(name + " requires at least one parameter");
throw new InternalExpressionException("'" + name + "' requires at least one parameter");
}
Value v0 = params.get(0).evalValue(c);
@@ -218,7 +218,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext) c;
if (params.size() == 0)
{
throw new InternalExpressionException(name + " requires at least one parameter");
throw new InternalExpressionException("'" + name + "' requires at least one parameter");
}
Value v0 = params.get(0).evalValue(c);
if (v0 instanceof BlockValue)
@@ -230,7 +230,7 @@ public class CarpetExpression
}
catch (NullPointerException ignored)
{
throw new InternalExpressionException(name + " function requires a block that is positioned in the world");
throw new InternalExpressionException("'" + name + "' function requires a block that is positioned in the world");
}
}
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
@@ -691,7 +691,7 @@ public class CarpetExpression
}
else
{
throw new InternalExpressionException("pos works only with a block or an entity type");
throw new InternalExpressionException("'pos' works only with a block or an entity type");
}
});
@@ -700,7 +700,7 @@ public class CarpetExpression
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
BlockPos pos = locator.block.getPos();
if (lv.size() <= locator.offset)
throw new InternalExpressionException("block_offset needs at least position, and direction");
throw new InternalExpressionException("'pos_offset' needs at least position, and direction");
String directionString = lv.get(locator.offset).evalValue(c).getString();
Direction dir = Direction.byName(directionString);
if (dir == null)
@@ -831,7 +831,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext)c;
ServerWorld world = cc.s.getWorld();
if (lv.size() < 2 || lv.size() % 2 == 1)
throw new InternalExpressionException("set block should have at least 2 params and odd attributes");
throw new InternalExpressionException("'set' should have at least 2 params and odd attributes");
BlockValue.LocatorResult targetLocator = BlockValue.fromParams(cc, lv, 0);
BlockValue.LocatorResult sourceLocator = BlockValue.fromParams(cc, lv, targetLocator.offset, true);
BlockState sourceBlockState = sourceLocator.block.getBlockState();
@@ -844,7 +844,7 @@ public class CarpetExpression
String paramString = lv.get(i).evalValue(c).getString();
Property<?> property = states.getProperty(paramString);
if (property == null)
throw new InternalExpressionException("property " + paramString + " doesn't apply to " + sourceLocator.block.getString());
throw new InternalExpressionException("Property " + paramString + " doesn't apply to " + sourceLocator.block.getString());
String paramValue = lv.get(i + 1).evalValue(c).getString();
sourceBlockState = setProperty(property, paramString, paramValue, sourceBlockState);
}
@@ -919,7 +919,7 @@ public class CarpetExpression
this.expr.addLazyFunction("harvest", -1, (c, t, lv) ->
{
if (lv.size()<2)
throw new InternalExpressionException("harvest takes at least 2 parameters: entity and block, or position, to harvest");
throw new InternalExpressionException("'harvest' takes at least 2 parameters: entity and block, or position, to harvest");
CarpetContext cc = (CarpetContext)c;
World world = cc.s.getWorld();
Value entityValue = lv.get(0).evalValue(cc);
@@ -944,7 +944,7 @@ public class CarpetExpression
this.expr.addLazyFunction("place_item", -1, (c, t, lv) ->
{
if (lv.size()<2)
throw new InternalExpressionException("place_item takes at least 2 parameters: item and block, or position, to place onto");
throw new InternalExpressionException("'place_item' takes at least 2 parameters: item and block, or position, to place onto");
CarpetContext cc = (CarpetContext) c;
String itemString = lv.get(0).evalValue(c).getString();
BlockValue.VectorLocator locator = BlockValue.locateVec(cc, lv, 1);
@@ -1008,7 +1008,7 @@ public class CarpetExpression
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext) c, lv, 0);
BlockState state = locator.block.getBlockState();
if (lv.size() <= locator.offset)
throw new InternalExpressionException("property requires to specify a property to query");
throw new InternalExpressionException("'property' requires to specify a property to query");
String tag = lv.get(locator.offset).evalValue(c).getString();
StateFactory<Block, BlockState> states = state.getBlock().getStateFactory();
Property<?> property = states.getProperty(tag);
@@ -1043,7 +1043,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext)c;
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
if (lv.size() == locator.offset)
throw new InternalExpressionException("set_biome needs a biome name as an argument");
throw new InternalExpressionException("'set_biome' needs a biome name as an argument");
String biomeName = lv.get(locator.offset+0).evalValue(c).getString();
Biome biome = Registry.BIOME.get(new Identifier(biomeName));
if (biome == null)
@@ -1223,7 +1223,7 @@ public class CarpetExpression
if (inventoryLocator == null)
return (_c, _t) -> Value.NULL;
if (lv.size() < inventoryLocator.offset+2)
throw new InternalExpressionException("inventory_set requires at least slot number and new stack size, and optional new item");
throw new InternalExpressionException("'inventory_set' requires at least slot number and new stack size, and optional new item");
int slot = (int) NumericValue.asNumber(lv.get(inventoryLocator.offset+0).evalValue(c)).getLong();
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
if (slot == inventoryLocator.inventory.getInvSize())
@@ -1317,7 +1317,7 @@ public class CarpetExpression
if (inventoryLocator == null)
return (_c, _t) -> Value.NULL;
if (lv.size() <= inventoryLocator.offset)
throw new InternalExpressionException("inventory_remove requires at least an item to be removed");
throw new InternalExpressionException("'inventory_remove' requires at least an item to be removed");
ItemStackArgument searchItem = NBTSerializableValue.parseItem(lv.get(inventoryLocator.offset).evalValue(c).getString());
int amount = 1;
if (lv.size() > inventoryLocator.offset+1)
@@ -1365,7 +1365,7 @@ public class CarpetExpression
if (inventoryLocator == null)
return (_c, _t) -> Value.NULL;
if (lv.size() == inventoryLocator.offset)
throw new InternalExpressionException("slot number is required for inventory_drop");
throw new InternalExpressionException("Slot number is required for inventory_drop");
int slot = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset).evalValue(c)).getLong();
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
if (slot == inventoryLocator.inventory.getInvSize())
@@ -1780,7 +1780,7 @@ public class CarpetExpression
this.expr.addLazyFunction("spawn", -1, (c, t, lv) -> {
CarpetContext cc = (CarpetContext)c;
if (lv.size() < 2)
throw new InternalExpressionException("spawn function takes mob name, and position to spawn");
throw new InternalExpressionException("'spawn' function takes mob name, and position to spawn");
String entityString = lv.get(0).evalValue(c).getString();
Identifier entityId;
try
@@ -1901,11 +1901,11 @@ public class CarpetExpression
this.expr.addLazyFunction("query", -1, (c, t, lv) -> {
if (lv.size()<2)
{
throw new InternalExpressionException("query_entity takes entity as a first argument, and queried feature as a second");
throw new InternalExpressionException("'query' takes entity as a first argument, and queried feature as a second");
}
Value v = lv.get(0).evalValue(c);
if (!(v instanceof EntityValue))
throw new InternalExpressionException("First argument to query_entity should be an entity");
throw new InternalExpressionException("First argument to query should be an entity");
String what = lv.get(1).evalValue(c).getString();
Value retval;
if (lv.size()==2)
@@ -1921,11 +1921,11 @@ public class CarpetExpression
this.expr.addLazyFunction("modify", -1, (c, t, lv) -> {
if (lv.size()<2)
{
throw new InternalExpressionException("modify_entity takes entity as a first argument, and queried feature as a second");
throw new InternalExpressionException("'modify' takes entity as a first argument, and queried feature as a second");
}
Value v = lv.get(0).evalValue(c);
if (!(v instanceof EntityValue))
throw new InternalExpressionException("First argument to get should be an entity");
throw new InternalExpressionException("First argument to modify should be an entity");
String what = lv.get(1).evalValue(c).getString();
if (lv.size()==2)
((EntityValue) v).set(what, null);
@@ -1940,10 +1940,10 @@ public class CarpetExpression
this.expr.addLazyFunction("entity_event", -1, (c, t, lv) ->
{
if (lv.size()<3)
throw new InternalExpressionException("entity_event requires at least 3 arguments, entity, event to be handled, and function name, with optional arguments");
throw new InternalExpressionException("'entity_event' requires at least 3 arguments, entity, event to be handled, and function name, with optional arguments");
Value v = lv.get(0).evalValue(c);
if (!(v instanceof EntityValue))
throw new InternalExpressionException("First argument to get should be an entity");
throw new InternalExpressionException("First argument to entity_event should be an entity");
String what = lv.get(1).evalValue(c).getString();
Value functionValue = lv.get(2).evalValue(c);
String function = null;
@@ -2000,7 +2000,7 @@ public class CarpetExpression
{
int lvsise = lv.size();
if (lvsise != 7 && lvsise != 10)
throw new InternalExpressionException("scan takes 2, or 3 triples of coords, and the expression");
throw new InternalExpressionException("'scan' takes 2, or 3 triples of coords, and the expression");
int cx = (int) NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
int cy = (int) NumericValue.asNumber(lv.get(1).evalValue(c)).getLong();
int cz = (int) NumericValue.asNumber(lv.get(2).evalValue(c)).getLong();
@@ -2133,7 +2133,7 @@ public class CarpetExpression
{
if (lv.size() != 3 && lv.size() != 6 && lv.size() != 9)
{
throw new InternalExpressionException("rectangular region should be specified with 3, 6, or 9 coordinates");
throw new InternalExpressionException("Rectangular region should be specified with 3, 6, or 9 coordinates");
}
int cx;
int cy;
@@ -2251,7 +2251,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext)c;
if (lv.size() != 3 && lv.size() != 4 && lv.size() != 5)
{
throw new InternalExpressionException("diamond region should be specified with 3 to 5 coordinates");
throw new InternalExpressionException("'diamond' region should be specified with 3 to 5 coordinates");
}
int cx;
@@ -2726,7 +2726,7 @@ public class CarpetExpression
}
catch (IndexOutOfBoundsException e)
{
throw new InternalExpressionException("create_marker requires a name and three coordinates, with optional direction, and optional block on its head");
throw new InternalExpressionException("'create_marker' requires a name and three coordinates, with optional direction, and optional block on its head");
}
ArmorStandEntity armorstand = new ArmorStandEntity(EntityType.ARMOR_STAND, cc.s.getWorld());
@@ -2872,7 +2872,7 @@ public class CarpetExpression
}
else
{
throw new InternalExpressionException("in_dimension accepts only world-localized block arguments");
throw new InternalExpressionException("'in_dimension' accepts only world-localized block arguments");
}
}
else
@@ -2905,7 +2905,7 @@ public class CarpetExpression
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
if (lv.size() <= locator.offset)
throw new InternalExpressionException("plop needs extra argument indicating what to plop");
throw new InternalExpressionException("'plop' needs extra argument indicating what to plop");
String what = lv.get(locator.offset).evalValue(c).getString();
Boolean res = FeatureGenerator.spawn(what, ((CarpetContext)c).s.getWorld(), locator.block.getPos());
if (res == null)
@@ -2917,12 +2917,12 @@ public class CarpetExpression
this.expr.addLazyFunction("schedule", -1, (c, t, lv) -> {
if (lv.size()<2)
throw new InternalExpressionException("schedule should have at least 2 arguments, delay and call name");
throw new InternalExpressionException("'schedule' should have at least 2 arguments, delay and call name");
Long delay = NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
String funname = lv.get(1).evalValue(c).getString();
CarpetContext cc = (CarpetContext)c;
if (!cc.host.globalFunctions.containsKey(funname))
throw new InternalExpressionException("function "+funname+" is not defined");
throw new InternalExpressionException("Function "+funname+" is not defined");
List<LazyValue> args = new ArrayList<>();
for (int i=2; i < lv.size(); i++)
{
@@ -2930,7 +2930,7 @@ public class CarpetExpression
args.add( (_c, _t) -> arg);
}
if (cc.host.globalFunctions.get(funname).getArguments().size() != args.size())
throw new InternalExpressionException("function "+funname+" takes "+
throw new InternalExpressionException("Function "+funname+" takes "+
cc.host.globalFunctions.get(funname).getArguments().size()+" arguments, "+args.size()+" provided.");
CarpetServer.scriptServer.events.scheduleCall(cc, funname, args, delay);
return (c_, t_) -> Value.TRUE;
@@ -2958,7 +2958,7 @@ public class CarpetExpression
this.expr.addLazyFunction("store_app_data", -1, (c, t, lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("store_app_data needs nbt tag and optional file");
throw new InternalExpressionException("'store_app_data' needs nbt tag and optional file");
Value val = lv.get(0).evalValue(c);
String file = null;
if (lv.size()>1)
@@ -3071,7 +3071,7 @@ public class CarpetExpression
}
catch (ArithmeticException ae)
{
throw new CarpetExpressionException("math doesn't compute... "+ae.getMessage());
throw new CarpetExpressionException("Math doesn't compute... "+ae.getMessage());
}
}
@@ -3118,7 +3118,7 @@ public class CarpetExpression
}
catch (ArithmeticException ae)
{
throw new CarpetExpressionException("math doesn't compute... "+ae.getMessage());
throw new CarpetExpressionException("Math doesn't compute... "+ae.getMessage());
}
}
@@ -62,7 +62,7 @@ public class CarpetScriptServer
{
if (CarpetSettings.scriptsAutoload)
{
Messenger.m(CarpetServer.minecraft_server.getCommandSource(), "Autoloading world scarpet apps");
Messenger.m(CarpetServer.minecraft_server.getCommandSource(), "Auto-loading world scarpet apps");
for (String moduleName: listAvailableModules(false))
{
addScriptHost(CarpetServer.minecraft_server.getCommandSource(), moduleName, true, true);
@@ -142,7 +142,7 @@ public class CarpetScriptServer
String code = module.getCode();
if (code == null)
{
Messenger.m(source, "r Unable to load the package - not found");
Messenger.m(source, "r Unable to load "+name+" app - code not found");
return null;
}
setChatErrorSnooper(source);
@@ -245,12 +245,12 @@ public class CarpetScriptServer
}
if (!host.globalFunctions.containsKey("__command"))
{
Messenger.m(source, "gi Package "+hostName+" loaded.");
Messenger.m(source, "gi "+hostName+" app loaded.");
return;
}
if (holyMoly.contains(hostName))
{
Messenger.m(source, "gi Package "+hostName+" loaded with no command.");
Messenger.m(source, "gi "+hostName+" app loaded with no command.");
Messenger.m(source, "gi Tried to mask vanilla command.");
return;
}
@@ -294,7 +294,7 @@ public class CarpetScriptServer
return 1;
})));
}
Messenger.m(source, "gi Package "+hostName+" loaded with /"+hostName+" command");
Messenger.m(source, "gi "+hostName+" app loaded with /"+hostName+" command");
CarpetServer.minecraft_server.getCommandManager().getDispatcher().register(command);
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
}
@@ -353,14 +353,14 @@ public class CarpetScriptServer
name = name.toLowerCase(Locale.ROOT);
if (!modules.containsKey(name))
{
Messenger.m(source, "r No such host found: ", "wb " + name);
Messenger.m(source, "r No such app found: ", "wb " + name);
return false;
}
// stop all events associated with name
events.removeAllHostEvents(name);
modules.remove(name);
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
Messenger.m(source, "w Removed host "+name);
Messenger.m(source, "gi Removed "+name+" app");
return true;
}
+22 -22
View File
@@ -964,7 +964,7 @@ public class Expression implements Cloneable
});
addLazyFunction("outer", 1, (c, t, lv) -> {
if (t != Context.LOCALIZATION)
throw new InternalExpressionException("outer scoping of variables is only possible in function signatures");
throw new InternalExpressionException("Outer scoping of variables is only possible in function signatures");
return (cc, tt) -> new GlobalValue(lv.get(0).evalValue(c));
});
@@ -998,7 +998,7 @@ public class Expression implements Cloneable
addLazyFunction("try", -1, (c, t, lv) ->
{
if (lv.size()==0)
throw new InternalExpressionException("try needs at least an expression block");
throw new InternalExpressionException("'try' needs at least an expression block");
try
{
Value retval = lv.get(0).evalValue(c, t);
@@ -1020,7 +1020,7 @@ public class Expression implements Cloneable
addLazyFunction("if", -1, (c, t, lv) ->
{
if ( lv.size() < 2 )
throw new InternalExpressionException("if statement needs to have at least one condition and one case");
throw new InternalExpressionException("'if' statement needs to have at least one condition and one case");
for (int i=0; i<lv.size()-1; i+=2)
{
if (lv.get(i).evalValue(c, Context.BOOLEAN).getBoolean())
@@ -1571,7 +1571,7 @@ public class Expression implements Cloneable
addFunction("max", (lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("MAX requires at least one parameter");
throw new InternalExpressionException("'max' requires at least one parameter");
Value max = null;
if (lv.size()==1 && lv.get(0) instanceof ListValue)
lv = ((ListValue) lv.get(0)).getItems();
@@ -1585,7 +1585,7 @@ public class Expression implements Cloneable
addFunction("min", (lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("MIN requires at least one parameter");
throw new InternalExpressionException("'min' requires at least one parameter");
Value min = null;
if (lv.size()==1 && lv.get(0) instanceof ListValue)
lv = ((ListValue) lv.get(0)).getItems();
@@ -1737,7 +1737,7 @@ public class Expression implements Cloneable
{
if (lv.size()<2 || lv.size()>3)
{
throw new InternalExpressionException("Incorrect number of attributes for loop, should be 2 or 3, not "+lv.size());
throw new InternalExpressionException("Incorrect number of attributes for 'loop', should be 2 or 3, not "+lv.size());
}
long limit = NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
Value lastOne = Value.NULL;
@@ -1766,13 +1766,13 @@ public class Expression implements Cloneable
{
if (lv.size()<2 || lv.size()>3)
{
throw new InternalExpressionException("Incorrect number of attributes for map, should be 2 or 3, not "+lv.size());
throw new InternalExpressionException("Incorrect number of attributes for 'map', should be 2 or 3, not "+lv.size());
}
Value rval= lv.get(0).evalValue(c);
if (!(rval instanceof AbstractListValue))
throw new InternalExpressionException("First argument of map function should be a list or iterator");
throw new InternalExpressionException("First argument of 'map' function should be a list or iterator");
Iterator<Value> iterator = ((AbstractListValue) rval).iterator();
LazyValue expr = lv.get(1);
LazyValue cond = null;
@@ -1812,12 +1812,12 @@ public class Expression implements Cloneable
{
if (lv.size()<2 || lv.size()>3)
{
throw new InternalExpressionException("Incorrect number of attributes for filter, should be 2 or 3, not "+lv.size());
throw new InternalExpressionException("Incorrect number of attributes for 'filter', should be 2 or 3, not "+lv.size());
}
Value rval= lv.get(0).evalValue(c);
if (!(rval instanceof AbstractListValue))
throw new InternalExpressionException("First argument of filter function should be a list or iterator");
throw new InternalExpressionException("First argument of 'filter' function should be a list or iterator");
Iterator<Value> iterator = ((AbstractListValue) rval).iterator();
LazyValue expr = lv.get(1);
LazyValue cond = null;
@@ -2249,7 +2249,7 @@ public class Expression implements Cloneable
addFunction("join", (lv) ->
{
if (lv.size() < 2)
throw new InternalExpressionException("join takes at least 2 arguments");
throw new InternalExpressionException("'join' takes at least 2 arguments");
String delimiter = lv.get(0).getString();
List<Value> toJoin;
if (lv.size()==2 && lv.get(1) instanceof LazyListValue)
@@ -2277,7 +2277,7 @@ public class Expression implements Cloneable
addFunction("slice", (lv) -> {
if (lv.size() != 2 && lv.size() != 3)
throw new InternalExpressionException("slice takes 2 or 3 arguments");
throw new InternalExpressionException("'slice' takes 2 or 3 arguments");
Value hwat = lv.get(0);
long from = NumericValue.asNumber(lv.get(1)).getLong();
long to = -1;
@@ -2301,7 +2301,7 @@ public class Expression implements Cloneable
{
Value v = lv.get(0).evalValue(c);
if (!(v instanceof ListValue))
throw new InternalExpressionException("First argument for sort_key should be a List");
throw new InternalExpressionException("First argument for 'sort_key' should be a List");
LazyValue sortKey = lv.get(1);
//scoping
LazyValue __ = c.getVariable("_");
@@ -2327,7 +2327,7 @@ public class Expression implements Cloneable
long step = 1;
int argsize = lv.size();
if (argsize == 0 || argsize > 3)
throw new InternalExpressionException("range accepts from 1 to 3 arguments, not "+argsize);
throw new InternalExpressionException("'range' accepts from 1 to 3 arguments, not "+argsize);
to = NumericValue.asNumber(lv.get(0)).getLong();
if (lv.size() > 1)
{
@@ -2406,7 +2406,7 @@ public class Expression implements Cloneable
addLazyFunction("get", -1, (c, t, lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("get requires parameters");
throw new InternalExpressionException("'get' requires parameters");
if (lv.size() == 1)
{
Value v = lv.get(0).evalValue(c, Context.LVALUE);
@@ -2433,7 +2433,7 @@ public class Expression implements Cloneable
addLazyFunction("has", -1, (c, t, lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("get requires parameters");
throw new InternalExpressionException("'has' requires parameters");
if (lv.size() == 1)
{
Value v = lv.get(0).evalValue(c, Context.LVALUE);
@@ -2461,7 +2461,7 @@ public class Expression implements Cloneable
addBinaryFunction("element", (v1, v2) ->
{
if (!(v1 instanceof ListValue))
throw new InternalExpressionException("First argument of get should be a list");
throw new InternalExpressionException("First argument of 'get' should be a list");
List<Value> items = ((ListValue)v1).getItems();
long index = NumericValue.asNumber(v2).getLong();
int numitems = items.size();
@@ -2475,7 +2475,7 @@ public class Expression implements Cloneable
{
if(lv.size()<2)
{
throw new InternalExpressionException("put takes at least three arguments, a container, address, and values to insert at that index");
throw new InternalExpressionException("'put' takes at least three arguments, a container, address, and values to insert at that index");
}
Value container = lv.get(0).evalValue(c, Context.LVALUE);
if (container instanceof LContainerValue)
@@ -2495,7 +2495,7 @@ public class Expression implements Cloneable
}
if(lv.size()<3)
{
throw new InternalExpressionException("put takes at least three arguments, a container, address, and values to insert at that index");
throw new InternalExpressionException("'put' takes at least three arguments, a container, address, and values to insert at that index");
}
if (!(container instanceof ContainerValueInterface))
{
@@ -2512,7 +2512,7 @@ public class Expression implements Cloneable
addLazyFunction("delete", -1, (c, t, lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("delete requires parameters");
throw new InternalExpressionException("'delete' requires parameters");
if (lv.size() == 1)
{
Value v = lv.get(0).evalValue(c, Context.LVALUE);
@@ -2742,7 +2742,7 @@ public class Expression implements Cloneable
addFunction("str", lv ->
{
if (lv.size() == 0)
throw new InternalExpressionException("str requires at least one argument");
throw new InternalExpressionException("'str' requires at least one argument");
String format = lv.get(0).getString();
if (lv.size() == 1)
return new StringValue(format);
@@ -2797,7 +2797,7 @@ public class Expression implements Cloneable
}
else
{
throw new InternalExpressionException("format not supported: "+m.group(6));
throw new InternalExpressionException("Format not supported: "+m.group(6));
}
i = m.end();
+1 -2
View File
@@ -113,7 +113,7 @@ public class ScriptHost
public String call(ServerCommandSource source, String call, List<Integer> coords, String arg)
{
if (CarpetServer.scriptServer.stopAll)
return "SCRIPTING PAUSED";
return "SCARPET PAUSED";
UserDefinedFunction acf = globalFunctions.get(call);
if (acf == null)
return "UNDEFINED";
@@ -292,7 +292,6 @@ public class ScriptHost
public void setPerPlayer(boolean isPerUser)
{
CarpetSettings.LOG.error("Setting per player for "+name+" of "+isPerUser);
perUser = isPerUser;
}
}
@@ -10,6 +10,6 @@ public abstract class AbstractListValue extends Value
public void fatality() { }
public void append(Value v)
{
throw new InternalExpressionException("Cannot append a value to abstract list");
throw new InternalExpressionException("Cannot append a value to an abstract list");
}
}
@@ -187,7 +187,7 @@ public class BlockValue extends Value
blockState = world.getBlockState(pos);
return blockState;
}
throw new InternalExpressionException("Attemted to fetch blockstate without world or stored blockstate");
throw new InternalExpressionException("Attempted to fetch block state without world or stored block state");
}
public CompoundTag getData()
@@ -164,7 +164,7 @@ public class EntityValue extends Value
public Value get(String what, Value arg)
{
if (!(featureAccessors.containsKey(what)))
throw new InternalExpressionException("unknown feature of entity: "+what);
throw new InternalExpressionException("Unknown entity feature: "+what);
return featureAccessors.get(what).apply(entity, arg);
}
private static Map<String, EquipmentSlot> inventorySlots = new HashMap<String, EquipmentSlot>(){{
@@ -331,7 +331,7 @@ public class EntityValue extends Value
if (a != null)
index = (6+(int)NumericValue.asNumber(a).getLong())%6;
if (index < 0 || index > 5)
throw new InternalExpressionException("facing order should be between -6 and 5");
throw new InternalExpressionException("Facing order should be between -6 and 5");
return new StringValue(Direction.getEntityFacingOrder(e)[index].asString());
});
@@ -352,7 +352,7 @@ public class EntityValue extends Value
{
List<Value> args = ((ListValue) a).getItems();
if (args.size()==0)
throw new InternalExpressionException("trace needs more arguments");
throw new InternalExpressionException("'trace' needs more arguments");
reach = (float) NumericValue.asNumber(args.get(0)).getDouble();
if (args.size() > 1)
{
@@ -415,7 +415,7 @@ public class EntityValue extends Value
public void set(String what, Value toWhat)
{
if (!(featureModifiers.containsKey(what)))
throw new InternalExpressionException("unknown action on entity: " + what);
throw new InternalExpressionException("Unknown entity action: " + what);
featureModifiers.get(what).accept(entity, toWhat);
}
@@ -443,7 +443,7 @@ public class EntityValue extends Value
{
if (!(v instanceof ListValue))
{
throw new InternalExpressionException("expected a list of 5 parameters as second argument");
throw new InternalExpressionException("Expected a list of 5 parameters as a second argument");
}
List<Value> coords = ((ListValue) v).getItems();
e.x = NumericValue.asNumber(coords.get(0)).getDouble();
@@ -460,7 +460,7 @@ public class EntityValue extends Value
{
if (!(v instanceof ListValue))
{
throw new InternalExpressionException("expected a list of 3 parameters as second argument");
throw new InternalExpressionException("Expected a list of 3 parameters as a second argument");
}
List<Value> coords = ((ListValue) v).getItems();
e.x = NumericValue.asNumber(coords.get(0)).getDouble();
@@ -507,7 +507,7 @@ public class EntityValue extends Value
{
if (!(v instanceof ListValue))
{
throw new InternalExpressionException("expected a list of 3 parameters as second argument");
throw new InternalExpressionException("Expected a list of 3 parameters as a second argument");
}
List<Value> coords = ((ListValue) v).getItems();
e.x += NumericValue.asNumber(coords.get(0)).getDouble();
@@ -521,7 +521,7 @@ public class EntityValue extends Value
{
if (!(v instanceof ListValue))
{
throw new InternalExpressionException("expected a list of 3 parameters as second argument");
throw new InternalExpressionException("Expected a list of 3 parameters as a second argument");
}
List<Value> coords = ((ListValue) v).getItems();
e.setVelocity(
@@ -554,7 +554,7 @@ public class EntityValue extends Value
{
if (!(v instanceof ListValue))
{
throw new InternalExpressionException("expected a list of 3 parameters as second argument");
throw new InternalExpressionException("Expected a list of 3 parameters as a second argument");
}
List<Value> coords = ((ListValue) v).getItems();
e.addVelocity(
@@ -590,7 +590,7 @@ public class EntityValue extends Value
put("drop_passengers", (e, v) -> e.removeAllPassengers());
put("mount_passengers", (e, v) -> {
if (v==null)
throw new InternalExpressionException("mount_passengers needs entities to ride");
throw new InternalExpressionException("'mount_passengers' needs entities to ride");
if (v instanceof EntityValue)
((EntityValue) v).getEntity().startRiding(e);
else if (v instanceof ListValue)
@@ -600,7 +600,7 @@ public class EntityValue extends Value
});
put("tag", (e, v) -> {
if (v==null)
throw new InternalExpressionException("tag requires parameters");
throw new InternalExpressionException("'tag' requires parameters");
if (v instanceof ListValue)
for (Value element : ((ListValue) v).getItems()) e.addScoreboardTag(element.getString());
else
@@ -608,7 +608,7 @@ public class EntityValue extends Value
});
put("clear_tag", (e, v) -> {
if (v==null)
throw new InternalExpressionException("clear_tag requires parameters");
throw new InternalExpressionException("'clear_tag' requires parameters");
if (v instanceof ListValue)
for (Value element : ((ListValue) v).getItems()) e.removeScoreboardTag(element.getString());
else
@@ -634,7 +634,7 @@ public class EntityValue extends Value
return;
MobEntityWithAi ec = (MobEntityWithAi)e;
if (v == null)
throw new InternalExpressionException("home requires at least one position argument, and optional distance, or null to cancel");
throw new InternalExpressionException("'home' requires at least one position argument, and optional distance, or null to cancel");
if (v instanceof NullValue)
{
ec.setWalkTarget(BlockPos.ORIGIN, -1);
@@ -650,7 +650,7 @@ public class EntityValue extends Value
if (v instanceof BlockValue)
{
pos = ((BlockValue) v).getPos();
if (pos == null) throw new InternalExpressionException("block is not positioned in the world");
if (pos == null) throw new InternalExpressionException("Block is not positioned in the world");
}
else if (v instanceof ListValue)
{
@@ -673,10 +673,10 @@ public class EntityValue extends Value
distance = (int) NumericValue.asNumber(lv.get(4)).getLong();
}
}
else throw new InternalExpressionException("home requires at least one position argument, and optional distance");
else throw new InternalExpressionException("'home' requires at least one position argument, and optional distance");
}
else throw new InternalExpressionException("home requires at least one position argument, and optional distance");
else throw new InternalExpressionException("'home' requires at least one position argument, and optional distance");
ec.setWalkTarget(pos, distance);
Map<String,Goal> tasks = ((MobEntityInterface)ec).getTemporaryTasks();
@@ -717,7 +717,7 @@ public class EntityValue extends Value
public void setEvent(CarpetContext cc, String event, String fun, List<Value> args)
{
if (!(events.containsKey(event)))
throw new InternalExpressionException("unknown entity event: " + event);
throw new InternalExpressionException("Unknown entity event: " + event);
events.get(event).accept(cc, entity, fun, args);
}
@@ -23,6 +23,6 @@ public class GlobalValue extends Value
@Override
public int hashCode()
{
throw new UnsupportedOperationException("global value cannot be used as map key");
throw new UnsupportedOperationException("Global value cannot be used as a map key");
}
}
@@ -15,7 +15,7 @@ public abstract class LazyListValue extends AbstractListValue implements Iterato
{
{
if (step == 0)
throw new InternalExpressionException("range will never end with zero step");
throw new InternalExpressionException("Range will never end with a zero step");
this.start = from;
this.current = this.start;
this.limit = to;
@@ -141,7 +141,7 @@ public abstract class LazyListValue extends AbstractListValue implements Iterato
}
catch (CloneNotSupportedException e)
{
throw new InternalExpressionException("cannot copy iterator");
throw new InternalExpressionException("Cannot copy iterators");
}
((LazyListValue)copy).reset();
return copy;
@@ -312,7 +312,7 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
return put(where, value, false, true);
if (condition.equalsIgnoreCase("replace"))
return put(where, value, true, false);
throw new InternalExpressionException("list put modifier could be either insert, or replace");
throw new InternalExpressionException("List 'put' modifier could be either 'insert', or 'replace'");
}
@Override
@@ -71,25 +71,25 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
@Override
public Value add(Value o)
{
throw new InternalExpressionException("cannot add to a map value");
throw new InternalExpressionException("Cannot add to a map value");
}
@Override
public Value subtract(Value v)
{
throw new InternalExpressionException("cannot subtract to a map value");
throw new InternalExpressionException("Cannot subtract from a map value");
}
@Override
public Value multiply(Value v)
{
throw new InternalExpressionException("cannot multiply to a map value");
throw new InternalExpressionException("Cannot multiply with a map value");
}
@Override
public Value divide(Value v)
{
throw new InternalExpressionException("cannot divide to a map value");
throw new InternalExpressionException("Cannot divide a map value");
}
public void put(Value v)
@@ -102,7 +102,7 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
ListValue pair = (ListValue)v;
if (pair.getItems().size() != 2)
{
throw new InternalExpressionException("map constructor requires elements that have two elements");
throw new InternalExpressionException("Map constructor requires elements that have two items");
}
map.put(pair.getItems().get(0), pair.getItems().get(1));
}
@@ -116,7 +116,7 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
@Override
public int compareTo(Value o)
{
throw new InternalExpressionException("cannot compare to a map value");
throw new InternalExpressionException("Cannot compare with a map value");
}
@Override
@@ -155,7 +155,7 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
@Override
public Value slice(long from, long to)
{
throw new InternalExpressionException("cannot slice a map value");
throw new InternalExpressionException("Cannot slice a map value");
}
@Override
@@ -50,7 +50,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
}
catch (CommandSyntaxException e)
{
throw new InternalExpressionException("Incorrect nbt data: "+nbtString);
throw new InternalExpressionException("Incorrect NBT data: "+nbtString);
}
};
}