CraftScriptContext lacks a delegate for WorldEdit.getBlocks method
LadyCailinBot opened this issue ยท 2 comments
WORLDEDIT-2889 - Reported by wolfiemario
CraftScriptContext has delegates for WorldEdit.getBlock, but not WorldEdit.getBlocks. I'm not sure if I'm missing something, but because craftscripts aren't given direct access to WorldEdit (honestly, perfectly understandable), there's no way to access getBlocks without a delegate.
Refusing to resort to Reflections, I just kludged together a mimic of getBlocks for my script. I'm posting it in the off chance anyone else experiencing this issue wants a workaround until it's fixed:
function getBlocks(list, allAllowed, allowNoData)
{
var blockList = list.split(",");
var blockTypes = new HashSet();
for(var i = 0; i < blockList.length; i++)
{
var type = context.getBlock(blockList[i], allAllowed);
if(!blockList[i].contains(":") && allowNoData) // Player did not specify metadata
type.setData(-1);
blockTypes.add(type);
}
return blockTypes;
}```
Understandably, getBlocks can be useful because it allows grabbing input similar to the first parameter of the //replace command.
Comment by wizjany
craftscriptcontext delegates are for minor convenience. everything is accessible already anyway.