Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
Fix minor bugs and add command to load 吗modification in the server
Browse files Browse the repository at this point in the history
  • Loading branch information
wohaopa committed May 27, 2024
1 parent 0c40830 commit c9af490
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
dependencies {
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.27-GTNH:dev")

implementation("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.163:dev")
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.163:dev")

implementation("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
implementation("com.github.GTNewHorizons:GTNH-Intergalactic:1.3.4:dev")
compileOnly("com.github.GTNewHorizons:GTNH-Intergalactic:1.3.4:dev")

runtimeOnly("com.github.GTNewHorizons:TecTech:5.3.45:dev")
compileOnly("com.github.GTNewHorizons:TecTech:5.3.45:dev")

// runtimeOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-352-GTNH:dev")
// runtimeOnly("com.github.GTNewHorizons:AE2FluidCraft-Rework:1.2.28-gtnh:dev")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;

import com.github.wohaopa.GTNHModify.handler.Handlers;

public class GTNHModifyCommand extends CommandBase {

@Override
Expand Down Expand Up @@ -38,7 +40,7 @@ public String getCommandUsage(ICommandSender sender) {
return "commands.gtnh-modify.usage";
}

private static final List<String> subCmds = Stream.of("hello", "export", "help")
private static final List<String> subCmds = Stream.of("hello", "export", "help", "load")
.sorted()
.collect(Collectors.toList());

Expand Down Expand Up @@ -86,6 +88,11 @@ public void processCommand(ICommandSender sender, String[] args) {
switch (test) {
case "help" -> printHelps(sender);
case "hello" -> sender.addChatMessage(new ChatComponentText("你好"));
case "load" -> {
if (Handlers.init())
sender.addChatMessage(new ChatComponentTranslation("commands.gtnh-modify.load.success"));
else sender.addChatMessage(new ChatComponentTranslation("commands.gtnh-modify.load.failure"));
}
default -> {
if (subCmds.contains(test)) {
printHelp(sender, test);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public GTNHModifyGuiConfig(GuiScreen guiScreen) {
guiScreen,
new ConfigElement(Config.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
GTNHModifyMod.MODID,
false,
true,
false,
GuiConfig.getAbridgedConfigPath(Config.config.toString()));
}
Expand Down
33 changes: 17 additions & 16 deletions src/main/java/com/github/wohaopa/GTNHModify/handler/Handlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ public class Handlers {
private static final String Suffix = "Handler";
private static final List<Method> methods = new ArrayList<>();

public static void init() {
if (!Strategy.prevInit()) return;

handlers.add("Minecraft");
if (ModHelper.hasGregtech) handlers.add("GregTech");
if (ModHelper.hasThaumcraft) handlers.add("Thaumcraft");
public static boolean init() {
if (!Strategy.prevInit()) return false;

GTNHModifyMod.LOG.info("Start processing the recipe");
if (methods.isEmpty()) {

handlers.add("Minecraft");
if (ModHelper.hasGregtech) handlers.add("GregTech");
if (ModHelper.hasThaumcraft) handlers.add("Thaumcraft");

String pkg = Handlers.class.getName()
.replace("Handlers", "");
for (String name : handlers) {
Expand All @@ -40,20 +41,20 @@ public static void init() {
GTNHModifyMod.LOG.debug("An error occurred while initializing handler. Reason: " + e.getMessage());
}
}

for (Method method : methods) {
try {
GTNHModifyMod.LOG.info(
"Invoke handler: " + method.getDeclaringClass()
.getName());
method.invoke(null);
} catch (IllegalAccessException | InvocationTargetException e) {
GTNHModifyMod.LOG.debug("An error occurred while executing handler. Reason: " + e.getMessage());
}
}
for (Method method : methods) {
try {
GTNHModifyMod.LOG.info(
"Invoke handler: " + method.getDeclaringClass()
.getName());
method.invoke(null);
} catch (IllegalAccessException | InvocationTargetException e) {
GTNHModifyMod.LOG.debug("An error occurred while executing handler. Reason: " + e.getMessage());
}
}

Strategy.postInit();
GTNHModifyMod.LOG.info("Complete processing the recipe");
return true;
}
}
7 changes: 7 additions & 0 deletions src/main/resources/assets/GTNHModify/lang/en_US.lang
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
commands.gtnh-modify.usage=Used to export some game content.
commands.gtnh-modify.help.usage=/gtnh-modify help: Get help
commands.gtnh-modify.export.usage=/gtnh-modify export: Export
commands.gtnh-modify.load.usage=/gtnh-modify load: Load modify if nei does not display correctly
commands.gtnh-modify.hello.usage=/gtnh-modify hello: HelloWorld

commands.gtnh-modify.load.success=Load Modify Success!
commands.gtnh-modify.load.failure=Load Modify Failure! Probably need a restart, or it's already loaded!

0 comments on commit c9af490

Please sign in to comment.