diff options
| author | shedaniel <daniel@shedaniel.me> | 2024-09-17 21:34:04 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2024-09-17 21:34:04 +0800 |
| commit | 3febdc4e1d6927f19d0de6fc8430765336d34d7e (patch) | |
| tree | e8cc88c46ce9b2ebf0954f94dcb56189f2fa5a1b /api/src/main/java/me/shedaniel/rei/impl | |
| parent | bc039e2d0a45409396c9156307d70529ccb28a3e (diff) | |
| parent | ccf3dcd60aa6c1d079dd57c59d9a89c2ca60b1e7 (diff) | |
| download | RoughlyEnoughItems-3febdc4e1d6927f19d0de6fc8430765336d34d7e.tar.gz RoughlyEnoughItems-3febdc4e1d6927f19d0de6fc8430765336d34d7e.tar.bz2 RoughlyEnoughItems-3febdc4e1d6927f19d0de6fc8430765336d34d7e.zip | |
Merge remote-tracking branch 'origin/12.x-1.20' into 13.x-1.20.2
# Conflicts:
# default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java
# fabric/src/main/resources/roughlyenoughitems.accessWidener
# runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java
# runtime/src/main/java/me/shedaniel/rei/impl/common/registry/RecipeManagerContextImpl.java
Diffstat (limited to 'api/src/main/java/me/shedaniel/rei/impl')
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloadContext.java | 48 | ||||
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadInterruptionContext.java | 63 |
2 files changed, 111 insertions, 0 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloadContext.java b/api/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloadContext.java new file mode 100644 index 000000000..0481b38d0 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloadContext.java @@ -0,0 +1,48 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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.impl.common.plugins; + +import me.shedaniel.rei.api.common.registry.ReloadStage; +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +public interface PluginReloadContext { + ReloadStage stage(); + + ReloadInterruptionContext interruptionContext(); + + static PluginReloadContext of(ReloadStage stage, ReloadInterruptionContext interruptionContext) { + return new PluginReloadContext() { + @Override + public ReloadStage stage() { + return stage; + } + + @Override + public ReloadInterruptionContext interruptionContext() { + return interruptionContext; + } + }; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadInterruptionContext.java b/api/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadInterruptionContext.java new file mode 100644 index 000000000..19201b20b --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadInterruptionContext.java @@ -0,0 +1,63 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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.impl.common.plugins; + +import me.shedaniel.rei.impl.common.InternalLogger; +import org.jetbrains.annotations.ApiStatus; + +@FunctionalInterface +@ApiStatus.Internal +public interface ReloadInterruptionContext { + boolean isInterrupted(); + + default void checkInterrupted() throws InterruptedException { + if (isInterrupted()) { + InternalLogger.getInstance().debug("Plugin reload interrupted!"); + throw new InterruptedException(); + } + } + + default ReloadInterruptionContext withJob(Runnable ifInterrupted) { + return new ReloadInterruptionContext() { + @Override + public boolean isInterrupted() { + return ReloadInterruptionContext.this.isInterrupted(); + } + + @Override + public void checkInterrupted() throws InterruptedException { + try { + ReloadInterruptionContext.this.checkInterrupted(); + } catch (InterruptedException e) { + ifInterrupted.run(); + throw e; + } + } + }; + } + + static ReloadInterruptionContext ofNever() { + return () -> false; + } +} |
