Fix /geyser offhand command on Bukkit (#611)

If CommandSender is not an instance of GeyserSession, we iterate through all GeyserSessions in order to find the sender.
This commit is contained in:
Camotoy 2020-05-21 18:48:24 -04:00 committed by GitHub
parent 93d15c16f5
commit 61e0e796da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,6 +56,16 @@ public class OffhandCommand extends GeyserCommand {
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(0,0,0),
BlockFace.DOWN);
session.sendDownstreamPacket(releaseItemPacket);
return;
}
// Needed for Bukkit - sender is not an instance of GeyserSession
for (GeyserSession session : connector.getPlayers().values()) {
if (sender.getName().equals(session.getPlayerEntity().getUsername())) {
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(0,0,0),
BlockFace.DOWN);
session.sendDownstreamPacket(releaseItemPacket);
break;
}
}
}
}