#is there a better way of making JSON items?

2 messages · Page 1 of 1 (latest)

olive meteor
#

This works, but i am just curious if i am misunderstanding something, or generally if something better exists


            Validate(obj)
            {
                if(typeof(obj)==="string")
                {
                    if(Item.exists(obj)){console.info("[OracularAPI] obj is an item!");return [Item.of(obj).toJson()]}
                    else if(Fluid.exists(obj)||Fluid.exists(obj.replace(/ \d+$/,""))){console.info("[OracularAPI] obj is a fluid!");return [Fluid.of(obj).toJson()]}
                    else
                    {
                        console.info("[OracularAPI] Failed to verify string!");
                        return this.Validate("minecraft:bedrock")
                        //also yet another way of me shitting on bedrock edition.
                    }
                }
                if(Array.isArray(obj)){console.info("[OracularAPI] obj is an array!");return obj.map(i=>this.Validate(i));}
                console.info("[OracularAPI] obj is a passthrough object!");return obj;//pass-through: user may be trying to pass already raw objects, assumed to be valid, errors are not my problem anyways
                //not my problem: the code this is supposed to replace has the same behaviour
            },

also, what is the deal with

Item.isItem()
rare summitBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!