Removed old initialization of the protected player manager. Added methods for creating a resource location and getting the mod version.

This commit is contained in:
2022-05-21 20:59:44 +01:00
parent e2bb99f280
commit 779f5a132d

View File

@ -4,14 +4,17 @@ import dev.micle.loginprotection.proxy.IProxy;
import dev.micle.loginprotection.proxy.Proxy;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
import java.util.Optional;
@Mod(LoginProtection.MOD_ID)
public class LoginProtection {
public static final String MOD_ID = "loginprotection";
public static ProtectedPlayers protected_players = new ProtectedPlayers();
private static final String PROTOCOL_VERSION = "1";
public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
@ -29,6 +32,21 @@ public class LoginProtection {
);
}
public static ResourceLocation createResourceLocation(String name) throws IllegalArgumentException {
if (name.contains(":")) {
throw new IllegalArgumentException("Name contains namespace!");
}
return new ResourceLocation(MOD_ID, name);
}
public static String getVersion() {
Optional<? extends ModContainer> modContainer = ModList.get().getModContainerById(MOD_ID);
if (modContainer.isPresent()) {
return modContainer.get().getModInfo().getVersion().toString();
}
return "0.0.0";
}
public static IProxy getProxy() {
return proxy;
}