Skip to content

Commit dda2b85

Browse files
committed
Do not unregister "/2fa" command of other plugins
1 parent 2c60de7 commit dda2b85

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/net/elytrium/limboauth/LimboAuth.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.j256.ormlite.table.TableInfo;
3535
import com.j256.ormlite.table.TableUtils;
3636
import com.velocitypowered.api.command.CommandManager;
37+
import com.velocitypowered.api.command.CommandMeta;
3738
import com.velocitypowered.api.event.EventManager;
3839
import com.velocitypowered.api.event.Subscribe;
3940
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
@@ -343,7 +344,6 @@ public void reload() {
343344
manager.unregister("changepassword");
344345
manager.unregister("forcechangepassword");
345346
manager.unregister("destroysession");
346-
manager.unregister("2fa");
347347
manager.unregister("limboauth");
348348

349349
manager.register("unregister", new UnregisterCommand(this, this.playerDao), "unreg");
@@ -354,7 +354,13 @@ public void reload() {
354354
manager.register("forcechangepassword", new ForceChangePasswordCommand(this, this.server, this.playerDao), "forcechangepass", "fcp");
355355
manager.register("destroysession", new DestroySessionCommand(this), "logout");
356356
if (Settings.IMP.MAIN.ENABLE_TOTP) {
357-
manager.register("2fa", new TotpCommand(this.playerDao), "totp");
357+
CommandMeta meta = manager.metaBuilder("2fa").aliases("totp").plugin(this).build();
358+
manager.register(meta, new TotpCommand(this.playerDao));
359+
} else {
360+
CommandMeta meta = manager.getCommandMeta("2fa");
361+
if (meta != null && this.equals(meta.getPlugin())) {
362+
manager.unregister("2fa");
363+
}
358364
}
359365
manager.register("limboauth", new LimboAuthCommand(this), "la", "auth", "lauth");
360366

0 commit comments

Comments
 (0)