Merge branch 'main' of https://github.com/HMCore/Core into main

This commit is contained in:
UnrealValentin
2021-04-11 22:45:59 +02:00
2 changed files with 12 additions and 9 deletions

View File

@@ -4,11 +4,11 @@ import org.hmcore.registration.ObjectInfo;
/** /**
* Represents a module that manages the objects that should get registered to Hytale. * Represents a module that manages the objects that should get registered to Hytale.
*
* @param <T> The object that should get registered * @param <T> The object that should get registered
* @param <I> Object that contains information about the object. Like the texture. * @param <I> Object that contains information about the object. Like the texture.
*/ */
public abstract class Module<T, I extends ObjectInfo> { public abstract class Module<T, I extends ObjectInfo> {
// //
// For registering Objects to Module and getting them // For registering Objects to Module and getting them
// Made for mods to call them // Made for mods to call them
@@ -16,6 +16,7 @@ public abstract class Module<T, I extends ObjectInfo> {
/** /**
* For checking if the Module has the module already in its list. * For checking if the Module has the module already in its list.
*
* @param name The name or registration key of the object to be checked * @param name The name or registration key of the object to be checked
* @return true when the object is already registered. * @return true when the object is already registered.
*/ */
@@ -23,6 +24,7 @@ public abstract class Module<T, I extends ObjectInfo> {
/** /**
* Gets the object for the registered name. * Gets the object for the registered name.
*
* @param name The name or key for the object that should be returned. * @param name The name or key for the object that should be returned.
* @return The object under the registered name or null if it doesn't exists. * @return The object under the registered name or null if it doesn't exists.
*/ */
@@ -30,7 +32,8 @@ public abstract class Module<T, I extends ObjectInfo> {
/** /**
* Registers the object to the module. * Registers the object to the module.
* @param name The name or key for the object to get registered under. *
* @param name The name or key for the object to get registered under.
* @param object The object that should get registered. * @param object The object that should get registered.
*/ */
public abstract void register(String name, T object); public abstract void register(String name, T object);
@@ -42,8 +45,9 @@ public abstract class Module<T, I extends ObjectInfo> {
* Adds an option for information to the object. * Adds an option for information to the object.
* There can be multiple options for information and the server administrators can choose which to use. * There can be multiple options for information and the server administrators can choose which to use.
* Per default the first registered option is used. * Per default the first registered option is used.
* @param name The name or key for the object the information should be added to. *
* @param infoName The name of the option. The name of the mod as example. * @param name The name or key for the object the information should be added to.
* @param infoName The name of the option. The name of the mod as example.
* @param objectInfo The info object that supplies the module with the required information. * @param objectInfo The info object that supplies the module with the required information.
*/ */
public abstract void addInfoToObject(String name, String infoName, I objectInfo); public abstract void addInfoToObject(String name, String infoName, I objectInfo);
@@ -51,11 +55,12 @@ public abstract class Module<T, I extends ObjectInfo> {
/** /**
* Simple utility function that automatically checks if the object already exists. * Simple utility function that automatically checks if the object already exists.
* If not, the object is registered. An easy boilerplate code prevention. * If not, the object is registered. An easy boilerplate code prevention.
*
* @param name * @param name
* @param object * @param object
*/ */
public void registerIfNonExistent(String name, T object) { public void registerIfNonExistent(String name, T object) {
if(!contains(name)) register(name, object); if (!contains(name)) register(name, object);
} }
// //
@@ -65,8 +70,8 @@ public abstract class Module<T, I extends ObjectInfo> {
/** /**
* Gets called when the phase of object registration to Hytale has come. * Gets called when the phase of object registration to Hytale has come.
*
* @return true when every object has been registered successfully. * @return true when every object has been registered successfully.
*/ */
public abstract boolean registerObjects(); public abstract boolean registerObjects();
} }

View File

@@ -1,5 +1,3 @@
package org.hmcore.registration package org.hmcore.registration
open class ObjectInfo(val texturePath: String) { open class ObjectInfo(val texturePath: String)
}