diff --git a/src/main/java/net/raphimc/viaproxy/cli/options/Options.java b/src/main/java/net/raphimc/viaproxy/cli/options/Options.java index dec4f05..4f88ab4 100644 --- a/src/main/java/net/raphimc/viaproxy/cli/options/Options.java +++ b/src/main/java/net/raphimc/viaproxy/cli/options/Options.java @@ -23,6 +23,8 @@ import joptsimple.OptionSpec; import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.plugins.PluginManager; import net.raphimc.viaproxy.plugins.events.GetDefaultPortEvent; +import net.raphimc.viaproxy.plugins.events.PostOptionsParseEvent; +import net.raphimc.viaproxy.plugins.events.PreOptionsParseEvent; import net.raphimc.viaproxy.saves.impl.accounts.Account; import net.raphimc.viaproxy.util.logging.Logger; @@ -68,6 +70,7 @@ public class Options { final OptionSpec localSocketAuth = parser.accepts("local_socket_auth", "Enable authentication over a local socket"); final OptionSpec betaCraftAuth = parser.accepts("betacraft_auth", "Use BetaCraft authentication servers for classic"); final OptionSpec resourcePackUrl = parser.acceptsAll(asList("resource_pack_url", "resource_pack", "rpu", "rp"), "URL of a resource pack which all connecting clients can optionally download").withRequiredArg().ofType(String.class); + PluginManager.EVENT_MANAGER.call(new PreOptionsParseEvent(parser)); final OptionSet options = parser.parse(args); if (options.has(help)) { @@ -95,6 +98,7 @@ public class Options { if (options.has(resourcePackUrl)) { RESOURCE_PACK_URL = options.valueOf(resourcePackUrl); } + PluginManager.EVENT_MANAGER.call(new PostOptionsParseEvent(options)); } } diff --git a/src/main/java/net/raphimc/viaproxy/plugins/events/PostOptionsParseEvent.java b/src/main/java/net/raphimc/viaproxy/plugins/events/PostOptionsParseEvent.java new file mode 100644 index 0000000..52c6d98 --- /dev/null +++ b/src/main/java/net/raphimc/viaproxy/plugins/events/PostOptionsParseEvent.java @@ -0,0 +1,34 @@ +/* + * This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viaproxy.plugins.events; + +import joptsimple.OptionSet; + +public class PostOptionsParseEvent { + + private final OptionSet options; + + public PostOptionsParseEvent(final OptionSet options) { + this.options = options; + } + + public OptionSet getOptions() { + return this.options; + } + +} diff --git a/src/main/java/net/raphimc/viaproxy/plugins/events/PreOptionsParseEvent.java b/src/main/java/net/raphimc/viaproxy/plugins/events/PreOptionsParseEvent.java new file mode 100644 index 0000000..280cdd8 --- /dev/null +++ b/src/main/java/net/raphimc/viaproxy/plugins/events/PreOptionsParseEvent.java @@ -0,0 +1,34 @@ +/* + * This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viaproxy.plugins.events; + +import joptsimple.OptionParser; + +public class PreOptionsParseEvent { + + private final OptionParser parser; + + public PreOptionsParseEvent(final OptionParser parser) { + this.parser = parser; + } + + public OptionParser getParser() { + return this.parser; + } + +}