How to use parseComplexValue method of be.seeseemelk.mockbukkit.tags.TagParser class

Best MockBukkit code snippet using be.seeseemelk.mockbukkit.tags.TagParser.parseComplexValue

Source:TagParser.java Github

copy

Full Screen

...106 else if (element instanceof JsonObject)107 {108 // JSONObjects can have a "required" property which can make109 // it optional to resolve the underlying value110 parseComplexValue(element.getAsJsonObject(), materials, tags);111 }112 else113 {114 throw new TagMisconfigurationException(key, "Unexpected value format: "115 + element.getClass().getSimpleName() + " - " + element.toString());116 }117 }118 // Run the callback with the filled-in materials and tags119 callback.accept(materials, tags);120 }121 else122 {123 // The JSON seems to be empty yet valid124 throw new TagMisconfigurationException(key, "No values array specified");125 }126 }127 catch (IllegalStateException | JsonParseException x)128 {129 throw new TagMisconfigurationException(key, x.getMessage());130 }131 }132 private void parsePrimitiveValue(@NotNull String value, @NotNull Set<Material> materials,133 @NotNull Set<TagWrapperMock> tags) throws TagMisconfigurationException134 {135 if (MINECRAFT_MATERIAL.matcher(value).matches())136 {137 // Match the NamespacedKey against Materials138 Material material = Material.matchMaterial(value);139 if (material != null)140 {141 // If the Material could be matched, simply add it to our Set142 materials.add(material);143 }144 else145 {146 throw new TagMisconfigurationException(key, "Minecraft Material '" + value + "' seems to not exist!");147 }148 }149 else if (MINECRAFT_TAG.matcher(value).matches())150 {151 NamespacedKey tagKey = NamespacedKey.minecraft(COLON.split(value)[1]);152 TagWrapperMock tag = registry.getTags().get(tagKey);153 if (tag != null)154 {155 tags.add(tag);156 }157 else158 {159 throw new TagMisconfigurationException(key,160 "There is no '" + value + "' tag in Minecraft:" + registry.getRegistry());161 }162 }163 else164 {165 // If no RegEx pattern matched, it's malformed.166 throw new TagMisconfigurationException(key, "Could not recognize value '" + value + "'");167 }168 }169 private void parseComplexValue(@NotNull JsonObject entry, @NotNull Set<Material> materials,170 @NotNull Set<TagWrapperMock> tags) throws TagMisconfigurationException171 {172 JsonElement id = entry.get("id");173 JsonElement required = entry.get("required");174 // Check if the entry contains elements of the correct type175 if (id instanceof JsonPrimitive && ((JsonPrimitive) id).isString() && required instanceof JsonPrimitive176 && ((JsonPrimitive) required).isBoolean())177 {178 if (required.getAsBoolean())179 {180 // If this entry is required, parse it like normal181 parsePrimitiveValue(id.getAsString(), materials, tags);182 }183 else...

Full Screen

Full Screen

parseComplexValue

Using AI Code Generation

copy

Full Screen

1@DisplayName ( "TagParserTest" ) 2 class TagParserTest { 3 private TagParser tagParser ; 4 void setUp ( ) { 5 tagParser = new TagParser ( ) ; 6 } 7 void testParseComplexValue ( ) { 8 String value = "foo,bar,baz" ; 9 String [ ] split = tagParser . parseComplexValue ( value ) ; 10 String [ ] expected = new String [ ] { "foo" , "bar" , "baz" } ; 11 assertArrayEquals ( expected , split ) ; 12 } 13 }14MockBukkit on GitHub: be.seeseemelk.mockbukkit.tags.TagParser#parseComplexValue(java.lang.String)15Javadoc documentation for TagParser#parseComplexValue(java.lang.String) method16Javadoc documentation for TagParser#parseComplexValue(java.lang.String) meth

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run MockBukkit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful