aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-08-27 05:26:06 +0800
committershedaniel <daniel@shedaniel.me>2021-08-27 05:26:31 +0800
commit113fe8f692f4f9bb113d28f6a1b3375bd8f0eec8 (patch)
treeda371c2c28ec95167aea4ebc91a6ff4a9f5f59b3 /api/src/main/java/me
parenta4776b33fd86731249cf9b02c2ea6fff1bce9350 (diff)
downloadRoughlyEnoughItems-113fe8f692f4f9bb113d28f6a1b3375bd8f0eec8.tar.gz
RoughlyEnoughItems-113fe8f692f4f9bb113d28f6a1b3375bd8f0eec8.tar.bz2
RoughlyEnoughItems-113fe8f692f4f9bb113d28f6a1b3375bd8f0eec8.zip
Add hints for if REI does not initialize properly
Diffstat (limited to 'api/src/main/java/me')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java20
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/registry/ReloadStage.java29
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/registry/Reloadable.java22
4 files changed, 69 insertions, 4 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java
index a5928679c..de413d6ab 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java
@@ -63,7 +63,7 @@ public interface EntryTypeRegistry extends Reloadable<REIPlugin<?>> {
}
/**
- * Registers a entry type, with its entry definition.
+ * Registers an entry type, with its entry definition.
*
* @param id the identifier of the entry type
* @param definition the definition of the entry
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java b/api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java
index 48cce495e..0a3a8e185 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java
@@ -34,15 +34,29 @@ public interface ParentReloadable<P extends REIPlugin<?>> extends Reloadable<P>
@Override
default void startReload() {
- for (Reloadable<P> reloadable : getReloadables()) {
- reloadable.startReload();
+ for (ReloadStage stage : ReloadStage.values()) {
+ startReload(stage);
}
}
@Override
default void endReload() {
+ for (ReloadStage stage : ReloadStage.values()) {
+ endReload(stage);
+ }
+ }
+
+ @Override
+ default void startReload(ReloadStage stage) {
+ for (Reloadable<P> reloadable : getReloadables()) {
+ reloadable.startReload(stage);
+ }
+ }
+
+ @Override
+ default void endReload(ReloadStage stage) {
for (Reloadable<P> reloadable : getReloadables()) {
- reloadable.endReload();
+ reloadable.endReload(stage);
}
}
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/registry/ReloadStage.java b/api/src/main/java/me/shedaniel/rei/api/common/registry/ReloadStage.java
new file mode 100644
index 000000000..cb1deff3c
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/api/common/registry/ReloadStage.java
@@ -0,0 +1,29 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.api.common.registry;
+
+public enum ReloadStage {
+ START,
+ END,
+}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/registry/Reloadable.java b/api/src/main/java/me/shedaniel/rei/api/common/registry/Reloadable.java
index d472ad72d..67b7174a5 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/registry/Reloadable.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/registry/Reloadable.java
@@ -27,10 +27,26 @@ import me.shedaniel.rei.api.common.plugins.REIPlugin;
@FunctionalInterface
public interface Reloadable<P extends REIPlugin<?>> {
+ default ReloadStage getStage() {
+ return ReloadStage.END;
+ }
+
void startReload();
+ default void startReload(ReloadStage stage) {
+ if (stage == getStage()) {
+ startReload();
+ }
+ }
+
default void endReload() {}
+ default void endReload(ReloadStage stage) {
+ if (stage == getStage()) {
+ endReload();
+ }
+ }
+
/**
* Accepts a {@link REIPlugin}
*
@@ -38,6 +54,12 @@ public interface Reloadable<P extends REIPlugin<?>> {
*/
default void acceptPlugin(P plugin) {}
+ default void acceptPlugin(P plugin, ReloadStage stage) {
+ if (stage == getStage()) {
+ acceptPlugin(plugin);
+ }
+ }
+
/**
* Returns whether {@link Reloadable#acceptPlugin(REIPlugin)} should be done in parallel.
*