Remove deprecated AuthLib API from Paper-API

Use the PlayerProfile API as a replacement
This commit is contained in:
Zach Brown 2018-07-25 21:49:43 -05:00
parent 7a058415e5
commit 0b2b5ecc33
4 changed files with 31 additions and 89 deletions

View file

@ -14,7 +14,7 @@ it without having to shade it in the plugin and going through
several layers of logging abstraction. several layers of logging abstraction.
diff --git a/pom.xml b/pom.xml diff --git a/pom.xml b/pom.xml
index bfe580f1..5167f5b9 100644 index a58d4424..a771e156 100644
--- a/pom.xml --- a/pom.xml
+++ b/pom.xml +++ b/pom.xml
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@

View file

@ -6,34 +6,15 @@ Subject: [PATCH] Profile Lookup Events
Adds a Pre Lookup Event and a Post Lookup Event so that plugins may prefill in profile data, and cache the responses from Adds a Pre Lookup Event and a Post Lookup Event so that plugins may prefill in profile data, and cache the responses from
profiles that had to be looked up. profiles that had to be looked up.
diff --git a/pom.xml b/pom.xml
index a58d4424..bfe580f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -0,0 +0,0 @@
<!-- Trove Provided by CraftBukkit -->
<scope>provided</scope>
</dependency>
+ <!-- Paper - Add Authlib for Profile API -->
+ <dependency>
+ <groupId>com.mojang</groupId>
+ <artifactId>authlib</artifactId>
+ <version>1.5.25</version> <!-- keep in sync with major MC versions -->
+ <scope>compile</scope> <!-- expose to Plugins -->
+ </dependency>
<dependency>
<groupId>co.aikar</groupId>
<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 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 new file mode 100644
index 00000000..3b6995a7 index 00000000..160c98fe
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.profile; +package com.destroystokyo.paper.event.profile;
+ +
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
+import com.mojang.authlib.GameProfile;
+import org.bukkit.Bukkit; +import org.bukkit.Bukkit;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
@ -60,16 +41,6 @@ index 00000000..3b6995a7
+ +
+ /** + /**
+ * @return The profile that was recently looked up. This profile can be mutated + * @return The profile that was recently looked up. This profile can be mutated
+ * @deprecated will be removed with 1.13, use {@link #getPlayerProfile()}
+ */
+ @Deprecated
+ @Nonnull
+ public GameProfile getProfile() {
+ return profile.getGameProfile();
+ }
+
+ /**
+ * @return The profile that was recently looked up. This profile can be mutated
+ */ + */
+ @Nonnull + @Nonnull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
@ -87,7 +58,7 @@ index 00000000..3b6995a7
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java 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 new file mode 100644
index 00000000..aa0666d5 index 00000000..e5a5986a
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
@ -96,8 +67,6 @@ index 00000000..aa0666d5
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty; +import com.destroystokyo.paper.profile.ProfileProperty;
+import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import com.mojang.authlib.properties.Property;
+import org.bukkit.Bukkit; +import org.bukkit.Bukkit;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
@ -162,48 +131,6 @@ index 00000000..aa0666d5
+ } + }
+ +
+ /** + /**
+ * Get the properties for this profile
+ *
+ * @return the property map to attach to the new {@link PlayerProfile}
+ * @deprecated will be removed with 1.13 Use {@link #getProfileProperties()}
+ */
+ @Deprecated
+ @Nonnull
+ public Multimap<String, Property> getProperties() {
+ Multimap<String, Property> props = ArrayListMultimap.create();
+
+ for (ProfileProperty property : properties) {
+ props.put(property.getName(), new Property(property.getName(), property.getValue(), property.getSignature()));
+ }
+ return props;
+ }
+
+ /**
+ * 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 Use {@link #setProfileProperties(Set)}
+ */
+ @Deprecated
+ public void setProperties(Multimap<String, Property> properties) {
+ this.properties = new HashSet<>();
+ properties.values().forEach(property -> {
+ this.properties.add(new ProfileProperty(property.getName(), property.getValue(), property.getSignature()));
+ });
+ }
+
+ /**
+ * 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 use {@link #addProfileProperties(Set)}
+ */
+ @Deprecated
+ public void addProperties(Multimap<String, Property> properties) {
+ properties.values().forEach(property -> {
+ this.properties.add(new ProfileProperty(property.getName(), property.getValue(), property.getSignature()));
+ });
+ }
+
+ /**
+ * @return The currently pending prepopulated properties. + * @return The currently pending prepopulated properties.
+ * Any property in this Set will be automatically prefilled on this Profile + * Any property in this Set will be automatically prefilled on this Profile
+ */ + */
@ -240,4 +167,27 @@ index 00000000..aa0666d5
+ } + }
+ +
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
index e060c38a..1a69e5f7 100644
--- a/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
+++ b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
@@ -0,0 +0,0 @@
package com.destroystokyo.paper.profile;
-import com.mojang.authlib.GameProfile;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
@@ -0,0 +0,0 @@ public interface PlayerProfile {
default boolean hasTextures() {
return hasProperty("textures");
}
-
- /**
- * @deprecated Will be removed in 1.13
- */
- @Deprecated
- GameProfile getGameProfile();
}
-- --

View file

@ -9,7 +9,7 @@ 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 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 new file mode 100644
index 00000000..662e79e3 index 00000000..a11f811e
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
@ -39,7 +39,6 @@ index 00000000..662e79e3
+package com.destroystokyo.paper.event.profile; +package com.destroystokyo.paper.event.profile;
+ +
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
+import com.mojang.authlib.GameProfile;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+ +
@ -81,15 +80,6 @@ index 00000000..662e79e3
+ } + }
+ +
+ /** + /**
+ * 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 + * @return The profile of the player trying to connect
+ */ + */
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add API methods to control if armour stands can move
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
index cf11a2225b..578d966401 100644 index cf11a2225..578d96640 100644
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java --- a/src/main/java/net/minecraft/server/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java +++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
@@ -0,0 +0,0 @@ public class EntityArmorStand extends EntityLiving { @@ -0,0 +0,0 @@ public class EntityArmorStand extends EntityLiving {
@ -31,7 +31,7 @@ index cf11a2225b..578d966401 100644
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
index 2b66a08ade..8a06cb1656 100644 index 2b66a08ad..124c3185b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
@@ -0,0 +0,0 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { @@ -0,0 +0,0 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@ -39,6 +39,7 @@ index 2b66a08ade..8a06cb1656 100644
getHandle().setMarker(marker); getHandle().setMarker(marker);
} }
+ +
+ // Paper start
+ @Override + @Override
+ public boolean canMove() { + public boolean canMove() {
+ return getHandle().canMove; + return getHandle().canMove;
@ -48,5 +49,6 @@ index 2b66a08ade..8a06cb1656 100644
+ public void setCanMove(boolean move) { + public void setCanMove(boolean move) {
+ getHandle().canMove = move; + getHandle().canMove = move;
+ } + }
+ // Paper end
} }
-- --