-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBackTools.java
More file actions
30 lines (24 loc) · 1.13 KB
/
BackTools.java
File metadata and controls
30 lines (24 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.daniking.backtools;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.function.Supplier;
public class BackTools implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger(BackTools.class);
@Override
public void onInitialize() {
final @NotNull String modName = this.getClass().getSimpleName();
final @NotNull Version version = FabricLoader.getInstance().getModContainer(modName.toLowerCase()).orElseThrow().getMetadata().getVersion();
BackTools.run(EnvType.SERVER, () -> () -> LOGGER.info("You are loading " + modName + " on a server." + modName + " is a client side-only mod!"));
BackTools.run(EnvType.CLIENT, () -> () -> LOGGER.info("{} V{} Initialized", modName, version.getFriendlyString()));
}
public static void run(final EnvType type, final Supplier<Runnable> supplier) {
if (type == FabricLoader.getInstance().getEnvironmentType()) {
supplier.get().run();
}
}
}