#include "BlockTypeGeneratorRule.h" BlockTypeGeneratorRule::BlockTypeGeneratorRule( Framework::JSON::JSONValue* zConfig, JExpressionMemory* zMemory) : GeneratorRule(zConfig, zMemory) { blockType = BlockType::getTypeId( zConfig->asObject()->zValue("blockType")->asString()->getString()); } Framework::Either BlockTypeGeneratorRule::createBlock( int x, int y, int z, int dimensionId) { return blockType; } BlockTypeGeneratorRuleFactory::BlockTypeGeneratorRuleFactory() : ReferenceCounter() {} GeneratorRule* BlockTypeGeneratorRuleFactory::createRule( Framework::JSON::JSONValue* zConfig, JExpressionMemory* zMemory) { return new BlockTypeGeneratorRule(zConfig, zMemory); } Framework::JSON::Validator::JSONValidator* BlockTypeGeneratorRuleFactory::getValidator() { Framework::RCArray blockTypeNames; for (int i = 0; i < StaticRegistry::INSTANCE.getCount(); i++) { if (StaticRegistry::INSTANCE.zElement(i)) { blockTypeNames.add(new Framework::Text( StaticRegistry::INSTANCE.zElement(i)->getName())); } } return GeneratorRule::addToValidator( Framework::JSON::Validator::JSONValidator::buildForObject() ->withRequiredString("type") ->withExactMatch("blockType") ->finishString() ->withRequiredString("blockType") ->whichIsOneOf(blockTypeNames) ->finishString()) ->finishObject(); }