Skip to content

Commit

Permalink
feat: register failed attempts of log in
Browse files Browse the repository at this point in the history
  • Loading branch information
zHackeed committed Dec 3, 2023
1 parent b0dab82 commit b6ad177
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/main/java/io/v4guard/shield/bungee/hooks/nLoginBungeeHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nickuc.login.api.event.bungee.auth.LoginEvent;
import com.nickuc.login.api.event.bungee.auth.RegisterEvent;
import com.nickuc.login.api.event.bungee.auth.WrongPasswordEvent;
import io.v4guard.shield.core.auth.AuthType;
import io.v4guard.shield.core.auth.Authentication;
import io.v4guard.shield.core.hook.AuthenticationHook;
Expand Down Expand Up @@ -40,4 +41,14 @@ public void onRegister(RegisterEvent event) {
v4GuardShieldCore.getInstance().getMessager().sendMessage(auth);
}

@EventHandler
public void onWrongPassword(WrongPasswordEvent event) {
Authentication auth = new Authentication(
event.getPlayer().getName(),
event.getPlayer().getUniqueId(),
AuthType.FAILED,
event.getPlayer().hasPermission("v4guard.accshield")
);
v4GuardShieldCore.getInstance().getMessager().sendMessage(auth);
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/v4guard/shield/core/auth/AuthType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public enum AuthType {

LOGIN, REGISTER, UNKNOWN;
LOGIN, REGISTER, FAILED, UNKNOWN;

}
13 changes: 13 additions & 0 deletions src/main/java/io/v4guard/shield/spigot/hooks/AuthMeSpigotHook.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.v4guard.shield.spigot.hooks;

import fr.xephi.authme.events.FailedLoginEvent;
import fr.xephi.authme.events.LoginEvent;
import fr.xephi.authme.events.RegisterEvent;
import io.v4guard.shield.core.auth.AuthType;
Expand Down Expand Up @@ -41,4 +42,16 @@ public void onRegister(RegisterEvent event) {
v4GuardShieldCore.getInstance().getMessager().sendMessage(auth);
}


@EventHandler
public void onWrongPassword(FailedLoginEvent event) {
Authentication auth = new Authentication(
event.getPlayer().getName(),
event.getPlayer().getUniqueId(),
AuthType.FAILED,
event.getPlayer().hasPermission("v4guard.accshield")
);

v4GuardShieldCore.getInstance().getMessager().sendMessage(auth);
}
}
12 changes: 12 additions & 0 deletions src/main/java/io/v4guard/shield/spigot/hooks/nLoginSpigotHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nickuc.login.api.event.bukkit.auth.LoginEvent;
import com.nickuc.login.api.event.bukkit.auth.RegisterEvent;
import com.nickuc.login.api.event.bukkit.auth.WrongPasswordEvent;
import io.v4guard.shield.core.auth.AuthType;
import io.v4guard.shield.core.auth.Authentication;
import io.v4guard.shield.core.hook.AuthenticationHook;
Expand Down Expand Up @@ -41,4 +42,15 @@ public void onRegister(RegisterEvent event) {
v4GuardShieldCore.getInstance().getMessager().sendMessage(auth);
}


@EventHandler
public void onWrongPassword(WrongPasswordEvent event) {
Authentication auth = new Authentication(
event.getPlayer().getName(),
event.getPlayer().getUniqueId(),
AuthType.FAILED,
event.getPlayer().hasPermission("v4guard.accshield")
);
v4GuardShieldCore.getInstance().getMessager().sendMessage(auth);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nickuc.login.api.event.velocity.auth.LoginEvent;
import com.nickuc.login.api.event.velocity.auth.RegisterEvent;
import com.nickuc.login.api.event.velocity.auth.WrongPasswordEvent;
import com.velocitypowered.api.event.Subscribe;
import io.v4guard.shield.core.auth.AuthType;
import io.v4guard.shield.core.auth.Authentication;
Expand Down Expand Up @@ -40,4 +41,15 @@ public void onRegister(RegisterEvent event) {
v4GuardShieldCore.getInstance().getMessager().sendMessage(auth);
}

@Subscribe
public void onWrongPassword(WrongPasswordEvent event) {
Authentication auth = new Authentication(
event.getPlayer().getUsername(),
event.getPlayer().getUniqueId(),
AuthType.FAILED,
event.getPlayer().hasPermission("v4guard.accshield")
);
v4GuardShieldCore.getInstance().getMessager().sendMessage(auth);
}

}

0 comments on commit b6ad177

Please sign in to comment.