diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 2b2c2947..c38de225 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -3,7 +3,7 @@ import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtensi dependencies { labyProcessor() labyApi("api") - addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.2") + addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.3") } labyModAnnotationProcessor { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 8b98b660..8703bb31 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -3,7 +3,7 @@ import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtensi dependencies { labyProcessor() api(project(":api")) - addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.2") + addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.3") } labyModAnnotationProcessor { diff --git a/core/src/main/java/com/rappytv/globaltags/command/GlobalTagCommand.java b/core/src/main/java/com/rappytv/globaltags/command/GlobalTagCommand.java index a1e098f5..4de4db44 100644 --- a/core/src/main/java/com/rappytv/globaltags/command/GlobalTagCommand.java +++ b/core/src/main/java/com/rappytv/globaltags/command/GlobalTagCommand.java @@ -5,7 +5,8 @@ import com.rappytv.globaltags.command.subcommands.ClearCacheCommand; import com.rappytv.globaltags.command.subcommands.LinkDiscordSubcommand; import com.rappytv.globaltags.command.subcommands.RenewCacheCommand; -import com.rappytv.globaltags.command.subcommands.UnlinkDiscordSubcommand; +import com.rappytv.globaltags.command.subcommands.UnlinkSubcommand; +import com.rappytv.globaltags.command.subcommands.VerifyCommand; import net.labymod.api.client.chat.command.Command; import net.labymod.api.client.component.Component; import net.labymod.api.client.component.TextComponent; @@ -27,7 +28,8 @@ public GlobalTagCommand(GlobalTagAddon addon) { withSubCommand(new ClearCacheCommand(api)); withSubCommand(new LinkDiscordSubcommand(api)); withSubCommand(new RenewCacheCommand(api)); - withSubCommand(new UnlinkDiscordSubcommand(api)); + withSubCommand(new UnlinkSubcommand(api)); + withSubCommand(new VerifyCommand(api)); } @Override diff --git a/core/src/main/java/com/rappytv/globaltags/command/subcommands/LinkDiscordSubcommand.java b/core/src/main/java/com/rappytv/globaltags/command/subcommands/LinkDiscordSubcommand.java index 7b462869..d0acd7e6 100644 --- a/core/src/main/java/com/rappytv/globaltags/command/subcommands/LinkDiscordSubcommand.java +++ b/core/src/main/java/com/rappytv/globaltags/command/subcommands/LinkDiscordSubcommand.java @@ -5,7 +5,10 @@ import net.labymod.api.Laby; import net.labymod.api.client.chat.command.SubCommand; import net.labymod.api.client.component.Component; +import net.labymod.api.client.component.event.ClickEvent; +import net.labymod.api.client.component.event.HoverEvent; import net.labymod.api.client.component.format.NamedTextColor; +import net.labymod.api.client.component.format.TextDecoration; public class LinkDiscordSubcommand extends SubCommand { @@ -17,22 +20,82 @@ public LinkDiscordSubcommand(GlobalTagAPI api) { } @Override - public boolean execute(String s, String[] strings) { - api.getApiHandler().linkDiscord((info) -> { - if(info.successful()) { - String code = info.data(); - Laby.references().chatExecutor().copyToClipboard(code); - displayMessage(GlobalTagAddon.prefix.copy().append(Component.translatable( - "globaltags.commands.link.discord.copied", - NamedTextColor.GREEN - ))); - } else displayMessage( - GlobalTagAddon.prefix.copy().append(Component.text( - info.data(), - NamedTextColor.RED - )) - ); - }); + public boolean execute(String prefix, String[] arguments) { + switch (arguments.length > 0 ? arguments[0].toLowerCase() : "none") { + case "discord": + api.getApiHandler().linkDiscord((info) -> { + if (info.successful()) { + String code = info.data(); + Laby.references().chatExecutor().copyToClipboard(code); + displayMessage(GlobalTagAddon.prefix.copy().append(Component.translatable( + "globaltags.commands.link.discord.copied", + NamedTextColor.GREEN + ))); + } else { + displayMessage( + GlobalTagAddon.prefix.copy().append(Component.text( + info.data(), + NamedTextColor.RED + )) + ); + } + }); + break; + case "email": + if (arguments.length < 2) { + displayMessage( + Component.empty() + .append(GlobalTagAddon.prefix) + .append(Component.translatable( + "globaltags.commands.usage", + NamedTextColor.RED, + Component.text("/gt link email
") + )) + ); + return true; + } + + api.getApiHandler().linkEmail(arguments[1], (info) -> { + if (info.successful()) { + displayMessage( + Component.empty() + .append(GlobalTagAddon.prefix) + .append(Component.text(info.data(), NamedTextColor.GREEN)) + .append(Component.newline()) + .append(GlobalTagAddon.prefix) + .append( + Component.translatable( + "globaltags.commands.link.email.verify", + NamedTextColor.AQUA + ) + .decorate(TextDecoration.UNDERLINED) + .clickEvent(ClickEvent.suggestCommand("/gt verify email ")) + .hoverEvent(HoverEvent.showText( + Component.translatable( + "globaltags.commands.link.email.hover") + )) + ) + ); + } else { + displayMessage( + Component.empty() + .append(GlobalTagAddon.prefix) + .append(Component.text(info.data(), NamedTextColor.RED)) + ); + } + }); + break; + default: + displayMessage( + Component.empty() + .append(GlobalTagAddon.prefix) + .append(Component.translatable( + "globaltags.commands.usage", + NamedTextColor.RED, + Component.text("/gt link")
+ ))
+ );
+ return true;
+ }
+
+ api.getApiHandler().verifyEmail(arguments[1], (response) -> displayMessage(
+ GlobalTagAddon.prefix.copy().append(Util.getResponseComponent(response))
+ ));
+ break;
+ default:
+ displayMessage(
+ Component.empty()
+ .append(GlobalTagAddon.prefix)
+ .append(Component.translatable(
+ "globaltags.commands.usage",
+ NamedTextColor.RED,
+ Component.text("/gt verify email ")
+ ))
+ );
+ }
+ return true;
+ }
+}
diff --git a/core/src/main/resources/assets/globaltags/i18n/de_de.json b/core/src/main/resources/assets/globaltags/i18n/de_de.json
index 8153290c..df369c13 100644
--- a/core/src/main/resources/assets/globaltags/i18n/de_de.json
+++ b/core/src/main/resources/assets/globaltags/i18n/de_de.json
@@ -128,6 +128,7 @@
"error": "Es ist ein Fehler aufgetreten"
},
"commands": {
+ "usage": "Benutzung: %s",
"base": {
"version": "Addon Version: %s",
"api": {
@@ -148,6 +149,10 @@
"link": {
"discord": {
"copied": "Der Code wurde in deine Zwischenablage kopiert!"
+ },
+ "email": {
+ "verify": "Email verifizieren",
+ "hover": "Klicke, um den Verifizierungscode einzugeben"
}
}
},
diff --git a/core/src/main/resources/assets/globaltags/i18n/en_us.json b/core/src/main/resources/assets/globaltags/i18n/en_us.json
index d67ebb9c..b7975cb0 100644
--- a/core/src/main/resources/assets/globaltags/i18n/en_us.json
+++ b/core/src/main/resources/assets/globaltags/i18n/en_us.json
@@ -128,6 +128,7 @@
"error": "An error ocurred"
},
"commands": {
+ "usage": "Usage: %s",
"base": {
"version": "Addon Version: %s",
"api": {
@@ -148,6 +149,10 @@
"link": {
"discord": {
"copied": "The code was copied to your clipboard!"
+ },
+ "email": {
+ "verify": "Verify email",
+ "hover": "Click to enter verification code"
}
}
},