This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config & direct native api usage
- Loading branch information
Showing
3 changed files
with
119 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.cosmiiko.bsodod; | ||
|
||
import net.minecraftforge.common.ForgeConfigSpec; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.config.ModConfig; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
// Thank god for https://cadiboo.github.io/tutorials/1.15.1/forge/3.3-config/ and screw Forge's docs | ||
@Mod.EventBusSubscriber(modid = "bsodod", bus = Mod.EventBusSubscriber.Bus.MOD) | ||
public class Config { | ||
public static final ClientConfig CLIENT; | ||
public static final ForgeConfigSpec CLIENT_SPEC; | ||
|
||
static { | ||
final Pair<ClientConfig, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(ClientConfig::new); | ||
CLIENT_SPEC = specPair.getRight(); | ||
CLIENT = specPair.getLeft(); | ||
} | ||
|
||
public static class ClientConfig { | ||
public final ForgeConfigSpec.ConfigValue<String> openUrl; | ||
public final ForgeConfigSpec.ConfigValue<Integer> delayInSecs; | ||
public final ForgeConfigSpec.ConfigValue<Boolean> defused; | ||
|
||
public ClientConfig(ForgeConfigSpec.Builder builder) { | ||
openUrl = builder | ||
.comment("URL Opened before the bluescreen. Set to 'none' to disable.") | ||
.define("openUrl", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"); | ||
|
||
delayInSecs = builder | ||
.comment("Delay in seconds before the blue screen.") | ||
.define("delayInSecs", 5); | ||
|
||
defused = builder | ||
.comment("Whether or not the mod is defused. If true, you will not blue screen.") | ||
.define("defused", false); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onModConfigEvent(final ModConfig.ModConfigEvent configEvent) { | ||
if (configEvent.getConfig().getSpec() == Config.CLIENT_SPEC) { | ||
Config.bakeConfig(); | ||
} | ||
} | ||
|
||
public static String openUrl; | ||
public static Integer delayInSecs; | ||
public static Boolean defused; | ||
|
||
public static void bakeConfig() { | ||
openUrl = CLIENT.openUrl.get(); | ||
delayInSecs = CLIENT.delayInSecs.get(); | ||
defused = CLIENT.defused.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.cosmiiko.bsodod; | ||
|
||
import com.sun.jna.Native; | ||
import com.sun.jna.Pointer; | ||
import com.sun.jna.win32.StdCallLibrary; | ||
import com.sun.jna.win32.W32APIOptions; | ||
|
||
public interface NtDll extends StdCallLibrary { | ||
NtDll INSTANCE = Native.loadLibrary("NtDll", NtDll.class, W32APIOptions.DEFAULT_OPTIONS); | ||
|
||
// See http://www.pinvoke.net/default.aspx/ntdll.RtlAdjustPrivilege | ||
public long RtlAdjustPrivilege(long Privilege, boolean bEnablePrivilege, boolean IsThreadPrivilege, Pointer PreviousValue); | ||
|
||
// See http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FError%2FNtRaiseHardError.html | ||
public long NtRaiseHardError(long ErrorStatus, long NumberOfParameters, long UnicodeStringParameterMask, int Parameters, long ValidResponseOption, Pointer Response); | ||
} |