2020-05-06 09:48:49 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2017-07-28 03:39:31 +00:00
From: Aikar <aikar@aikar.co>
Date: Mon, 3 Jul 2017 18:11:10 -0500
Subject: [PATCH] ProfileWhitelistVerifyEvent
2021-03-16 07:19:45 +00:00
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 398fd08341eae503d53dcca42bbbd1c27c60cc17..41b63da42067397122897d23fd7fb0e517d7c552 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -614,9 +614,9 @@ public abstract class PlayerList {
2020-06-28 08:43:47 +00:00
// return chatmessage;
2021-02-21 19:45:33 +00:00
if (!gameprofilebanentry.hasExpired()) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Spigot // Paper - Adventure
2020-06-28 08:43:47 +00:00
- } else if (!this.isWhitelisted(gameprofile)) {
2021-02-21 19:45:33 +00:00
- chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
2021-02-23 13:45:09 +00:00
- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure
2020-06-28 08:43:47 +00:00
+ } else if (!this.isWhitelisted(gameprofile, event)) { // Paper
2021-02-21 19:45:33 +00:00
+ //chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); // Paper
2017-07-28 03:39:31 +00:00
+ //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);
2021-03-16 07:19:45 +00:00
@@ -1008,9 +1008,25 @@ public abstract class PlayerList {
2018-07-18 00:08:13 +00:00
this.server.getCommandDispatcher().a(entityplayer);
2017-07-28 03:39:31 +00:00
}
+ // Paper start
public boolean isWhitelisted(GameProfile gameprofile) {
- return !this.hasWhitelist || this.operators.d(gameprofile) || this.whitelist.d(gameprofile);
+ return isWhitelisted(gameprofile, null);
2019-04-27 23:23:53 +00:00
}
2017-07-28 03:39:31 +00:00
+ 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;
2018-01-19 05:12:03 +00:00
+ event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(MCUtil.toBukkit(gameprofile), this.hasWhitelist, isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
2017-07-28 03:39:31 +00:00
+ event.callEvent();
+ if (!event.isWhitelisted()) {
+ if (loginEvent != null) {
2021-02-23 13:45:09 +00:00
+ loginEvent.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getKickMessage() == null ? org.spigotmc.SpigotConfig.whitelistMessage : event.getKickMessage()));
2017-07-28 03:39:31 +00:00
+ }
+ return false;
+ }
+ return true;
2019-04-27 23:23:53 +00:00
+ }
2017-07-28 03:39:31 +00:00
+ // Paper end
public boolean isOp(GameProfile gameprofile) {
2020-08-25 02:22:08 +00:00
return this.operators.d(gameprofile) || this.server.a(gameprofile) && this.server.getSaveData().o() || this.v;