aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/elytrium/limboauth/LimboAuth.java
diff options
context:
space:
mode:
authorPetr Ilin <hevav@hevav.dev>2022-02-07 14:59:58 +0300
committerPetr Ilin <hevav@hevav.dev>2022-02-07 14:59:58 +0300
commit43eb1dbe330eed35ff7bd2c2b932b1f113745a95 (patch)
tree7c33f326eaf5c793df3b028f48835df1e3041e2d /src/main/java/net/elytrium/limboauth/LimboAuth.java
parent11dc5edc485a93d05eb2485ad80b4df7afbde6d9 (diff)
downloadLimboAuth-43eb1dbe330eed35ff7bd2c2b932b1f113745a95.tar.gz
LimboAuth-43eb1dbe330eed35ff7bd2c2b932b1f113745a95.tar.bz2
LimboAuth-43eb1dbe330eed35ff7bd2c2b932b1f113745a95.zip
Registering commands on Limbo (fixes Forge 1.18 issue)
Diffstat (limited to 'src/main/java/net/elytrium/limboauth/LimboAuth.java')
-rw-r--r--src/main/java/net/elytrium/limboauth/LimboAuth.java47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java
index e6abf06..c574314 100644
--- a/src/main/java/net/elytrium/limboauth/LimboAuth.java
+++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java
@@ -17,6 +17,7 @@
package net.elytrium.limboauth;
+import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.DaoManager;
@@ -24,7 +25,11 @@ import com.j256.ormlite.field.FieldType;
import com.j256.ormlite.jdbc.JdbcPooledConnectionSource;
import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.table.TableUtils;
+import com.mojang.brigadier.tree.CommandNode;
import com.velocitypowered.api.command.CommandManager;
+import com.velocitypowered.api.command.CommandMeta;
+import com.velocitypowered.api.command.CommandSource;
+import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Dependency;
@@ -47,6 +52,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -84,6 +90,7 @@ import net.kyori.adventure.title.Title;
import org.bstats.charts.SimplePie;
import org.bstats.charts.SingleLineChart;
import org.bstats.velocity.Metrics;
+import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
@Plugin(
@@ -262,7 +269,12 @@ public class LimboAuth {
}
}
- this.authServer = this.factory.createLimbo(authWorld).setName("LimboAuth");
+ this.authServer = this.factory
+ .createLimbo(authWorld)
+ .setName("LimboAuth")
+ .registerCommand(new AuthCommandMeta(this, ImmutableList.of("2fa", "totp")), new AuthCommand())
+ .registerCommand(new AuthCommandMeta(this, ImmutableList.of("login", "l", "log")), new AuthCommand())
+ .registerCommand(new AuthCommandMeta(this, ImmutableList.of("reg", "register")), new AuthCommand());
this.server.getEventManager().unregisterListeners(this);
this.server.getEventManager().register(this, new AuthListener(this, this.playerDao));
@@ -488,4 +500,37 @@ public class LimboAuth {
return this.checkTime;
}
}
+
+ private static class AuthCommandMeta implements CommandMeta {
+
+ private final LimboAuth plugin;
+ private final Collection<String> aliases;
+
+ AuthCommandMeta(LimboAuth plugin, Collection<String> aliases) {
+ this.plugin = plugin;
+ this.aliases = aliases;
+ }
+
+ @Override
+ public Collection<String> getAliases() {
+ return this.aliases;
+ }
+
+ @Override
+ public Collection<CommandNode<CommandSource>> getHints() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public @Nullable Object getPlugin() {
+ return this.plugin;
+ }
+ }
+
+ private static class AuthCommand implements SimpleCommand {
+ @Override
+ public void execute(Invocation invocation) {
+
+ }
+ }
}