refactor argument parsers
This commit is contained in:
1 parent
022addf4e1
commit
fb1a03b3f7
6 files changed
+317
-252
No files matched your search
@@ -18,6 +18,7 @@ import carpet.script.exception.ContinueStatement;
|
||||
import carpet.script.exception.ExitStatement;
|
||||
import carpet.script.exception.ExpressionException;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.utils.CarpetArgParser;
|
||||
import carpet.script.value.BlockValue;
|
||||
import carpet.script.value.EntityValue;
|
||||
import carpet.script.value.FunctionValue;
|
||||
@@ -132,7 +133,6 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static carpet.script.utils.WorldTools.canHasChunk;
|
||||
@@ -175,7 +175,7 @@ public class CarpetExpression
|
||||
Value retval = test.apply(((BlockValue) v0).getBlockState(), ((BlockValue) v0).getPos()) ? Value.TRUE : Value.FALSE;
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
|
||||
BlockValue block = CarpetArgParser.locateBlock(cc, params, 0).block;
|
||||
Value retval = test.apply(block.getBlockState(), block.getPos()) ? Value.TRUE : Value.FALSE;
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public class CarpetExpression
|
||||
Value retval = strVal != null ? new StringValue(strVal) : Value.NULL;
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
|
||||
BlockValue block = CarpetArgParser.locateBlock(cc, params, 0).block;
|
||||
String strVal = test.apply(block.getBlockState(), block.getPos());
|
||||
Value retval = strVal != null ? new StringValue(strVal) : Value.NULL;
|
||||
return (c_, t_) -> retval;
|
||||
@@ -231,7 +231,7 @@ public class CarpetExpression
|
||||
throw new InternalExpressionException("'" + name + "' function requires a block that is positioned in the world");
|
||||
}
|
||||
}
|
||||
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
|
||||
BlockValue block = CarpetArgParser.locateBlock(cc, params, 0).block;
|
||||
Value retval = test.apply(block.getBlockState(), block.getPos(), cc.s.getWorld());
|
||||
return (c_, t_) -> retval;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ public class CarpetExpression
|
||||
{
|
||||
throw new InternalExpressionException("Block requires at least one parameter");
|
||||
}
|
||||
BlockValue retval = BlockValue.fromParams(cc, lv, 0, true).block;
|
||||
BlockValue retval = CarpetArgParser.locateBlock(cc, lv, 0, true).block;
|
||||
// fixing block state and data
|
||||
retval.getBlockState();
|
||||
retval.getData();
|
||||
@@ -414,7 +414,7 @@ public class CarpetExpression
|
||||
{
|
||||
throw new InternalExpressionException("Block requires at least one parameter");
|
||||
}
|
||||
CompoundTag tag = BlockValue.fromParams(cc, lv, 0, true).block.getData();
|
||||
CompoundTag tag = CarpetArgParser.locateBlock(cc, lv, 0, true).block.getData();
|
||||
if (tag == null)
|
||||
return (c_, t_) -> Value.NULL;
|
||||
Value retval = new NBTSerializableValue(tag);
|
||||
@@ -426,7 +426,7 @@ public class CarpetExpression
|
||||
{
|
||||
CarpetContext cc = (CarpetContext) c;
|
||||
if (lv.size() == 0) throw new InternalExpressionException("'poi' requires at least one parameter");
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0, false);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0, false);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
PointOfInterestStorage store = cc.s.getWorld().getPointOfInterestStorage();
|
||||
if (lv.size() == locator.offset)
|
||||
@@ -492,7 +492,7 @@ public class CarpetExpression
|
||||
{
|
||||
CarpetContext cc = (CarpetContext) c;
|
||||
if (lv.size() == 0) throw new InternalExpressionException("'set_poi' requires at least one parameter");
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0, false);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0, false);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
if (lv.size() < locator.offset) throw new InternalExpressionException("'set_poi' requires the new poi type or null, after position argument");
|
||||
Value poi = lv.get(locator.offset+0).evalValue(c);
|
||||
@@ -559,7 +559,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("pos_offset", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
if (lv.size() <= locator.offset)
|
||||
throw new InternalExpressionException("'pos_offset' needs at least position, and direction");
|
||||
@@ -622,7 +622,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("in_slime_chunk", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockPos pos = BlockValue.fromParams((CarpetContext)c, lv, 0).block.getPos();
|
||||
BlockPos pos = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0).block.getPos();
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
Value ret = new NumericValue(ChunkRandom.create(
|
||||
chunkPos.x, chunkPos.z,
|
||||
@@ -646,7 +646,7 @@ public class CarpetExpression
|
||||
case "surface": htype = Heightmap.Type.WORLD_SURFACE; break;
|
||||
default: throw new InternalExpressionException("Unknown heightmap type: "+type);
|
||||
}
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 1);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext)c, lv, 1);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
int x = pos.getX();
|
||||
int z = pos.getZ();
|
||||
@@ -658,21 +658,21 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("loaded", -1, (c, t, lv) ->
|
||||
{
|
||||
Value retval = ((CarpetContext) c).s.getWorld().isChunkLoaded(BlockValue.fromParams((CarpetContext) c, lv, 0).block.getPos()) ? Value.TRUE : Value.FALSE;
|
||||
Value retval = ((CarpetContext) c).s.getWorld().isChunkLoaded(CarpetArgParser.locateBlock((CarpetContext) c, lv, 0).block.getPos()) ? Value.TRUE : Value.FALSE;
|
||||
return (c_, t_) -> retval;
|
||||
});
|
||||
|
||||
// Deprecated, use loaded_status as more indicative
|
||||
this.expr.addLazyFunction("loaded_ep", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockPos pos = BlockValue.fromParams((CarpetContext)c, lv, 0).block.getPos();
|
||||
BlockPos pos = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0).block.getPos();
|
||||
Value retval = ((CarpetContext)c).s.getWorld().getChunkManager().shouldTickChunk(new ChunkPos(pos))?Value.TRUE : Value.FALSE;
|
||||
return (c_, t_) -> retval;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("loaded_status", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockPos pos = BlockValue.fromParams((CarpetContext)c, lv, 0).block.getPos();
|
||||
BlockPos pos = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0).block.getPos();
|
||||
WorldChunk chunk = ((CarpetContext)c).s.getWorld().getChunkManager().getWorldChunk(pos.getX()>>4, pos.getZ()>>4, false);
|
||||
if (chunk == null)
|
||||
return LazyValue.ZERO;
|
||||
@@ -682,7 +682,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("is_chunk_generated", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
boolean force = false;
|
||||
if (lv.size() > locator.offset)
|
||||
@@ -693,11 +693,11 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("generation_status", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locatorResult = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
BlockPos pos = locatorResult.block.getPos();
|
||||
CarpetArgParser.BlockArgument blockArgument = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0);
|
||||
BlockPos pos = blockArgument.block.getPos();
|
||||
boolean forceLoad = false;
|
||||
if (lv.size() > locatorResult.offset)
|
||||
forceLoad = lv.get(locatorResult.offset).evalValue(c, Context.BOOLEAN).getBoolean();
|
||||
if (lv.size() > blockArgument.offset)
|
||||
forceLoad = lv.get(blockArgument.offset).evalValue(c, Context.BOOLEAN).getBoolean();
|
||||
Chunk chunk = ((CarpetContext)c).s.getWorld().getChunk(pos.getX()>>4, pos.getZ()>>4, ChunkStatus.EMPTY, forceLoad);
|
||||
if (chunk == null)
|
||||
return LazyValue.NULL;
|
||||
@@ -731,8 +731,8 @@ public class CarpetExpression
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue.LocatorResult locatorResult = BlockValue.fromParams((CarpetContext) c, lv, 0);
|
||||
BlockPos pos = locatorResult.block.getPos();
|
||||
CarpetArgParser.BlockArgument blockArgument = CarpetArgParser.locateBlock((CarpetContext) c, lv, 0);
|
||||
BlockPos pos = blockArgument.block.getPos();
|
||||
SortedArraySet<ChunkTicket<?>> tickets = levelTickets.get(new ChunkPos(pos).toLong());
|
||||
if (tickets != null)
|
||||
{
|
||||
@@ -804,8 +804,8 @@ public class CarpetExpression
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
if (lv.size() < 2 || lv.size() % 2 == 1)
|
||||
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);
|
||||
CarpetArgParser.BlockArgument targetLocator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument sourceLocator = CarpetArgParser.locateBlock(cc, lv, targetLocator.offset, true);
|
||||
BlockState sourceBlockState = sourceLocator.block.getBlockState();
|
||||
BlockState targetBlockState = world.getBlockState(targetLocator.block.getPos());
|
||||
if (sourceLocator.offset < lv.size())
|
||||
@@ -854,7 +854,7 @@ public class CarpetExpression
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
BlockState state = locator.block.getBlockState();
|
||||
if (state.isAir())
|
||||
return (c_, t_) -> Value.FALSE;
|
||||
@@ -964,7 +964,7 @@ public class CarpetExpression
|
||||
if (!(e instanceof ServerPlayerEntity))
|
||||
return (c_, t_) -> Value.FALSE;
|
||||
ServerPlayerEntity player = (ServerPlayerEntity)e;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 1);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 1);
|
||||
BlockPos where = locator.block.getPos();
|
||||
BlockState state = locator.block.getBlockState();
|
||||
Block block = state.getBlock();
|
||||
@@ -982,7 +982,7 @@ public class CarpetExpression
|
||||
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);
|
||||
CarpetArgParser.Vector3Argument locator = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
ItemStackArgument stackArg = NBTSerializableValue.parseItem(itemString);
|
||||
BlockPos where = new BlockPos(locator.vec);
|
||||
String facing = "up";
|
||||
@@ -1038,7 +1038,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("property", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext) c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((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");
|
||||
@@ -1053,7 +1053,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("block_properties", -1, (c, t, lv) ->
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext) c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext) c, lv, 0);
|
||||
BlockState state = locator.block.getBlockState();
|
||||
StateManager<Block, BlockState> states = state.getBlock().getStateManager();
|
||||
Value res = ListValue.wrap(states.getProperties().stream().map(
|
||||
@@ -1064,7 +1064,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("biome", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Biome biome = world.getBiome(pos);
|
||||
@@ -1075,7 +1075,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("set_biome", -1, (c, t, lv) ->
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
if (lv.size() == locator.offset)
|
||||
throw new InternalExpressionException("'set_biome' needs a biome name as an argument");
|
||||
String biomeName = lv.get(locator.offset+0).evalValue(c).getString();
|
||||
@@ -1092,7 +1092,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("structure_references", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Map<String, LongSet> references = world.getChunk(pos).getStructureReferences();
|
||||
@@ -1117,7 +1117,7 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("structures", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
@@ -1159,7 +1159,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("set_structure", -1, (c, t, lv) ->
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
@@ -1223,27 +1223,27 @@ public class CarpetExpression
|
||||
{
|
||||
List<Value> listVal = ((ListValue) first).getItems();
|
||||
int offset = 0;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParamValues(cc, listVal, 0, false, false);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.fromParamValues(cc, listVal, 0, false, false);
|
||||
requestedChunks.add(new ChunkPos(locator.block.getPos()));
|
||||
while (listVal.size() > locator.offset)
|
||||
{
|
||||
locator = BlockValue.fromParamValues(cc, listVal, locator.offset, false, false);
|
||||
locator = CarpetArgParser.fromParamValues(cc, listVal, locator.offset, false, false);
|
||||
requestedChunks.add(new ChunkPos(locator.block.getPos()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParamValues(cc, Collections.singletonList(first), 0, false, false);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.fromParamValues(cc, Collections.singletonList(first), 0, false, false);
|
||||
requestedChunks.add(new ChunkPos(locator.block.getPos()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
ChunkPos from = new ChunkPos(locator.block.getPos());
|
||||
if (lv.size() > locator.offset)
|
||||
{
|
||||
locator = BlockValue.fromParams(cc, lv, locator.offset);
|
||||
locator = CarpetArgParser.locateBlock(cc, lv, locator.offset);
|
||||
ChunkPos to = new ChunkPos(locator.block.getPos());
|
||||
int xmax = Math.max(from.x, to.x);
|
||||
int zmax = Math.max(from.z, to.z);
|
||||
@@ -1285,7 +1285,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("inhabited_time", -1, (c, t, lv) ->
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock(cc, lv, 0);
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Value ret = new NumericValue(cc.s.getWorld().getChunk(pos).getInhabitedTime());
|
||||
return (_c, _t) -> ret;
|
||||
@@ -1765,7 +1765,7 @@ public class CarpetExpression
|
||||
return LazyValue.NULL;
|
||||
}
|
||||
|
||||
BlockValue.VectorLocator position = BlockValue.locateVec(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument position = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
if (position.fromBlock)
|
||||
position.vec = position.vec.subtract(0, 0.5, 0);
|
||||
CompoundTag tag = new CompoundTag();
|
||||
@@ -2087,7 +2087,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("neighbours", -1, (c, t, lv)->
|
||||
{
|
||||
|
||||
BlockPos center = BlockValue.fromParams((CarpetContext) c, lv,0).block.getPos();
|
||||
BlockPos center = CarpetArgParser.locateBlock((CarpetContext) c, lv,0).block.getPos();
|
||||
ServerWorld world = ((CarpetContext) c).s.getWorld();
|
||||
|
||||
List<Value> neighbours = new ArrayList<>();
|
||||
@@ -2381,12 +2381,30 @@ public class CarpetExpression
|
||||
|
||||
private static Map<String,SoundCategory> mixerMap = Arrays.stream(SoundCategory.values()).collect(Collectors.toMap(SoundCategory::getName, k -> k));
|
||||
|
||||
private void API_Interapperability()
|
||||
{
|
||||
//todo doc and test all
|
||||
this.expr.addLazyFunction("loaded_apps", 0, (c, t, lv) ->
|
||||
{
|
||||
// return a set of all loaded apps
|
||||
Value ret = new MapValue(((CarpetScriptHost) c.host).getScriptServer().modules.keySet().stream().map(StringValue::new).collect(Collectors.toSet()));
|
||||
return (cc, tt) -> ret;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("is_app_loaded", 1, (c, t, lv) ->
|
||||
{
|
||||
Value ret = new NumericValue(((CarpetScriptHost) c.host).getScriptServer().modules.containsKey(lv.get(0).evalValue(c).getString()));
|
||||
return (cc, tt) -> ret;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void API_AuxiliaryAspects()
|
||||
{
|
||||
this.expr.addLazyFunction("sound", -1, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
Identifier soundName = new Identifier(lv.get(0).evalValue(c).getString());
|
||||
BlockValue.VectorLocator locator = BlockValue.locateVec(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument locator = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
if (Registry.SOUND_EVENT.get(soundName) == null)
|
||||
throw new InternalExpressionException("No such sound: "+soundName.getPath());
|
||||
float volume = 1.0F;
|
||||
@@ -2423,7 +2441,7 @@ public class CarpetExpression
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
MinecraftServer ms = cc.s.getMinecraftServer();
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockValue.VectorLocator locator = BlockValue.locateVec(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument locator = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
String particleName = lv.get(0).evalValue(c).getString();
|
||||
int count = 10;
|
||||
double speed = 0;
|
||||
@@ -2471,8 +2489,8 @@ public class CarpetExpression
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
String particleName = lv.get(0).evalValue(c).getString();
|
||||
ParticleEffect particle = getParticleData(particleName);
|
||||
BlockValue.VectorLocator pos1 = BlockValue.locateVec(cc, lv, 1);
|
||||
BlockValue.VectorLocator pos2 = BlockValue.locateVec(cc, lv, pos1.offset);
|
||||
CarpetArgParser.Vector3Argument pos1 = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument pos2 = CarpetArgParser.locateVector(cc, lv, pos1.offset);
|
||||
int offset = pos2.offset;
|
||||
double density = (lv.size() > offset)? NumericValue.asNumber(lv.get(offset).evalValue(c)).getDouble():1.0;
|
||||
if (density <= 0)
|
||||
@@ -2489,8 +2507,8 @@ public class CarpetExpression
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
String particleName = lv.get(0).evalValue(c).getString();
|
||||
ParticleEffect particle = getParticleData(particleName);
|
||||
BlockValue.VectorLocator pos1 = BlockValue.locateVec(cc, lv, 1);
|
||||
BlockValue.VectorLocator pos2 = BlockValue.locateVec(cc, lv, pos1.offset);
|
||||
CarpetArgParser.Vector3Argument pos1 = CarpetArgParser.locateVector(cc, lv, 1);
|
||||
CarpetArgParser.Vector3Argument pos2 = CarpetArgParser.locateVector(cc, lv, pos1.offset);
|
||||
int offset = pos2.offset;
|
||||
double density = 1.0;
|
||||
if (lv.size() > offset)
|
||||
@@ -2531,17 +2549,17 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("create_marker", -1, (c, t, lv) ->{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockState targetBlock = null;
|
||||
BlockValue.VectorLocator pointLocator;
|
||||
CarpetArgParser.Vector3Argument pointLocator;
|
||||
boolean interactable = true;
|
||||
String name;
|
||||
try
|
||||
{
|
||||
Value nameValue = lv.get(0).evalValue(c);
|
||||
name = nameValue instanceof NullValue ? "" : nameValue.getString();
|
||||
pointLocator = BlockValue.locateVec(cc, lv, 1, true);
|
||||
pointLocator = CarpetArgParser.locateVector(cc, lv, 1, true);
|
||||
if (lv.size()>pointLocator.offset)
|
||||
{
|
||||
BlockValue.LocatorResult blockLocator = BlockValue.fromParams(cc, lv, pointLocator.offset, true, true);
|
||||
CarpetArgParser.BlockArgument blockLocator = CarpetArgParser.locateBlock(cc, lv, pointLocator.offset, true, true);
|
||||
if (blockLocator.block != null) targetBlock = blockLocator.block.getBlockState();
|
||||
if (lv.size() > blockLocator.offset)
|
||||
{
|
||||
@@ -2790,7 +2808,7 @@ public class CarpetExpression
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
|
||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||
CarpetArgParser.BlockArgument locator = CarpetArgParser.locateBlock((CarpetContext)c, lv, 0);
|
||||
if (lv.size() <= locator.offset)
|
||||
throw new InternalExpressionException("'plop' needs extra argument indicating what to plop");
|
||||
String what = lv.get(locator.offset).evalValue(c).getString();
|
||||
@@ -2946,6 +2964,7 @@ public class CarpetExpression
|
||||
API_IteratingOverAreasOfBlocks();
|
||||
API_AuxiliaryAspects();
|
||||
API_Scoreboard();
|
||||
API_Interapperability();
|
||||
}
|
||||
|
||||
public boolean fillAndScanCommand(ScriptHost host, int x, int y, int z)
|
||||
|
||||
@@ -491,4 +491,9 @@ public class CarpetScriptHost extends ScriptHost
|
||||
{
|
||||
handleErrorWithStack(message, new CarpetExpressionException(exc.getMessage(), exc.stack));
|
||||
}
|
||||
|
||||
public CarpetScriptServer getScriptServer()
|
||||
{
|
||||
return scriptServer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package carpet.script.utils;
|
||||
|
||||
import carpet.script.value.FunctionValue;
|
||||
|
||||
public class ArgParser
|
||||
{
|
||||
public static class FunctionArgument
|
||||
{
|
||||
public final FunctionValue function;
|
||||
public final int offset;
|
||||
FunctionArgument(FunctionValue f, int o)
|
||||
{
|
||||
function = f;
|
||||
offset = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package carpet.script.utils;
|
||||
|
||||
import carpet.script.CarpetContext;
|
||||
import carpet.script.LazyValue;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.value.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CarpetArgParser
|
||||
{
|
||||
public static Vector3Argument locateVector(CarpetContext c, List<LazyValue> params, int offset)
|
||||
{
|
||||
return locateVector(c,params, offset, false);
|
||||
}
|
||||
|
||||
public static Vector3Argument locateVector(CarpetContext c, List<LazyValue> params, int offset, boolean optionalDirection)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset).evalValue(c);
|
||||
if (v1 instanceof BlockValue)
|
||||
{
|
||||
return (new Vector3Argument(new Vec3d(((BlockValue) v1).getPos()).add(0.5,0.5,0.5), 1+offset)).fromBlock();
|
||||
}
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
Vec3d pos = new Vec3d(
|
||||
NumericValue.asNumber(args.get(0)).getDouble(),
|
||||
NumericValue.asNumber(args.get(1)).getDouble(),
|
||||
NumericValue.asNumber(args.get(2)).getDouble());
|
||||
double yaw = 0.0D;
|
||||
double pitch = 0.0D;
|
||||
if (args.size()>3 && optionalDirection)
|
||||
{
|
||||
yaw = NumericValue.asNumber(args.get(3)).getDouble();
|
||||
pitch = NumericValue.asNumber(args.get(4)).getDouble();
|
||||
}
|
||||
return new Vector3Argument(pos,offset+1, yaw, pitch);
|
||||
}
|
||||
Vec3d pos = new Vec3d(
|
||||
NumericValue.asNumber(v1).getDouble(),
|
||||
NumericValue.asNumber(params.get(1 + offset).evalValue(c)).getDouble(),
|
||||
NumericValue.asNumber(params.get(2 + offset).evalValue(c)).getDouble());
|
||||
double yaw = 0.0D;
|
||||
double pitch = 0.0D;
|
||||
int eatenLength = 3;
|
||||
if (params.size()>3+offset && optionalDirection)
|
||||
{
|
||||
yaw = NumericValue.asNumber(params.get(3 + offset).evalValue(c)).getDouble();
|
||||
pitch = NumericValue.asNumber(params.get(4 + offset).evalValue(c)).getDouble();
|
||||
eatenLength = 5;
|
||||
}
|
||||
|
||||
return new Vector3Argument(pos,offset+eatenLength, yaw, pitch);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new InternalExpressionException("Position should be defined either by three coordinates, or a block value");
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockArgument locateBlock(CarpetContext c, List<LazyValue> params, int offset)
|
||||
{
|
||||
return locateBlock(c, params,offset, false, false);
|
||||
}
|
||||
|
||||
public static BlockArgument locateBlock(CarpetContext c, List<LazyValue> params, int offset, boolean acceptString)
|
||||
{
|
||||
return locateBlock(c, params,offset, acceptString, false);
|
||||
}
|
||||
|
||||
public static BlockArgument locateBlock(CarpetContext c, List<LazyValue> params, int offset, boolean acceptString, boolean optional)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset).evalValue(c);
|
||||
//add conditional from string name
|
||||
if (optional && v1 instanceof NullValue)
|
||||
{
|
||||
return new BlockArgument(null, 1+offset);
|
||||
}
|
||||
if (acceptString && v1 instanceof StringValue)
|
||||
{
|
||||
return new BlockArgument(BlockValue.fromString(v1.getString()), 1+offset);
|
||||
}
|
||||
if (v1 instanceof BlockValue)
|
||||
{
|
||||
return new BlockArgument(((BlockValue) v1), 1+offset);
|
||||
}
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
int xpos = (int) NumericValue.asNumber(args.get(0)).getLong();
|
||||
int ypos = (int) NumericValue.asNumber(args.get(1)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber(args.get(2)).getLong();
|
||||
return new BlockArgument(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getWorld(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
1+offset);
|
||||
}
|
||||
int xpos = (int) NumericValue.asNumber(v1).getLong();
|
||||
int ypos = (int) NumericValue.asNumber( params.get(1 + offset).evalValue(c)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber( params.get(2 + offset).evalValue(c)).getLong();
|
||||
return new BlockArgument(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getWorld(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
3+offset
|
||||
);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new InternalExpressionException("Block should be defined either by three coordinates, a block value, or a proper string");
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockArgument fromParamValues(CarpetContext c, List<Value> params, int offset, boolean acceptString, boolean optional)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset);
|
||||
//add conditional from string name
|
||||
if (optional && v1 instanceof NullValue)
|
||||
{
|
||||
return new BlockArgument(null, 1+offset);
|
||||
}
|
||||
if (acceptString && v1 instanceof StringValue)
|
||||
{
|
||||
return new BlockArgument(BlockValue.fromString(v1.getString()), 1+offset);
|
||||
}
|
||||
if (v1 instanceof BlockValue)
|
||||
{
|
||||
return new BlockArgument(((BlockValue) v1), 1+offset);
|
||||
}
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
int xpos = (int) NumericValue.asNumber(args.get(0)).getLong();
|
||||
int ypos = (int) NumericValue.asNumber(args.get(1)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber(args.get(2)).getLong();
|
||||
return new BlockArgument(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getWorld(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
1+offset);
|
||||
}
|
||||
int xpos = (int) NumericValue.asNumber(v1).getLong();
|
||||
int ypos = (int) NumericValue.asNumber( params.get(1 + offset)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber( params.get(2 + offset)).getLong();
|
||||
return new BlockArgument(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getWorld(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
3+offset
|
||||
);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new InternalExpressionException("Block should be defined either by three coordinates, a block value, or a proper string");
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockArgument
|
||||
{
|
||||
public final BlockValue block;
|
||||
public final int offset;
|
||||
BlockArgument(BlockValue b, int o)
|
||||
{
|
||||
block = b;
|
||||
offset = o;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Vector3Argument
|
||||
{
|
||||
public Vec3d vec;
|
||||
public final int offset;
|
||||
public final double yaw;
|
||||
public final double pitch;
|
||||
public boolean fromBlock;
|
||||
Vector3Argument(Vec3d v, int o)
|
||||
{
|
||||
vec = v;
|
||||
offset = o;
|
||||
yaw = 0.0D;
|
||||
pitch = 0.0D;
|
||||
}
|
||||
Vector3Argument(Vec3d v, int o, double y, double p)
|
||||
{
|
||||
vec = v;
|
||||
offset = o;
|
||||
yaw = y;
|
||||
pitch = p;
|
||||
}
|
||||
|
||||
public Vector3Argument fromBlock()
|
||||
{
|
||||
fromBlock = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,172 +72,11 @@ public class BlockValue extends Value
|
||||
throw new InternalExpressionException("Cannot parse block: "+str);
|
||||
}
|
||||
|
||||
public static VectorLocator locateVec(CarpetContext c, List<LazyValue> params, int offset)
|
||||
{
|
||||
return locateVec(c,params, offset, false);
|
||||
}
|
||||
public static VectorLocator locateVec(CarpetContext c, List<LazyValue> params, int offset, boolean optionalDirection)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset).evalValue(c);
|
||||
if (v1 instanceof BlockValue)
|
||||
{
|
||||
return (new VectorLocator(new Vec3d(((BlockValue) v1).getPos()).add(0.5,0.5,0.5), 1+offset)).fromBlock();
|
||||
}
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
Vec3d pos = new Vec3d(
|
||||
NumericValue.asNumber(args.get(0)).getDouble(),
|
||||
NumericValue.asNumber(args.get(1)).getDouble(),
|
||||
NumericValue.asNumber(args.get(2)).getDouble());
|
||||
double yaw = 0.0D;
|
||||
double pitch = 0.0D;
|
||||
if (args.size()>3 && optionalDirection)
|
||||
{
|
||||
yaw = NumericValue.asNumber(args.get(3)).getDouble();
|
||||
pitch = NumericValue.asNumber(args.get(4)).getDouble();
|
||||
}
|
||||
return new VectorLocator(pos,offset+1, yaw, pitch);
|
||||
}
|
||||
Vec3d pos = new Vec3d(
|
||||
NumericValue.asNumber(v1).getDouble(),
|
||||
NumericValue.asNumber(params.get(1 + offset).evalValue(c)).getDouble(),
|
||||
NumericValue.asNumber(params.get(2 + offset).evalValue(c)).getDouble());
|
||||
double yaw = 0.0D;
|
||||
double pitch = 0.0D;
|
||||
int eatenLength = 3;
|
||||
if (params.size()>3+offset && optionalDirection)
|
||||
{
|
||||
yaw = NumericValue.asNumber(params.get(3 + offset).evalValue(c)).getDouble();
|
||||
pitch = NumericValue.asNumber(params.get(4 + offset).evalValue(c)).getDouble();
|
||||
eatenLength = 5;
|
||||
}
|
||||
|
||||
return new VectorLocator(pos,offset+eatenLength, yaw, pitch);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new InternalExpressionException("Position should be defined either by three coordinates, or a block value");
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockPos locateBlockPos(CarpetContext c, int xpos, int ypos, int zpos)
|
||||
{
|
||||
return new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos);
|
||||
}
|
||||
|
||||
public static LocatorResult fromParams(CarpetContext c, List<LazyValue> params, int offset)
|
||||
{
|
||||
return fromParams(c, params,offset, false, false);
|
||||
}
|
||||
|
||||
public static LocatorResult fromParams(CarpetContext c, List<LazyValue> params, int offset, boolean acceptString)
|
||||
{
|
||||
return fromParams(c, params,offset, acceptString, false);
|
||||
}
|
||||
|
||||
public static LocatorResult fromParams(CarpetContext c, List<LazyValue> params, int offset, boolean acceptString, boolean optional)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset).evalValue(c);
|
||||
//add conditional from string name
|
||||
if (optional && v1 instanceof NullValue)
|
||||
{
|
||||
return new LocatorResult(null, 1+offset);
|
||||
}
|
||||
if (acceptString && v1 instanceof StringValue)
|
||||
{
|
||||
return new LocatorResult(fromString(v1.getString()), 1+offset);
|
||||
}
|
||||
if (v1 instanceof BlockValue)
|
||||
{
|
||||
return new LocatorResult(((BlockValue) v1), 1+offset);
|
||||
}
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
int xpos = (int) NumericValue.asNumber(args.get(0)).getLong();
|
||||
int ypos = (int) NumericValue.asNumber(args.get(1)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber(args.get(2)).getLong();
|
||||
return new LocatorResult(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getWorld(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
1+offset);
|
||||
}
|
||||
int xpos = (int) NumericValue.asNumber(v1).getLong();
|
||||
int ypos = (int) NumericValue.asNumber( params.get(1 + offset).evalValue(c)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber( params.get(2 + offset).evalValue(c)).getLong();
|
||||
return new LocatorResult(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getWorld(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
3+offset
|
||||
);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new InternalExpressionException("Block should be defined either by three coordinates, a block value, or a proper string");
|
||||
}
|
||||
}
|
||||
|
||||
public static LocatorResult fromParamValues(CarpetContext c, List<Value> params, int offset, boolean acceptString, boolean optional)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset);
|
||||
//add conditional from string name
|
||||
if (optional && v1 instanceof NullValue)
|
||||
{
|
||||
return new LocatorResult(null, 1+offset);
|
||||
}
|
||||
if (acceptString && v1 instanceof StringValue)
|
||||
{
|
||||
return new LocatorResult(fromString(v1.getString()), 1+offset);
|
||||
}
|
||||
if (v1 instanceof BlockValue)
|
||||
{
|
||||
return new LocatorResult(((BlockValue) v1), 1+offset);
|
||||
}
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
int xpos = (int) NumericValue.asNumber(args.get(0)).getLong();
|
||||
int ypos = (int) NumericValue.asNumber(args.get(1)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber(args.get(2)).getLong();
|
||||
return new LocatorResult(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getWorld(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
1+offset);
|
||||
}
|
||||
int xpos = (int) NumericValue.asNumber(v1).getLong();
|
||||
int ypos = (int) NumericValue.asNumber( params.get(1 + offset)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber( params.get(2 + offset)).getLong();
|
||||
return new LocatorResult(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getWorld(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
3+offset
|
||||
);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new InternalExpressionException("Block should be defined either by three coordinates, a block value, or a proper string");
|
||||
}
|
||||
}
|
||||
|
||||
public BlockState getBlockState()
|
||||
{
|
||||
if (blockState != null)
|
||||
@@ -342,46 +181,6 @@ public class BlockValue extends Value
|
||||
public ServerWorld getWorld() { return world;}
|
||||
|
||||
|
||||
public static class LocatorResult
|
||||
{
|
||||
public final BlockValue block;
|
||||
public final int offset;
|
||||
LocatorResult(BlockValue b, int o)
|
||||
{
|
||||
block = b;
|
||||
offset = o;
|
||||
}
|
||||
}
|
||||
|
||||
public static class VectorLocator
|
||||
{
|
||||
public Vec3d vec;
|
||||
public final int offset;
|
||||
public final double yaw;
|
||||
public final double pitch;
|
||||
public boolean fromBlock;
|
||||
VectorLocator(Vec3d v, int o)
|
||||
{
|
||||
vec = v;
|
||||
offset = o;
|
||||
yaw = 0.0D;
|
||||
pitch = 0.0D;
|
||||
}
|
||||
VectorLocator(Vec3d v, int o, double y, double p)
|
||||
{
|
||||
vec = v;
|
||||
offset = o;
|
||||
yaw = y;
|
||||
pitch = p;
|
||||
}
|
||||
|
||||
public VectorLocator fromBlock()
|
||||
{
|
||||
fromBlock = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SpecificDirection {
|
||||
UP("up",0.5, 0.0, 0.5, Direction.UP),
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MapValue extends AbstractListValue implements ContainerValueInterface
|
||||
@@ -27,6 +28,15 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
|
||||
}
|
||||
}
|
||||
|
||||
public MapValue(Set<Value> keySet)
|
||||
{
|
||||
this();
|
||||
for (Value v : keySet)
|
||||
{
|
||||
map.put(v, Value.NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Value> iterator()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user