RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.util.parser.impl.GlobalObjectParser Class Reference

The class that loads all global object on startup. More...

Inheritance diagram for com.runehive.util.parser.impl.GlobalObjectParser:
Collaboration diagram for com.runehive.util.parser.impl.GlobalObjectParser:

Public Member Functions

 GlobalObjectParser ()
Public Member Functions inherited from com.runehive.util.parser.GsonParser
final void deserialize ()
 The method that deserializes the file information.
 GsonParser (String path)
 Creates a new GsonParser.
 GsonParser (String path, boolean log)
 Creates a new GsonParser.
void initialize (int size)
Public Member Functions inherited from com.runehive.util.parser.GenericParser
 GenericParser (String path, String extension, boolean log)
 Creates a new GenericParser.
final int getIndex ()
 Gets the current index of the line being parsed.
void onRead ()
 The method called after all the data has been parsed.
void run ()
String toString ()

Protected Member Functions

void parse (JsonObject data)
 The method allows a user to modify the data as its being parsed.
Protected Member Functions inherited from com.runehive.util.parser.GsonParser
void onEnd ()
 This method handles what happens after the parser has ended.

Additional Inherited Members

Protected Attributes inherited from com.runehive.util.parser.GsonParser
transient Gson builder
 The Gson object.
Protected Attributes inherited from com.runehive.util.parser.GenericParser
int index
 The index of the current line being parsed.
final Path path
 The path of the file to parse.

Detailed Description

The class that loads all global object on startup.

Author
Daniel

Definition at line 15 of file GlobalObjectParser.java.

Constructor & Destructor Documentation

◆ GlobalObjectParser()

com.runehive.util.parser.impl.GlobalObjectParser.GlobalObjectParser ( )

Definition at line 17 of file GlobalObjectParser.java.

17 {
18 super("def/object/global_objects", false);
19 }

Member Function Documentation

◆ parse()

void com.runehive.util.parser.impl.GlobalObjectParser.parse ( JsonObject data)
protected

The method allows a user to modify the data as its being parsed.

Parameters
dataThe JsonObject that contains all serialized information.

Reimplemented from com.runehive.util.parser.GsonParser.

Definition at line 22 of file GlobalObjectParser.java.

22 {
23 int id = data.get("id").getAsInt();
24 ObjectType type = ObjectType.valueOf(data.get("type").getAsInt()).orElseThrow(IllegalArgumentException::new);
25 ObjectDirection rotation = ObjectDirection.valueOf(data.get("rotation").getAsString());
26 Position position = builder.fromJson(data.get("position"), Position.class);
27 new CustomGameObject(id, position, rotation, type).register();
28 }

References com.runehive.util.parser.GsonParser.builder, com.runehive.game.world.object.CustomGameObject.register(), com.runehive.game.world.object.ObjectDirection.valueOf(), and com.runehive.game.world.object.ObjectType.valueOf().

Here is the call graph for this function:

The documentation for this class was generated from the following file: