start on some javadocs
This commit is contained in:
parent
1fae5c1cf6
commit
5ee37d5436
5 changed files with 96 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
package lol.pyr.znpcsplus.api.entity;
|
||||
|
||||
/**
|
||||
* Class that represents a unique property
|
||||
* @param <T> The type of the value of this property
|
||||
*/
|
||||
public interface EntityProperty<T> {
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
|
|
@ -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<EntityProperty<?>> 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 <T> The expected type of the returned property key
|
||||
*/
|
||||
<T> EntityProperty<T> getByName(String name, Class<T> 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);
|
||||
}
|
||||
|
|
|
@ -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 <T> The type of the property value
|
||||
*/
|
||||
<T> T getProperty(EntityProperty<T> 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 <T> The type of the property value
|
||||
*/
|
||||
<T> void setProperty(EntityProperty<T> 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<EntityProperty<?>> getAppliedProperties();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue