Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for updating passwords when using nLogin #44

Merged
merged 2 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bukkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
compileOnly 'dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'io.netty:netty-all:4.1.25.Final'
compileOnly 'fr.xephi:authme:5.6.0-beta2'
compileOnly 'com.nickuc.login:nlogin-api:10.2'
compileOnly 'com.nickuc.login:nlogin-api:10.3'
compileOnly 'me.clip:placeholderapi:2.11.1'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.azuriom.azlink.bukkit.AzLinkBukkitPlugin;
import com.azuriom.azlink.common.integrations.BaseNLogin;
import com.nickuc.login.api.enums.TwoFactorType;
import com.nickuc.login.api.event.bukkit.account.PasswordUpdateEvent;
import com.nickuc.login.api.event.bukkit.auth.RegisterEvent;
import com.nickuc.login.api.event.bukkit.twofactor.TwoFactorAddEvent;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -36,6 +37,11 @@ public void onRegister(RegisterEvent event) {
handleRegister(player.getUniqueId(), player.getName(), event.getPassword(), address);
}

@EventHandler
public void onPasswordUpdate(PasswordUpdateEvent event) {
handleUpdatePassword(event.getPlayerId(), event.getPlayerName(), event.getNewPassword());
}

public static void register(AzLinkBukkitPlugin plugin) {
if (ensureApiVersion(plugin)) {
plugin.getServer().getPluginManager().registerEvents(new NLoginIntegration(plugin), plugin);
Expand Down
2 changes: 1 addition & 1 deletion bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: The plugin to link your Azuriom website with your server.
website: https://azuriom.com
main: com.azuriom.azlink.bukkit.AzLinkBukkitPlugin
api-version: 1.13
softdepend: [PlaceholderAPI, SkinsRestorer]
softdepend: [nLogin, PlaceholderAPI, SkinsRestorer]
loadbefore: [AuthMe]
folia-supported: true
commands:
Expand Down
2 changes: 1 addition & 1 deletion bungee/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repositories {
dependencies {
implementation project(':azlink-common')
compileOnly 'net.md-5:bungeecord-api:1.16-R0.4'
compileOnly 'com.nickuc.login:nlogin-api:10.2'
compileOnly 'com.nickuc.login:nlogin-api:10.3'
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.azuriom.azlink.bungee.AzLinkBungeePlugin;
import com.azuriom.azlink.common.integrations.BaseNLogin;
import com.nickuc.login.api.enums.TwoFactorType;
import com.nickuc.login.api.event.bungee.account.PasswordUpdateEvent;
import com.nickuc.login.api.event.bungee.auth.RegisterEvent;
import com.nickuc.login.api.event.bungee.twofactor.TwoFactorAddEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
Expand Down Expand Up @@ -38,6 +39,11 @@ public void onRegister(RegisterEvent event) {
handleRegister(player.getUniqueId(), player.getName(), event.getPassword(), address);
}

@EventHandler
public void onPasswordUpdate(PasswordUpdateEvent event) {
handleUpdatePassword(event.getPlayerId(), event.getPlayerName(), event.getNewPassword());
}

public static void register(AzLinkBungeePlugin plugin) {
if (ensureApiVersion(plugin)) {
plugin.getProxy().getPluginManager().registerListener(plugin, new NLoginIntegration(plugin));
Expand Down
2 changes: 1 addition & 1 deletion bungee/src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ version: ${pluginVersion}
author: Azuriom Team
description: The plugin to link your Azuriom website with your server.
main: com.azuriom.azlink.bungee.AzLinkBungeePlugin
softdepend: [SkinsRestorer]
softdepend: [nLogin, SkinsRestorer]
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
compileOnly 'com.google.code.gson:gson:2.10.1'
compileOnly 'io.netty:netty-all:4.1.42.Final'
compileOnly 'net.skinsrestorer:skinsrestorer-api:15.0.2'
compileOnly 'com.nickuc.login:nlogin-api:10.2'
compileOnly 'com.nickuc.login:nlogin-api:10.3'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ protected void handleRegister(UUID uuid, String name, String password, InetAddre
});
}

protected void handleUpdatePassword(UUID uuid, String name, String password) {
this.plugin.getHttpClient()
.updatePassword(uuid, password)
.exceptionally(ex -> {
this.plugin.getLogger().error("Unable to update password for " + name, ex);

return null;
});
}

protected static boolean ensureApiVersion(AzLinkPlatform platform) {
if (nLoginAPI.getApi().getApiVersion() < 5) {
platform.getPlugin().getLogger().warn("nLogin integration requires API v5 or higher");
Expand Down
2 changes: 1 addition & 1 deletion velocity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
compileOnly 'com.velocitypowered:velocity-api:3.1.1'
compileOnly 'net.elytrium.limboapi:api:1.1.13'
compileOnly 'net.elytrium:limboauth:1.1.1'
compileOnly 'com.nickuc.login:nlogin-api:10.2'
compileOnly 'com.nickuc.login:nlogin-api:10.3'
annotationProcessor 'com.velocitypowered:velocity-api:3.1.1'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
authors = "Azuriom Team",
dependencies = {
@Dependency(id = "limboauth", optional = true),
@Dependency(id = "nlogin", optional = true),
@Dependency(id = "skinsrestorer", optional = true),
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.azuriom.azlink.velocity.AzLinkVelocityPlugin;
import com.nickuc.login.api.enums.TwoFactorType;
import com.nickuc.login.api.event.velocity.twofactor.TwoFactorAddEvent;
import com.nickuc.login.api.event.velocity.account.PasswordUpdateEvent;
import com.nickuc.login.api.event.velocity.auth.RegisterEvent;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.proxy.Player;
Expand Down Expand Up @@ -33,6 +34,11 @@ public void onRegister(RegisterEvent event) {
handleRegister(player.getUniqueId(), player.getUsername(), event.getPassword(), address);
}

@Subscribe
public void onPasswordUpdate(PasswordUpdateEvent event) {
handleUpdatePassword(event.getPlayerId(), event.getPlayerName(), event.getNewPassword());
}

public static void register(AzLinkVelocityPlugin plugin) {
if (ensureApiVersion(plugin)) {
plugin.getProxy().getEventManager().register(plugin, new NLoginIntegration(plugin));
Expand Down
Loading