RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
GlobalObjectParser.java
1package com.osroyale.util.parser.impl;
2
3import com.google.gson.JsonObject;
4import com.osroyale.game.world.object.ObjectType;
5import com.osroyale.game.world.position.Position;
6import com.osroyale.game.world.object.CustomGameObject;
7import com.osroyale.game.world.object.ObjectDirection;
8import com.osroyale.util.parser.GsonParser;
9
29
30* The class that loads all global object on startup.
31 *
32 * @author Daniel
33 */
34public class GlobalObjectParser extends GsonParser {
35
36 public GlobalObjectParser() {
37 super("def/object/global_objects", false);
38 }
39
40 @Override
41 protected void parse(JsonObject data) {
42 int id = data.get("id").getAsInt();
43 ObjectType type = ObjectType.valueOf(data.get("type").getAsInt()).orElseThrow(IllegalArgumentException::new);
44 ObjectDirection rotation = ObjectDirection.valueOf(data.get("rotation").getAsString());
45 Position position = builder.fromJson(data.get("position"), Position.class);
46 new CustomGameObject(id, position, rotation, type).register();
47 }
48}
static Optional< ObjectDirection > valueOf(final int id)
static Optional< ObjectType > valueOf(final int id)