This commit is contained in:
games647
2021-09-22 12:13:33 +02:00
parent c2ec8c93b0
commit 37ac04c8ed
5 changed files with 20 additions and 14 deletions

View File

@ -47,10 +47,7 @@ import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.proxy.server.RegisteredServer; 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.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -62,6 +59,10 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.slf4j.Logger;
//TODO: Support for floodgate //TODO: Support for floodgate
@Plugin(id = PomData.NAME, name = PomData.DISPLAY_NAME, description = PomData.DESCRIPTION, url = PomData.URL, @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"}) version = PomData.VERSION, authors = {"games647", "https://github.com/games647/FastLogin/graphs/contributors"})
@ -94,10 +95,10 @@ public class FastLoginVelocity implements PlatformPlugin<CommandSource> {
return; 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 ConnectListener(this, core.getRateLimiter()));
server.getEventManager().register(this, new PluginMessageListener(this)); 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 @Subscribe
@ -184,8 +185,7 @@ public class FastLoginVelocity implements PlatformPlugin<CommandSource> {
if (shouldGenerate) { if (shouldGenerate) {
proxyId = UUID.randomUUID(); proxyId = UUID.randomUUID();
try { try {
Files.write(idFile, Collections.singletonList(proxyId.toString()), Files.write(idFile, Collections.singletonList(proxyId.toString()), StandardOpenOption.CREATE);
StandardCharsets.UTF_8, StandardOpenOption.CREATE);
} catch (IOException e) { } catch (IOException e) {
logger.error("Unable to save proxy id to '{}'", idFile.toAbsolutePath()); logger.error("Unable to save proxy id to '{}'", idFile.toAbsolutePath());
logger.error("Detailed exception:", e); logger.error("Detailed exception:", e);

View File

@ -31,9 +31,11 @@ import com.github.games647.fastlogin.core.shared.LoginSession;
public class VelocityLoginSession extends LoginSession { public class VelocityLoginSession extends LoginSession {
private boolean alreadySaved; private boolean alreadySaved;
private boolean alreadyLogged; private boolean alreadyLogged;
public VelocityLoginSession(String requestUsername, boolean registered, StoredProfile profile) { public VelocityLoginSession(String requestUsername, boolean registered, StoredProfile profile) {
super(requestUsername, registered, profile); super(requestUsername, registered, profile);
} }
public synchronized void setRegistered(boolean registered) { public synchronized void setRegistered(boolean registered) {
this.registered = registered; this.registered = registered;
} }

View File

@ -28,16 +28,17 @@ package com.github.games647.fastlogin.velocity;
import com.github.games647.fastlogin.core.shared.LoginSource; import com.github.games647.fastlogin.core.shared.LoginSource;
import com.velocitypowered.api.event.connection.PreLoginEvent; import com.velocitypowered.api.event.connection.PreLoginEvent;
import com.velocitypowered.api.proxy.InboundConnection; import com.velocitypowered.api.proxy.InboundConnection;
import java.net.InetSocketAddress;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.net.InetSocketAddress;
public class VelocityLoginSource implements LoginSource { public class VelocityLoginSource implements LoginSource {
private InboundConnection connection; private final InboundConnection connection;
private PreLoginEvent preLoginEvent; private final PreLoginEvent preLoginEvent;
public VelocityLoginSource(InboundConnection connection, PreLoginEvent preLoginEvent) { public VelocityLoginSource(InboundConnection connection, PreLoginEvent preLoginEvent) {
this.connection = connection; this.connection = connection;

View File

@ -32,7 +32,8 @@ import com.velocitypowered.api.event.ResultedEvent;
import java.util.Objects; import java.util.Objects;
public class VelocityFastLoginAutoLoginEvent implements FastLoginAutoLoginEvent, ResultedEvent<ResultedEvent.GenericResult> { public class VelocityFastLoginAutoLoginEvent
implements FastLoginAutoLoginEvent, ResultedEvent<ResultedEvent.GenericResult> {
private final LoginSession session; private final LoginSession session;
private final StoredProfile profile; private final StoredProfile profile;

View File

@ -59,11 +59,12 @@ public class ConnectListener {
this.rateLimiter = rateLimiter; this.rateLimiter = rateLimiter;
} }
@Subscribe() @Subscribe
public void onPreLogin(PreLoginEvent preLoginEvent, Continuation continuation) { public void onPreLogin(PreLoginEvent preLoginEvent, Continuation continuation) {
if (!preLoginEvent.getResult().isAllowed()) { if (!preLoginEvent.getResult().isAllowed()) {
return; return;
} }
InboundConnection connection = preLoginEvent.getConnection(); InboundConnection connection = preLoginEvent.getConnection();
if (!rateLimiter.tryAcquire()) { if (!rateLimiter.tryAcquire()) {
plugin.getLog().warn("Simple Anti-Bot join limit - Ignoring {}", connection); plugin.getLog().warn("Simple Anti-Bot join limit - Ignoring {}", connection);
@ -105,9 +106,10 @@ public class ConnectListener {
private List<GameProfile.Property> removeSkin(List<GameProfile.Property> oldProperties) { private List<GameProfile.Property> removeSkin(List<GameProfile.Property> oldProperties) {
List<GameProfile.Property> newProperties = new ArrayList<>(oldProperties.size() - 1); List<GameProfile.Property> newProperties = new ArrayList<>(oldProperties.size() - 1);
for (GameProfile.Property property : oldProperties) { for (GameProfile.Property property : oldProperties) {
if (!property.getName().equals("textures")) if (!"textures".equals(property.getName()))
newProperties.add(property); newProperties.add(property);
} }
return newProperties; return newProperties;
} }