General minor code clean up and typo fixes

This commit is contained in:
games647
2022-06-11 09:31:08 +02:00
parent 0af22d9927
commit 7652943f2a
19 changed files with 26 additions and 40 deletions
@@ -52,12 +52,6 @@ public class AsyncScheduler {
private final AtomicInteger currentlyRunning = new AtomicInteger();
/*
private final ExecutorService databaseExecutor = new ThreadPoolExecutor(1, 10,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(MAX_CAPACITY));
*/
public AsyncScheduler(Logger logger, Executor processingPool) {
this.logger = logger;
this.processingPool = processingPool;
@@ -76,9 +70,4 @@ public class AsyncScheduler {
return null;
});
}
public void shutdown() {
// MoreExecutors.shutdownAndAwaitTermination(processingPool, 1, TimeUnit.MINUTES);
//MoreExecutors.shutdownAndAwaitTermination(databaseExecutor, 1, TimeUnit.MINUTES);
}
}
@@ -115,9 +115,8 @@ public class StoredProfile extends Profile {
@Override
public synchronized boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof StoredProfile)) return false;
if (!(o instanceof StoredProfile that)) return false;
if (!super.equals(o)) return false;
StoredProfile that = (StoredProfile) o;
return rowId == that.rowId && premium == that.premium
&& Objects.equals(lastIp, that.lastIp) && lastLogin.equals(that.lastLogin);
}
@@ -80,7 +80,7 @@ public class LoginActionMessage implements ChannelMessage {
//Data is sent through a random player. We have to tell the Bukkit version of this plugin the target
output.writeUTF(playerName);
//proxy identifier to check if it's a acceptable proxy
//proxy identifier to check if it's an acceptable proxy
output.writeLong(proxyId.getMostSignificantBits());
output.writeLong(proxyId.getLeastSignificantBits());
}
@@ -312,7 +312,6 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
public void close() {
plugin.getLog().info("Safely shutting down scheduler. This could take up to one minute.");
plugin.getScheduler().shutdown();
if (storage != null) {
storage.close();
@@ -50,7 +50,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
protected final String autoRegisterFloodgate;
protected final String allowNameConflict;
//variables initialized through run() and accesses by subclasss
//variables initialized through run() and accesses by subclass
protected boolean isRegistered;
protected StoredProfile profile;
protected boolean isLinked;
@@ -71,7 +71,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
public void run() {
core.getPlugin().getLog().info("Player {} is connecting through Geyser Floodgate.", username);
// check if the Bedrock player is linked to a Java account
// check if the Bedrock player is linked to a Java account
isLinked = floodgatePlayer.getLinkedPlayer() != null;
//this happens on Bukkit if it's connected to Bungee
@@ -96,7 +96,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
}
} catch (Exception ex) {
core.getPlugin().getLog().error(
"An error has occured while checking if player {} is registered",
"An error has occurred while checking if player {} is registered",
username, ex);
return;
}
@@ -104,7 +104,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
//decide if checks should be made for conflicting Java player names
if (isNameCheckRequired()) {
// check for conflicting Premium Java name
Optional<Profile> premiumUUID = Optional.empty();
Optional<Profile> premiumUUID;
try {
premiumUUID = core.getResolver().findProfile(username);
} catch (IOException | RateLimitException e) {
@@ -138,7 +138,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
* Decide if the player can be automatically registered or logged in.<br>
* The config option 'non-conflicting' is ignored by this function, as name
* conflicts are checked by a different part of the code.
*
*
* @param configValue the value of either 'autoLoginFloodgate' or
* 'autoRegisterFloodgate' from config.yml
* @return true if the Player can be registered automatically
@@ -150,14 +150,14 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
}
/**
* Decides wether checks for conflicting Java names should be made
* Decides whether checks for conflicting Java names should be made
* @return ture if an API call to Mojang is needed
*/
private boolean isNameCheckRequired() {
//linked players have the same name as their Java profile
//OR
//if allowNameConflict is 'false' or 'linked' and the player had a conflicting
//name, than they would have been kicked in FloodgateHook#checkNameConflict
//name, then they would have been kicked in FloodgateHook#checkNameConflict
if (isLinked || !"true".equals(allowNameConflict)) {
return false;
}
@@ -93,7 +93,7 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
premiumUUID = core.getResolver().findProfile(username);
}
if (!premiumUUID.isPresent()
if (premiumUUID.isEmpty()
|| (!checkNameChange(source, username, premiumUUID.get())
&& !checkPremiumName(source, username, profile))) {
//nothing detected the player as premium -> start a cracked session
@@ -27,7 +27,6 @@ package com.github.games647.fastlogin.core.shared;
import com.github.games647.fastlogin.core.StoredProfile;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import java.util.UUID;
@@ -35,7 +34,7 @@ public abstract class LoginSession {
private final StoredProfile profile;
private String requestUsername;
private final String requestUsername;
private String username;
private UUID uuid;
@@ -59,8 +59,8 @@ public interface PlatformPlugin<C> {
default ThreadFactory getThreadFactory() {
return new ThreadFactoryBuilder()
.setNameFormat(getName() + " Pool Thread #%1$d")
// Hikari create daemons by default and we could daemon threads for our own scheduler too
// because we safely shutdown
// Hikari create daemons by default. We could daemon threads for our own scheduler too
// because we safely shut down
.setDaemon(true)
.build();
}
@@ -52,7 +52,7 @@ public class MySQLStorage extends SQLStorage {
config.addDataSourceProperty("useSSL", useSSL);
config.addDataSourceProperty("requireSSL", useSSL);
// adding paranoid hides hostname, username, version and so
// adding paranoid, hides hostname, username, version and so
// could be useful for hiding server details
config.addDataSourceProperty("paranoid", true);
@@ -86,7 +86,7 @@ public class MySQLStorage extends SQLStorage {
config.addDataSourceProperty("elideSetAutoCommits", true);
// default true - internal timers for idle calculation -> removes System.getCurrentTimeMillis call per query
// Some platforms are slow on this and it could affect the throughput about 3% according to MySQL
// Some platforms are slow on this, it could affect the throughput about 3% according to MySQL
// performance gems presentation
// In our case it can be useful to see the time in error messages
// config.addDataSourceProperty("maintainTimeStats", false);
+1 -1
View File
@@ -278,7 +278,7 @@ driver: 'org.sqlite.JDBC'
database: '{pluginDir}/FastLogin.db'
# MySQL/MariaDB
# If you want to enable it uncomment only the lines below this not this line.
# If you want to enable it, uncomment only the lines below; this not this line.
# If on velocity use 'fastlogin.mariadb.jdbc.Driver' as driver
#driver: 'com.mysql.jdbc.Driver'
#host: '127.0.0.1'
+1 -1
View File
@@ -90,7 +90,7 @@ invalid-request: '&4Invalid request'
not-started: '&cServer is not fully started yet. Please retry'
# Warning message if a user invoked /premium command
premium-warning: '&c&lWARNING: &6This command should &lonly&6 be invoked if you are the owner of this paid Minecraft account
premium-warning: '&c&lWARNING: &6This command should&l only&6 be invoked if you are the owner of this paid Minecraft account
Type &a/premium&6 again to confirm'
# ========= Bungee/Waterfall only ================================