Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7955

Failure teleporting players between worlds using player.teleport() when player has attribute modifiers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • 4378-Spigot-e65d67a-8ef9079 (MC: 1.21.3)
    • Yes

      When teleporting a player to another dimension, the teleport fails, and the player attributes get extremely broken. Player won't be able to chat or load new chunks.

      I made a test plugin that tries to teleport you to the nether ceiling when you interact with anything. To see the issue, load the plugin, and interact with the air. You won't be teleported, and you won't be able to chat either.

      Notable part of the exception is:
      Caused by: java.lang.IllegalArgumentException: Modifier is already applied on this attribute!

      Full Exception:

      [22:28:36 ERROR]: Could not pass event PlayerInteractEvent to TestPlugin v1.0
      org.bukkit.event.EventException: null
      	at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
      	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
      	at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:601) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
      	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:588) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
      	at org.bukkit.craftbukkit.v1_21_R2.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:579) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at org.bukkit.craftbukkit.v1_21_R2.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:541) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at org.bukkit.craftbukkit.v1_21_R2.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:537) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1666) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.network.protocol.game.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:47) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.network.protocol.game.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:10) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$0(PlayerConnectionUtils.java:35) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:164) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1319) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:210) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.util.thread.IAsyncTaskHandler.B(SourceFile:138) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.MinecraftServer.bv(MinecraftServer.java:1298) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.MinecraftServer.B(MinecraftServer.java:1291) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.util.thread.IAsyncTaskHandler.b(SourceFile:147) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1248) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.MinecraftServer.x_(MinecraftServer.java:1258) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1101) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
      Caused by: java.lang.IllegalArgumentException: Modifier is already applied on this attribute!
      	at net.minecraft.world.entity.ai.attributes.AttributeModifiable.f(SourceFile:81) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.world.entity.ai.attributes.AttributeModifiable.d(SourceFile:107) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.world.entity.ai.attributes.AttributeModifiable.a(SourceFile:113) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.world.entity.ai.attributes.AttributeMapBase.b(SourceFile:124) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap$1.forEach(Object2ObjectOpenHashMap.java:1188) ~[fastutil-8.5.12.jar:?]
      	at net.minecraft.world.entity.ai.attributes.AttributeMapBase.c(SourceFile:121) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.level.EntityPlayer.a(EntityPlayer.java:2089) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at net.minecraft.server.players.PlayerList.respawn(PlayerList.java:664) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer.teleport(CraftPlayer.java:1100) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity.teleport(CraftEntity.java:191) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4378-Spigot-e65d67a-8ef9079]
      	at us.starcatcher.TestPlugin.TestPlugin$EventListener.onPlayerInteract(TestPlugin.java:20) ~[?:?]
      	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
      	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
      	at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
      	... 24 more
      

      Plugin to reproduce:

      public class TestPlugin extends JavaPlugin implements Listener
      {
      	private class EventListener implements Listener
      	{
      		@EventHandler
      		public void onPlayerInteract(PlayerInteractEvent event) {
      			var player = event.getPlayer();
      			Location loc = new Location(getServer().getWorld("world_nether"), 0, 128, 0);
      			player.teleport(loc);
      		}
      	}
      
      	public void onEnable()
      	{
      		getServer().getPluginManager().registerEvents(new EventListener(), this);
      	}
      }
      

            Unassigned Unassigned
            jacob1 jacob1
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: