diff --git a/api/src/main/java/lol/pyr/znpcsplus/api/NpcApiProvider.java b/api/src/main/java/lol/pyr/znpcsplus/api/NpcApiProvider.java index 1221709..29e2abb 100644 --- a/api/src/main/java/lol/pyr/znpcsplus/api/NpcApiProvider.java +++ b/api/src/main/java/lol/pyr/znpcsplus/api/NpcApiProvider.java @@ -11,6 +11,11 @@ public class NpcApiProvider { throw new UnsupportedOperationException(); } + /** + * Static method that returns the api instance of the plugin + * + * @return The instance of the api for the ZNPCsPlus plugin + */ public static NpcApi get() { if (api == null) throw new IllegalStateException( "ZNPCsPlus plugin isn't enabled yet!\n" + @@ -19,11 +24,19 @@ public class NpcApiProvider { return api; } + /** + * Internal method used to register the main instance of the plugin as the api provider + * You probably shouldn't call this method under any circumstances + */ public static void register(Plugin plugin, NpcApi api) { NpcApiProvider.api = api; Bukkit.getServicesManager().register(NpcApi.class, api, plugin, ServicePriority.Normal); } + /** + * Internal method used to unregister the plugin from the provider when the plugin shuts down + * You probably shouldn't call this method under any circumstances + */ public static void unregister() { Bukkit.getServicesManager().unregister(api); NpcApiProvider.api = null; diff --git a/api/src/main/java/lol/pyr/znpcsplus/api/entity/EntityProperty.java b/api/src/main/java/lol/pyr/znpcsplus/api/entity/EntityProperty.java index 69db24e..6ad3f89 100644 --- a/api/src/main/java/lol/pyr/znpcsplus/api/entity/EntityProperty.java +++ b/api/src/main/java/lol/pyr/znpcsplus/api/entity/EntityProperty.java @@ -1,7 +1,25 @@ package lol.pyr.znpcsplus.api.entity; +/** + * Class that represents a unique property + * @param The type of the value of this property + */ public interface EntityProperty { + /** + * The default value of this property, if this is provided in {@link PropertyHolder#setProperty(EntityProperty, Object)} + * as the value the property will be removed from the holder + * + * @return The default value of this property + */ T getDefaultValue(); + + /** + * @return The name of this property + */ String getName(); + + /** + * @return Whether this property can be modified by players using commands + */ boolean isPlayerModifiable(); } diff --git a/api/src/main/java/lol/pyr/znpcsplus/api/entity/EntityPropertyRegistry.java b/api/src/main/java/lol/pyr/znpcsplus/api/entity/EntityPropertyRegistry.java index dad18d8..69e7adf 100644 --- a/api/src/main/java/lol/pyr/znpcsplus/api/entity/EntityPropertyRegistry.java +++ b/api/src/main/java/lol/pyr/znpcsplus/api/entity/EntityPropertyRegistry.java @@ -2,9 +2,40 @@ package lol.pyr.znpcsplus.api.entity; import java.util.Collection; +/** + * Class responsible for providing entity property keys + * Some property keys are only registered in certain situations for example different minecraft versions + */ public interface EntityPropertyRegistry { + /** + * @return All of the possible property keys + */ Collection> getAll(); + + /** + * Get a property key by it's name + * + * @param name The name of a property key + * @return The property key corresponding to the name or null if there is none + */ EntityProperty getByName(String name); + + /** + * Get a property key by it's name and automatically cast the property to the proper type + * If you don't know the type of the property you are requesting use {@link EntityPropertyRegistry#getByName(String)} instead + * + * @param name The name of a property key + * @param type The class of the expected type of the returned property key + * @return The property key corresponding to the name + * @param The expected type of the returned property key + */ EntityProperty getByName(String name, Class type); + + /** + * Register a dummy property that can be used to store unique information per npc + * + * @param name The name of the new property + * @param type The type of the new property + */ void registerDummy(String name, Class type); } diff --git a/api/src/main/java/lol/pyr/znpcsplus/api/entity/PropertyHolder.java b/api/src/main/java/lol/pyr/znpcsplus/api/entity/PropertyHolder.java index 178b365..1c4fb67 100644 --- a/api/src/main/java/lol/pyr/znpcsplus/api/entity/PropertyHolder.java +++ b/api/src/main/java/lol/pyr/znpcsplus/api/entity/PropertyHolder.java @@ -2,9 +2,40 @@ package lol.pyr.znpcsplus.api.entity; import java.util.Set; +/** + * Represents classes that have property values attatched to them + */ public interface PropertyHolder { + /** + * Method used to get the value of a property from a property holder + * + * @param key Unique key representing a property + * @return The value associated with the provided property key & this holder + * @param The type of the property value + */ T getProperty(EntityProperty key); + + /** + * Method used to check if a property holder has a value set for a specific property key + * + * @param key Unique key representing a property + * @return Whether this holder has a value set for the provided key + */ boolean hasProperty(EntityProperty key); + + /** + * Method used to set a value for the provided key on this property holder + * + * @param key Unique key representing a property + * @param value The value to assign to the property key on this holder + * @param The type of the property value + */ void setProperty(EntityProperty key, T value); + + /** + * Method used to get a set of all of the property keys that this holder has a value for + * + * @return List of property keys + */ Set> getAppliedProperties(); } diff --git a/api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java b/api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java index 49a185d..e84775a 100644 --- a/api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java +++ b/api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java @@ -25,4 +25,7 @@ public interface Npc extends PropertyHolder { void hide(Player player); void show(Player player); void respawn(Player player); + + void setHeadRotation(Player player, float yaw, float pitch); + void setHeadRotation(float yaw, float pitch); }