Browse Source

add json schema export for config files

Kolja Strohm 2 weeks ago
parent
commit
574e9216c6

+ 4 - 2
FactoryCraft/Animal.cpp

@@ -182,8 +182,10 @@ JSONObjectValidationBuilder* AnimalEntityTypeFactory::addToValidator(
         ->withRequiredAttribute("spawns",
             Framework::Validator::DataValidator::buildForArray()
                 ->addAcceptedObjectInArray()
-                ->withRequiredString("itemType")
-                ->finishString()
+                ->withRequiredAttribute("itemType",
+                    Game::INSTANCE->zTypeRegistry()
+                        ->getValidator<Framework::Text>(
+                            ItemTypeNameFactory::TYPE_ID))
                 ->withRequiredNumber("chance")
                 ->finishNumber()
                 ->withRequiredNumber("min")

+ 19 - 17
FactoryCraft/BasicBlocks.cpp

@@ -186,9 +186,10 @@ JSONObjectValidationBuilder* BasicBlockTypeFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
     return BlockTypeFactoryBase::addToValidator(
-        builder->withRequiredString("itemType")
-            ->withDefault("")
-            ->finishString()
+        builder
+            ->withRequiredAttribute("itemType",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    ItemTypeNameFactory::TYPE_ID))
             ->withRequiredBool("transparent")
             ->withDefault(false)
             ->finishBool()
@@ -363,20 +364,21 @@ JSONObjectValidationBuilder*
 AdditionalItemSpawningBlockTypeFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    return BasicBlockTypeFactory::addToValidator(
-        builder->withRequiredAttribute("spawns",
-            Framework::Validator::DataValidator::buildForArray()
-                ->addAcceptedObjectInArray()
-                ->withRequiredString("itemType")
-                ->finishString()
-                ->withRequiredNumber("chance")
-                ->finishNumber()
-                ->withRequiredNumber("min")
-                ->finishNumber()
-                ->withRequiredNumber("max")
-                ->finishNumber()
-                ->finishObject()
-                ->finishArray()));
+    return BasicBlockTypeFactory::addToValidator(builder->withRequiredAttribute(
+        "spawns",
+        Framework::Validator::DataValidator::buildForArray()
+            ->addAcceptedObjectInArray()
+            ->withRequiredAttribute("itemType",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    ItemTypeNameFactory::TYPE_ID))
+            ->withRequiredNumber("chance")
+            ->finishNumber()
+            ->withRequiredNumber("min")
+            ->finishNumber()
+            ->withRequiredNumber("max")
+            ->finishNumber()
+            ->finishObject()
+            ->finishArray()));
 }
 
 const char* AdditionalItemSpawningBlockTypeFactory::getTypeToken() const

+ 6 - 4
FactoryCraft/BasicTool.cpp

@@ -629,8 +629,9 @@ JSONObjectValidationBuilder* BasicToolItemTypeFactory::addToValidator(
             ->withDefault(0.0)
             ->whichIsGreaterOrEqual(0.0)
             ->finishNumber()
-            ->withRequiredString("brokenItemTypeName")
-            ->finishString()
+            ->withRequiredAttribute("brokenItemTypeName",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    ItemTypeNameFactory::TYPE_ID))
             ->withRequiredAttribute("levelUpRule",
                 Game::INSTANCE->zTypeRegistry()
                     ->getValidator<ItemSkillLevelUpRule>())
@@ -864,8 +865,9 @@ JSONObjectValidationBuilder* BlockReplaceItemSkillConfigFactory::addToValidator(
     return builder
         ->withRequiredAttribute("targetFilter",
             Game::INSTANCE->zTypeRegistry()->getValidator<BlockFilter>())
-        ->withRequiredString("replacementBlockType")
-        ->finishString()
+        ->withRequiredAttribute("replacementBlockType",
+            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                BlockTypeNameFactory::TYPE_ID))
         ->withRequiredNumber("cooldownTicks")
         ->whichIsGreaterOrEqual(0)
         ->withDefault(20)

+ 3 - 2
FactoryCraft/BlockFilter.cpp

@@ -269,8 +269,9 @@ JSONObjectValidationBuilder* BlockFilterBlockTypeFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
     return builder->withRequiredArray("typeNames")
-        ->addAcceptedStringInArray()
-        ->finishString()
+        ->addAcceptedTypeInArray(
+            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                BlockTypeNameFactory::TYPE_ID))
         ->finishArray();
 }
 

+ 3 - 12
FactoryCraft/BlockInstanceGeneratorRule.cpp

@@ -57,19 +57,10 @@ Framework::JSON::JSONObject* BlockInstanceGeneratorRuleFactory::toJsonObject(
 JSONObjectValidationBuilder* BlockInstanceGeneratorRuleFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    Framework::RCArray<Framework::Text> blockTypeNames;
-    for (int i = 0; i < Game::INSTANCE->getBlockTypeCount(); i++)
-    {
-        if (Game::INSTANCE->zBlockType(i))
-        {
-            blockTypeNames.add(
-                new Framework::Text(Game::INSTANCE->zBlockType(i)->getName()));
-        }
-    }
     return GeneratorRuleFactory::addToValidator(
-        builder->withRequiredString("blockType")
-            ->whichIsOneOf(blockTypeNames)
-            ->finishString());
+        builder->withRequiredAttribute("blockType",
+            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                BlockTypeNameFactory::TYPE_ID)));
 }
 
 const char* BlockInstanceGeneratorRuleFactory::getTypeToken() const

+ 3 - 12
FactoryCraft/BlockTypeGeneratorRule.cpp

@@ -56,19 +56,10 @@ Framework::JSON::JSONObject* BlockTypeGeneratorRuleFactory::toJsonObject(
 JSONObjectValidationBuilder* BlockTypeGeneratorRuleFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    Framework::RCArray<Framework::Text> blockTypeNames;
-    for (int i = 0; i < Game::INSTANCE->getBlockTypeCount(); i++)
-    {
-        if (Game::INSTANCE->zBlockType(i))
-        {
-            blockTypeNames.add(
-                new Framework::Text(Game::INSTANCE->zBlockType(i)->getName()));
-        }
-    }
     return GeneratorRuleFactory::addToValidator(
-        builder->withRequiredString("blockType")
-            ->whichIsOneOf(blockTypeNames)
-            ->finishString());
+        builder->withRequiredAttribute("blockType",
+            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                BlockTypeNameFactory::TYPE_ID)));
 }
 
 const char* BlockTypeGeneratorRuleFactory::getTypeToken() const

+ 49 - 0
FactoryCraft/BlockTypeNameFactory.cpp

@@ -0,0 +1,49 @@
+#include "BlockTypeNameFactory.h"
+
+const Framework::Text BlockTypeNameFactory::TYPE_ID = "BlockTypeName";
+
+BlockTypeNameFactory::BlockTypeNameFactory()
+    : SimpleTypeFactory<Framework::Text*>(),
+      blockTypeNames(0)
+{}
+
+BlockTypeNameFactory::~BlockTypeNameFactory()
+{
+    if (blockTypeNames)
+    {
+        blockTypeNames->release();
+    }
+}
+
+void BlockTypeNameFactory::setBlockTypeNames(
+    Framework::RCArray<Framework::Text>* blockTypeNames)
+{
+    this->blockTypeNames = blockTypeNames;
+}
+
+Framework::Text* BlockTypeNameFactory::fromJson(
+    Framework::JSON::JSONValue* zJson) const
+{
+    return new Framework::Text(zJson->asString()->getString());
+}
+
+Framework::JSON::JSONValue* BlockTypeNameFactory::toJson(
+    Framework::Text* value) const
+{
+    return new Framework::JSON::JSONString(value->getText());
+}
+
+Framework::Validator::DataValidator* BlockTypeNameFactory::getValidator() const
+{
+    if (!blockTypeNames)
+    {
+        return Framework::Validator::DataValidator::buildForString()
+            ->finishString();
+    }
+    else
+    {
+        return Framework::Validator::DataValidator::buildForString()
+            ->whichIsOneOf(*blockTypeNames)
+            ->finishString();
+    }
+}

+ 20 - 0
FactoryCraft/BlockTypeNameFactory.h

@@ -0,0 +1,20 @@
+#pragma once
+
+#include "TypeRegistry.h"
+
+class BlockTypeNameFactory : public SimpleTypeFactory<Framework::Text*>
+{
+public:
+    static const Framework::Text TYPE_ID;
+
+private:
+    Framework::RCArray<Framework::Text>* blockTypeNames;
+
+public:
+    BlockTypeNameFactory();
+    ~BlockTypeNameFactory();
+    void setBlockTypeNames(Framework::RCArray<Framework::Text>* blockTypeNames);
+    Framework::Text* fromJson(Framework::JSON::JSONValue* zJson) const override;
+    Framework::JSON::JSONValue* toJson(Framework::Text* value) const override;
+    Framework::Validator::DataValidator* getValidator() const override;
+};

+ 1 - 0
FactoryCraft/EntityGenerator.cpp

@@ -114,6 +114,7 @@ JSONObjectValidationBuilder* EntityGeneratorFactory::addToValidator(
                 new Framework::Text(Game::INSTANCE->zEntityType(i)->getName()));
         }
     }
+    // TODO: add EntityTypeNameFactory
     return builder->withRequiredAttribute("noise", JNoise::getValidator(true))
         ->withRequiredNumber("threshold")
         ->whichIsOptional()

+ 4 - 0
FactoryCraft/FactoryCraft.vcxproj

@@ -102,6 +102,7 @@
     <ClInclude Include="BlockFilter.h" />
     <ClInclude Include="BlockInfoCommand.h" />
     <ClInclude Include="BlockInstanceGeneratorRule.h" />
+    <ClInclude Include="BlockTypeNameFactory.h" />
     <ClInclude Include="EntityGenerator.h" />
     <ClInclude Include="FactorizeNoise.h" />
     <ClInclude Include="FlattenNoise.h" />
@@ -151,6 +152,7 @@
     <ClInclude Include="ItemSlot.h" />
     <ClInclude Include="ItemStack.h" />
     <ClInclude Include="ItemType.h" />
+    <ClInclude Include="ItemTypeNameFactory.h" />
     <ClInclude Include="JNoise.h" />
     <ClInclude Include="JsonExpression.h" />
     <ClInclude Include="JsonUtils.h" />
@@ -215,6 +217,7 @@
     <ClCompile Include="BlockInstanceGeneratorRule.cpp" />
     <ClCompile Include="BlockType.cpp" />
     <ClCompile Include="BlockTypeGeneratorRule.cpp" />
+    <ClCompile Include="BlockTypeNameFactory.cpp" />
     <ClCompile Include="CaveGenerator.cpp" />
     <ClCompile Include="Chat.cpp" />
     <ClCompile Include="ChatCommand.cpp" />
@@ -254,6 +257,7 @@
     <ClCompile Include="ItemSlot.cpp" />
     <ClCompile Include="ItemStack.cpp" />
     <ClCompile Include="ItemType.cpp" />
+    <ClCompile Include="ItemTypeNameFactory.cpp" />
     <ClCompile Include="JNoise.cpp" />
     <ClCompile Include="JsonExpression.cpp" />
     <ClCompile Include="JsonUtils.cpp" />

+ 12 - 0
FactoryCraft/FactoryCraft.vcxproj.filters

@@ -417,6 +417,12 @@
     <ClInclude Include="GameClient.h">
       <Filter>game</Filter>
     </ClInclude>
+    <ClInclude Include="BlockTypeNameFactory.h">
+      <Filter>server\config</Filter>
+    </ClInclude>
+    <ClInclude Include="ItemTypeNameFactory.h">
+      <Filter>server\config</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Server.cpp">
@@ -713,5 +719,11 @@
     <ClCompile Include="GameClient.cpp">
       <Filter>game</Filter>
     </ClCompile>
+    <ClCompile Include="BlockTypeNameFactory.cpp">
+      <Filter>server\config</Filter>
+    </ClCompile>
+    <ClCompile Include="ItemTypeNameFactory.cpp">
+      <Filter>server\config</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 56 - 1
FactoryCraft/Game.cpp

@@ -32,6 +32,8 @@ Game::Game(Framework::Text name, Framework::Text worldsDir)
     : Thread(),
       name(name),
       typeRegistry(new TypeRegistry()),
+      blockTypeNameFactory(new BlockTypeNameFactory()),
+      itemTypeNameFactory(new ItemTypeNameFactory()),
       dimensions(new RCArray<Dimension>()),
       clients(new RCArray<GameClient>()),
       questManager(new QuestManager()),
@@ -60,6 +62,11 @@ Game::Game(Framework::Text name, Framework::Text worldsDir)
       multiblockStructureTypes(0),
       multiblockStructureTypeCount(0)
 {
+    typeRegistry->registerType(
+        BlockTypeNameFactory::TYPE_ID, blockTypeNameFactory);
+    typeRegistry->registerType(
+        ItemTypeNameFactory::TYPE_ID, itemTypeNameFactory);
+
     if (!DateiExistiert(path)) DateiPfadErstellen(path + "/");
     Datei d;
     d.setDatei(path + "/eid");
@@ -154,10 +161,14 @@ void Game::initialize()
     {
         blockTypes[blockTypeCount++] = blockType;
     }
+    Framework::RCArray<Framework::Text>* blockTypeNames
+        = new Framework::RCArray<Framework::Text>();
     for (int i = 0; i < blockTypeCount; i++)
     {
+        blockTypeNames->add(new Framework::Text(blockTypes[i]->getName()));
         blockTypes[i]->setTypeId(i);
     }
+    blockTypeNameFactory->setBlockTypeNames(blockTypeNames);
     Framework::Logging::info() << "Loading item types";
     Framework::Array<ItemType*> itemTypeArray;
     validator
@@ -210,13 +221,17 @@ void Game::initialize()
     {
         itemTypes[itemTypeCount++] = itemType;
     }
+    Framework::RCArray<Framework::Text>* itemTypeNames
+        = new Framework::RCArray<Framework::Text>();
     for (int i = 0; i < itemTypeCount; i++)
     {
         itemTypes[i]->setTypeId(i);
+        itemTypeNames->add(new Framework::Text(itemTypes[i]->getName()));
     }
+    itemTypeNameFactory->setItemTypeNames(itemTypeNames);
     Framework::Logging::info() << "Loading entity types";
     Framework::Array<EntityType*> entityTypeArray;
-    /* validator
+    /*validator
         = Framework::JSON::Validator::JSONValidator::buildForArray()
               ->addAcceptedTypeInArray(typeRegistry->getValidator<EntityType>())
               ->removeInvalidEntries()
@@ -328,6 +343,46 @@ void Game::initialize()
     // save syntax info
     Framework::DateiRemove("data/syntax");
     typeRegistry->writeSyntaxInfo("data/syntax");
+
+    validator
+        = Framework::Validator::DataValidator::buildForArray()
+              ->addAcceptedTypeInArray(typeRegistry->getValidator<BlockType>())
+              ->finishArray();
+    Framework::JSON::JSONObject* schema = validator->getJsonSchema();
+    Framework::Datei syntaxFile;
+    syntaxFile.setDatei("data/syntax/schema/blocks.json");
+    syntaxFile.erstellen();
+    syntaxFile.open(Framework::Datei::Style::schreiben);
+    syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
+    syntaxFile.close();
+    schema->release();
+    validator->release();
+
+    validator
+        = Framework::Validator::DataValidator::buildForArray()
+              ->addAcceptedTypeInArray(typeRegistry->getValidator<ItemType>())
+              ->finishArray();
+    schema = validator->getJsonSchema();
+    syntaxFile.setDatei("data/syntax/schema/items.json");
+    syntaxFile.erstellen();
+    syntaxFile.open(Framework::Datei::Style::schreiben);
+    syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
+    syntaxFile.close();
+    schema->release();
+    validator->release();
+    validator
+        = Framework::Validator::DataValidator::buildForArray()
+              ->addAcceptedTypeInArray(typeRegistry->getValidator<EntityType>())
+              ->finishArray();
+    schema = validator->getJsonSchema();
+    syntaxFile.setDatei("data/syntax/schema/entities.json");
+    syntaxFile.erstellen();
+    syntaxFile.open(Framework::Datei::Style::schreiben);
+    syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
+    syntaxFile.close();
+    schema->release();
+    validator->release();
+
     // initialize world generator and world loader
     int seed = 0;
     int index = 0;

+ 4 - 0
FactoryCraft/Game.h

@@ -10,8 +10,10 @@
 #include <Thread.h>
 
 #include "Area.h"
+#include "BlockTypeNameFactory.h"
 #include "Constants.h"
 #include "GameClient.h"
+#include "ItemTypeNameFactory.h"
 #include "NetworkMessage.h"
 #include "TypeRegistry.h"
 
@@ -39,6 +41,8 @@ public:
 private:
     Framework::Text name;
     TypeRegistry* typeRegistry;
+    BlockTypeNameFactory* blockTypeNameFactory;
+    ItemTypeNameFactory* itemTypeNameFactory;
     Framework::RCArray<Dimension>* dimensions;
     Framework::RCArray<GameClient>* clients;
     Framework::Array<std::function<void()>> actions;

+ 3 - 2
FactoryCraft/GrowingPlant.cpp

@@ -364,8 +364,9 @@ JSONObjectValidationBuilder* GrowingPlantBlockTypeFactory::addToValidator(
             ->finishString()
             ->withRequiredNumber("ticksNeeded")
             ->finishNumber()
-            ->withRequiredString("blockTypeAfterGrowth")
-            ->finishString()
+            ->withRequiredAttribute("blockTypeAfterGrowth",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    BlockTypeNameFactory::TYPE_ID))
             ->withRequiredArray("states")
             ->addAcceptedObjectInArray()
             ->withRequiredNumber("percentage")

+ 4 - 12
FactoryCraft/Item.cpp

@@ -201,17 +201,9 @@ Framework::JSON::JSONObject* ItemJsonType::toJsonObject(Item* zObject) const
 JSONObjectValidationBuilder* ItemJsonType::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    Framework::RCArray<Framework::Text> itemTypes;
-    for (int index = 0; index < Game::INSTANCE->getItemTypeCount(); index++)
-    {
-        if (Game::INSTANCE->zItemType(index))
-        {
-            itemTypes.add(new Framework::Text(
-                Game::INSTANCE->zItemType(index)->getName()));
-        }
-    }
-    return builder->withRequiredString("type")
-        ->whichIsOneOf(itemTypes)
-        ->finishString()
+    return builder
+        ->withRequiredAttribute("type",
+            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                ItemTypeNameFactory::TYPE_ID))
         ->allowAdditionalAttriutes();
 }

+ 3 - 12
FactoryCraft/ItemFilter.cpp

@@ -465,18 +465,9 @@ Framework::JSON::JSONObject* TypeItemFilterFactory::toJsonObject(
 JSONObjectValidationBuilder* TypeItemFilterFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    Framework::RCArray<Framework::Text> types;
-    for (int i = 0; i < Game::INSTANCE->getItemTypeCount(); i++)
-    {
-        if (Game::INSTANCE->zItemType(i))
-        {
-            types.add(
-                new Framework::Text(Game::INSTANCE->zItemType(i)->getName()));
-        }
-    }
-    return builder->withRequiredString("itemType")
-        ->whichIsOneOf(types)
-        ->finishString();
+    return builder->withRequiredAttribute("itemType",
+        Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+            ItemTypeNameFactory::TYPE_ID));
 }
 
 const char* TypeItemFilterFactory::getTypeToken() const

+ 49 - 0
FactoryCraft/ItemTypeNameFactory.cpp

@@ -0,0 +1,49 @@
+#include "ItemTypeNameFactory.h"
+
+const Framework::Text ItemTypeNameFactory::TYPE_ID = "ItemTypeName";
+
+ItemTypeNameFactory::ItemTypeNameFactory()
+    : SimpleTypeFactory<Framework::Text*>(),
+      itemTypeNames(0)
+{}
+
+ItemTypeNameFactory::~ItemTypeNameFactory()
+{
+    if (itemTypeNames)
+    {
+        itemTypeNames->release();
+    }
+}
+
+void ItemTypeNameFactory::setItemTypeNames(
+    Framework::RCArray<Framework::Text>* itemTypeNames)
+{
+    this->itemTypeNames = itemTypeNames;
+}
+
+Framework::Text* ItemTypeNameFactory::fromJson(
+    Framework::JSON::JSONValue* zJson) const
+{
+    return new Framework::Text(zJson->asString()->getString());
+}
+
+Framework::JSON::JSONValue* ItemTypeNameFactory::toJson(
+    Framework::Text* value) const
+{
+    return new Framework::JSON::JSONString(value->getText());
+}
+
+Framework::Validator::DataValidator* ItemTypeNameFactory::getValidator() const
+{
+    if (!itemTypeNames)
+    {
+        return Framework::Validator::DataValidator::buildForString()
+            ->finishString();
+    }
+    else
+    {
+        return Framework::Validator::DataValidator::buildForString()
+            ->whichIsOneOf(*itemTypeNames)
+            ->finishString();
+    }
+}

+ 20 - 0
FactoryCraft/ItemTypeNameFactory.h

@@ -0,0 +1,20 @@
+#pragma once
+
+#include "TypeRegistry.h"
+
+class ItemTypeNameFactory : public SimpleTypeFactory<Framework::Text*>
+{
+public:
+    static const Framework::Text TYPE_ID;
+
+private:
+    Framework::RCArray<Framework::Text>* itemTypeNames;
+
+public:
+    ItemTypeNameFactory();
+    ~ItemTypeNameFactory();
+    void setItemTypeNames(Framework::RCArray<Framework::Text>* itemTypeNames);
+    Framework::Text* fromJson(Framework::JSON::JSONValue* zJson) const override;
+    Framework::JSON::JSONValue* toJson(Framework::Text* value) const override;
+    Framework::Validator::DataValidator* getValidator() const override;
+};

+ 4 - 12
FactoryCraft/JsonExpression.cpp

@@ -888,18 +888,10 @@ Framework::JSON::JSONObject* JBlockTypeBoolExpressionFactory::toJsonObject(
 JSONObjectValidationBuilder* JBlockTypeBoolExpressionFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    Framework::RCArray<Framework::Text> blockTypeNames;
-    for (int i = 0; i < Game::INSTANCE->getBlockTypeCount(); i++)
-    {
-        if (Game::INSTANCE->zBlockType(i))
-        {
-            blockTypeNames.add(
-                new Framework::Text(Game::INSTANCE->zBlockType(i)->getName()));
-        }
-    }
-    return builder->withRequiredString("blockType")
-        ->whichIsOneOf(blockTypeNames)
-        ->finishString()
+    return builder
+        ->withRequiredAttribute("blockType",
+            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                BlockTypeNameFactory::TYPE_ID))
         ->withRequiredAttribute("x",
             Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>())
         ->withRequiredAttribute("y",

+ 4 - 2
FactoryCraft/LightSources.cpp

@@ -263,8 +263,10 @@ JSONObjectValidationBuilder* BasicLightSourceBlockTypeFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
     return BlockTypeFactoryBase::addToValidator(
-        builder->withRequiredString("itemType")
-            ->finishString()
+        builder
+            ->withRequiredAttribute("itemType",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    ItemTypeNameFactory::TYPE_ID))
             ->withRequiredBool("transparent")
             ->withDefault(true)
             ->finishBool()

+ 8 - 0
FactoryCraft/Quest.cpp

@@ -731,6 +731,14 @@ void QuestManager::loadQuests()
                     validPart->asObject()));
         }
         valid->release();
+        Framework::JSON::JSONObject* schema = validator->getJsonSchema();
+        Framework::Datei syntaxFile;
+        syntaxFile.setDatei("data/syntax/schema/quests.json");
+        syntaxFile.erstellen();
+        syntaxFile.open(Framework::Datei::Style::schreiben);
+        syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
+        syntaxFile.close();
+        schema->release();
         validator->release();
     }
     value = Framework::JSON::loadJSONFromFile(questDir + "/parties.json");

+ 4 - 12
FactoryCraft/Recipie.cpp

@@ -196,18 +196,10 @@ JSONObjectValidationBuilder* RecipieOutputFactory::addToValidator(
         = new Framework::JSON::JSONObject();
     defaultModifier->addValue(
         "type", new Framework::JSON::JSONString("doNothing"));
-    Framework::RCArray<Framework::Text> itemTypes;
-    for (int i = 0; i < Game::INSTANCE->getItemTypeCount(); i++)
-    {
-        if (Game::INSTANCE->zItemType(i))
-        {
-            itemTypes.add(
-                new Framework::Text(Game::INSTANCE->zItemType(i)->getName()));
-        }
-    }
-    return builder->withRequiredString("itemType")
-        ->whichIsOneOf(itemTypes)
-        ->finishString()
+    return builder
+        ->withRequiredAttribute("itemType",
+            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                ItemTypeNameFactory::TYPE_ID))
         ->withRequiredAttribute("modifier",
             Game::INSTANCE->zTypeRegistry()->getValidator<ItemModifier>())
         ->withRequiredObject("modifier")

+ 16 - 7
FactoryCraft/RecipieLoader.cpp

@@ -24,16 +24,16 @@ RecipieLoader::~RecipieLoader()
 
 void RecipieLoader::loadRecipies(const char* path)
 {
+    DataValidator* validator
+        = Framework::Validator::DataValidator::buildForArray()
+              ->addAcceptedTypeInArray(
+                  Game::INSTANCE->zTypeRegistry()->getValidator<Recipie>())
+              ->removeInvalidEntries()
+              ->finishArray();
     loadAllJsonsFromDirectory(
-        path, [this](JSONValue* zJson, Framework::Text path) {
+        path, [this, &validator](JSONValue* zJson, Framework::Text path) {
             Framework::Logging::info()
                 << "loading recipies from '" << path << "'";
-            DataValidator* validator
-                = Framework::Validator::DataValidator::buildForArray()
-                      ->addAcceptedTypeInArray(Game::INSTANCE->zTypeRegistry()
-                                                   ->getValidator<Recipie>())
-                      ->removeInvalidEntries()
-                      ->finishArray();
             Framework::RCArray<ValidationResult> invalidParts;
             JSONValue* valid = validator->getValidParts(zJson, &invalidParts);
             for (ValidationResult* invalidPart : invalidParts)
@@ -64,6 +64,15 @@ void RecipieLoader::loadRecipies(const char* path)
             }
             Framework::Logging::info() << count << " recipies were loaded.";
         });
+    Framework::JSON::JSONObject* schema = validator->getJsonSchema();
+    Framework::Datei syntaxFile;
+    syntaxFile.setDatei("data/syntax/schema/recipies.json");
+    syntaxFile.erstellen();
+    syntaxFile.open(Framework::Datei::Style::schreiben);
+    syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
+    syntaxFile.close();
+    schema->release();
+    validator->release();
 }
 
 RecipieList* RecipieLoader::zRecipieList(const char* name) const

+ 10 - 6
FactoryCraft/TreeSeblingBlock.cpp

@@ -286,12 +286,16 @@ JSONObjectValidationBuilder* TreeSeblingBlockTypeFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
     return BlockTypeFactoryBase::addToValidator(
-        builder->withRequiredString("itemType")
-            ->finishString()
-            ->withRequiredString("woodType")
-            ->finishString()
-            ->withRequiredString("leavesType")
-            ->finishString()
+        builder
+            ->withRequiredAttribute("itemType",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    ItemTypeNameFactory::TYPE_ID))
+            ->withRequiredAttribute("woodType",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    BlockTypeNameFactory::TYPE_ID))
+            ->withRequiredAttribute("leavesType",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    BlockTypeNameFactory::TYPE_ID))
             ->withRequiredBool("transparent")
             ->withDefault(true)
             ->finishBool()

+ 7 - 15
FactoryCraft/TreeTemplate.cpp

@@ -157,22 +157,14 @@ Framework::JSON::JSONObject* TreeTemplateFactory::toJsonObject(
 JSONObjectValidationBuilder* TreeTemplateFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    Framework::RCArray<Framework::Text> blockTypeNames;
-    for (int i = 0; i < Game::INSTANCE->getBlockTypeCount(); i++)
-    {
-        if (Game::INSTANCE->zBlockType(i))
-        {
-            blockTypeNames.add(
-                new Framework::Text(Game::INSTANCE->zBlockType(i)->getName()));
-        }
-    }
     return GeneratorTemplateFactory::addToValidator(
-        builder->withRequiredString("wood")
-            ->whichIsOneOf(blockTypeNames)
-            ->finishString()
-            ->withRequiredString("leaves")
-            ->whichIsOneOf(blockTypeNames)
-            ->finishString()
+        builder
+            ->withRequiredAttribute("wood",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    BlockTypeNameFactory::TYPE_ID))
+            ->withRequiredAttribute("leaves",
+                Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
+                    BlockTypeNameFactory::TYPE_ID))
             ->withRequiredNumber("minSize")
             ->whichIsGreaterThen(0)
             ->finishNumber()

+ 6 - 1
FactoryCraft/TypeRegistry.h

@@ -422,7 +422,12 @@ public:
     template<typename T>
     Framework::Validator::DataValidator* getValidator() const
     {
-        Framework::Text typeId = typeid(T).name();
+        return getValidator<T>(typeid(T).name());
+    }
+
+    template<typename T> Framework::Validator::DataValidator* getValidator(
+        Framework::Text typeId) const
+    {
         TypeFatoryRef* typeFactoryRef
             = parsableTypes.z(typeId, typeId.getLength());
         if (!typeFactoryRef)

+ 8 - 0
FactoryCraft/WorldGenerator.cpp

@@ -53,6 +53,14 @@ WorldGenerator::WorldGenerator(int seed)
                 valid->release();
             }
         });
+    Framework::JSON::JSONObject* schema = configValidator->getJsonSchema();
+    Framework::Datei syntaxFile;
+    syntaxFile.setDatei("data/syntax/schema/generator.json");
+    syntaxFile.erstellen();
+    syntaxFile.open(Framework::Datei::Style::schreiben);
+    syntaxFile.schreibe(schema->toString(), schema->toString().getLength());
+    syntaxFile.close();
+    schema->release();
     configValidator->release();
 
     start();

+ 4 - 0
Windows Version/Windows Version.vcxproj

@@ -172,6 +172,7 @@ copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll<
     <ClCompile Include="..\FactoryCraft\BlockInstanceGeneratorRule.cpp" />
     <ClCompile Include="..\FactoryCraft\BlockType.cpp" />
     <ClCompile Include="..\FactoryCraft\BlockTypeGeneratorRule.cpp" />
+    <ClCompile Include="..\FactoryCraft\BlockTypeNameFactory.cpp" />
     <ClCompile Include="..\FactoryCraft\CaveGenerator.cpp" />
     <ClCompile Include="..\FactoryCraft\Chat.cpp" />
     <ClCompile Include="..\FactoryCraft\ChatCommand.cpp" />
@@ -211,6 +212,7 @@ copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll<
     <ClCompile Include="..\FactoryCraft\ItemSlot.cpp" />
     <ClCompile Include="..\FactoryCraft\ItemStack.cpp" />
     <ClCompile Include="..\FactoryCraft\ItemType.cpp" />
+    <ClCompile Include="..\FactoryCraft\ItemTypeNameFactory.cpp" />
     <ClCompile Include="..\FactoryCraft\JNoise.cpp" />
     <ClCompile Include="..\FactoryCraft\JsonExpression.cpp" />
     <ClCompile Include="..\FactoryCraft\JsonUtils.cpp" />
@@ -264,6 +266,7 @@ copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll<
     <ClInclude Include="..\FactoryCraft\BlockFilter.h" />
     <ClInclude Include="..\FactoryCraft\BlockInfoCommand.h" />
     <ClInclude Include="..\FactoryCraft\BlockInstanceGeneratorRule.h" />
+    <ClInclude Include="..\FactoryCraft\BlockTypeNameFactory.h" />
     <ClInclude Include="..\FactoryCraft\EntityGenerator.h" />
     <ClInclude Include="..\FactoryCraft\FactorizeNoise.h" />
     <ClInclude Include="..\FactoryCraft\FlattenNoise.h" />
@@ -313,6 +316,7 @@ copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll<
     <ClInclude Include="..\FactoryCraft\ItemSlot.h" />
     <ClInclude Include="..\FactoryCraft\ItemStack.h" />
     <ClInclude Include="..\FactoryCraft\ItemType.h" />
+    <ClInclude Include="..\FactoryCraft\ItemTypeNameFactory.h" />
     <ClInclude Include="..\FactoryCraft\JNoise.h" />
     <ClInclude Include="..\FactoryCraft\JsonExpression.h" />
     <ClInclude Include="..\FactoryCraft\JsonUtils.h" />

+ 12 - 0
Windows Version/Windows Version.vcxproj.filters

@@ -402,6 +402,12 @@
     <ClCompile Include="..\FactoryCraft\GameClient.cpp">
       <Filter>game</Filter>
     </ClCompile>
+    <ClCompile Include="..\FactoryCraft\BlockTypeNameFactory.cpp">
+      <Filter>server\config</Filter>
+    </ClCompile>
+    <ClCompile Include="..\FactoryCraft\ItemTypeNameFactory.cpp">
+      <Filter>server\config</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\FactoryCraft\Chunk.h">
@@ -713,5 +719,11 @@
     <ClInclude Include="..\FactoryCraft\GameClient.h">
       <Filter>game</Filter>
     </ClInclude>
+    <ClInclude Include="..\FactoryCraft\BlockTypeNameFactory.h">
+      <Filter>server\config</Filter>
+    </ClInclude>
+    <ClInclude Include="..\FactoryCraft\ItemTypeNameFactory.h">
+      <Filter>server\config</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>

+ 1 - 0
Windows Version/data/blocks/blockTypes.json

@@ -405,6 +405,7 @@
   {
     "type": "grass",
     "name": "Grass",
+    "itemType": "",
     "model": {
       "modelPath": "grass",
       "texturePaths": [

+ 1 - 0
Windows Version/data/generator/overworld.json

@@ -241,6 +241,7 @@
     "bioms": [
       {
         "name": "Grassland",
+        "entities": [],
         "structurCollections": [
           {
             "activeNoise": {