mirror of
https://github.com/HMCore/Core.git
synced 2025-12-12 13:56:19 +00:00
Merge branch 'main' of https://github.com/HMCore/Core into main
This commit is contained in:
@@ -4,11 +4,11 @@ import org.hmcore.registration.ObjectInfo;
|
||||
|
||||
/**
|
||||
* Represents a module that manages the objects that should get registered to Hytale.
|
||||
*
|
||||
* @param <T> The object that should get registered
|
||||
* @param <I> Object that contains information about the object. Like the texture.
|
||||
*/
|
||||
public abstract class Module<T, I extends ObjectInfo> {
|
||||
|
||||
//
|
||||
// For registering Objects to Module and getting 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.
|
||||
*
|
||||
* @param name The name or registration key of the object to be checked
|
||||
* @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.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@@ -30,7 +32,8 @@ public abstract class Module<T, I extends ObjectInfo> {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
* There can be multiple options for information and the server administrators can choose which to use.
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
* If not, the object is registered. An easy boilerplate code prevention.
|
||||
*
|
||||
* @param name
|
||||
* @param 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.
|
||||
*
|
||||
* @return true when every object has been registered successfully.
|
||||
*/
|
||||
public abstract boolean registerObjects();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
package org.hmcore.registration
|
||||
|
||||
open class ObjectInfo(val texturePath: String) {
|
||||
|
||||
}
|
||||
open class ObjectInfo(val texturePath: String)
|
||||
|
||||
Reference in New Issue
Block a user