Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
Move ProfileWhitelistVerifyEvent to use new PlayerProfile API
Also update javadocs on lookup events to link the new methods to use
Dieser Commit ist enthalten in:
Ursprung
18e3bf685c
Commit
531981a1cc
@ -1,4 +1,4 @@
|
||||
From 094a75a6f82a16f8a5f6c27c24ba503b74443a8f Mon Sep 17 00:00:00 2001
|
||||
From b1eb117fbca758844625ae8de33b71f3d526ea0a Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 17 Jun 2017 16:30:44 -0400
|
||||
Subject: [PATCH] Profile Lookup Events
|
||||
@ -26,7 +26,7 @@ index c8b37997..13994dc2 100644
|
||||
<artifactId>fastutil-lite</artifactId>
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..e4b36255
|
||||
index 00000000..3b6995a7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java
|
||||
@@ -0,0 +1,55 @@
|
||||
@ -60,7 +60,7 @@ index 00000000..e4b36255
|
||||
+
|
||||
+ /**
|
||||
+ * @return The profile that was recently looked up. This profile can be mutated
|
||||
+ * @deprecated will be removed with 1.13
|
||||
+ * @deprecated will be removed with 1.13, use {@link #getPlayerProfile()}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Nonnull
|
||||
@ -87,7 +87,7 @@ index 00000000..e4b36255
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..0a657904
|
||||
index 00000000..aa0666d5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java
|
||||
@@ -0,0 +1,149 @@
|
||||
@ -165,7 +165,7 @@ index 00000000..0a657904
|
||||
+ * Get the properties for this profile
|
||||
+ *
|
||||
+ * @return the property map to attach to the new {@link PlayerProfile}
|
||||
+ * @deprecated will be removed with 1.13
|
||||
+ * @deprecated will be removed with 1.13 Use {@link #getProfileProperties()}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Nonnull
|
||||
@ -181,7 +181,7 @@ index 00000000..0a657904
|
||||
+ /**
|
||||
+ * Completely replaces all Properties with the new provided properties
|
||||
+ * @param properties the properties to set on the new profile
|
||||
+ * @deprecated will be removed with 1.13
|
||||
+ * @deprecated will be removed with 1.13 Use {@link #setProfileProperties(Set)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public void setProperties(Multimap<String, Property> properties) {
|
||||
@ -194,7 +194,7 @@ index 00000000..0a657904
|
||||
+ /**
|
||||
+ * Adds additional properties, without removing the original properties
|
||||
+ * @param properties the properties to add to the existing properties
|
||||
+ * @deprecated will be removed with 1.13
|
||||
+ * @deprecated will be removed with 1.13 use {@link #addProfileProperties(Set)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public void addProperties(Multimap<String, Property> properties) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 75a76f4448b91caeb0c7ab06a8cdf5f26deb8818 Mon Sep 17 00:00:00 2001
|
||||
From 69a0afed643918933b0ad8f6d81780dafa33cf6b Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 3 Jul 2017 18:11:34 -0500
|
||||
Subject: [PATCH] ProfileWhitelistVerifyEvent
|
||||
@ -9,10 +9,10 @@ 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
|
||||
index 00000000..662e79e3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
|
||||
@@ -0,0 +1,110 @@
|
||||
@@ -0,0 +1,120 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2017 - Daniel Ennis (Aikar) - MIT License
|
||||
+ *
|
||||
@ -38,6 +38,7 @@ index 00000000..59b69b23
|
||||
+
|
||||
+package com.destroystokyo.paper.event.profile;
|
||||
+
|
||||
+import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
@ -51,13 +52,13 @@ index 00000000..59b69b23
|
||||
+ */
|
||||
+public class ProfileWhitelistVerifyEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final GameProfile profile;
|
||||
+ private final PlayerProfile 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) {
|
||||
+ public ProfileWhitelistVerifyEvent(final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, String kickMessage) {
|
||||
+ this.profile = profile;
|
||||
+ this.whitelistEnabled = whitelistEnabled;
|
||||
+ this.whitelisted = whitelisted;
|
||||
@ -81,8 +82,17 @@ index 00000000..59b69b23
|
||||
+
|
||||
+ /**
|
||||
+ * The gameprofile of the player trying to connect
|
||||
+ * @deprecated Will be removed in 1.13, use #{@link #getPlayerProfile()}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ public GameProfile getProfile() {
|
||||
+ return profile.getGameProfile();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return The profile of the player trying to connect
|
||||
+ */
|
||||
+ public PlayerProfile getPlayerProfile() {
|
||||
+ return profile;
|
||||
+ }
|
||||
+
|
||||
|
@ -1,4 +1,4 @@
|
||||
From f325f4f1ec5258fa734ad2b77293c59e8862c8d0 Mon Sep 17 00:00:00 2001
|
||||
From a59807ca537039ab042ad9d452339e8d652cd5fc Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 15 Jan 2018 22:11:48 -0500
|
||||
Subject: [PATCH] Basic PlayerProfile API
|
||||
@ -119,6 +119,31 @@ index 000000000..6e9a6a2e6
|
||||
+ return new Property(property.getName(), property.getValue(), property.getSignature());
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
index 02940d697..f38afb72e 100644
|
||||
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
@@ -1,6 +1,9 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
+import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
@@ -66,6 +69,10 @@ public final class MCUtil {
|
||||
return run.get();
|
||||
}
|
||||
|
||||
+ public static PlayerProfile toBukkit(GameProfile profile) {
|
||||
+ return CraftPlayerProfile.from(profile);
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Calculates distance between 2 entities
|
||||
* @param e1
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 8d0a9e8ca..f0ae65f08 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
|
@ -1,11 +1,11 @@
|
||||
From 2cb950c06bc8c5d3d461968dc63055fb6e4f7fd7 Mon Sep 17 00:00:00 2001
|
||||
From c688ef07e5abac3735463beb6682d873211a8475 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 219734689..00b8887bc 100644
|
||||
index 219734689..6af671c45 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -538,9 +538,9 @@ public abstract class PlayerList {
|
||||
@ -33,7 +33,7 @@ index 219734689..00b8887bc 100644
|
||||
+ 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 = 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) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren