aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0160-ProfileWhitelistVerifyEvent.patch
blob: 4b6d02529cb7e724ebf527dadf3d038c3c50582b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 3 Jul 2017 18:11:10 -0500
Subject: [PATCH] ProfileWhitelistVerifyEvent


diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 9db65b9d8f66ff83dcf32274fec98a425e7353d8..738a69a1a5765897fb3ca3b4ceb07cddade0d27f 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -615,9 +615,9 @@ public abstract class PlayerList {
 
             // return chatmessage;
             if (!gameprofilebanentry.hasExpired()) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Spigot // Paper - Adventure
-        } else if (!this.isWhitelisted(gameprofile)) {
-            chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
-            event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure
+        } else if (!this.isWhitelisted(gameprofile, event)) { // Paper
+            //chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); // Paper
+            //event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot // Paper - moved to isWhitelisted
         } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) {
             IpBanEntry ipbanentry = this.l.get(socketaddress);
 
@@ -1009,9 +1009,25 @@ public abstract class PlayerList {
         this.server.getCommandDispatcher().a(entityplayer);
     }
 
+    // Paper start
     public boolean isWhitelisted(GameProfile gameprofile) {
-        return !this.hasWhitelist || this.operators.d(gameprofile) || this.whitelist.d(gameprofile);
+        return isWhitelisted(gameprofile, null);
     }
+    public boolean isWhitelisted(GameProfile gameprofile, org.bukkit.event.player.PlayerLoginEvent loginEvent) {
+        boolean isOp = this.operators.d(gameprofile);
+        boolean isWhitelisted = !this.hasWhitelist || isOp || this.whitelist.d(gameprofile);
+        final com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent event;
+        event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(MCUtil.toBukkit(gameprofile), this.hasWhitelist, isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
+        event.callEvent();
+        if (!event.isWhitelisted()) {
+            if (loginEvent != null) {
+                loginEvent.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getKickMessage() == null ? org.spigotmc.SpigotConfig.whitelistMessage : event.getKickMessage()));
+            }
+            return false;
+        }
+        return true;
+    }
+    // Paper end
 
     public boolean isOp(GameProfile gameprofile) {
         return this.operators.d(gameprofile) || this.server.a(gameprofile) && this.server.getSaveData().o() || this.v;