diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginAutoLoginEvent.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginAutoLoginEvent.java new file mode 100644 index 00000000..dec52e2c --- /dev/null +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginAutoLoginEvent.java @@ -0,0 +1,50 @@ +package com.github.games647.fastlogin.bukkit.event; + +import com.github.games647.fastlogin.core.StoredProfile; +import com.github.games647.fastlogin.core.shared.LoginSession; +import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class BukkitFastLoginAutoLoginEvent extends Event implements FastLoginAutoLoginEvent, Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private final LoginSession session; + private final StoredProfile profile; + private boolean cancelled; + + public BukkitFastLoginAutoLoginEvent(LoginSession session, StoredProfile profile) { + this.session = session; + this.profile = profile; + } + + @Override + public LoginSession getSession() { + return session; + } + + @Override + public StoredProfile getProfile() { + return profile; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPreLoginEvent.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPreLoginEvent.java new file mode 100644 index 00000000..b5a0ccef --- /dev/null +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPreLoginEvent.java @@ -0,0 +1,46 @@ +package com.github.games647.fastlogin.bukkit.event; + +import com.github.games647.fastlogin.core.StoredProfile; +import com.github.games647.fastlogin.core.shared.LoginSource; +import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class BukkitFastLoginPreLoginEvent extends Event implements FastLoginPreLoginEvent { + + private static final HandlerList handlers = new HandlerList(); + private final String username; + private final LoginSource source; + private final StoredProfile profile; + + public BukkitFastLoginPreLoginEvent(String username, LoginSource source, StoredProfile profile) { + super(true); + this.username = username; + this.source = source; + this.profile = profile; + } + + @Override + public String getUsername() { + return username; + } + + @Override + public LoginSource getSource() { + return source; + } + + @Override + public StoredProfile getProfile() { + return profile; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java index 622f4727..0d46909f 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java @@ -4,12 +4,14 @@ import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketEvent; import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; +import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.JoinManagement; import java.security.PublicKey; import java.util.Random; +import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -46,6 +48,13 @@ public class NameCheckTask extends JoinManagement + codemc-repo @@ -88,13 +90,16 @@ me.vik1395 BungeeAuth 1.4 - provided + system + ${project.basedir}/lib/BungeeAuth-1.4.jar + diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginAutoLoginEvent.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginAutoLoginEvent.java new file mode 100644 index 00000000..8d5b642d --- /dev/null +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginAutoLoginEvent.java @@ -0,0 +1,39 @@ +package com.github.games647.fastlogin.bungee.event; + +import com.github.games647.fastlogin.core.StoredProfile; +import com.github.games647.fastlogin.core.shared.LoginSession; +import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent; +import net.md_5.bungee.api.plugin.Cancellable; +import net.md_5.bungee.api.plugin.Event; + +public class BungeeFastLoginAutoLoginEvent extends Event implements FastLoginAutoLoginEvent, Cancellable { + + private final LoginSession session; + private final StoredProfile profile; + private boolean cancelled; + + public BungeeFastLoginAutoLoginEvent(LoginSession session, StoredProfile profile) { + this.session = session; + this.profile = profile; + } + + @Override + public LoginSession getSession() { + return session; + } + + @Override + public StoredProfile getProfile() { + return profile; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } +} diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginPreLoginEvent.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginPreLoginEvent.java new file mode 100644 index 00000000..e496d2d1 --- /dev/null +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginPreLoginEvent.java @@ -0,0 +1,34 @@ +package com.github.games647.fastlogin.bungee.event; + +import com.github.games647.fastlogin.core.StoredProfile; +import com.github.games647.fastlogin.core.shared.LoginSource; +import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; +import net.md_5.bungee.api.plugin.Event; + +public class BungeeFastLoginPreLoginEvent extends Event implements FastLoginPreLoginEvent { + + private final String username; + private final LoginSource source; + private final StoredProfile profile; + + public BungeeFastLoginPreLoginEvent(String username, LoginSource source, StoredProfile profile) { + this.username = username; + this.source = source; + this.profile = profile; + } + + @Override + public String getUsername() { + return username; + } + + @Override + public LoginSource getSource() { + return source; + } + + @Override + public StoredProfile getProfile() { + return profile; + } +} diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java index 16c09da2..bc2664a5 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java @@ -3,9 +3,11 @@ package com.github.games647.fastlogin.bungee.task; import com.github.games647.fastlogin.bungee.BungeeLoginSession; import com.github.games647.fastlogin.bungee.BungeeLoginSource; import com.github.games647.fastlogin.bungee.FastLoginBungee; +import com.github.games647.fastlogin.bungee.event.BungeeFastLoginPreLoginEvent; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.JoinManagement; +import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -41,6 +43,13 @@ public class AsyncPremiumCheck extends JoinManagement> { public void sendLocaleMessage(String key, C receiver) { String message = localeMessages.get(key); if (message != null) { - plugin.sendMessage(receiver, message); + plugin.sendMultiLineMessage(receiver, message); } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java index 501e4f19..b485896a 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java @@ -3,6 +3,7 @@ package com.github.games647.fastlogin.core.shared; import com.github.games647.fastlogin.core.AuthStorage; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.hooks.AuthPlugin; +import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent; public abstract class ForceLoginManagement

> implements Runnable { @@ -40,7 +41,7 @@ public abstract class ForceLoginManagement

{ @@ -25,6 +26,8 @@ public abstract class JoinManagement

{ return; } + callFastLoginPreLoginEvent(username, source, profile); + Configuration config = core.getConfig(); String ip = source.getAddress().getAddress().getHostAddress(); @@ -101,6 +104,8 @@ public abstract class JoinManagement

{ return false; } + public abstract FastLoginPreLoginEvent callFastLoginPreLoginEvent(String username, S source, StoredProfile profile); + public abstract void requestPremiumLogin(S source, StoredProfile profile, String username, boolean registered); public abstract void startCrackedSession(S source, StoredProfile profile, String username); diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java index 2fec3b8d..eeb622f7 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java @@ -15,6 +15,12 @@ public interface PlatformPlugin { void sendMessage(C receiver, String message); + default void sendMultiLineMessage(C receiver, String message) { + for (String line : message.split("%nl%")) { + sendMessage(receiver, line); + } + } + default ThreadFactory getThreadFactory() { return null; } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginAutoLoginEvent.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginAutoLoginEvent.java new file mode 100644 index 00000000..5d768f3f --- /dev/null +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginAutoLoginEvent.java @@ -0,0 +1,9 @@ +package com.github.games647.fastlogin.core.shared.event; + +import com.github.games647.fastlogin.core.StoredProfile; +import com.github.games647.fastlogin.core.shared.LoginSession; + +public interface FastLoginAutoLoginEvent extends FastLoginCancellableEvent { + LoginSession getSession(); + StoredProfile getProfile(); +} diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginCancellableEvent.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginCancellableEvent.java new file mode 100644 index 00000000..111159be --- /dev/null +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginCancellableEvent.java @@ -0,0 +1,7 @@ +package com.github.games647.fastlogin.core.shared.event; + +public interface FastLoginCancellableEvent { + + boolean isCancelled(); + void setCancelled(boolean cancelled); +} diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginPreLoginEvent.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginPreLoginEvent.java new file mode 100644 index 00000000..93b72059 --- /dev/null +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/event/FastLoginPreLoginEvent.java @@ -0,0 +1,11 @@ +package com.github.games647.fastlogin.core.shared.event; + +import com.github.games647.fastlogin.core.StoredProfile; +import com.github.games647.fastlogin.core.shared.LoginSource; + +public interface FastLoginPreLoginEvent { + + String getUsername(); + LoginSource getSource(); + StoredProfile getProfile(); +}