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> 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/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(); +}