Fix OfflinePlayer#getPlayerProfile returning deprecated type (#8543)

This commit is contained in:
Jake Potrebic 2022-12-20 10:56:33 -08:00
parent d20d36a172
commit b28618e07c
4 changed files with 40 additions and 11 deletions

View file

@ -201,8 +201,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static Map<String, String> initReplacementsMap() private static Map<String, String> initReplacementsMap()
{ {
@@ -0,0 +0,0 @@ public class Commodore @@ -0,0 +0,0 @@ public class Commodore
{ super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf);
desc = getOriginalOrRewrite(desc); return;
} }
+ if (owner.equals("org/bukkit/advancement/Advancement") && name.equals("getDisplay") && desc.endsWith(")Lorg/bukkit/advancement/AdvancementDisplay;")) { + if (owner.equals("org/bukkit/advancement/Advancement") && name.equals("getDisplay") && desc.endsWith(")Lorg/bukkit/advancement/AdvancementDisplay;")) {
+ super.visitTypeInsn(Opcodes.CHECKCAST, CB_PACKAGE + "/advancement/CraftAdvancement"); + super.visitTypeInsn(Opcodes.CHECKCAST, CB_PACKAGE + "/advancement/CraftAdvancement");
@ -210,8 +210,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return; + return;
+ } + }
// Paper end // Paper end
if ( modern ) if ( modern )
{
diff --git a/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java b/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java diff --git a/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java b/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000

View file

@ -167,20 +167,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
{ {
switch ( name ) switch ( name )
@@ -0,0 +0,0 @@ public class Commodore @@ -0,0 +0,0 @@ public class Commodore
return;
} }
+ // Paper start - Rewrite plugins // Paper start - Rewrite plugins
+ owner = getOriginalOrRewrite( owner) ; + owner = getOriginalOrRewrite( owner) ;
+ if (desc != null) + if (desc != null)
+ { + {
+ desc = getOriginalOrRewrite(desc); + desc = getOriginalOrRewrite(desc);
+ } + }
+ // Paper end if (owner.equals("org/bukkit/OfflinePlayer") && name.equals("getPlayerProfile") && desc.equals("()Lorg/bukkit/profile/PlayerProfile;")) {
+ super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf);
if ( modern ) return;
{
if ( owner.equals( "org/bukkit/Material" ) )
@@ -0,0 +0,0 @@ public class Commodore @@ -0,0 +0,0 @@ public class Commodore
@Override @Override
public void visitLdcInsn(Object value) public void visitLdcInsn(Object value)

View file

@ -21,5 +21,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return; + return;
+ } + }
// Paper end // Paper end
if ( modern ) if ( modern )
{

View file

@ -26,6 +26,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
playerName = gameProfile.getName(); playerName = gameProfile.getName();
uniqueId = gameProfile.getId(); uniqueId = gameProfile.getId();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -0,0 +0,0 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
}
@Override
- public PlayerProfile getPlayerProfile() {
- return new CraftPlayerProfile(this.profile);
+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() { // Paper
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile); // Paper
}
public Server getServer() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@ -146,3 +161,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void onEntityRemove(Entity entity) { public void onEntityRemove(Entity entity) {
this.hiddenEntities.remove(entity.getUUID()); this.hiddenEntities.remove(entity.getUUID());
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -0,0 +0,0 @@ public class Commodore
return;
}
+ // Paper start - Rewrite plugins
+ if (owner.equals("org/bukkit/OfflinePlayer") && name.equals("getPlayerProfile") && desc.equals("()Lorg/bukkit/profile/PlayerProfile;")) {
+ super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf);
+ return;
+ }
+ // Paper end
if ( modern )
{
if ( owner.equals( "org/bukkit/Material" ) )