Skip to content

Commit

Permalink
Spotless and add syncConfigValues
Browse files Browse the repository at this point in the history
  • Loading branch information
tier940 committed Sep 17, 2024
1 parent af284c2 commit 5c39a86
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 64 deletions.
28 changes: 20 additions & 8 deletions src/main/java/com/github/gtexpert/testmod/TestMod.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
package com.github.gtexpert.testmod;

import com.github.gtexpert.testmod.api.util.ModLog;
import com.github.gtexpert.testmod.module.ModuleManager;
import com.github.gtexpert.testmod.module.Modules;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.*;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import com.github.gtexpert.testmod.api.ModValues;
import com.github.gtexpert.testmod.api.util.ModLog;
import com.github.gtexpert.testmod.module.ModuleManager;
import com.github.gtexpert.testmod.module.Modules;

@Mod(
modid = Tags.MODID,
name = Tags.MODNAME,
version = Tags.VERSION,
dependencies = ""
)
modid = Tags.MODID,
name = Tags.MODNAME,
version = Tags.VERSION,
dependencies = "")
public class TestMod {

private ModuleManager moduleManager;

@Mod.EventHandler
Expand Down Expand Up @@ -121,4 +126,11 @@ public void registerRecipesLow(RegistryEvent.Register<IRecipe> event) {
public void registerRecipesLowest(RegistryEvent.Register<IRecipe> event) {
moduleManager.registerRecipesLowest(event);
}

@SubscribeEvent
public static void syncConfigValues(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(ModValues.MODID)) {
ConfigManager.sync(ModValues.MODID, Config.Type.INSTANCE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
import com.github.gtexpert.testmod.Tags;

public class ModValues {

public static final String MODID = Tags.MODID;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.gtexpert.testmod.api.modules;


import java.util.Collections;
import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.gtexpert.testmod.api.modules;

public interface IModuleContainer {

/**
* The ID of this container. If this is your mod's only container, you should use your mod ID to prevent collisions.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.github.gtexpert.testmod.api.modules;

import com.github.gtexpert.testmod.api.util.ModUtility;
import net.minecraft.util.ResourceLocation;

import com.github.gtexpert.testmod.api.util.ModUtility;

public interface IModuleManager {

default boolean isModuleEnabled(String containerID, String moduleID) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.gtexpert.testmod.api.modules;


/**
* Basically {@link net.minecraftforge.fml.common.LoaderState} but only for launch stages.
* Also includes early module stages.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.github.gtexpert.testmod.api.util;

import com.github.gtexpert.testmod.Tags;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.github.gtexpert.testmod.Tags;

public class ModLog {

public static Logger logger = LogManager.getLogger(Tags.MODNAME);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.github.gtexpert.testmod.api.util;

import com.github.gtexpert.testmod.api.ModValues;
import net.minecraft.util.ResourceLocation;

import org.jetbrains.annotations.NotNull;

import com.github.gtexpert.testmod.api.ModValues;

public class ModUtility {

public static @NotNull ResourceLocation id(String path) {
return new ResourceLocation(ModValues.MODID, path);
}
Expand Down
57 changes: 28 additions & 29 deletions src/main/java/com/github/gtexpert/testmod/api/util/Mods.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;


public enum Mods {

AEAdditions(Names.AE_ADDITIONS),
Expand All @@ -44,27 +43,27 @@ public enum Mods {
ExtraCPUs(Names.EXTRA_CPUS),
ExtraTrees(Names.EXTRA_TREES),
Forestry(Names.FORESTRY),
// ForestryApiculture(Names.FORESTRY, forestryModule(Names.FORESTRY_APICULTURE)),
// ForestryArboriculture(Names.FORESTRY, forestryModule(Names.FORESTRY_ARBORICULTURE)),
// ForestryCharcoal(Names.FORESTRY, forestryModule(Names.FORESTRY_CHARCOAL)),
// ForestryCore(Names.FORESTRY, forestryModule(Names.FORESTRY_CORE)),
// ForestryEnergy(Names.FORESTRY, forestryModule(Names.FORESTRY_ENERGY)),
// ForestryFactory(Names.FORESTRY, forestryModule(Names.FORESTRY_FACTORY)),
// ForestryWorktable(Names.FORESTRY, forestryModule(Names.FORESTRY_WORKTABLE)),
// ForestryFarming(Names.FORESTRY, forestryModule(Names.FORESTRY_FARMING)),
// ForestryClimatology(Names.FORESTRY, forestryModule(Names.FORESTRY_CLIMATOLOGY)),
// ForestryGreenhouse(Names.FORESTRY, forestryModule(Names.FORESTRY_GREENHOUSE)),
// ForestryFluids(Names.FORESTRY, forestryModule(Names.FORESTRY_FLUIDS)),
// ForestryFood(Names.FORESTRY, forestryModule(Names.FORESTRY_FOOD)),
// ForestryLepidopterology(Names.FORESTRY, forestryModule(Names.FORESTRY_LEPIDOPTEROLOGY)),
// ForestryMail(Names.FORESTRY, forestryModule(Names.FORESTRY_MAIL)),
// ForestryCrate(Names.FORESTRY, forestryModule(Names.FORESTRY_CRATE)),
// ForestryBackpacks(Names.FORESTRY, forestryModule(Names.FORESTRY_BACKPACKS)),
// ForestryDatabase(Names.FORESTRY, forestryModule(Names.FORESTRY_DATABASE)),
// ForestrySorting(Names.FORESTRY, forestryModule(Names.FORESTRY_SORTING)),
// ForestryBook(Names.FORESTRY, forestryModule(Names.FORESTRY_BOOK)),
// ForestryCultivation(Names.FORESTRY, forestryModule(Names.FORESTRY_CULTIVATION)),
// ForestryResearch(Names.FORESTRY, forestryModule(Names.FORESTRY_RESEARCH)),
// ForestryApiculture(Names.FORESTRY, forestryModule(Names.FORESTRY_APICULTURE)),
// ForestryArboriculture(Names.FORESTRY, forestryModule(Names.FORESTRY_ARBORICULTURE)),
// ForestryCharcoal(Names.FORESTRY, forestryModule(Names.FORESTRY_CHARCOAL)),
// ForestryCore(Names.FORESTRY, forestryModule(Names.FORESTRY_CORE)),
// ForestryEnergy(Names.FORESTRY, forestryModule(Names.FORESTRY_ENERGY)),
// ForestryFactory(Names.FORESTRY, forestryModule(Names.FORESTRY_FACTORY)),
// ForestryWorktable(Names.FORESTRY, forestryModule(Names.FORESTRY_WORKTABLE)),
// ForestryFarming(Names.FORESTRY, forestryModule(Names.FORESTRY_FARMING)),
// ForestryClimatology(Names.FORESTRY, forestryModule(Names.FORESTRY_CLIMATOLOGY)),
// ForestryGreenhouse(Names.FORESTRY, forestryModule(Names.FORESTRY_GREENHOUSE)),
// ForestryFluids(Names.FORESTRY, forestryModule(Names.FORESTRY_FLUIDS)),
// ForestryFood(Names.FORESTRY, forestryModule(Names.FORESTRY_FOOD)),
// ForestryLepidopterology(Names.FORESTRY, forestryModule(Names.FORESTRY_LEPIDOPTEROLOGY)),
// ForestryMail(Names.FORESTRY, forestryModule(Names.FORESTRY_MAIL)),
// ForestryCrate(Names.FORESTRY, forestryModule(Names.FORESTRY_CRATE)),
// ForestryBackpacks(Names.FORESTRY, forestryModule(Names.FORESTRY_BACKPACKS)),
// ForestryDatabase(Names.FORESTRY, forestryModule(Names.FORESTRY_DATABASE)),
// ForestrySorting(Names.FORESTRY, forestryModule(Names.FORESTRY_SORTING)),
// ForestryBook(Names.FORESTRY, forestryModule(Names.FORESTRY_BOOK)),
// ForestryCultivation(Names.FORESTRY, forestryModule(Names.FORESTRY_CULTIVATION)),
// ForestryResearch(Names.FORESTRY, forestryModule(Names.FORESTRY_RESEARCH)),
GalacticraftCore(Names.GALACTICRAFT_CORE),
Genetics(Names.GENETICS),
Gendustry(Names.GENDUSTRY),
Expand Down Expand Up @@ -297,11 +296,11 @@ private static Function<Mods, Boolean> versionExcludes(String versionPart) {
}

/** Test if a specific Forestry module is enabled. */
// private static Function<Mods, Boolean> forestryModule(String moduleID) {
// if (Forestry.isModLoaded()) {
// return mod -> forestry.modules.ModuleHelper.isEnabled(moduleID);
// } else {
// return $ -> false;
// }
// }
// private static Function<Mods, Boolean> forestryModule(String moduleID) {
// if (Forestry.isModLoaded()) {
// return mod -> forestry.modules.ModuleHelper.isEnabled(moduleID);
// } else {
// return $ -> false;
// }
// }
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.github.gtexpert.testmod.client;

import com.github.gtexpert.testmod.common.CommonProxy;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;

import com.github.gtexpert.testmod.common.CommonProxy;

@Mod.EventBusSubscriber(Side.CLIENT)
public class ClientProxy extends CommonProxy {

@Override
public void preInit(FMLPreInitializationEvent event) {
super.preInit(event);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.github.gtexpert.testmod.common;

import com.github.gtexpert.testmod.api.ModValues;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import com.github.gtexpert.testmod.api.ModValues;

@Mod.EventBusSubscriber(modid = ModValues.MODID)
public class CommonProxy {

Expand Down
29 changes: 15 additions & 14 deletions src/main/java/com/github/gtexpert/testmod/core/CoreModule.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package com.github.gtexpert.testmod.core;

import com.github.gtexpert.testmod.Tags;
import com.github.gtexpert.testmod.api.ModValues;
import com.github.gtexpert.testmod.api.modules.IModule;
import com.github.gtexpert.testmod.api.modules.TModule;
import com.github.gtexpert.testmod.common.CommonProxy;
import com.github.gtexpert.testmod.module.Modules;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;

import com.github.gtexpert.testmod.Tags;
import com.github.gtexpert.testmod.api.ModValues;
import com.github.gtexpert.testmod.api.modules.IModule;
import com.github.gtexpert.testmod.api.modules.TModule;
import com.github.gtexpert.testmod.common.CommonProxy;
import com.github.gtexpert.testmod.module.Modules;

@TModule(
moduleID = Modules.MODULE_CORE,
containerID = ModValues.MODID,
name = "TestMod Core",
description = "Core of TestMod",
coreModule = true
)
moduleID = Modules.MODULE_CORE,
containerID = ModValues.MODID,
name = "TestMod Core",
description = "Core of TestMod",
coreModule = true)
public class CoreModule implements IModule {

public static final Logger logger = LogManager.getLogger(Tags.MODNAME + " Core");
@SidedProxy(modId = ModValues.MODID,
clientSide = "com.github.gtexpert.testmod.client.ClientProxy",
serverSide = "com.github.gtexpert.testmod.common.CommonProxy")
clientSide = "com.github.gtexpert.testmod.client.ClientProxy",
serverSide = "com.github.gtexpert.testmod.common.CommonProxy")
public static CommonProxy proxy;

@Override
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/github/gtexpert/testmod/module/BaseModule.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.github.gtexpert.testmod.module;

import com.github.gtexpert.testmod.api.modules.IModule;
import com.github.gtexpert.testmod.api.util.ModUtility;
import java.util.Collections;
import java.util.Set;

import net.minecraft.util.ResourceLocation;

import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.Set;
import com.github.gtexpert.testmod.api.modules.IModule;
import com.github.gtexpert.testmod.api.util.ModUtility;

public abstract class BaseModule implements IModule {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import java.util.*;
import java.util.stream.Collectors;

import com.github.gtexpert.testmod.api.ModValues;
import com.github.gtexpert.testmod.api.modules.*;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
Expand All @@ -24,6 +22,9 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;

import com.github.gtexpert.testmod.api.ModValues;
import com.github.gtexpert.testmod.api.modules.*;

public class ModuleManager implements IModuleManager {

private static final ModuleManager INSTANCE = new ModuleManager();
Expand Down

0 comments on commit 5c39a86

Please sign in to comment.