Interface HologramController
public interface HologramController
The HologramController is basically the brain of the hologram.
It handles what exactly is supposed to happen when interacting the hologram and stores additional information that are needed to process those actions.
Storing informations is for instance required for the team selector. In this case it'll store the currently selected team.
To read/write use serialize(JsonObject)
or deserialize(JsonObject)
.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
A controller might contain some properties of the hologram.void
deserialize
(com.google.gson.JsonObject json) Reads all the permanent data of this controller from a json object that was previously added withserialize(JsonObject)
.Returns the hologram to which this controller is (possibly) bound to.getType()
Returns the type of this controller.void
handleInteract
(Player player) Simulate as if a player would right-click on himboolean
isActive()
Returns if the controller is still bound to an existing hologram.void
serialize
(com.google.gson.JsonObject json) Puts all the permanent data of this controller into a json object.
-
Method Details
-
getType
HologramControllerType getType()Returns the type of this controller.- Returns:
- The type of the controller
-
getHologram
HologramEntity getHologram()Returns the hologram to which this controller is (possibly) bound to.It's possible that the hologram has a new controller. Use
isActive()
to verify that this one is currently the active one.- Returns:
- The hologram to which this controller instance is (possibly) bound to
-
isActive
boolean isActive()Returns if the controller is still bound to an existing hologram.- Returns:
- If it is still active
-
handleInteract
Simulate as if a player would right-click on him- Parameters:
player
- The player who touched him
-
applyProperties
void applyProperties()A controller might contain some properties of the hologram. Use this method to apply those properties, such as the display name, to the hologram. -
serialize
Puts all the permanent data of this controller into a json object.For instance this'd add the team of the teamselectstatue if the type is
HologramControllerType.TEAM_SELECTOR
- Parameters:
json
- The json to which it shall be added to- Throws:
Exception
- Errors that might occur during that
-
deserialize
Reads all the permanent data of this controller from a json object that was previously added withserialize(JsonObject)
.For instance this'd read and update the team of the teamselectstatue if the type is
HologramControllerType.TEAM_SELECTOR
- Parameters:
json
- The json from which it shall be read from- Throws:
Exception
- Errors that might occur during that
-