|
| 1 | +/* |
| 2 | + * This is free and unencumbered software released into the public domain. |
| 3 | + * |
| 4 | + * Anyone is free to copy, modify, publish, use, compile, sell, or |
| 5 | + * distribute this software, either in source code form or as a compiled |
| 6 | + * binary, for any purpose, commercial or non-commercial, and by any |
| 7 | + * means. |
| 8 | + * |
| 9 | + * In jurisdictions that recognize copyright laws, the author or authors |
| 10 | + * of this software dedicate any and all copyright interest in the |
| 11 | + * software to the public domain. We make this dedication for the benefit |
| 12 | + * of the public at large and to the detriment of our heirs and |
| 13 | + * successors. We intend this dedication to be an overt act of |
| 14 | + * relinquishment in perpetuity of all present and future rights to this |
| 15 | + * software under copyright law. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 | + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 21 | + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 22 | + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 | + * OTHER DEALINGS IN THE SOFTWARE. |
| 24 | + * |
| 25 | + * For more information, please refer to <https://unlicense.org/> |
| 26 | + */ |
| 27 | + |
| 28 | +package dev.triassic.template.mod.fabric; |
| 29 | + |
| 30 | +import dev.triassic.template.TemplateImpl; |
| 31 | +import dev.triassic.template.TemplatePlugin; |
| 32 | +import dev.triassic.template.command.Commander; |
| 33 | +import dev.triassic.template.mod.fabric.command.FabricCommander; |
| 34 | +import dev.triassic.template.util.PlatformType; |
| 35 | +import java.nio.file.Path; |
| 36 | +import net.fabricmc.api.ModInitializer; |
| 37 | +import net.fabricmc.loader.api.FabricLoader; |
| 38 | +import org.checkerframework.checker.nullness.qual.NonNull; |
| 39 | +import org.incendo.cloud.CommandManager; |
| 40 | +import org.incendo.cloud.SenderMapper; |
| 41 | +import org.incendo.cloud.execution.ExecutionCoordinator; |
| 42 | +import org.incendo.cloud.fabric.FabricServerCommandManager; |
| 43 | +import org.slf4j.Logger; |
| 44 | +import org.slf4j.LoggerFactory; |
| 45 | + |
| 46 | +/** |
| 47 | + * hey!!!. |
| 48 | + */ |
| 49 | +public final class FabricTemplateMod implements ModInitializer, TemplatePlugin { |
| 50 | + |
| 51 | + private Logger logger; |
| 52 | + private FabricServerCommandManager<Commander> commandManager; |
| 53 | + private TemplateImpl impl; |
| 54 | + |
| 55 | + @Override |
| 56 | + public void onInitialize() { |
| 57 | + this.logger = LoggerFactory.getLogger(FabricTemplateMod.class); |
| 58 | + this.commandManager = new FabricServerCommandManager<>( |
| 59 | + ExecutionCoordinator.simpleCoordinator(), |
| 60 | + SenderMapper.create( |
| 61 | + FabricCommander::from, |
| 62 | + commander -> ((FabricCommander) commander).source() |
| 63 | + ) |
| 64 | + ); |
| 65 | + |
| 66 | + this.impl = new TemplateImpl(this); |
| 67 | + impl.initialize(); |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public @NonNull Logger logger() { |
| 72 | + return logger; |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public @NonNull Path dataDirectory() { |
| 77 | + return FabricLoader.getInstance().getConfigDir(); |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public @NonNull PlatformType platformType() { |
| 82 | + return PlatformType.FABRIC; |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public @NonNull CommandManager<Commander> commandManager() { |
| 87 | + return this.commandManager; |
| 88 | + } |
| 89 | +} |
0 commit comments