diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig')
14 files changed, 51 insertions, 35 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSize.java b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSize.java new file mode 100644 index 0000000..5a919c6 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSize.java @@ -0,0 +1,6 @@ +package cc.polyfrost.oneconfig.config.data; + +public class OptionSize { + public static final int SINGLE = 1; + public static final int DUAL = 2; +} diff --git a/src/main/java/cc/polyfrost/oneconfig/events/EventManager.java b/src/main/java/cc/polyfrost/oneconfig/events/EventManager.java index cb75a12..05bb196 100644 --- a/src/main/java/cc/polyfrost/oneconfig/events/EventManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/events/EventManager.java @@ -10,9 +10,13 @@ public final class EventManager { /** * The instance of the {@link EventManager}. */ - public static final EventManager INSTANCE = new EventManager(); + private static final EventManager INSTANCE = new EventManager(); private final EventBus eventBus = new EventBus(new LMFInvoker(), Throwable::printStackTrace); + public static EventManager getEventManager() { + return INSTANCE; + } + private EventManager() { } diff --git a/src/main/java/cc/polyfrost/oneconfig/events/event/InitializationEvent.java b/src/main/java/cc/polyfrost/oneconfig/events/event/InitializationEvent.java new file mode 100644 index 0000000..c068914 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/events/event/InitializationEvent.java @@ -0,0 +1,5 @@ +package cc.polyfrost.oneconfig.events.event; + +/** Called when the game is initialized. */ +public class InitializationEvent { +} diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java index 51e3a6f..948f4ec 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java @@ -63,8 +63,8 @@ public class OneConfig { testConfig = new TestConfig(); CommandManager.INSTANCE.registerCommand(OneConfigCommand.class); CommandManager.INSTANCE.registerCommand(TestCommand.class); - EventManager.INSTANCE.register(new HudCore()); - EventManager.INSTANCE.register(HypixelUtils.INSTANCE); + EventManager.getEventManager().register(new HudCore()); + EventManager.getEventManager().register(HypixelUtils.INSTANCE); reloadModsList(); initialized = true; } diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java b/src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java index f5c332f..d248df8 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java @@ -22,15 +22,15 @@ import java.util.List; /** * An implementation of the BlurMC mod by tterrag1098. * <p> - * For the original source see https://github.com/tterrag1098/Blur/blob/1.8.9/src/main/java/com/tterrag/blur/Blur.java - * For the public license, see https://github.com/tterrag1098/Blur/blob/1.8.9/LICENSE + * For the original source see <a href="https://github.com/tterrag1098/Blur/blob/1.8.9/src/main/java/com/tterrag/blur/Blur.java">...</a> + * For the public license, see <a href="https://github.com/tterrag1098/Blur/blob/1.8.9/LICENSE">...</a> * <p> - * License available under https://github.com/boomboompower/ToggleChat/blob/master/src/main/resources/licenses/BlurMC-License.txt + * License available under <a href="https://github.com/boomboompower/ToggleChat/blob/master/src/main/resources/licenses/BlurMC-License.txt">...</a> * * @author tterrag1098, boomboompower * <p> * Taken from ToggleChat - * https://github.com/boomboompower/ToggleChat/blob/master/LICENSE + * <a href="https://github.com/boomboompower/ToggleChat/blob/master/LICENSE">...</a> */ public class BlurHandler { public static BlurHandler INSTANCE = new BlurHandler(); @@ -43,7 +43,7 @@ public class BlurHandler { * Simply initializes the blur mod so events are properly handled by forge. */ public void load() { - EventManager.INSTANCE.register(this); + EventManager.getEventManager().register(this); } @Subscribe diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java index f08d37e..8422e1e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java @@ -12,6 +12,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class GuiIngameForgeMixin { @Inject(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;post(Lnet/minecraftforge/client/event/RenderGameOverlayEvent$ElementType;)V", shift = At.Shift.AFTER, remap = false), remap = true) private void onRenderGameOverlay(float partialTicks, CallbackInfo ci) { - EventManager.INSTANCE.post(new HudRenderEvent(partialTicks)); + EventManager.getEventManager().post(new HudRenderEvent(partialTicks)); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java index f0d201c..6456cf9 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java @@ -27,27 +27,28 @@ public class MinecraftMixin { @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;onInitializationComplete()V", shift = At.Shift.AFTER, remap = false), remap = true) private void onInit(CallbackInfo ci) { + EventManager.getEventManager().post(new InitializationEvent()); OneConfig.init(); } @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickStart(F)V", shift = At.Shift.AFTER, remap = false), remap = true) private void onRenderTickStart(CallbackInfo ci) { - EventManager.INSTANCE.post(new RenderEvent(Stage.START, timer.renderPartialTicks)); + EventManager.getEventManager().post(new RenderEvent(Stage.START, timer.renderPartialTicks)); } @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickEnd(F)V", shift = At.Shift.AFTER, remap = false), remap = true) private void onRenderTickEnd(CallbackInfo ci) { - EventManager.INSTANCE.post(new RenderEvent(Stage.END, timer.renderPartialTicks)); + EventManager.getEventManager().post(new RenderEvent(Stage.END, timer.renderPartialTicks)); } @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPreClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) private void onClientTickStart(CallbackInfo ci) { - EventManager.INSTANCE.post(new TickEvent(Stage.START)); + EventManager.getEventManager().post(new TickEvent(Stage.START)); } @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPostClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) private void onClientTickEnd(CallbackInfo ci) { - EventManager.INSTANCE.post(new TickEvent(Stage.END)); + EventManager.getEventManager().post(new TickEvent(Stage.END)); } @ModifyArg(method = "displayGuiScreen", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/eventhandler/EventBus;post(Lnet/minecraftforge/fml/common/eventhandler/Event;)Z", remap = false), remap = true) @@ -55,7 +56,7 @@ public class MinecraftMixin { if (a instanceof GuiOpenEvent) { GuiOpenEvent forgeEvent = (GuiOpenEvent) a; ScreenOpenEvent event = new ScreenOpenEvent(forgeEvent.gui); - EventManager.INSTANCE.post(event); + EventManager.getEventManager().post(event); if (event.isCancelled) { forgeEvent.setCanceled(true); } @@ -66,11 +67,11 @@ public class MinecraftMixin { @Inject(method = "runGameLoop", at = @At(value = "FIELD", target = "Lnet/minecraft/util/Timer;renderPartialTicks:F", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER)) private void onNonDeltaTickTimerUpdate(CallbackInfo ci) { - EventManager.INSTANCE.post(new TimerUpdateEvent(timer, false)); + EventManager.getEventManager().post(new TimerUpdateEvent(timer, false)); } @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Timer;updateTimer()V", shift = At.Shift.AFTER, ordinal = 1)) private void onDeltaTickTimerUpdate(CallbackInfo ci) { - EventManager.INSTANCE.post(new TimerUpdateEvent(timer, true)); + EventManager.getEventManager().post(new TimerUpdateEvent(timer, true)); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java index 877d540..0673c77 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java @@ -17,7 +17,7 @@ public class NetHandlerPlayClientMixin { @Inject(method = "addToSendQueue", at = @At("HEAD"), cancellable = true) private void onSendPacket(Packet<?> p_147297_1_, CallbackInfo ci) { SendPacketEvent event = new SendPacketEvent(p_147297_1_); - EventManager.INSTANCE.post(event); + EventManager.getEventManager().post(event); if (event.isCancelled) { ci.cancel(); } @@ -27,7 +27,7 @@ public class NetHandlerPlayClientMixin { private void onClientChat(S02PacketChat packetIn, CallbackInfo ci) { if (packetIn.getType() == 0) { ChatReceiveEvent event = new ChatReceiveEvent(packetIn.getChatComponent()); - EventManager.INSTANCE.post(event); + EventManager.getEventManager().post(event); if (event.isCancelled) { ci.cancel(); } diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java index 51988f2..89346f6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java @@ -15,7 +15,7 @@ public class NetworkManagerMixin { @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) private void onReceivePacket(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_, CallbackInfo ci) { ReceivePacketEvent event = new ReceivePacketEvent(p_channelRead0_2_); - EventManager.INSTANCE.post(event); + EventManager.getEventManager().post(event); if (event.isCancelled) { ci.cancel(); } diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java index d1fce6a..5e9b1bc 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java @@ -16,6 +16,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class WorldClientMixin { @Inject(method = "<init>", at = @At("RETURN")) private void onWorldLoad(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_, CallbackInfo ci) { - EventManager.INSTANCE.post(new WorldLoadEvent()); + EventManager.getEventManager().post(new WorldLoadEvent()); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java index ab3b09f..dc3babd 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java @@ -14,45 +14,45 @@ public class TestConfig extends Config { @Switch( name = "Test Switch", - size = 2 + size = OptionSize.DUAL ) public boolean testSwitch = false; @Checkbox( name = "Check box", - size = 2 + size = OptionSize.DUAL ) public static boolean testCheckBox = true; @Info( text = "Test Info", type = InfoType.ERROR, - size = 2 + size = OptionSize.DUAL ) boolean ignored; @Header( text = "Test Header", - size = 2 + size = OptionSize.DUAL ) boolean ignored1; @Dropdown( name = "Test Dropdown", options = {"option1", "option2", "option3"}, - size = 2 + size = OptionSize.DUAL ) private int testDropdown = 0; @Color( name = "Test Color", - size = 2 + size = OptionSize.DUAL ) OneColor testColor = new OneColor(0, 255, 255); @Text( name = "Test Text", - size = 2 + size = OptionSize.DUAL ) private static String testText = "Epic Text"; @@ -71,7 +71,7 @@ public class TestConfig extends Config { @KeyBind( name = "Test KeyBind", - size = 2 + size = OptionSize.DUAL ) OneKeyBind testKeyBind = new OneKeyBind(UKeyboard.KEY_LSHIFT, UKeyboard.KEY_S); @@ -79,7 +79,7 @@ public class TestConfig extends Config { name = "Test Dual Option", left = "YES", right = "NO", - size = 2 + size = OptionSize.DUAL ) boolean testDualOption = false; @@ -100,14 +100,14 @@ public class TestConfig extends Config { @Switch( name = "Test Switch", - size = 2, + size = OptionSize.DUAL, category = "Category 2" ) boolean testSwitch1 = false; @Switch( name = "Test Switch", - size = 2, + size = OptionSize.DUAL, category = "Category 2", subcategory = "Test Subcategory" ) diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java index 7b6be2c..6cda00c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java @@ -13,7 +13,7 @@ public class TickDelay { private int delay; public TickDelay(Runnable functionName, int ticks) { - EventManager.INSTANCE.register(this); + EventManager.getEventManager().register(this); delay = ticks; function = functionName; } @@ -24,7 +24,7 @@ public class TickDelay { // Delay expired if (delay < 1) { function.run(); - EventManager.INSTANCE.unregister(this); + EventManager.getEventManager().unregister(this); } delay--; } diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java index 973e003..c80814f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java @@ -17,7 +17,7 @@ public final class GuiUtils { private static long deltaTime = 17L; static { - EventManager.INSTANCE.register(new GuiUtils()); + EventManager.getEventManager().register(new GuiUtils()); } /** diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java index a952053..36dc46c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java @@ -123,7 +123,7 @@ public class HypixelUtils { previousLocraw = parsed; inGame = true; // If your gamemode does not return "lobby", boolean inGame is true. } - EventManager.INSTANCE.post(new LocrawEvent(locraw)); + EventManager.getEventManager().post(new LocrawEvent(locraw)); event.isCancelled = true; } } catch (Exception ex) { |