Changed formatting to have bracing on a new line
This commit is contained in:
parent
e5eddd6c45
commit
e48eedb874
189 changed files with 6092 additions and 4041 deletions
|
@ -10,72 +10,91 @@ import WayofTime.bloodmagic.api.ritual.Ritual;
|
|||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
public class RitualRegistry {
|
||||
public class RitualRegistry
|
||||
{
|
||||
|
||||
public static final Map<Ritual, Boolean> enabledRituals = new HashMap<Ritual, Boolean>();
|
||||
private static final BiMap<String, Ritual> registry = HashBiMap.create();
|
||||
// Ordered list for actions that depend on the order that the rituals were registered in
|
||||
private static final ArrayList<String> orderedIdList = new ArrayList<String>();
|
||||
// Ordered list for actions that depend on the order that the rituals were
|
||||
// registered in
|
||||
private static final ArrayList<String> orderedIdList = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* The safe way to register a new Ritual.
|
||||
*
|
||||
* @param ritual - The ritual to register.
|
||||
* @param id - The ID for the ritual. Cannot be duplicated.
|
||||
*
|
||||
* @param ritual
|
||||
* - The ritual to register.
|
||||
* @param id
|
||||
* - The ID for the ritual. Cannot be duplicated.
|
||||
*/
|
||||
public static void registerRitual(Ritual ritual, String id) {
|
||||
if (ritual != null) {
|
||||
public static void registerRitual(Ritual ritual, String id)
|
||||
{
|
||||
if (ritual != null)
|
||||
{
|
||||
if (registry.containsKey(id))
|
||||
BloodMagicAPI.getLogger().error("Duplicate ritual id: %s", id);
|
||||
else {
|
||||
else
|
||||
{
|
||||
registry.put(id, ritual);
|
||||
orderedIdList.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Ritual getRitualForId(String id) {
|
||||
public static Ritual getRitualForId(String id)
|
||||
{
|
||||
return registry.get(id);
|
||||
}
|
||||
|
||||
public static String getIdForRitual(Ritual ritual) {
|
||||
public static String getIdForRitual(Ritual ritual)
|
||||
{
|
||||
return registry.inverse().get(ritual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty() {
|
||||
public static boolean isMapEmpty()
|
||||
{
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize() {
|
||||
public static int getMapSize()
|
||||
{
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(Ritual ritual) {
|
||||
try {
|
||||
public static boolean ritualEnabled(Ritual ritual)
|
||||
{
|
||||
try
|
||||
{
|
||||
return enabledRituals.get(ritual);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
BloodMagicAPI.getLogger().error("Invalid Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static BiMap<String, Ritual> getRegistry() {
|
||||
public static BiMap<String, Ritual> getRegistry()
|
||||
{
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static Map<Ritual, Boolean> getEnabledMap() {
|
||||
public static Map<Ritual, Boolean> getEnabledMap()
|
||||
{
|
||||
return new HashMap<Ritual, Boolean>(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
public static ArrayList<String> getIds()
|
||||
{
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
||||
public static ArrayList<String> getOrderedIds() {
|
||||
return orderedIdList;
|
||||
|
||||
public static ArrayList<String> getOrderedIds()
|
||||
{
|
||||
return orderedIdList;
|
||||
}
|
||||
|
||||
public static ArrayList<Ritual> getRituals() {
|
||||
public static ArrayList<Ritual> getRituals()
|
||||
{
|
||||
return new ArrayList<Ritual>(registry.values());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue