mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-03-02 10:41:43 +01:00
Merge pull request #103 from AuthMe-Team/realname-update
This commit is contained in:
commit
584fe1d67f
8
pom.xml
8
pom.xml
@ -346,6 +346,12 @@
|
||||
<id>xephi-repo</id>
|
||||
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
|
||||
<!-- PermissionsEx Repo (Re-added, since Xephi's repo was down) -->
|
||||
<repository>
|
||||
<id>pex-repo</id>
|
||||
<url>https://pex-repo.aoeu.xyz/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -486,7 +492,7 @@
|
||||
<dependency>
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
<version>1.23.4</version>
|
||||
<version>1.23.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -230,6 +230,15 @@ public class CacheDataSource implements DataSource {
|
||||
cachedAuths.invalidate(oldOne);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
boolean result = source.updateRealName(user, realName);
|
||||
if (result) {
|
||||
cachedAuths.refresh(user);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
return source.getAllAuths();
|
||||
|
@ -204,6 +204,7 @@ public interface DataSource {
|
||||
*/
|
||||
void updateName(String oldOne, String newOne);
|
||||
|
||||
boolean updateRealName(String user, String realName);
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
*
|
||||
|
@ -716,6 +716,11 @@ public class FlatFile implements DataSource {
|
||||
this.removeAuth(oldOne);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
BufferedReader br = null;
|
||||
|
@ -885,6 +885,21 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
try (Connection con = getConnection()) {
|
||||
String sql = "UPDATE " + tableName + " SET " + col.REAL_NAME + "=? WHERE " + col.NAME + "=?;";
|
||||
PreparedStatement pst = con.prepareStatement(sql);
|
||||
pst.setString(1, realName);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
logSqlException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
|
@ -593,6 +593,20 @@ public class SQLite implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
String sql = "UPDATE " + tableName + " SET " + col.REAL_NAME + "=? WHERE " + col.NAME + "=?;";
|
||||
try(PreparedStatement pst = con.prepareStatement(sql)) {
|
||||
pst.setString(1, realName);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
logSqlException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
|
@ -12,7 +12,6 @@ import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.GeoLiteAPI;
|
||||
@ -109,7 +108,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
|
||||
return;
|
||||
}
|
||||
if(!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
|
||||
if (!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
|
||||
return;
|
||||
}
|
||||
if (Settings.allowCommands.contains(cmd)) {
|
||||
@ -250,8 +249,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (realName.isEmpty() || realName.equals("Player")) {
|
||||
auth.setRealName(event.getName());
|
||||
plugin.getDataSource().saveAuth(auth);
|
||||
plugin.getDataSource().updateRealName(event.getName().toLowerCase(), event.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user