diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java index 15e7beea..9de54b5a 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java @@ -47,10 +47,7 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.api.proxy.server.RegisteredServer; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -import org.slf4j.Logger; -import java.io.File; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; @@ -62,6 +59,10 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.ConcurrentMap; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; + +import org.slf4j.Logger; + //TODO: Support for floodgate @Plugin(id = PomData.NAME, name = PomData.DISPLAY_NAME, description = PomData.DESCRIPTION, url = PomData.URL, version = PomData.VERSION, authors = {"games647", "https://github.com/games647/FastLogin/graphs/contributors"}) @@ -94,10 +95,10 @@ public class FastLoginVelocity implements PlatformPlugin { return; } - server.getChannelRegistrar().register(MinecraftChannelIdentifier.create(getName(), ChangePremiumMessage.CHANGE_CHANNEL)); - server.getChannelRegistrar().register(MinecraftChannelIdentifier.create(getName(), SuccessMessage.SUCCESS_CHANNEL)); server.getEventManager().register(this, new ConnectListener(this, core.getRateLimiter())); server.getEventManager().register(this, new PluginMessageListener(this)); + server.getChannelRegistrar().register(MinecraftChannelIdentifier.create(getName(), ChangePremiumMessage.CHANGE_CHANNEL)); + server.getChannelRegistrar().register(MinecraftChannelIdentifier.create(getName(), SuccessMessage.SUCCESS_CHANNEL)); } @Subscribe @@ -184,8 +185,7 @@ public class FastLoginVelocity implements PlatformPlugin { if (shouldGenerate) { proxyId = UUID.randomUUID(); try { - Files.write(idFile, Collections.singletonList(proxyId.toString()), - StandardCharsets.UTF_8, StandardOpenOption.CREATE); + Files.write(idFile, Collections.singletonList(proxyId.toString()), StandardOpenOption.CREATE); } catch (IOException e) { logger.error("Unable to save proxy id to '{}'", idFile.toAbsolutePath()); logger.error("Detailed exception:", e); diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/VelocityLoginSession.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/VelocityLoginSession.java index 5a71ee98..be5d314d 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/VelocityLoginSession.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/VelocityLoginSession.java @@ -31,9 +31,11 @@ import com.github.games647.fastlogin.core.shared.LoginSession; public class VelocityLoginSession extends LoginSession { private boolean alreadySaved; private boolean alreadyLogged; + public VelocityLoginSession(String requestUsername, boolean registered, StoredProfile profile) { super(requestUsername, registered, profile); } + public synchronized void setRegistered(boolean registered) { this.registered = registered; } diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/VelocityLoginSource.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/VelocityLoginSource.java index 766c79f6..d2ee5102 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/VelocityLoginSource.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/VelocityLoginSource.java @@ -28,16 +28,17 @@ package com.github.games647.fastlogin.velocity; import com.github.games647.fastlogin.core.shared.LoginSource; import com.velocitypowered.api.event.connection.PreLoginEvent; import com.velocitypowered.api.proxy.InboundConnection; + +import java.net.InetSocketAddress; + import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -import java.net.InetSocketAddress; - public class VelocityLoginSource implements LoginSource { - private InboundConnection connection; - private PreLoginEvent preLoginEvent; + private final InboundConnection connection; + private final PreLoginEvent preLoginEvent; public VelocityLoginSource(InboundConnection connection, PreLoginEvent preLoginEvent) { this.connection = connection; diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/event/VelocityFastLoginAutoLoginEvent.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/event/VelocityFastLoginAutoLoginEvent.java index 09b72603..61ecb1a8 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/event/VelocityFastLoginAutoLoginEvent.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/event/VelocityFastLoginAutoLoginEvent.java @@ -32,7 +32,8 @@ import com.velocitypowered.api.event.ResultedEvent; import java.util.Objects; -public class VelocityFastLoginAutoLoginEvent implements FastLoginAutoLoginEvent, ResultedEvent { +public class VelocityFastLoginAutoLoginEvent + implements FastLoginAutoLoginEvent, ResultedEvent { private final LoginSession session; private final StoredProfile profile; diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/listener/ConnectListener.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/listener/ConnectListener.java index 73f73963..acb24c7b 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/listener/ConnectListener.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/listener/ConnectListener.java @@ -59,11 +59,12 @@ public class ConnectListener { this.rateLimiter = rateLimiter; } - @Subscribe() + @Subscribe public void onPreLogin(PreLoginEvent preLoginEvent, Continuation continuation) { if (!preLoginEvent.getResult().isAllowed()) { return; } + InboundConnection connection = preLoginEvent.getConnection(); if (!rateLimiter.tryAcquire()) { plugin.getLog().warn("Simple Anti-Bot join limit - Ignoring {}", connection); @@ -105,9 +106,10 @@ public class ConnectListener { private List removeSkin(List oldProperties) { List newProperties = new ArrayList<>(oldProperties.size() - 1); for (GameProfile.Property property : oldProperties) { - if (!property.getName().equals("textures")) + if (!"textures".equals(property.getName())) newProperties.add(property); } + return newProperties; }