forked from TuxCoding/FastLogin
General minor code clean up and typo fixes
This commit is contained in:
1
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
1
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@ -36,7 +36,6 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Server log
|
label: Server log
|
||||||
description: The error, stacktrace or link the complete log. You can use the links above for long versions.
|
description: The error, stacktrace or link the complete log. You can use the links above for long versions.
|
||||||
render: shell
|
|
||||||
placeholder: https://hastebin.com/ / https://gist.github.com/
|
placeholder: https://hastebin.com/ / https://gist.github.com/
|
||||||
- type: input
|
- type: input
|
||||||
attributes:
|
attributes:
|
||||||
|
@ -125,6 +125,6 @@ Install the plugin on both platforms, that is proxy (BungeeCord or Velocity) and
|
|||||||
* MySQL/MariaDB requires an external database server running. Check your server provider if there is one available
|
* MySQL/MariaDB requires an external database server running. Check your server provider if there is one available
|
||||||
or install one.
|
or install one.
|
||||||
6. Set proxy and Spigot in offline mode by setting the value `onlinemode` in your `config.yml` to false
|
6. Set proxy and Spigot in offline mode by setting the value `onlinemode` in your `config.yml` to false
|
||||||
7. You should *always* firewall your Spigot server that it's only accessible through your proxy
|
7. You should *always* configure the firewall for your Spigot server so that it's only accessible through your proxy
|
||||||
* This is also the case without this plugin
|
* This is also the case without this plugin
|
||||||
* https://www.spigotmc.org/wiki/bungeecord-installation/#post-installation
|
* https://www.spigotmc.org/wiki/bungeecord-installation/#post-installation
|
||||||
|
@ -124,7 +124,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
logger.info("Floodgate prefix injection workaround has been enabled.");
|
logger.info("Floodgate prefix injection workaround has been enabled.");
|
||||||
logger.info("If you have problems joining the server, try disabling it in the configuration.");
|
logger.info("If you have problems joining the server, try disabling it in the configuration.");
|
||||||
} else {
|
} else {
|
||||||
logger.warn("We have detected that you are runnging FastLogin alongside Floodgate and ProtocolLib.");
|
logger.warn("We have detected that you are running FastLogin alongside Floodgate and ProtocolLib.");
|
||||||
logger.warn("Currently there is an issue with FastLogin that prevents Floodgate name prefixes from showing up "
|
logger.warn("Currently there is an issue with FastLogin that prevents Floodgate name prefixes from showing up "
|
||||||
+ "when it is together used with ProtocolLib.");
|
+ "when it is together used with ProtocolLib.");
|
||||||
logger.warn("If you would like to use Floodgate name prefixes, you can enable an experimental workaround by changing "
|
logger.warn("If you would like to use Floodgate name prefixes, you can enable an experimental workaround by changing "
|
||||||
|
@ -81,7 +81,7 @@ public abstract class ToggleCommand implements CommandExecutor {
|
|||||||
plugin.getBungeeManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
|
plugin.getBungeeManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
|
||||||
} else {
|
} else {
|
||||||
Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
|
Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
|
||||||
if (!optPlayer.isPresent()) {
|
if (optPlayer.isEmpty()) {
|
||||||
plugin.getLog().info("No player online to send a plugin message to the proxy");
|
plugin.getLog().info("No player online to send a plugin message to the proxy");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,6 @@ public class AsyncScheduler {
|
|||||||
|
|
||||||
private final AtomicInteger currentlyRunning = new AtomicInteger();
|
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) {
|
public AsyncScheduler(Logger logger, Executor processingPool) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.processingPool = processingPool;
|
this.processingPool = processingPool;
|
||||||
@ -76,9 +70,4 @@ public class AsyncScheduler {
|
|||||||
return null;
|
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
|
@Override
|
||||||
public synchronized boolean equals(Object o) {
|
public synchronized boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (!(o instanceof StoredProfile)) return false;
|
if (!(o instanceof StoredProfile that)) return false;
|
||||||
if (!super.equals(o)) return false;
|
if (!super.equals(o)) return false;
|
||||||
StoredProfile that = (StoredProfile) o;
|
|
||||||
return rowId == that.rowId && premium == that.premium
|
return rowId == that.rowId && premium == that.premium
|
||||||
&& Objects.equals(lastIp, that.lastIp) && lastLogin.equals(that.lastLogin);
|
&& 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
|
//Data is sent through a random player. We have to tell the Bukkit version of this plugin the target
|
||||||
output.writeUTF(playerName);
|
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.getMostSignificantBits());
|
||||||
output.writeLong(proxyId.getLeastSignificantBits());
|
output.writeLong(proxyId.getLeastSignificantBits());
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,6 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
|
|||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
plugin.getLog().info("Safely shutting down scheduler. This could take up to one minute.");
|
plugin.getLog().info("Safely shutting down scheduler. This could take up to one minute.");
|
||||||
plugin.getScheduler().shutdown();
|
|
||||||
|
|
||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
storage.close();
|
storage.close();
|
||||||
|
@ -50,7 +50,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
|
|||||||
protected final String autoRegisterFloodgate;
|
protected final String autoRegisterFloodgate;
|
||||||
protected final String allowNameConflict;
|
protected final String allowNameConflict;
|
||||||
|
|
||||||
//variables initialized through run() and accesses by subclasss
|
//variables initialized through run() and accesses by subclass
|
||||||
protected boolean isRegistered;
|
protected boolean isRegistered;
|
||||||
protected StoredProfile profile;
|
protected StoredProfile profile;
|
||||||
protected boolean isLinked;
|
protected boolean isLinked;
|
||||||
@ -71,7 +71,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
|
|||||||
public void run() {
|
public void run() {
|
||||||
core.getPlugin().getLog().info("Player {} is connecting through Geyser Floodgate.", username);
|
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;
|
isLinked = floodgatePlayer.getLinkedPlayer() != null;
|
||||||
|
|
||||||
//this happens on Bukkit if it's connected to Bungee
|
//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) {
|
} catch (Exception ex) {
|
||||||
core.getPlugin().getLog().error(
|
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);
|
username, ex);
|
||||||
return;
|
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
|
//decide if checks should be made for conflicting Java player names
|
||||||
if (isNameCheckRequired()) {
|
if (isNameCheckRequired()) {
|
||||||
// check for conflicting Premium Java name
|
// check for conflicting Premium Java name
|
||||||
Optional<Profile> premiumUUID = Optional.empty();
|
Optional<Profile> premiumUUID;
|
||||||
try {
|
try {
|
||||||
premiumUUID = core.getResolver().findProfile(username);
|
premiumUUID = core.getResolver().findProfile(username);
|
||||||
} catch (IOException | RateLimitException e) {
|
} 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>
|
* Decide if the player can be automatically registered or logged in.<br>
|
||||||
* The config option 'non-conflicting' is ignored by this function, as name
|
* The config option 'non-conflicting' is ignored by this function, as name
|
||||||
* conflicts are checked by a different part of the code.
|
* conflicts are checked by a different part of the code.
|
||||||
*
|
*
|
||||||
* @param configValue the value of either 'autoLoginFloodgate' or
|
* @param configValue the value of either 'autoLoginFloodgate' or
|
||||||
* 'autoRegisterFloodgate' from config.yml
|
* 'autoRegisterFloodgate' from config.yml
|
||||||
* @return true if the Player can be registered automatically
|
* @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
|
* @return ture if an API call to Mojang is needed
|
||||||
*/
|
*/
|
||||||
private boolean isNameCheckRequired() {
|
private boolean isNameCheckRequired() {
|
||||||
//linked players have the same name as their Java profile
|
//linked players have the same name as their Java profile
|
||||||
//OR
|
//OR
|
||||||
//if allowNameConflict is 'false' or 'linked' and the player had a conflicting
|
//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)) {
|
if (isLinked || !"true".equals(allowNameConflict)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
|||||||
premiumUUID = core.getResolver().findProfile(username);
|
premiumUUID = core.getResolver().findProfile(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!premiumUUID.isPresent()
|
if (premiumUUID.isEmpty()
|
||||||
|| (!checkNameChange(source, username, premiumUUID.get())
|
|| (!checkNameChange(source, username, premiumUUID.get())
|
||||||
&& !checkPremiumName(source, username, profile))) {
|
&& !checkPremiumName(source, username, profile))) {
|
||||||
//nothing detected the player as premium -> start a cracked session
|
//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.github.games647.fastlogin.core.StoredProfile;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Objects;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ public abstract class LoginSession {
|
|||||||
|
|
||||||
private final StoredProfile profile;
|
private final StoredProfile profile;
|
||||||
|
|
||||||
private String requestUsername;
|
private final String requestUsername;
|
||||||
private String username;
|
private String username;
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ public interface PlatformPlugin<C> {
|
|||||||
default ThreadFactory getThreadFactory() {
|
default ThreadFactory getThreadFactory() {
|
||||||
return new ThreadFactoryBuilder()
|
return new ThreadFactoryBuilder()
|
||||||
.setNameFormat(getName() + " Pool Thread #%1$d")
|
.setNameFormat(getName() + " Pool Thread #%1$d")
|
||||||
// Hikari create daemons by default and we could daemon threads for our own scheduler too
|
// Hikari create daemons by default. We could daemon threads for our own scheduler too
|
||||||
// because we safely shutdown
|
// because we safely shut down
|
||||||
.setDaemon(true)
|
.setDaemon(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class MySQLStorage extends SQLStorage {
|
|||||||
config.addDataSourceProperty("useSSL", useSSL);
|
config.addDataSourceProperty("useSSL", useSSL);
|
||||||
config.addDataSourceProperty("requireSSL", 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
|
// could be useful for hiding server details
|
||||||
config.addDataSourceProperty("paranoid", true);
|
config.addDataSourceProperty("paranoid", true);
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class MySQLStorage extends SQLStorage {
|
|||||||
config.addDataSourceProperty("elideSetAutoCommits", true);
|
config.addDataSourceProperty("elideSetAutoCommits", true);
|
||||||
|
|
||||||
// default true - internal timers for idle calculation -> removes System.getCurrentTimeMillis call per query
|
// 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
|
// performance gems presentation
|
||||||
// In our case it can be useful to see the time in error messages
|
// In our case it can be useful to see the time in error messages
|
||||||
// config.addDataSourceProperty("maintainTimeStats", false);
|
// config.addDataSourceProperty("maintainTimeStats", false);
|
||||||
|
@ -278,7 +278,7 @@ driver: 'org.sqlite.JDBC'
|
|||||||
database: '{pluginDir}/FastLogin.db'
|
database: '{pluginDir}/FastLogin.db'
|
||||||
|
|
||||||
# MySQL/MariaDB
|
# 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
|
# If on velocity use 'fastlogin.mariadb.jdbc.Driver' as driver
|
||||||
#driver: 'com.mysql.jdbc.Driver'
|
#driver: 'com.mysql.jdbc.Driver'
|
||||||
#host: '127.0.0.1'
|
#host: '127.0.0.1'
|
||||||
|
@ -90,7 +90,7 @@ invalid-request: '&4Invalid request'
|
|||||||
not-started: '&cServer is not fully started yet. Please retry'
|
not-started: '&cServer is not fully started yet. Please retry'
|
||||||
|
|
||||||
# Warning message if a user invoked /premium command
|
# 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'
|
Type &a/premium&6 again to confirm'
|
||||||
|
|
||||||
# ========= Bungee/Waterfall only ================================
|
# ========= Bungee/Waterfall only ================================
|
||||||
|
2
pom.xml
2
pom.xml
@ -48,7 +48,7 @@
|
|||||||
<!-- Set default for non-git clones -->
|
<!-- Set default for non-git clones -->
|
||||||
<git.commit.id>Unknown</git.commit.id>
|
<git.commit.id>Unknown</git.commit.id>
|
||||||
|
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.17</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<!--This have to be in lowercase because it's used by plugin.yml-->
|
<!--This has to be in lowercase because it's used by plugin.yml-->
|
||||||
<artifactId>fastlogin.velocity</artifactId>
|
<artifactId>fastlogin.velocity</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
@ -40,10 +40,11 @@ import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
|||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
|
||||||
public class PluginMessageListener {
|
public class PluginMessageListener {
|
||||||
|
|
||||||
private final FastLoginVelocity plugin;
|
private final FastLoginVelocity plugin;
|
||||||
@ -66,7 +67,7 @@ public class PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//the client shouldn't be able to read the messages in order to know something about server internal states
|
//the client shouldn't be able to read the messages in order to know something about server internal states
|
||||||
//moreover the client shouldn't be able fake a running premium check by sending the result message
|
//moreover the client shouldn't be able to fake a running premium check by sending the result message
|
||||||
pluginMessageEvent.setResult(PluginMessageEvent.ForwardResult.handled());
|
pluginMessageEvent.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||||
|
|
||||||
if (!(pluginMessageEvent.getSource() instanceof ServerConnection)) {
|
if (!(pluginMessageEvent.getSource() instanceof ServerConnection)) {
|
||||||
|
@ -49,7 +49,7 @@ public class ForceLoginTask
|
|||||||
private final RegisteredServer server;
|
private final RegisteredServer server;
|
||||||
|
|
||||||
//treat player as if they had a premium account, even when they don't
|
//treat player as if they had a premium account, even when they don't
|
||||||
//used for Floodgate auto login/register
|
//used to do auto login for Floodgate aut
|
||||||
private final boolean forcedOnlineMode;
|
private final boolean forcedOnlineMode;
|
||||||
|
|
||||||
public ForceLoginTask(FastLoginCore<Player, CommandSource, FastLoginVelocity> core,
|
public ForceLoginTask(FastLoginCore<Player, CommandSource, FastLoginVelocity> core,
|
||||||
|
Reference in New Issue
Block a user