aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-04-10 21:25:39 +0800
committershedaniel <daniel@shedaniel.me>2020-04-10 21:25:39 +0800
commit7121053d7b8a54dff0089ad60e3c3082be5572e0 (patch)
treecbf1c79014011b82c9cdd047be828307f9a2302b /src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java
parentdf107611287fd75dafbef1d0a5c91a8bac2f1e2d (diff)
downloadRoughlyEnoughItems-7121053d7b8a54dff0089ad60e3c3082be5572e0.tar.gz
RoughlyEnoughItems-7121053d7b8a54dff0089ad60e3c3082be5572e0.tar.bz2
RoughlyEnoughItems-7121053d7b8a54dff0089ad60e3c3082be5572e0.zip
Error Screen when Fabric API is not installed
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java')
-rw-r--r--src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java
new file mode 100644
index 000000000..a6c71f6cb
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java
@@ -0,0 +1,60 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 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;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.util.Pair;
+import org.jetbrains.annotations.ApiStatus;
+
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+@ApiStatus.Internal
+public class RoughlyEnoughItemsState {
+ private RoughlyEnoughItemsState() {}
+
+ private static List<Pair<String, String>> failedToLoad = new ArrayList<>();
+ private static Set<String> failedToLoadSet = new LinkedHashSet<>();
+
+ public static void failedToLoad(String reason) {
+ if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER || FabricLoader.getInstance().isDevelopmentEnvironment())
+ throw new RuntimeException(reason);
+ if (RoughlyEnoughItemsState.failedToLoadSet.add(reason + " " + null))
+ RoughlyEnoughItemsState.failedToLoad.add(new Pair<>(reason, null));
+ }
+
+ public static void failedToLoad(String reason, String link) {
+ if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER || FabricLoader.getInstance().isDevelopmentEnvironment())
+ throw new RuntimeException(reason + " " + link);
+ if (RoughlyEnoughItemsState.failedToLoadSet.add(reason + " " + link))
+ RoughlyEnoughItemsState.failedToLoad.add(new Pair<>(reason, link));
+ }
+
+ public static List<Pair<String, String>> getFailedToLoad() {
+ return failedToLoad;
+ }
+}