mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-06 10:45:37 +01:00
57 lines
2.3 KiB
Diff
57 lines
2.3 KiB
Diff
From f34f232e1ba5b0498d5b6cab7c68938163ac3022 Mon Sep 17 00:00:00 2001
|
|
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
|
|
Date: Wed, 16 Dec 2020 17:57:23 +0800
|
|
Subject: [PATCH] Make PlayerHandshakeEvent cancellable
|
|
|
|
|
|
diff --git a/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java b/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java
|
|
index 2f7b38d9e..e29b0ed35 100644
|
|
--- a/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java
|
|
+++ b/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java
|
|
@@ -2,8 +2,11 @@ package net.md_5.bungee.api.event;
|
|
|
|
import lombok.Data;
|
|
import lombok.EqualsAndHashCode;
|
|
+import lombok.Getter;
|
|
+import lombok.Setter;
|
|
import lombok.ToString;
|
|
import net.md_5.bungee.api.connection.PendingConnection;
|
|
+import net.md_5.bungee.api.plugin.Cancellable;
|
|
import net.md_5.bungee.api.plugin.Event;
|
|
import net.md_5.bungee.protocol.packet.Handshake;
|
|
|
|
@@ -14,8 +17,11 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
|
@Data
|
|
@ToString(callSuper = false)
|
|
@EqualsAndHashCode(callSuper = false)
|
|
-public class PlayerHandshakeEvent extends Event
|
|
-{
|
|
+// FlameCord - Implement cancellable
|
|
+public class PlayerHandshakeEvent extends Event implements Cancellable {
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private boolean cancelled = false;
|
|
|
|
/**
|
|
* Connection attempting to login.
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
index 7a403a1ab..5132c537f 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
@@ -339,7 +339,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|
|
|
this.virtualHost = InetSocketAddress.createUnresolved( handshake.getHost(), handshake.getPort() );
|
|
|
|
- bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) );
|
|
+ // FlameCord - Make PlayerHandshakeEvent cancellable
|
|
+ if (bungee.getPluginManager().callEvent(new PlayerHandshakeEvent(InitialHandler.this, handshake)).isCancelled()) {
|
|
+ ch.close();
|
|
+ return;
|
|
+ }
|
|
|
|
switch ( handshake.getRequestedProtocol() )
|
|
{
|
|
--
|
|
2.32.0.windows.1
|
|
|