Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 19:10:09 +01:00
ProfileWhitelistVerifyEvent
Fires when the server is validating if a player is whitelisted. Allows you to do dynamic whitelisting and change of kick message
Dieser Commit ist enthalten in:
Ursprung
5c5e998cde
Commit
5b6dfbc428
128
Spigot-API-Patches/0065-ProfileWhitelistVerifyEvent.patch
Normale Datei
128
Spigot-API-Patches/0065-ProfileWhitelistVerifyEvent.patch
Normale Datei
@ -0,0 +1,128 @@
|
||||
From e422959fbe06c2055a5089da77024835870a5662 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 3 Jul 2017 18:11:34 -0500
|
||||
Subject: [PATCH] ProfileWhitelistVerifyEvent
|
||||
|
||||
Fires when the server is validating if a player is whitelisted.
|
||||
|
||||
Allows you to do dynamic whitelisting and change of kick message
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..59b69b23
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
|
||||
@@ -0,0 +1,110 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2017 - Daniel Ennis (Aikar) - MIT License
|
||||
+ *
|
||||
+ * Permission is hereby granted, free of charge, to any person obtaining
|
||||
+ * a copy of this software and associated documentation files (the
|
||||
+ * "Software"), to deal in the Software without restriction, including
|
||||
+ * without limitation the rights to use, copy, modify, merge, publish,
|
||||
+ * distribute, sublicense, and/or sell copies of the Software, and to
|
||||
+ * permit persons to whom the Software is furnished to do so, subject to
|
||||
+ * the following conditions:
|
||||
+ *
|
||||
+ * The above copyright notice and this permission notice shall be
|
||||
+ * included in all copies or substantial portions of the Software.
|
||||
+ *
|
||||
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+ */
|
||||
+
|
||||
+package com.destroystokyo.paper.event.profile;
|
||||
+
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+
|
||||
+/**
|
||||
+ * Fires when the server needs to verify if a player is whitelisted.
|
||||
+ *
|
||||
+ * Plugins may override/control the servers whitelist with this event,
|
||||
+ * and dynamically change the kick message.
|
||||
+ *
|
||||
+ */
|
||||
+public class ProfileWhitelistVerifyEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final GameProfile profile;
|
||||
+ private final boolean whitelistEnabled;
|
||||
+ private boolean whitelisted;
|
||||
+ private final boolean isOp;
|
||||
+ private String kickMessage;
|
||||
+
|
||||
+ public ProfileWhitelistVerifyEvent(final GameProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, String kickMessage) {
|
||||
+ this.profile = profile;
|
||||
+ this.whitelistEnabled = whitelistEnabled;
|
||||
+ this.whitelisted = whitelisted;
|
||||
+ this.isOp = isOp;
|
||||
+ this.kickMessage = kickMessage;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the currently planned message to send to the user if they are not whitelisted
|
||||
+ */
|
||||
+ public String getKickMessage() {
|
||||
+ return kickMessage;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to null to use the server configured default
|
||||
+ */
|
||||
+ public void setKickMessage(String kickMessage) {
|
||||
+ this.kickMessage = kickMessage;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * The gameprofile of the player trying to connect
|
||||
+ */
|
||||
+ public GameProfile getProfile() {
|
||||
+ return profile;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Whether the player is whitelisted to play on this server (whitelist may be off is why its true)
|
||||
+ */
|
||||
+ public boolean isWhitelisted() {
|
||||
+ return whitelisted;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Changes the players whitelisted state. false will deny the login
|
||||
+ */
|
||||
+ public void setWhitelisted(boolean whitelisted) {
|
||||
+ this.whitelisted = whitelisted;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns if the player obtained whitelist status by having op
|
||||
+ */
|
||||
+ public boolean isOp() {
|
||||
+ return isOp;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns if the server even has whitelist on
|
||||
+ */
|
||||
+ public boolean isWhitelistEnabled() {
|
||||
+ return whitelistEnabled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.13.0
|
||||
|
@ -1,11 +1,11 @@
|
||||
From 5348dcffeb074face49dbc88117a2cfb7375d18b Mon Sep 17 00:00:00 2001
|
||||
From 4e9b597d5c6e078739e0662f73de519766c3926c Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 26 Jul 2017 21:12:15 -0400
|
||||
Subject: [PATCH] Fix Recipe Books
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 682211cdd..1fed465bf 100644
|
||||
index 682211cdd..0f7e82d27 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -2027,12 +2027,6 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
@ -47,6 +47,28 @@ index 682211cdd..1fed465bf 100644
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2075,7 +2079,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
while (iterator.hasNext()) {
|
||||
packetplayinautorecipe_a = (PacketPlayInAutoRecipe.a) iterator.next();
|
||||
itemstack = this.player.inventory.getItem(packetplayinautorecipe_a.c);
|
||||
- if (this.a(packetplayinautorecipe_a.a, itemstack)) {
|
||||
+ if (this.a(packetplayinautorecipe_a.a, itemstack) && itemstack.getCount() >= packetplayinautorecipe_a.a.getCount()) { // Paper
|
||||
i = packetplayinautorecipe_a.a.getCount();
|
||||
if (itemstack.getCount() == i) {
|
||||
this.player.inventory.splitWithoutUpdate(packetplayinautorecipe_a.c);
|
||||
@@ -2085,6 +2089,12 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
|
||||
this.player.activeContainer.b(packetplayinautorecipe_a.b, packetplayinautorecipe_a.a);
|
||||
}
|
||||
+ // Paper start
|
||||
+ else {
|
||||
+ this.player.getBukkitEntity().updateInventory();
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.13.0
|
||||
|
||||
|
52
Spigot-Server-Patches/0230-ProfileWhitelistVerifyEvent.patch
Normale Datei
52
Spigot-Server-Patches/0230-ProfileWhitelistVerifyEvent.patch
Normale Datei
@ -0,0 +1,52 @@
|
||||
From 1f4300aee18c3589dc5031b8f4958672eb951212 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/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
index c47e05c19..a038d0987 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -536,9 +536,9 @@ public abstract class PlayerList {
|
||||
|
||||
// return s;
|
||||
if (!gameprofilebanentry.hasExpired()) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s); // Spigot
|
||||
- } else if (!this.isWhitelisted(gameprofile)) {
|
||||
+ } else if (!this.isWhitelisted(gameprofile, event)) { // Paper
|
||||
// return "You are not white-listed on this server!";
|
||||
- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot
|
||||
+ //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);
|
||||
|
||||
@@ -1200,9 +1200,25 @@ public abstract class PlayerList {
|
||||
|
||||
}
|
||||
|
||||
+ // 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(gameprofile, this.hasWhitelist, isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
|
||||
+ event.callEvent();
|
||||
+ if (!event.isWhitelisted()) {
|
||||
+ if (loginEvent != null) {
|
||||
+ loginEvent.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, 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.R() && this.server.worlds.get(0).getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.u; // CraftBukkit
|
||||
--
|
||||
2.13.0
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren