mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
chore: add javadocs to MenuTypes; ids menu item types must now be unique
This commit is contained in:
@@ -10,21 +10,42 @@ public class Types {
|
|||||||
|
|
||||||
private static final HashMap<String, Type> types = new HashMap<>();
|
private static final HashMap<String, Type> types = new HashMap<>();
|
||||||
|
|
||||||
private static TypeCosmetic TYPE_COSMETIC = new TypeCosmetic();
|
private static final TypeCosmetic TYPE_COSMETIC = new TypeCosmetic();
|
||||||
private static TypeEmpty TYPE_EMPTY = new TypeEmpty();
|
private static final TypeEmpty TYPE_EMPTY = new TypeEmpty();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get's a Menu Item type. Add custom menu item types with {@link #addType(Type)}
|
||||||
|
* @param id A non-case sensitive ID
|
||||||
|
* @return The type of Menu Item
|
||||||
|
*/
|
||||||
public static Type getType(@NotNull String id) {
|
public static Type getType(@NotNull String id) {
|
||||||
return types.get(id.toUpperCase());
|
return types.get(id.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a type is valid. Add custom menu item types with {@link #addType(Type)}
|
||||||
|
* @param id A non-case sensitive ID
|
||||||
|
* @return True if exists, False if not.
|
||||||
|
*/
|
||||||
public static boolean isType(@NotNull String id) {
|
public static boolean isType(@NotNull String id) {
|
||||||
return types.containsKey(id.toUpperCase());
|
return types.containsKey(id.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addType(Type type) {
|
/**
|
||||||
types.put(type.getId().toUpperCase(), type);
|
* Adds a Menu Item Type to the types HashMap for reference. Menu Types will automatically be added using this method.
|
||||||
|
* @param type A non-null {@link Type} that'll be added. ID should be unique; can't be duplicated
|
||||||
|
*/
|
||||||
|
public static boolean addType(@NotNull Type type) {
|
||||||
|
String id = type.getId().toUpperCase();
|
||||||
|
if (types.containsKey(id)) return false;
|
||||||
|
types.put(id, type);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default menu item; {@link TypeEmpty}
|
||||||
|
* @return The empty menu type.
|
||||||
|
*/
|
||||||
public static TypeEmpty getDefaultType() {
|
public static TypeEmpty getDefaultType() {
|
||||||
return TYPE_EMPTY;
|
return TYPE_EMPTY;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user